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; std::vector<std::tuple<int, std::string>> behaviours;
if (end == '{') { if (end == '{') {
index++; 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) == '}') { if (data.at(index) == '}') {
break; break;
} }

View File

@ -416,3 +416,26 @@ type fooClass {
engine->Release(); 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();
}