| 835 | |
| 836 | #if AS_PROCESS_METADATA == 1 |
| 837 | int CScriptBuilder::ExtractMetadata(int pos, vector<string> &metadata) |
| 838 | { |
| 839 | metadata.clear(); |
| 840 | |
| 841 | // Extract all metadata. They can be separated by whitespace and comments |
| 842 | for (;;) |
| 843 | { |
| 844 | string metadataString = ""; |
| 845 | |
| 846 | // Overwrite the metadata with space characters to allow compilation |
| 847 | modifiedScript[pos] = ' '; |
| 848 | |
| 849 | // Skip opening brackets |
| 850 | pos += 1; |
| 851 | |
| 852 | int level = 1; |
| 853 | asUINT len = 0; |
| 854 | while (level > 0 && pos < (int)modifiedScript.size()) |
| 855 | { |
| 856 | asETokenClass t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len); |
| 857 | if (t == asTC_KEYWORD) |
| 858 | { |
| 859 | if (modifiedScript[pos] == '[') |
| 860 | level++; |
| 861 | else if (modifiedScript[pos] == ']') |
| 862 | level--; |
| 863 | } |
| 864 | |
| 865 | // Copy the metadata to our buffer |
| 866 | if (level > 0) |
| 867 | metadataString.append(&modifiedScript[pos], len); |
| 868 | |
| 869 | // Overwrite the metadata with space characters to allow compilation |
| 870 | if (t != asTC_WHITESPACE) |
| 871 | OverwriteCode(pos, len); |
| 872 | |
| 873 | pos += len; |
| 874 | } |
| 875 | |
| 876 | metadata.push_back(metadataString); |
| 877 | |
| 878 | // Check for more metadata. Possibly separated by comments |
| 879 | asETokenClass t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len); |
| 880 | while (t == asTC_COMMENT || t == asTC_WHITESPACE) |
| 881 | { |
| 882 | pos += len; |
| 883 | t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len); |
| 884 | } |
| 885 | |
| 886 | if (modifiedScript[pos] != '[') |
| 887 | break; |
| 888 | } |
| 889 | |
| 890 | return pos; |
| 891 | } |
| 892 | |
| 893 | int CScriptBuilder::ExtractDeclaration(int pos, string &name, string &declaration, int &type) |
| 894 | { |
nothing calls this directly
no outgoing calls
no test coverage detected