Jump to content
  • Advertisement
Sign in to follow this  
noizex

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

This topic is 724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :/

Edited by noizex

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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 :)

Edited by noizex

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!