Jump to content
  • Advertisement
Sign in to follow this  
Takayuki

Question on Array

This topic is 3073 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

Isn't there something good method though the value of Array cannot be correctly received by the function of C++? ////////// CMyClass ////////// void CMyClass::IntTest(const int *pint) { ..... } ////////// Register ////////// r = engine->RegisterObjectMethod("CMyClass", "void IntTest1(const int &in)", asMETHODPR(CMyClass, IntTest, (const int *), void),asCALL_THISCALL); assert(r>=0); r = engine->RegisterObjectMethod("CMyClass", "void IntTest2(const int[] &in)", asMETHODPR(CMyClass, IntTest, (const int *), void),asCALL_THISCALL); assert(r>=0); ////////// Script code ////////// CMyClass my; int[] aint(2); aint[0] = 111; aint[1] = 222; my.IntTest1(aint[0]); // good value my.IntTest2(aint); // bad value

Share this post


Link to post
Share on other sites
Advertisement
It seems to be able to take a correct value in the Generic function though it tested a little.

asIScriptArray *ar = (asIScriptArray*)gen->GetArgAddress(0);
ar->GetElementPointer(0); // good value

Share this post


Link to post
Share on other sites
I'm sorry. It solved it.

////////// CMyClass //////////
void CMyClass::IntTest(const int *pint)
{
.....
}

void CMyClass::IntTest(asIScriptArray *ar)
{
/**/ IntTest((int*)ar->GetElementPointer(0));
}

////////// Register //////////
r = engine->RegisterObjectMethod("CMyClass", "void IntTest1(const int &in)", asMETHODPR(CMyClass, IntTest, (const int *), void),asCALL_THISCALL); assert(r>=0);
r = engine->RegisterObjectMethod("CMyClass", "void IntTest2(const int[] &in)", asMETHODPR(CMyClass, IntTest, (asIScriptArray *), void),asCALL_THISCALL); assert(r>=0);

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!