Jump to content
  • Advertisement
Sign in to follow this  
chasester123

Adding handles to angel script objects in c++

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

So this is a fairly simple question though Idk how easy the answer is. 

 

Assume i have a c++ class cClass and an as class asClass: also assume that cClass allows reference handles.

 

class asClass

{

   cClass @parent;

}

 

Now the question is how do I assign what @parent is pointing to in c++.

 

//c++ code

void someFunc()

{

 asIScriptObject *n =   asEngine->CreateUninitializedScriptObject(sometypeinfo)

cClass *c = new cClass();

//how do i assign n::parent handle to point to the memory location of c.

}

 

chasester

Edited by chasester123

Share this post


Link to post
Share on other sites
Advertisement

To do that you'll find the property 'parent' in the asClass, then get the address of the property and use it to set the pointer to the cClass.

 

// Find the property 'parent' in the asClass and set the pointer to cClass
for( int i = 0; i < n->GetPropertyCount(); i++ )
{
  if( string(n->GetPropertyName(i)) == "parent" )
  {
    // Set the property to point to the cClass
    *reinterpret_cast<cClass**>(n->GetAddressOfProperty(i)) = c;
    
    // Increment the refcount of cClass since asClass now holds a reference
    c->AddRef();
  }
}

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!