Skip to content

Commit

Permalink
asITypeInfo::GetFactoryByDecl now matches the factory even if the inf…
Browse files Browse the repository at this point in the history
…ormed function name is different

git-svn-id: http://svn.code.sf.net/p/angelscript/code/trunk@2736 404ce1b2-830e-0410-a2e2-b09542c77caf
  • Loading branch information
angelcode committed Jul 5, 2021
1 parent 1f4e7e6 commit f7aed93
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sdk/angelscript/source/as_scriptengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,9 @@ int asCScriptEngine::GetFactoryIdByDecl(const asCObjectType *ot, const char *dec
for( asUINT n = 0; n < ot->beh.factories.GetLength(); n++ )
{
asCScriptFunction *f = scriptFunctions[ot->beh.factories[n]];
if( f->IsSignatureEqual(&func) )

// We don't really care if the name of the function is correct
if( f->IsSignatureExceptNameEqual(&func) )
{
id = ot->beh.factories[n];
break;
Expand Down
3 changes: 2 additions & 1 deletion sdk/docs/articles/changes2.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<h1>AngelScript Change Log</h1>

<h2>Version 2.35.1 WIP - 2021/06/05</h2>
<h2>Version 2.35.1 WIP - 2021/07/04</h2>

<ul>
<li>Bug fixes
Expand Down Expand Up @@ -43,6 +43,7 @@ <h2>Version 2.35.1 WIP - 2021/06/05</h2>
<li>Added config and cmake changes to make the library buildable for Mac M1 (Thanks David Carlier)
<li>asIScriptModule::CompileFunction now also invokes JIT compiler if set (Thanks gjl)
<li>asIScriptModule::GetImportedFunctionDeclaration now includes the namespace (Thanks Phong Ba)
<li>asITypeInfo::GetFactoryByDecl now matches the factory even if the informed function name is different (Thanks Yauheni Akhotnikau)
</ul>
<li>Script language
<ul>
Expand Down
6 changes: 6 additions & 0 deletions sdk/tests/test_feature/source/test_registertype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,12 @@ bool Test()
engine->RegisterObjectBehaviour("rect", asBEHAVE_FACTORY, "rect @f()", asFUNCTION(0), asCALL_GENERIC);
engine->RegisterObjectBehaviour("rect", asBEHAVE_LIST_FACTORY, "rect @f(int&in) {repeat {repeat_same int}}", asFUNCTION(0), asCALL_GENERIC);

// Test that it is possible to find the factory function even without knowing the name of it
asITypeInfo* type = engine->GetTypeInfoByDecl("rect");
asIScriptFunction *func = type->GetFactoryByDecl("rect @blah()");
if (func == 0)
TEST_FAILED;

asIScriptModule *mod = engine->GetModule("test", asGM_ALWAYS_CREATE);
mod->AddScriptSection("test",
"void main() \n"
Expand Down

0 comments on commit f7aed93

Please sign in to comment.