Extern Extends

Monkey Archive Forums/Monkey Discussion/Extern Extends

AdamRedwoods(Posted 2011) [#1]

Import "openb3d/src/entity.h"
Import "openb3d/src/camera.h"

Extern

Class Entity = "Entity"
	Method PositionEntity:Void(x:Float,y:Float,z:Float,glob:Int=False)
	Method MoveEntity:Void(mx:Float,my:Float,mz:Float)
	Method TranslateEntity:Void(tx:Float,ty:Float,tz:Float,glob:Int=False)
	Method ScaleEntity:Void(x:Float,y:Float,z:Float,glob:Int=False)
	Method RotateEntity:Void(x:Float,y:Float,z:Float,glob:Int=False)
	Method TurnEntity:Void(x:Float,y:Float,z:Float,glob:Int=False)
	Method PointEntity:Void(target_ent:Entity, roll:Float=0.0)
End

Extern

Class Camera Extends Entity  = "Camera"
	Function CreateCamera:Camera(parent:Entity = Null)
End


gives error:
error: ISO C++ forbids declaration of 'Camera' with no type

Any ideas? Should I make a work-around?

The problem is that it's a function, but even:
Public

Function CreateCamera:Camera(parent:Entity = Null)
	Local c:Camera = New Camera
	c.CreateCamera(parent)
	Return c
End
causes the same error...


AdamRedwoods(Posted 2011) [#2]
It was a pathing issue, but now I'm getting casting issues "dynamic_cast<gc_object*>".


skid(Posted 2011) [#3]
You will probably need to drop the extends entity bit and simply copy the entity methods into the camera declaration.


AdamRedwoods(Posted 2011) [#4]
I thought about that, but it turns out it was something with dynamic casting in the GC.

I ended up just wrapping the static functions in camera. Not sure if this is the *right* thing to do, but it compiled (but now need to get xcode to build with a subproject).

class CCamera : public Camera, public Object {
public:
	CCamera();
	~CCamera();
	static CCamera* CreateCamera(Entity* parent_ent=NULL);
};