🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Register handle as reference

Started by
2 comments, last by cvet 9 years, 3 months ago

Hello.

In some cases need to register handle, but disable possibility to null it (e.g. like reference or value type).

Possible to add registering properties with this behaviour? Like this:

ScriptString* str = ScriptString::GetFromPool(); // Class can't be allocated on stack

Engine->RegisterGlobalProperty( "string& str", &str ); // Here i want register like handle, but protect from nulling it

Same for RegisterObjectProperty where need type class offset, not pointer.

Advertisement

You can register the global property like this:

ScriptString* str = ScriptString::GetFromPool();
Engine->RegisterGlobalProperty("string str", str);

For class members it is a bit more tricky. In this case it is currently only possible by using virtual properties (i.e. a couple of get/set functions).

I'll look into adding support for & when registering properties to indicate that the property needs to be de-referenced when accessed.

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

I've finally added support for registering class members as references, e.g.

engine->RegisterObjectProperty("type", "complex &cmplx", asOFFSET(type, cmplx));

This is available in revision 2142.

Regards,

Andreas

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

Thanks!

This topic is closed to new replies.

Advertisement