Asitypeinfo::getmethodbydecl() Returns Null For Method With Handle Argument

Started by
1 comment, last by noizex 7 years, 9 months ago

Feel weird posting so much, but I ran into another problem. I usually try to check many times if it's not my error, but here I ran out of ideas what might be wrong, especially that other 2 functions prove I'm right.

Problem: asITypeInfo::GetMethodByDecl() returns null for a method that exists in a class and can be found with GetMethodByName() and GetMethodByIndex()

C++ code:


std::cout << "=== by index === \n";
int count = typeInfo->GetMethodCount();
for(int i = 0; i < count; i++)
{
    asIScriptFunction* f = typeInfo->GetMethodByIndex(m);
    std::cout << "idx=" << m << ", funcdecl=" << f->GetDeclaration() << "\n";
}
     
std::cout << "=== by name === \n";
asIScriptFunction* f = typeInfo->GetMethodByName("foobar");
std::cout << f->GetDeclaration() << std::endl;
      
std::cout << "=== by decl === \n";
asIScriptFunction* f2 = typeInfo->GetMethodByDecl(f->GetDeclaration());  // I even send f->GetDeclaration() here from
                                                                         // previous fetch to be 100% sure I didn't make
                                                                         // a typo, and it still returns 0 
std::cout << f2->GetDeclaration() << std::endl;

AS code:


class Foo
{
}

class Player
{
    void foobar(Foo@ f)
    {
    }
}

Output:

=== by index ===

idx=4, funcdecl=void Player::foobar(Foo@)
=== by name ===
void Player::foobar(Foo@)
=== by decl ===
Segmentation fault (core dumped) (segfault because I don't check for null just call ->GetDeclaration() to see if it retrieved the right one, but what it returns is just 0

PS. Anyone knows why GameDev filters post title in this weird way? Doesn't make it more readable, to be honest :/


Where are we and when are we and who are we?
How many people in how many places at how many times?
Advertisement

Don't feel bad about asking questions :)

GetMethodByDecl should be done without the class method name, i.e. instead of "void Player::foobar(Foo@)" it should be "void foobar(Foo@)".

You can pass false as argument to GetDeclaration to get the function declaration without the object name.

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

Ok, I will check it. This is really weird because I first tried it without Player:: and it didn't find the declaration, then tried several options (as I saw the other functions returning prefixed decl) and it worked. Now I tried it again without the prefix and it found the correct asIScriptFunction *dumb* no idea what went wrong, but thanks for explaining :)


Where are we and when are we and who are we?
How many people in how many places at how many times?

This topic is closed to new replies.

Advertisement