Sign in to follow this  
Pogacha

Registering Abstract Classes

Recommended Posts

Pogacha    122
Hi, We are currently trying make AngelScript work with our engine and we get to the point were we couldn't advance anymore. I searched for an answer on this but it seems I'm not understanding something because haven't found a similar question. I have a class called Surface it is abstract (some member functions and some pure virtual functions) I want to use it in the scripts in this way (as I use it in my engine): Surface@ the_surface = Get_ResourceManager().Get_Surface("TheSurfaceID"); the_surface.Draw( 10 - the_surface.Get_Width()/2, 20 ); Being Draw a virtual method and Get_Width a member method. I'm not sure if the function needs to be wrapped with a proxy class so the virtual methods take place in the C++ side. class SurfaceProxy { Surface* ptr; public: void Draw(int x, int y) { ptr->Draw(x,y); } ... RegisterSurfaceProxyAsSurfaceForAngelScript(); In the documentation it says they can be virtual but I'm not sure if this apply to polymorphism. Is there any example doing something similar I can check? Thanks in advance :) [Edited by - Pogacha on April 28, 2010 6:54:45 AM]

Share this post


Link to post
Share on other sites
WitchLord    4677
AngelScript supports the registration of abstract classes to allow polymorphism. There is no need to use wrappers for this as the abstract methods would be registered as normal virtual class methods.

You may want to take a look at the pages Registering a reference type and Registering class hierarchies in the manual.



The only restriction on the class methods is that methods for classes that use virtual inheritance is not supported. If you do happen to use virtual inheritance (which is unlikely) you will have to use wrapper functions to register these methods.

Share this post


Link to post
Share on other sites

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