Advertisement

Version 2.33.0 WIP vs. version 2.32.1 WIP

Started by September 04, 2018 04:57 PM
5 comments, last by IronHawk 6 years, 2 months ago

Hello!

I found that the code below returns different results in  "2.32.1 WIP" and "2.33.0 WIP":


asIScriptFunction *scriptFunction = ...;

std::string declaration = scriptFunction->GetDeclaration(false);

The function is a class member, but I'm not asking for a class name.

In version "2.32.1 WIP" the resulting string is:


MyNamespace::MyReturnType@ functionName(int)

But in "2.33.0 WIP": I'm getting just:


MyReturnType@ functionName(int).

So the namespace name is not included into the return type name.

This breaks many of my existing code.

What is a reason of this change (maybe it's a bug)?

 

Thanks!

The default arguments to GetDeclaration says not to include namespace. 

Call the method with as scriptFunction->GetDeclaration(false, true); and you should get the result you need.

 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Hello WitchLord!

Quote

The default arguments to GetDeclaration says not to include namespace. 

Call the method with as scriptFunction->GetDeclaration(false, true); and you should get the result you need.

Well... as written in docs:

includeNamespace - Indicates whether the namespace should be prepended to the function name

And in 2.32.1 WIP with (false, true) I really getting:


MyNamespace::MyReturnType@ MyNamespace::functionName(int)
     

So the result type always returned as fully-qualified in previous version, but this logic is now broken.

I'll look into it. It might be a bug then.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

There was indeed a bug, which I've now fixed in revision 2536.

 

The following code demonstrates the correct behaviour:


asIScriptModule *mod = engine->GetModule("test", asGM_ALWAYS_CREATE);
mod->AddScriptSection("test",
	"namespace A { class B { } }\n"
	"class C { A::B @func() { return null; } } \n"
	"namespace A { class D { B @func() { return null; } } } \n");
r = mod->Build();
if (r < 0)
	TEST_FAILED;

asITypeInfo *t = mod->GetTypeInfoByName("C");
asIScriptFunction *f = t->GetMethodByName("func");
if (std::string(f->GetDeclaration()) != "A::B@ C::func()")
	TEST_FAILED;
if (std::string(f->GetDeclaration(true, false)) != "A::B@ C::func()")
	TEST_FAILED;
if (std::string(f->GetDeclaration(false, false)) != "A::B@ func()")
	TEST_FAILED;
if (std::string(f->GetDeclaration(true, true)) != "A::B@ C::func()")
	TEST_FAILED;
if (std::string(f->GetDeclaration(false, true)) != "A::B@ func()")
	TEST_FAILED;

t = mod->GetTypeInfoByDecl("A::D");
f = t->GetMethodByName("func");
if (std::string(f->GetDeclaration()) != "B@ D::func()")
	TEST_FAILED;
if (std::string(f->GetDeclaration(true, false)) != "B@ D::func()")
	TEST_FAILED;
if (std::string(f->GetDeclaration(false, false)) != "B@ func()")
	TEST_FAILED;
if (std::string(f->GetDeclaration(true, true)) != "A::B@ A::D::func()")
	TEST_FAILED;
if (std::string(f->GetDeclaration(false, true)) != "A::B@ func()")
	TEST_FAILED;

 

GetDeclaration will always include namespaces for those types that are in a different namespace than the function/method itself. This is why you see in the first case that the namespace has been included for the return type even though the GetDeclaration was called with false for includeNamespace. 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Good!

I'll update to new version.

Thank you!

This topic is closed to new replies.

Advertisement