Jump to content

  • Log In with Google      Sign In   
  • Create Account

AnantaDas

Member Since 20 Jan 2013
Offline Last Active Jan 31 2013 01:23 PM

Posts I've Made

In Topic: AngelScript "this"?

22 January 2013 - 04:40 AM

Thanks for help, I revised my code and everything is working fine now :)


In Topic: AngelScript "this"?

20 January 2013 - 09:41 AM

The problem is that with &in the reference is not to the actual object. Instead the reference is to a copy of the object, in order to guarantee that the original is not modified. As the copy is performed within the constructor the infinite loop occurs.

You should pass a reference to a handle instead, i.e. InitScriptInstance(@this);

This will pass a reference to a handle to the object. Observe that your c++ function will need to dereference the reference in order to get the actual object.

Regards,
Andreas

 

Thanks for the reply, however, I don't think I understand it properly. Let me summarize:

 

1. In AngelScript I will have InitScriptInstance( @this ); as you wrote

 

2. In C++ I will register the function using declaration "void InitScriptInstance( ?&in )", is this still correct?

 

3. The function itself will look like this

void InitScriptInstance( void* pointer, int type )
{
   asIScriptObject* obj = (asIScriptObject*)pointer;
}

 

This does not work, so I guess one of the three steps caused misunderstanding on my side. Would you please care to elaborate?

Thanks

 

P.S.: If I rewrite the 'pointer' getter in the function above like this:

asIScriptObject** obj = (asIScriptObject**)pointer;

the dereference *obj is then NULL.


PARTNERS