History

Fixes for code review

ksuprynowicz committed 4 years ago

Commit 586bd7f1 parent e9bfdd416 files · +142 −117Browse files

Showing the changes to libraries/script-engine/src/EventTypes.cpp (1 of 16 files). Show all

Unified · Split

libraries/script-engine/src/EventTypes.cpp+11−8
@@ -17,15 +17,18 @@ · 16 unmodified lines
1717 #include "PointerEvent.h"
1818 #include "ScriptEngine.h"
1919 #include "ScriptEngineCast.h"
20+#include "ScriptManager.h"
2021 #include "SpatialEvent.h"
2122 #include "TouchEvent.h"
2223 #include "WheelEvent.h"
2324
24−void registerEventTypes(ScriptEngine* engine) {
25− scriptRegisterMetaType<KeyEvent, KeyEvent::toScriptValue, KeyEvent::fromScriptValue>(engine, "KeyEvent");
26− scriptRegisterMetaType<MouseEvent, MouseEvent::toScriptValue, MouseEvent::fromScriptValue>(engine, "MouseEvent");
27− scriptRegisterMetaType<PointerEvent, PointerEvent::toScriptValue, PointerEvent::fromScriptValue>(engine, "PointerEvent");
28− scriptRegisterMetaType<TouchEvent, TouchEvent::toScriptValue, TouchEvent::fromScriptValue>(engine, "TouchEvent");
29− scriptRegisterMetaType<WheelEvent, WheelEvent::toScriptValue, WheelEvent::fromScriptValue>(engine, "WheelEvent");
30− scriptRegisterMetaType<SpatialEvent, SpatialEvent::toScriptValue, SpatialEvent::fromScriptValue>(engine, "SpatialEvent");
31−}
25+STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
26+ auto scriptEngine = manager->engine().get();
27+
28+ scriptRegisterMetaType<KeyEvent, KeyEvent::toScriptValue, KeyEvent::fromScriptValue>(scriptEngine, "KeyEvent");
29+ scriptRegisterMetaType<MouseEvent, MouseEvent::toScriptValue, MouseEvent::fromScriptValue>(scriptEngine, "MouseEvent");
30+ scriptRegisterMetaType<PointerEvent, PointerEvent::toScriptValue, PointerEvent::fromScriptValue>(scriptEngine, "PointerEvent");
31+ scriptRegisterMetaType<TouchEvent, TouchEvent::toScriptValue, TouchEvent::fromScriptValue>(scriptEngine, "TouchEvent");
32+ scriptRegisterMetaType<WheelEvent, WheelEvent::toScriptValue, WheelEvent::fromScriptValue>(scriptEngine, "WheelEvent");
33+ scriptRegisterMetaType<SpatialEvent, SpatialEvent::toScriptValue, SpatialEvent::fromScriptValue>(scriptEngine, "SpatialEvent");
34+}));