Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


- - - - -

Static / Type members?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Jake Albano   Members   -  Reputation: 646

Like
0Likes
Like

Posted 30 January 2013 - 10:37 AM

I've recently gotten in the habit of using static member constants and the named constructor idiom to improve readability of my C++ code. For example:

 

Vector3 vec = Vector3::Up;
Matrix mat = Matrix::Identity;

if (getPosition() == Vector3::Zero)
{
}

 

I think the addition of constant class members to Angelscript would be really helpful. Something like this -- in C++:

class MyCType
{
    ...
    static const int MyConst;
};

...

engine->RegisterTypeProperty("MyType", "int myConst", &MyCType::myConst); // just like RegisterGlobalProperty

 

...and in Angelscript:

int foo = MyType.myConst; // properties accessed through the type, not an instance

 

Is there any chance we'll see a feature like this? I'd be willing to try and implement it myself, but I have no idea where to start.


Edited by Jake Albano, 30 January 2013 - 10:39 AM.


Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3415

Like
0Likes
Like

Posted 30 January 2013 - 11:43 AM

Static class members and constants are on my to-do list, but currently with a very low priority as it is really just syntactic sugar. They are after all nothing more than global variables and constants declared in the namespace of the class.

 

I haven't begun thinking about how I want these to be stored or registered in AngelScript, but it is quite possible the namespace feature will come in handy here, by simply allowing the class name to be used as namespace identifier too. 


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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS