Jump to content
  • Advertisement
Sign in to follow this  
droz

Register method for all script classes

This topic is 2291 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking for a way to register a class method for all script classes. I would like to be able to have a toString() method for every object. Have you given any thought to allowing this?

I did figure out how to register the method inside asCObectType, but it crashes when calling it (and I don't really want to modify angelscript).

Thanks,
Jeremy

Share this post


Link to post
Share on other sites
Advertisement
I haven't thought of this before.

To make this work nicely it would have to be a special kind of registration, possibly something like 'RegisterDefaultScriptClassMethod'. Once registered with the engine, the builder to include the method as one of the members for all script classes that are built. Or, the compiler could be modified to understand this method directly and call it even though it wasn't explicitly declared in the class.

Do you really have to make this a class method? It would be much easier to use a global function that takes the object as argument instead. You can then use the variable argument type to accept any type you want (like the any add-on). A global function would also be able to function for primitive types.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!