Jump to content
  • Advertisement
Sign in to follow this  

Inheritance From Internal C++ Classes

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



class a 
a *def;
class c : a
 int abc;

class b : c

I Tried something like this but kept running into an error where angel script was not properly set up, then it crashed angel script. 


What is the proper way to inherit from a c++ class, what flags do I have to set to get it to work correctly?



Share this post

Link to post
Share on other sites

Extending classes can't be done using built-in means. You'll have to write some code to make it work.

I've put together a utility library last week that takes care of most of it, it's on Github: https://github.com/SamVanheer/AngelscriptUtils


The code you want is the extension support, which is defined primarily in 3 files:





CASExtendAdapter is a template class that is inherited from to implement the adapter between the C++ and script class.

The other files define helper functions to define script code that scripts can inherit from to extend from the classes.


For an example of its use, see these classes:





The typedefs are critical for the macros to work. Otherwise you'll have to write a lot more code to handle each call separately.


The script API is just as important as the C++ code:




Registering the C++ class API, the base class method call type and the interface you can use to take handles to script extensions is an important part.


Creating the instance is handled like this:



The library is a WIP, but this should let you get started with your own code.


Based on your script code and what you said about it not being set up correctly, you're still having problems with getting Angelscript integration done. I suggest getting that set up before trying to integrate class extension support.

Share this post

Link to post
Share on other sites

@Solokiller: Thanks for sharing this. I'll have to take a look at what you've done myself. Perhaps I'll include some of this as helper add-ons (with your permission of course).


@chasester123: The manual has an article 'Inheriting from application registered classes'. Hopefully it should allow you to get your implementation working.

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!