Advertisement

How to alter an object handle value from host application?

Started by January 19, 2015 12:07 PM
2 comments, last by WitchLord 9 years, 10 months ago

I faced a problem when I wanted to change the content of a member variable in my script class.

This is my class:


class Foo
{
  int baz1;
  Bar@ baz2;
}

I can easily change value types in C++ by:


int* value = (int*)addressOfbaz1;
(*value) = 456;

But this doesn't work with object handles and I know why, but I don't know how I can alter the address that object handles are pointing to.

Shouldn't it be possible to do this?


Bar** ppBar = (Bar**) addressOfBaz2;

*ppBar = pToSomeOtherBarInstance;
Advertisement

Hey I didn't try that at all. Thanks for the reply. It's solved.

Just don't forget to properly update the reference count of the objects referred to by the handle. Otherwise you'll get memory leaks (if you forget to call Release()), or dangling pointers (if you forget to call AddRef()).

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement