Moved empty virtual methods to script side

This commit is contained in:
ZZYZX 2017-01-30 11:56:03 +02:00
parent 2382a76be5
commit 5751f84350
2 changed files with 19 additions and 25 deletions

View file

@ -368,17 +368,10 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, Unregister)
ACTION_RETURN_BOOL(E_UnregisterHandler(handler)); ACTION_RETURN_BOOL(E_UnregisterHandler(handler));
} }
#define DEFINE_EVENT_HANDLER(cls, funcname, args) DEFINE_ACTION_FUNCTION(cls, funcname) \ #define DEFINE_EVENT_HANDLER(cls, funcname, args) void cls::funcname(args) \
{ \
PARAM_SELF_PROLOGUE(cls); \
return 0; \
} \
void cls::funcname(args) \
{ \ { \
IFVIRTUAL(cls, funcname) \ IFVIRTUAL(cls, funcname) \
{ \ { \
if (func == cls##_##funcname##_VMPtr) \
return; \
VMValue params[1] = { (cls*)this }; \ VMValue params[1] = { (cls*)this }; \
GlobalVMStack.Call(func, params, 1, nullptr, 0, nullptr); \ GlobalVMStack.Call(func, params, 1, nullptr, 0, nullptr); \
} \ } \

View file

@ -9,22 +9,23 @@ class StaticEventHandler : Object native
protected static native bool Register(StaticEventHandler handler); protected static native bool Register(StaticEventHandler handler);
protected static native bool Unregister(StaticEventHandler handler); protected static native bool Unregister(StaticEventHandler handler);
virtual native void WorldLoaded(); // world stuff
virtual native void WorldUnloaded(); virtual void WorldLoaded() {}
virtual native void WorldThingSpawned(); virtual void WorldUnloaded() {}
virtual void WorldThingSpawned() {}
virtual native void RenderFrame(); // render stuff
virtual void RenderFrame() {}
} }
class StaticRenderEventHandler : StaticEventHandler native class StaticRenderEventHandler : StaticEventHandler native
{ {
// for frame and camera // for frame and camera
native readonly Vector3 ViewPos; native readonly Vector3 ViewPos;
native readonly double ViewAngle; native readonly double ViewAngle;
native readonly double ViewPitch; native readonly double ViewPitch;
native readonly double ViewRoll; native readonly double ViewRoll;
native readonly double FracTic; native readonly double FracTic;
native readonly Actor Camera; native readonly Actor Camera;
} }
class StaticWorldEventHandler : StaticEventHandler native class StaticWorldEventHandler : StaticEventHandler native
@ -36,12 +37,12 @@ class StaticWorldEventHandler : StaticEventHandler native
class EventHandler : StaticEventHandler native class EventHandler : StaticEventHandler native
{ {
static native StaticEventHandler Create(class<StaticEventHandler> type); static native StaticEventHandler Create(class<StaticEventHandler> type);
static native StaticEventHandler CreateOnce(class<StaticEventHandler> type); static native StaticEventHandler CreateOnce(class<StaticEventHandler> type);
static native StaticEventHandler Find(class<StaticEventHandler> type); static native StaticEventHandler Find(class<StaticEventHandler> type);
static native bool Register(StaticEventHandler handler); static native bool Register(StaticEventHandler handler);
static native bool Unregister(StaticEventHandler handler); static native bool Unregister(StaticEventHandler handler);
} }
class RenderEventHandler : StaticRenderEventHandler native { } class RenderEventHandler : StaticRenderEventHandler native { }