MCPcopy Create free account
hub / github.com/anjo76/angelscript / ExtractMetadata

Method ExtractMetadata

sdk/add_on/scriptbuilder/scriptbuilder.cpp:900–954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

898
899#if AS_PROCESS_METADATA == 1
900int 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
956int CScriptBuilder::ExtractDeclaration(int pos, string &name, string &declaration, int &type)
957{

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
ParseTokenMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected