Fixes issue where type def would read too much.

This commit is contained in:
Deukhoofd 2021-10-24 15:15:18 +02:00
parent a4cbc16545
commit 25e02057ae
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 28 additions and 1 deletions

View File

@ -68,7 +68,11 @@ namespace ASTypeDefParser {
std::vector<std::tuple<int, std::string>> behaviours;
if (end == '{') {
index++;
while (index <= data.size()) {
while (index < data.size()) {
if (std::string(" \r\n\t").find(data.at(index)) != std::string::npos){
index++;
continue;
}
if (data.at(index) == '}') {
break;
}

View File

@ -416,3 +416,26 @@ type fooClass {
engine->Release();
}
TEST_CASE("Register Type and func") {
asIScriptEngine* engine = asCreateScriptEngine();
engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL);
ASTypeDefParser::TypeDefResult res;
ASTypeDefParser::Parser::ParseAndRegister(res, R"(
type fooClass {
void Foo();
}
func fooClass@ CreateFoo();
)");
res.RegisterTypes(engine);
res.RegisterImplementation(engine);
auto type = engine->GetTypeInfoByName("fooClass");
REQUIRE(type != nullptr);
auto func = engine->GetGlobalFunctionByDecl("fooClass@ CreateFoo()");
REQUIRE(func != nullptr);
engine->Release();
}