| 891 | } |
| 892 | |
| 893 | int CScriptBuilder::ExtractDeclaration(int pos, string &name, string &declaration, int &type) |
| 894 | { |
| 895 | declaration = ""; |
| 896 | type = 0; |
| 897 | |
| 898 | int start = pos; |
| 899 | |
| 900 | std::string token; |
| 901 | asUINT len = 0; |
| 902 | asETokenClass t = asTC_WHITESPACE; |
| 903 | |
| 904 | // Skip white spaces, comments, and leading decorators |
| 905 | do |
| 906 | { |
| 907 | pos += len; |
| 908 | t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len); |
| 909 | token.assign(&modifiedScript[pos], len); |
| 910 | } while ( t == asTC_WHITESPACE || t == asTC_COMMENT || |
| 911 | token == "private" || token == "protected" || |
| 912 | token == "shared" || token == "external" || |
| 913 | token == "final" || token == "abstract" ); |
| 914 | |
| 915 | // We're expecting, either a class, interface, function, or variable declaration |
| 916 | if( t == asTC_KEYWORD || t == asTC_IDENTIFIER ) |
| 917 | { |
| 918 | token.assign(&modifiedScript[pos], len); |
| 919 | if( token == "interface" || token == "class" || token == "enum" ) |
| 920 | { |
| 921 | // Skip white spaces and comments |
| 922 | do |
| 923 | { |
| 924 | pos += len; |
| 925 | t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len); |
| 926 | } while ( t == asTC_WHITESPACE || t == asTC_COMMENT ); |
| 927 | |
| 928 | if( t == asTC_IDENTIFIER ) |
| 929 | { |
| 930 | type = MDT_TYPE; |
| 931 | declaration.assign(&modifiedScript[pos], len); |
| 932 | pos += len; |
| 933 | return pos; |
| 934 | } |
| 935 | } |
| 936 | else |
| 937 | { |
| 938 | // For function declarations, store everything up to the start of the |
| 939 | // statement block, except for succeeding decorators (final, override, etc) |
| 940 | |
| 941 | // For variable declaration store just the name as there can only be one |
| 942 | |
| 943 | // We'll only know if the declaration is a variable or function declaration |
| 944 | // when we see the statement block, or absense of a statement block. |
| 945 | bool hasParenthesis = false; |
| 946 | int nestedParenthesis = 0; |
| 947 | declaration.append(&modifiedScript[pos], len); |
| 948 | pos += len; |
| 949 | for(; pos < (int)modifiedScript.size();) |
| 950 | { |
nothing calls this directly
no outgoing calls
no test coverage detected