🎉 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!

How to use typedef (user type ) in angelscript ?

Started by
2 comments, last by zopenge 16 years, 3 months ago
I had done this : typedef unsigned long DWORD; how can I use DWORD in angelscript ? thanks !
Advertisement
Hello. I think this is what you need:

RegisterObjectType(const char *name, int byteSize, asDWORD flags);



and here is an example:

engine->RegisterObjectType("DWORD", sizeof (DWORD), asOBJ_APP_PRIMITIVE);



Here is the link to the Object types (the last parameter):
http://www.angelcode.com/angelscript/sdk/docs/manual/pages/ref_objecttypes.html#primitive
format c: /q
If you wanted to register it as an object type you would have to register it as:

engine->RegisterObjectType("DWORD", sizeof(DWORD), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_PRIMITIVE);


You would also have to register the proper behaviours to allow the scripts to use this type as the other primitive types, i.e. all math operators, comparison operators, and cast operators.

However, in the WIP version that you can download from the SVN, there is a much easier way to register it:

engine->RegisterTypedef("DWORD", "uint32");


The RegisterTypedef feature (and most of the others) that are added to the WIP, are contributions from Digital_Asphyxia.

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

That's really a good news for AS users ~ :)
Thanks ! But I also expect for the next release version .

This topic is closed to new replies.

Advertisement