Sign in to follow this  
Takayuki

Question on Array

Recommended Posts

Takayuki    104
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
Takayuki    104
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
Takayuki    104
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

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