Sign in to follow this  

Question on Array

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

This topic is 2890 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this