Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Multiple Inheritance Problem


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
1 reply to this topic

#1 imitation   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 April 2004 - 03:02 AM

I''ve recently come up against a problem with angelscript and my engine, where i''ve used multiple inheritance with an object, eg. Door, and have not been able to register a method for it (using RegisterObjectMethod). If Door inherits from Object + Scriptable, the compiler complains:
error C2440: ''type cast'' : cannot convert from ''void (__thiscall Door::*)(int)'' to ''void (__thiscall asCDummy::*)(void)''
        Pointers to members have different representations; cannot cast between them
 
The same goes for if Scriptable inherits from Object, and Door inherits from Scriptable. However, if Door just inherits from Object, all is well, it compiles fine. Is this a limitation in angelscript or c++? or am I just going about it incorrectly? and is there a way around it, without having to redesign all my classes?

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3263

Like
Likes
Like

Posted 08 April 2004 - 09:00 AM

I''m not sure, but I think you are trying to take the pointer of a virtual method, which is different from a fixed method because it needs to do a lookup in the virtual table.

AngelScript doesn''t support virtual methods yet, and even if it did you would probably have trouble with the multiple inheritance, as it requires yet another step when calling the methods.

I''m afraid that at the moment your best choice is to write proxy functions that will be able to figure out the correct way of calling the object methods. Example:


void Door_DoSomething(Door *door)
{
door->DoSomething();
}

engine->RegisterObjectMethod("door", "void DoSomething()", asFUNCTION(Door_DoSomething), asCALL_CDECL_OBJLAST);


The other solution would be to redesign your classes, so that they don''t use virtual methods.

In the future I''m hoping to have support for virtual functions in AngelScript, but I think I will not be able to find a good solution for multiple inheritance because each compiler does it a different way.

Regards,
Andreas

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game




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