Hmm. Actually the code is already capable of parsing metadata for shared/abstract classes. Not for mixins, though, since that is useless anyway (at least until the logic outlined above is implemented).
The following test works and is part of the regression test suite already:
// Test metadata on external shared entities
{
bout.buffer = "";
engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL);
asIScriptModule *mod = engine->GetModule("test", asGM_ALWAYS_CREATE);
mod->AddScriptSection("test",
"shared class test {} \n"
"shared interface intf {} \n"
"shared enum boo {} \n"
"shared void func() {} \n");
r = mod->Build();
if (r < 0)
TEST_FAILED;
CScriptBuilder builder;
builder.StartNewModule(engine, "mod");
builder.AddSectionFromMemory("test1",
"[external test] \n"
"external shared class test; \n"
"[external intf] \n"
"external shared interface intf; \n"
"[external boo] \n"
"external shared enum boo; \n"
"[external func] \n"
"external shared void func(); \n");
r = builder.BuildModule();
if (r < 0)
TEST_FAILED;
if (bout.buffer != "")
{
PRINTF("%s", bout.buffer.c_str());
TEST_FAILED;
}
asITypeInfo *type = engine->GetModule("mod")->GetTypeInfoByName("test");
if (type == 0)
TEST_FAILED;
else
{
int typeId = type->GetTypeId();
vector<string> metadata = builder.GetMetadataForType(typeId);
if (metadata[0] != "external test")
TEST_FAILED;
}
vector<string> metadata = builder.GetMetadataForFunc(engine->GetModule("mod")->GetFunctionByName("func"));
if (metadata[0] != "external func")
TEST_FAILED;
metadata = builder.GetMetadataForType(engine->GetModule("mod")->GetTypeInfoByName("boo")->GetTypeId());
if (metadata[0] != "external boo")
TEST_FAILED;
metadata = builder.GetMetadataForType(engine->GetModule("mod")->GetTypeInfoByName("intf")->GetTypeId());
if (metadata[0] != "external intf")
TEST_FAILED;
}
The decorators for the classes are skipped in the function CScriptBuilder::ExtractDeclaration on line 905:
// Skip white spaces, comments, and leading decorators
do
{
pos += len;
t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
token.assign(&modifiedScript[pos], len);
} while ( t == asTC_WHITESPACE || t == asTC_COMMENT ||
token == "private" || token == "protected" ||
token == "shared" || token == "external" ||
token == "final" || token == "abstract" );
Can you give an example of a script that doesn't work with the latest WIP?