Jump to content
  • Advertisement
Miss

Enum size

Recommended Posts

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.)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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);

 

Share this post


Link to post
Share on other sites

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.

Edited by Denis Brachet

Share this post


Link to post
Share on other sites

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; }");

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

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