| 898 | |
| 899 | #if AS_PROCESS_METADATA == 1 |
| 900 | int CScriptBuilder::ExtractMetadata(int pos, vector<string> &metadata) |
| 901 | { |
| 902 | metadata.clear(); |
| 903 | |
| 904 | // Extract all metadata. They can be separated by whitespace and comments |
| 905 | for (;;) |
| 906 | { |
| 907 | string metadataString = ""; |
| 908 | |
| 909 | // Overwrite the metadata with space characters to allow compilation |
| 910 | modifiedScript[pos] = ' '; |
| 911 | |
| 912 | // Skip opening brackets |
| 913 | pos += 1; |
| 914 | |
| 915 | int level = 1; |
| 916 | asUINT len = 0; |
| 917 | while (level > 0 && pos < (int)modifiedScript.size()) |
| 918 | { |
| 919 | asETokenClass t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len); |
| 920 | if (t == asTC_KEYWORD) |
| 921 | { |
| 922 | if (modifiedScript[pos] == '[') |
| 923 | level++; |
| 924 | else if (modifiedScript[pos] == ']') |
| 925 | level--; |
| 926 | } |
| 927 | |
| 928 | // Copy the metadata to our buffer |
| 929 | if (level > 0) |
| 930 | metadataString.append(&modifiedScript[pos], len); |
| 931 | |
| 932 | // Overwrite the metadata with space characters to allow compilation |
| 933 | if (t != asTC_WHITESPACE) |
| 934 | OverwriteCode(pos, len); |
| 935 | |
| 936 | pos += len; |
| 937 | } |
| 938 | |
| 939 | metadata.push_back(metadataString); |
| 940 | |
| 941 | // Check for more metadata. Possibly separated by comments |
| 942 | asETokenClass t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len); |
| 943 | while (t == asTC_COMMENT || t == asTC_WHITESPACE) |
| 944 | { |
| 945 | pos += len; |
| 946 | t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len); |
| 947 | } |
| 948 | |
| 949 | if (modifiedScript[pos] != '[') |
| 950 | break; |
| 951 | } |
| 952 | |
| 953 | return pos; |
| 954 | } |
| 955 | |
| 956 | int CScriptBuilder::ExtractDeclaration(int pos, string &name, string &declaration, int &type) |
| 957 | { |
nothing calls this directly
no test coverage detected