Sign in to follow this  

Register method for all script classes

This topic is 2078 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
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

This topic is 2078 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.

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

Sign in to follow this