Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

RegisterStaticMethod


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
2 replies to this topic

#1 Edgyr45   Members   -  Reputation: 127

Like
0Likes
Like

Posted 22 February 2013 - 02:01 PM

Hi,

For the creation of instances, I would like it to look like this :

//in angelscript:
void Function()
{
    Sprite @mMySprite = Sprite.Create();
}

 

I would like to stay away from global functions. If I have n object types to create, I would have to have n x global creates to do. And in our case, n might be big (in fact, we cannot know in advance since we parse and generate code from the production's project)

 

What I was searching for was a way to create a global function, which is a templated function, but mask it under an object type in AngelScript, for exemple : 

engine->RegisterGlobalFunction("Sprite@ Sprite.Create()", asFUNCTION(SomeClass, Factory<Sprite>), asCALL_CDECL);

Or in english : I know this is a global function but make the user belive it's a static so I can show it in the script IDE's intellisense and in scripts

 

Thanks!



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3377

Like
0Likes
Like

Posted 22 February 2013 - 02:16 PM

The script language currently doesn't have support for static class methods. It's on my to-do list, but currently have no estimate as to when I'll be able to implement it.

 

In the meantime global functions is the way to do it. If you have lot's of similar static methods you can possibly use namespaces to emulate the static method. But I'd recommend going with a simple prefix or suffix in the function name. For example:

 

engine->RegisterGlobalFunction("Sprite@ CreateSprite()", asFUNCTION(SomeClass, Factory<Sprite>), asCALL_CDECL);
// or
engine->RegisterGlobalFunction("Sprite@ Sprite_Create()", asFUNCTION(SomeClass, Factory<Sprite>), asCALL_CDECL);

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

#3 Edgyr45   Members   -  Reputation: 127

Like
0Likes
Like

Posted 22 February 2013 - 02:25 PM

Allright! I'll keep an eye on this feature.

Thanks for the answer!






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