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

Enum size

Started by
19 comments, last by Denis Brachet 3 years, 8 months ago

I just ran into an issue with a function in C++ returning an enum with 1 byte in size (enum "inherits" from uint8_t). The function was registered as a thiscall. Angelscript seemed to assume it wasn't 1 byte in size, causing it to return an invalid value. I had to write a wrapper function work around this. Is there a way to specify size for enums?

(This was on x86 on Angelscript 2.32.0 by the way.)

Advertisement

Currently it is not possible to specify the size of enums declared in AngelScript. All of them are 32 bits.

I have it on my to-do list to add support for different sized enums, though it is not currently very high priority.

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 have the same problem. What do you think would be the best workaround?
Is there a way to register constants from C++ code?

The engine can add a script section to modules with all the constants that should be available to scripts by default. 


// Add a module with all the constants that should be available to scripts
module->AddScriptSection("constants", "const uint8 SOME_CONSTANT = 4;");
// Add the dynamically loaded script
module->AddScriptSection(filename, scriptFromFile);

 

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

Great! Thank you!

And...is it possible to add a namespace in this way (via C++)? Just to mimic enum class and place constants in it.

Yes, of course.


// Add a module with all the constants that should be available to scripts
module->AddScriptSection("constants", "namespace Foo { const uint8 SOME_CONSTANT = 4; }");

 

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

Wonderful!

Thank you for your very fast help!

On 10/15/2018 at 8:59 PM, WitchLord said:

Currently it is not possible to specify the size of enums declared in AngelScript. All of them are 32 bits.

I have it on my to-do list to add support for different sized enums, though it is not currently very high priority.

Hello WitchLord, 

do you have any news about this topic?

 

Not yet, I'm afraid.

I've now bumped the priority up though. 

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

27 minutes ago, WitchLord said:

Not yet, I'm afraid.

I've now bumped the priority up though. 

It was just a ping just to know. :)

This topic is closed to new replies.

Advertisement