From 8e91009bc4808748489bfbc2af0b3b2c1ed1d595 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Tue, 19 Jun 2018 11:37:12 -0700 Subject: [PATCH] Cleanup event types --- lime/_backend/native/NativeApplication.hx | 31 ++++---- project/include/app/ApplicationEvent.h | 22 ++---- project/include/graphics/RenderEvent.h | 21 ++---- project/include/system/ClipboardEvent.h | 21 ++---- project/include/system/SensorEvent.h | 26 ++----- project/include/ui/DropEvent.h | 22 ++---- project/include/ui/GamepadEvent.h | 27 ++----- project/include/ui/JoystickEvent.h | 28 ++------ project/include/ui/KeyEvent.h | 24 ++----- project/include/ui/MouseEvent.h | 27 ++----- project/include/ui/TextEvent.h | 25 ++----- project/include/ui/TouchEvent.h | 28 ++------ project/include/ui/WindowEvent.h | 26 ++----- project/include/utils/Resource.h | 3 +- project/include/utils/String.h | 23 ------ project/src/ExternalInterface.cpp | 75 ++++++++++---------- project/src/app/ApplicationEvent.cpp | 2 +- project/src/backend/sdl/SDLApplication.cpp | 12 +++- project/src/graphics/RenderEvent.cpp | 2 +- project/src/graphics/cairo/CairoBindings.cpp | 5 +- project/src/media/openal/OpenALBindings.cpp | 3 +- project/src/system/ClipboardEvent.cpp | 2 +- project/src/system/SensorEvent.cpp | 2 +- project/src/ui/DropEvent.cpp | 4 +- project/src/ui/GamepadEvent.cpp | 6 +- project/src/ui/JoystickEvent.cpp | 6 +- project/src/ui/KeyEvent.cpp | 2 +- project/src/ui/MouseEvent.cpp | 2 +- project/src/ui/TextEvent.cpp | 8 +-- project/src/ui/TouchEvent.cpp | 2 +- project/src/ui/WindowEvent.cpp | 2 +- 31 files changed, 160 insertions(+), 329 deletions(-) delete mode 100644 project/include/utils/String.h diff --git a/lime/_backend/native/NativeApplication.hx b/lime/_backend/native/NativeApplication.hx index ad0020563..de7c324b9 100644 --- a/lime/_backend/native/NativeApplication.hx +++ b/lime/_backend/native/NativeApplication.hx @@ -113,7 +113,6 @@ class NativeApplication { public function exec ():Int { #if !macro - #if lime_cffi NativeCFFI.lime_application_event_manager_register (handleApplicationEvent, applicationEventInfo); NativeCFFI.lime_clipboard_event_manager_register (handleClipboardEvent, clipboardEventInfo); @@ -220,7 +219,7 @@ class NativeApplication { for (window in parent.windows) { - window.onDropFile.dispatch (dropEventInfo.file); + window.onDropFile.dispatch (#if hl @:privateAccess String.fromUTF8 (dropEventInfo.file) #else dropEventInfo.file #end); } @@ -234,7 +233,7 @@ class NativeApplication { case AXIS_MOVE: var gamepad = Gamepad.devices.get (gamepadEventInfo.id); - if (gamepad != null) gamepad.onAxisMove.dispatch (gamepadEventInfo.axis, gamepadEventInfo.value); + if (gamepad != null) gamepad.onAxisMove.dispatch (gamepadEventInfo.axis, gamepadEventInfo.axisValue); case BUTTON_DOWN: @@ -271,7 +270,7 @@ class NativeApplication { case HAT_MOVE: var joystick = Joystick.devices.get (joystickEventInfo.id); - if (joystick != null) joystick.onHatMove.dispatch (joystickEventInfo.index, joystickEventInfo.value); + if (joystick != null) joystick.onHatMove.dispatch (joystickEventInfo.index, joystickEventInfo.eventValue); case TRACKBALL_MOVE: @@ -527,11 +526,11 @@ class NativeApplication { case TEXT_INPUT: - window.onTextInput.dispatch (textEventInfo.text); + window.onTextInput.dispatch (#if hl @:privateAccess String.fromUTF8 (textEventInfo.text) #else textEventInfo.text #end); case TEXT_EDIT: - window.onTextEdit.dispatch (textEventInfo.text, textEventInfo.start, textEventInfo.length); + window.onTextEdit.dispatch (#if hl @:privateAccess String.fromUTF8 (textEventInfo.text) #else textEventInfo.text #end, textEventInfo.start, textEventInfo.length); default: @@ -807,11 +806,11 @@ class NativeApplication { @:keep /*private*/ class DropEventInfo { - public var file:String; + public var file:#if hl hl.Bytes #else String #end; public var type:DropEventType; - public function new (type:DropEventType = null, file:String = null) { + public function new (type:DropEventType = null, file = null) { this.type = type; this.file = file; @@ -843,7 +842,7 @@ class NativeApplication { public var button:Int; public var id:Int; public var type:GamepadEventType; - public var value:Float; + public var axisValue:Float; public function new (type:GamepadEventType = null, id:Int = 0, button:Int = 0, axis:Int = 0, value:Float = 0) { @@ -852,14 +851,14 @@ class NativeApplication { this.id = id; this.button = button; this.axis = axis; - this.value = value; + this.axisValue = value; } public function clone ():GamepadEventInfo { - return new GamepadEventInfo (type, id, button, axis, value); + return new GamepadEventInfo (type, id, button, axis, axisValue); } @@ -884,7 +883,7 @@ class NativeApplication { public var id:Int; public var index:Int; public var type:JoystickEventType; - public var value:Int; + public var eventValue:Int; public var x:Float; public var y:Float; @@ -894,7 +893,7 @@ class NativeApplication { this.type = type; this.id = id; this.index = index; - this.value = value; + this.eventValue = value; this.x = x; this.y = y; @@ -903,7 +902,7 @@ class NativeApplication { public function clone ():JoystickEventInfo { - return new JoystickEventInfo (type, id, index, value, x, y); + return new JoystickEventInfo (type, id, index, eventValue, x, y); } @@ -1085,12 +1084,12 @@ class NativeApplication { public var id:Int; public var length:Int; public var start:Int; - public var text:String; + public var text:#if hl hl.Bytes #else String #end; public var type:TextEventType; public var windowID:Int; - public function new (type:TextEventType = null, windowID:Int = 0, text:String = "", start:Int = 0, length:Int = 0) { + public function new (type:TextEventType = null, windowID:Int = 0, text = null, start:Int = 0, length:Int = 0) { this.type = type; this.windowID = windowID; diff --git a/project/include/app/ApplicationEvent.h b/project/include/app/ApplicationEvent.h index e5b7dcbdc..5bd333092 100644 --- a/project/include/app/ApplicationEvent.h +++ b/project/include/app/ApplicationEvent.h @@ -17,28 +17,18 @@ namespace lime { }; - struct HL_ApplicationEvent { + struct ApplicationEvent { hl_type* t; int deltaTime; ApplicationEventType type; - }; - - - class ApplicationEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - ApplicationEvent (); - - static void Dispatch (ApplicationEvent* event); - - int deltaTime; - ApplicationEventType type; + ApplicationEvent (); + + static void Dispatch (ApplicationEvent* event); }; diff --git a/project/include/graphics/RenderEvent.h b/project/include/graphics/RenderEvent.h index ece4214b4..2a509cb66 100644 --- a/project/include/graphics/RenderEvent.h +++ b/project/include/graphics/RenderEvent.h @@ -18,26 +18,17 @@ namespace lime { }; - struct HL_RenderEvent { + struct RenderEvent { hl_type* t; RenderEventType type; - }; - - - class RenderEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - RenderEvent (); - - static void Dispatch (RenderEvent* event); - - RenderEventType type; + RenderEvent (); + + static void Dispatch (RenderEvent* event); }; diff --git a/project/include/system/ClipboardEvent.h b/project/include/system/ClipboardEvent.h index 907320fef..21de0ab33 100644 --- a/project/include/system/ClipboardEvent.h +++ b/project/include/system/ClipboardEvent.h @@ -16,26 +16,17 @@ namespace lime { }; - struct HL_ClipboardEvent { + struct ClipboardEvent { hl_type* t; ClipboardEventType type; - }; - - - class ClipboardEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - ClipboardEvent (); - - static void Dispatch (ClipboardEvent* event); - - ClipboardEventType type; + ClipboardEvent (); + + static void Dispatch (ClipboardEvent* event); }; diff --git a/project/include/system/SensorEvent.h b/project/include/system/SensorEvent.h index c5f78f568..ab5d431c2 100644 --- a/project/include/system/SensorEvent.h +++ b/project/include/system/SensorEvent.h @@ -16,7 +16,7 @@ namespace lime { }; - struct HL_SensorEvent { + struct SensorEvent { hl_type* t; int id; @@ -25,26 +25,12 @@ namespace lime { double z; SensorEventType type; - }; - - - class SensorEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - SensorEvent (); - - static void Dispatch (SensorEvent* event); - - int id; - SensorEventType type; - double x; - double y; - double z; - + SensorEvent (); + + static void Dispatch (SensorEvent* event); }; diff --git a/project/include/ui/DropEvent.h b/project/include/ui/DropEvent.h index f92fe8b13..7d1cb390d 100644 --- a/project/include/ui/DropEvent.h +++ b/project/include/ui/DropEvent.h @@ -16,28 +16,18 @@ namespace lime { }; - struct HL_DropEvent { + struct DropEvent { hl_type* t; vbyte* file; DropEventType type; - }; - - - class DropEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - DropEvent (); - - static void Dispatch (DropEvent* event); - - char* file; - DropEventType type; + DropEvent (); + + static void Dispatch (DropEvent* event); }; diff --git a/project/include/ui/GamepadEvent.h b/project/include/ui/GamepadEvent.h index 7c6440a91..b83333079 100644 --- a/project/include/ui/GamepadEvent.h +++ b/project/include/ui/GamepadEvent.h @@ -20,34 +20,21 @@ namespace lime { }; - struct HL_GamepadEvent { + struct GamepadEvent { hl_type* t; int axis; int button; int id; GamepadEventType type; - double value; + double axisValue; - }; - - - class GamepadEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - GamepadEvent (); - - static void Dispatch (GamepadEvent* event); - - int axis; - double axisValue; - int button; - int id; - GamepadEventType type; + GamepadEvent (); + + static void Dispatch (GamepadEvent* event); }; diff --git a/project/include/ui/JoystickEvent.h b/project/include/ui/JoystickEvent.h index fc122db78..0a07c8cf3 100644 --- a/project/include/ui/JoystickEvent.h +++ b/project/include/ui/JoystickEvent.h @@ -22,36 +22,22 @@ namespace lime { }; - struct HL_JoystickEvent { + struct JoystickEvent { hl_type* t; int id; int index; JoystickEventType type; - int value; + int eventValue; double x; double y; - }; - - - class JoystickEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - JoystickEvent (); - - static void Dispatch (JoystickEvent* event); - - int eventValue; - int id; - int index; - JoystickEventType type; - double x; - double y; + JoystickEvent (); + + static void Dispatch (JoystickEvent* event); }; diff --git a/project/include/ui/KeyEvent.h b/project/include/ui/KeyEvent.h index a741d9ef9..0a7188e08 100644 --- a/project/include/ui/KeyEvent.h +++ b/project/include/ui/KeyEvent.h @@ -18,7 +18,7 @@ namespace lime { }; - struct HL_KeyEvent { + struct KeyEvent { hl_type* t; int keyCode; @@ -26,24 +26,12 @@ namespace lime { KeyEventType type; int windowID; - }; - - - class KeyEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - KeyEvent (); - - static void Dispatch (KeyEvent* event); - - double keyCode; - uint16_t modifier; - KeyEventType type; - uint32_t windowID; + KeyEvent (); + + static void Dispatch (KeyEvent* event); }; diff --git a/project/include/ui/MouseEvent.h b/project/include/ui/MouseEvent.h index f6b492bb8..d88841f81 100644 --- a/project/include/ui/MouseEvent.h +++ b/project/include/ui/MouseEvent.h @@ -20,7 +20,7 @@ namespace lime { }; - struct HL_MouseEvent { + struct MouseEvent { hl_type* t; int button; @@ -31,27 +31,12 @@ namespace lime { double x; double y; - }; - - - class MouseEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - MouseEvent (); - - static void Dispatch (MouseEvent* event); - - int button; - double movementX; - double movementY; - MouseEventType type; - uint32_t windowID; - double x; - double y; + MouseEvent (); + + static void Dispatch (MouseEvent* event); }; diff --git a/project/include/ui/TextEvent.h b/project/include/ui/TextEvent.h index f8893889a..2735d7bc6 100644 --- a/project/include/ui/TextEvent.h +++ b/project/include/ui/TextEvent.h @@ -18,7 +18,7 @@ namespace lime { }; - struct HL_TextEvent { + struct TextEvent { hl_type* t; int id; @@ -28,25 +28,12 @@ namespace lime { TextEventType type; int windowID; - }; - - - class TextEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - TextEvent (); - - static void Dispatch (TextEvent* event); - - long length; - long start; - char text[32]; - TextEventType type; - uint32_t windowID; + TextEvent (); + + static void Dispatch (TextEvent* event); }; diff --git a/project/include/ui/TouchEvent.h b/project/include/ui/TouchEvent.h index f84ecc67e..f746e67cf 100644 --- a/project/include/ui/TouchEvent.h +++ b/project/include/ui/TouchEvent.h @@ -19,7 +19,7 @@ namespace lime { }; - struct HL_TouchEvent { + struct TouchEvent { hl_type* t; int device; @@ -31,28 +31,12 @@ namespace lime { double x; double y; - }; - - - class TouchEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - TouchEvent (); - - static void Dispatch (TouchEvent* event); - - uint32_t device; - float dx; - float dy; - uint32_t id; - float pressure; - TouchEventType type; - float x; - float y; + TouchEvent (); + + static void Dispatch (TouchEvent* event); }; diff --git a/project/include/ui/WindowEvent.h b/project/include/ui/WindowEvent.h index f7ecf1fa2..83ab56992 100644 --- a/project/include/ui/WindowEvent.h +++ b/project/include/ui/WindowEvent.h @@ -28,7 +28,7 @@ namespace lime { }; - struct HL_WindowEvent { + struct WindowEvent { hl_type* t; int height; @@ -38,26 +38,12 @@ namespace lime { int x; int y; - }; - - - class WindowEvent { + static ValuePointer* callback; + static ValuePointer* eventObject; - public: - - static ValuePointer* callback; - static ValuePointer* eventObject; - - WindowEvent (); - - static void Dispatch (WindowEvent* event); - - int height; - WindowEventType type; - int width; - uint32_t windowID; - int x; - int y; + WindowEvent (); + + static void Dispatch (WindowEvent* event); }; diff --git a/project/include/utils/Resource.h b/project/include/utils/Resource.h index 21b5d58be..e9db3d875 100644 --- a/project/include/utils/Resource.h +++ b/project/include/utils/Resource.h @@ -4,7 +4,6 @@ #include #include -#include namespace lime { @@ -15,7 +14,7 @@ namespace lime { Resource () : data (NULL), path (NULL) {} Resource (const char* path) : data (NULL), path (path) {} - Resource (HL_String* path) : data (NULL), path (path ? hl_to_utf8 ((const uchar*)path->bytes) : NULL) {} + Resource (hl_vstring* path) : data (NULL), path (path ? hl_to_utf8 ((const uchar*)path->bytes) : NULL) {} Resource (Bytes* data) : data (data), path (NULL) {} Bytes* data; diff --git a/project/include/utils/String.h b/project/include/utils/String.h deleted file mode 100644 index f31197946..000000000 --- a/project/include/utils/String.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef LIME_UTILS_STRING_H -#define LIME_UTILS_STRING_H - - -#include - - -namespace lime { - - - struct HL_String { - - hl_type* t; - unsigned char* bytes; - int length; - - }; - - -} - - -#endif \ No newline at end of file diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index fbd8c9b55..30682826f 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include DEFINE_KIND (k_finalizer); @@ -206,7 +205,7 @@ namespace lime { } - HL_PRIM void hl_lime_application_event_manager_register (vclosure* callback, HL_ApplicationEvent* eventObject) { + HL_PRIM void hl_lime_application_event_manager_register (vclosure* callback, ApplicationEvent* eventObject) { ApplicationEvent::callback = new ValuePointer (callback); ApplicationEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -373,7 +372,7 @@ namespace lime { } - HL_PRIM AudioBuffer* hl_lime_audio_load_file (HL_String* data, AudioBuffer* buffer) { + HL_PRIM AudioBuffer* hl_lime_audio_load_file (hl_vstring* data, AudioBuffer* buffer) { Resource resource = Resource (data ? hl_to_utf8 ((const uchar*)data->bytes) : NULL); @@ -483,7 +482,7 @@ namespace lime { } - HL_PRIM Bytes* hl_lime_bytes_read_file (HL_String* path, Bytes* bytes) { + HL_PRIM Bytes* hl_lime_bytes_read_file (hl_vstring* path, Bytes* bytes) { if (!path) return 0; bytes->ReadFile (hl_to_utf8 ((const uchar*)path->bytes)); @@ -530,7 +529,7 @@ namespace lime { } - HL_PRIM void hl_lime_clipboard_event_manager_register (vclosure* callback, HL_ClipboardEvent* eventObject) { + HL_PRIM void hl_lime_clipboard_event_manager_register (vclosure* callback, ClipboardEvent* eventObject) { ClipboardEvent::callback = new ValuePointer (callback); ClipboardEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -588,7 +587,7 @@ namespace lime { } - HL_PRIM void hl_lime_clipboard_set_text (HL_String* text) { + HL_PRIM void hl_lime_clipboard_set_text (hl_vstring* text) { Clipboard::SetText (text ? (const char*)hl_to_utf8 ((const uchar*)text->bytes) : NULL); @@ -673,7 +672,7 @@ namespace lime { } - HL_PRIM void hl_lime_drop_event_manager_register (vclosure* callback, HL_DropEvent* eventObject) { + HL_PRIM void hl_lime_drop_event_manager_register (vclosure* callback, DropEvent* eventObject) { DropEvent::callback = new ValuePointer (callback); DropEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -715,7 +714,7 @@ namespace lime { } - HL_PRIM vbyte* hl_lime_file_dialog_open_directory (HL_String* title, HL_String* filter, HL_String* defaultPath) { + HL_PRIM vbyte* hl_lime_file_dialog_open_directory (hl_vstring* title, hl_vstring* filter, hl_vstring* defaultPath) { // #ifdef LIME_TINYFILEDIALOGS @@ -783,7 +782,7 @@ namespace lime { } - HL_PRIM vbyte* hl_lime_file_dialog_open_file (HL_String* title, HL_String* filter, HL_String* defaultPath) { + HL_PRIM vbyte* hl_lime_file_dialog_open_file (hl_vstring* title, hl_vstring* filter, hl_vstring* defaultPath) { // #ifdef LIME_TINYFILEDIALOGS @@ -850,7 +849,7 @@ namespace lime { } - HL_PRIM hl_varray* hl_lime_file_dialog_open_files (HL_String* title, HL_String* filter, HL_String* defaultPath) { + HL_PRIM hl_varray* hl_lime_file_dialog_open_files (hl_vstring* title, hl_vstring* filter, hl_vstring* defaultPath) { // #ifdef LIME_TINYFILEDIALOGS @@ -917,7 +916,7 @@ namespace lime { } - HL_PRIM vbyte* hl_lime_file_dialog_save_file (HL_String* title, HL_String* filter, HL_String* defaultPath) { + HL_PRIM vbyte* hl_lime_file_dialog_save_file (hl_vstring* title, hl_vstring* filter, hl_vstring* defaultPath) { // #ifdef LIME_TINYFILEDIALOGS @@ -987,7 +986,7 @@ namespace lime { } - HL_PRIM int hl_lime_file_watcher_add_directory (HL_CFFIPointer* handle, HL_String* path, bool recursive) { + HL_PRIM int hl_lime_file_watcher_add_directory (HL_CFFIPointer* handle, hl_vstring* path, bool recursive) { #ifdef LIME_EFSW FileWatcher* watcher = (FileWatcher*)handle->ptr; @@ -1127,7 +1126,7 @@ namespace lime { } - HL_PRIM int hl_lime_font_get_glyph_index (HL_CFFIPointer* fontHandle, HL_String* character) { + HL_PRIM int hl_lime_font_get_glyph_index (HL_CFFIPointer* fontHandle, hl_vstring* character) { #ifdef LIME_FREETYPE Font *font = (Font*)fontHandle->ptr; @@ -1151,7 +1150,7 @@ namespace lime { } - HL_PRIM hl_varray* hl_lime_font_get_glyph_indices (HL_CFFIPointer* fontHandle, HL_String* characters) { + HL_PRIM hl_varray* hl_lime_font_get_glyph_indices (HL_CFFIPointer* fontHandle, hl_vstring* characters) { // #ifdef LIME_FREETYPE // Font *font = (Font*)fontHandle->ptr; @@ -1392,7 +1391,7 @@ namespace lime { } - HL_PRIM HL_CFFIPointer* hl_lime_font_load_file (HL_String* data) { + HL_PRIM HL_CFFIPointer* hl_lime_font_load_file (hl_vstring* data) { #ifdef LIME_FREETYPE Resource resource = Resource (data ? hl_to_utf8 ((const uchar*)data->bytes) : NULL); @@ -1544,7 +1543,7 @@ namespace lime { HL_PRIM void hl_lime_gamepad_add_mappings (hl_varray* mappings) { int length = mappings->size; - HL_String** mappingsData = hl_aptr (mappings, HL_String*); + hl_vstring** mappingsData = hl_aptr (mappings, hl_vstring*); for (int i = 0; i < length; i++) { @@ -1563,7 +1562,7 @@ namespace lime { } - HL_PRIM void hl_lime_gamepad_event_manager_register (vclosure* callback, HL_GamepadEvent* eventObject) { + HL_PRIM void hl_lime_gamepad_event_manager_register (vclosure* callback, GamepadEvent* eventObject) { GamepadEvent::callback = new ValuePointer (callback); GamepadEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -1854,7 +1853,7 @@ namespace lime { } - HL_PRIM ImageBuffer* hl_lime_image_load_file (HL_String* data, ImageBuffer* buffer) { + HL_PRIM ImageBuffer* hl_lime_image_load_file (hl_vstring* data, ImageBuffer* buffer) { Resource resource = Resource (data); @@ -2174,7 +2173,7 @@ namespace lime { } - HL_PRIM void hl_lime_joystick_event_manager_register (vclosure* callback, HL_JoystickEvent* eventObject) { + HL_PRIM void hl_lime_joystick_event_manager_register (vclosure* callback, JoystickEvent* eventObject) { JoystickEvent::callback = new ValuePointer (callback); JoystickEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -2323,7 +2322,7 @@ namespace lime { } - HL_PRIM ImageBuffer* hl_lime_jpeg_decode_file (HL_String* path, bool decodeData, ImageBuffer* buffer) { + HL_PRIM ImageBuffer* hl_lime_jpeg_decode_file (hl_vstring* path, bool decodeData, ImageBuffer* buffer) { Resource resource = Resource (path); @@ -2376,7 +2375,7 @@ namespace lime { } - HL_PRIM void hl_lime_key_event_manager_register (vclosure* callback, HL_KeyEvent* eventObject) { + HL_PRIM void hl_lime_key_event_manager_register (vclosure* callback, KeyEvent* eventObject) { KeyEvent::callback = new ValuePointer (callback); KeyEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -2489,7 +2488,7 @@ namespace lime { } - HL_PRIM void hl_lime_mouse_event_manager_register (vclosure* callback, HL_MouseEvent* eventObject) { + HL_PRIM void hl_lime_mouse_event_manager_register (vclosure* callback, MouseEvent* eventObject) { MouseEvent::callback = new ValuePointer (callback); MouseEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -2646,7 +2645,7 @@ namespace lime { } - HL_PRIM ImageBuffer* hl_lime_png_decode_file (HL_String* path, bool decodeData, ImageBuffer* buffer) { + HL_PRIM ImageBuffer* hl_lime_png_decode_file (hl_vstring* path, bool decodeData, ImageBuffer* buffer) { Resource resource = Resource (path); @@ -2671,7 +2670,7 @@ namespace lime { } - HL_PRIM void hl_lime_render_event_manager_register (vclosure* callback, HL_RenderEvent* eventObject) { + HL_PRIM void hl_lime_render_event_manager_register (vclosure* callback, RenderEvent* eventObject) { RenderEvent::callback = new ValuePointer (callback); RenderEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -2848,7 +2847,7 @@ namespace lime { } - HL_PRIM void hl_lime_sensor_event_manager_register (vclosure* callback, HL_SensorEvent* eventObject) { + HL_PRIM void hl_lime_sensor_event_manager_register (vclosure* callback, SensorEvent* eventObject) { SensorEvent::callback = new ValuePointer (callback); SensorEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -2971,7 +2970,7 @@ namespace lime { } - HL_PRIM vbyte* hl_lime_system_get_directory (int type, HL_String* company, HL_String* title) { + HL_PRIM vbyte* hl_lime_system_get_directory (int type, hl_vstring* company, hl_vstring* title) { std::wstring* path = System::GetDirectory ((SystemDirectory)type, company ? (char*)hl_to_utf8 ((const uchar*)company->bytes) : NULL, title ? (char*)hl_to_utf8 ((const uchar*)title->bytes) : NULL); @@ -3283,7 +3282,7 @@ namespace lime { } - HL_PRIM void hl_lime_text_event_manager_register (vclosure* callback, HL_TextEvent* eventObject) { + HL_PRIM void hl_lime_text_event_manager_register (vclosure* callback, TextEvent* eventObject) { TextEvent::callback = new ValuePointer (callback); TextEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -3307,7 +3306,7 @@ namespace lime { } - HL_PRIM HL_CFFIPointer* hl_lime_text_layout_create (int direction, HL_String* script, HL_String* language) { + HL_PRIM HL_CFFIPointer* hl_lime_text_layout_create (int direction, hl_vstring* script, hl_vstring* language) { #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) @@ -3342,7 +3341,7 @@ namespace lime { } - HL_PRIM Bytes* hl_lime_text_layout_position (HL_CFFIPointer* textHandle, HL_CFFIPointer* fontHandle, int size, HL_String* textString, Bytes* data) { + HL_PRIM Bytes* hl_lime_text_layout_position (HL_CFFIPointer* textHandle, HL_CFFIPointer* fontHandle, int size, hl_vstring* textString, Bytes* data) { #if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ) @@ -3388,7 +3387,7 @@ namespace lime { } - HL_PRIM void hl_lime_text_layout_set_language (HL_CFFIPointer* textHandle, HL_String* language) { + HL_PRIM void hl_lime_text_layout_set_language (HL_CFFIPointer* textHandle, hl_vstring* language) { #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) TextLayout *text = (TextLayout*)textHandle->ptr; @@ -3408,7 +3407,7 @@ namespace lime { } - HL_PRIM void hl_lime_text_layout_set_script (HL_CFFIPointer* textHandle, HL_String* script) { + HL_PRIM void hl_lime_text_layout_set_script (HL_CFFIPointer* textHandle, hl_vstring* script) { #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) TextLayout *text = (TextLayout*)textHandle->ptr; @@ -3426,7 +3425,7 @@ namespace lime { } - HL_PRIM void hl_lime_touch_event_manager_register (vclosure* callback, HL_TouchEvent* eventObject) { + HL_PRIM void hl_lime_touch_event_manager_register (vclosure* callback, TouchEvent* eventObject) { TouchEvent::callback = new ValuePointer (callback); TouchEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -3442,7 +3441,7 @@ namespace lime { } - HL_PRIM void hl_lime_window_alert (HL_CFFIPointer* window, HL_String* message, HL_String* title) { + HL_PRIM void hl_lime_window_alert (HL_CFFIPointer* window, hl_vstring* message, hl_vstring* title) { Window* targetWindow = (Window*)window->ptr; targetWindow->Alert (message ? (const char*)hl_to_utf8 ((const uchar*)message) : NULL, title ? (const char*)hl_to_utf8 ((const uchar*)title) : NULL); @@ -3474,7 +3473,7 @@ namespace lime { } - HL_PRIM HL_CFFIPointer* hl_lime_window_create (HL_CFFIPointer* application, int width, int height, int flags, HL_String* title) { + HL_PRIM HL_CFFIPointer* hl_lime_window_create (HL_CFFIPointer* application, int width, int height, int flags, hl_vstring* title) { Window* window = CreateWindow ((Application*)application->ptr, width, height, flags, (const char*)hl_to_utf8 ((const uchar*)title->bytes)); return HLCFFIPointer (window, (hl_finalizer)hl_gc_window); @@ -3490,7 +3489,7 @@ namespace lime { } - HL_PRIM void hl_lime_window_event_manager_register (vclosure* callback, HL_WindowEvent* eventObject) { + HL_PRIM void hl_lime_window_event_manager_register (vclosure* callback, WindowEvent* eventObject) { WindowEvent::callback = new ValuePointer (callback); WindowEvent::eventObject = new ValuePointer ((vobj*)eventObject); @@ -3839,7 +3838,7 @@ namespace lime { } - HL_PRIM HL_String* hl_lime_window_set_title (HL_CFFIPointer* window, HL_String* title) { + HL_PRIM hl_vstring* hl_lime_window_set_title (HL_CFFIPointer* window, hl_vstring* title) { Window* targetWindow = (Window*)window->ptr; const char* result = targetWindow->SetTitle ((char*)hl_to_utf8 ((const uchar*)title->bytes)); @@ -4091,7 +4090,7 @@ namespace lime { #define _TCFFIPOINTER _DYN #define _TCLIPBOARD_EVENT _OBJ (_I32) #define _TDISPLAYMODE _OBJ (_I32 _I32 _I32 _I32) - #define _TDROP_EVENT _OBJ (_STRING _I32) + #define _TDROP_EVENT _OBJ (_BYTES _I32) #define _TGAMEPAD_EVENT _OBJ (_I32 _I32 _I32 _I32 _F64) #define _TJOYSTICK_EVENT _OBJ (_I32 _I32 _I32 _I32 _F64 _F64) #define _TKEY_EVENT _OBJ (_I32 _I32 _I32 _I32) @@ -4099,7 +4098,7 @@ namespace lime { #define _TRECTANGLE _OBJ (_F64 _F64 _F64 _F64) #define _TRENDER_EVENT _OBJ (_ENUM _I32) #define _TSENSOR_EVENT _OBJ (_I32 _F64 _F64 _F64 _I32) - #define _TTEXT_EVENT _OBJ (_I32 _I32 _I32 _STRING _I32 _I32) + #define _TTEXT_EVENT _OBJ (_I32 _I32 _I32 _BYTES _I32 _I32) #define _TTOUCH_EVENT _OBJ (_I32 _F64 _F64 _I32 _F64 _I32 _F64 _F64) #define _TVECTOR2 _OBJ (_I32 _I32 _I32) #define _TVORBISFILE _OBJ (_I32 _DYN) diff --git a/project/src/app/ApplicationEvent.cpp b/project/src/app/ApplicationEvent.cpp index 9e09e148a..22cd02f15 100644 --- a/project/src/app/ApplicationEvent.cpp +++ b/project/src/app/ApplicationEvent.cpp @@ -42,7 +42,7 @@ namespace lime { } else { - HL_ApplicationEvent* eventObject = (HL_ApplicationEvent*)ApplicationEvent::eventObject->Get (); + ApplicationEvent* eventObject = (ApplicationEvent*)ApplicationEvent::eventObject->Get (); eventObject->deltaTime = event->deltaTime; eventObject->type = event->type; diff --git a/project/src/backend/sdl/SDLApplication.cpp b/project/src/backend/sdl/SDLApplication.cpp index d4e4866c4..64cc71430 100644 --- a/project/src/backend/sdl/SDLApplication.cpp +++ b/project/src/backend/sdl/SDLApplication.cpp @@ -342,7 +342,7 @@ namespace lime { if (DropEvent::callback) { dropEvent.type = DROP_FILE; - dropEvent.file = event->drop.file; + dropEvent.file = (vbyte*)event->drop.file; DropEvent::Dispatch (&dropEvent); SDL_free (dropEvent.file); @@ -682,7 +682,15 @@ namespace lime { } - strcpy (textEvent.text, event->text.text); + if (textEvent.text) { + + free (textEvent.text); + + } + + textEvent.text = (vbyte*)malloc (strlen (event->text.text) + 1); + strcpy ((char*)textEvent.text, event->text.text); + textEvent.windowID = event->text.windowID; TextEvent::Dispatch (&textEvent); diff --git a/project/src/graphics/RenderEvent.cpp b/project/src/graphics/RenderEvent.cpp index 7213b1948..1207c9aaf 100644 --- a/project/src/graphics/RenderEvent.cpp +++ b/project/src/graphics/RenderEvent.cpp @@ -37,7 +37,7 @@ namespace lime { } else { - HL_RenderEvent* eventObject = (HL_RenderEvent*)RenderEvent::eventObject->Get (); + RenderEvent* eventObject = (RenderEvent*)RenderEvent::eventObject->Get (); eventObject->type = event->type; diff --git a/project/src/graphics/cairo/CairoBindings.cpp b/project/src/graphics/cairo/CairoBindings.cpp index 9c5134cfc..754a03426 100644 --- a/project/src/graphics/cairo/CairoBindings.cpp +++ b/project/src/graphics/cairo/CairoBindings.cpp @@ -8,7 +8,6 @@ #include #include #include -#include namespace lime { @@ -2116,7 +2115,7 @@ namespace lime { } - HL_PRIM void hl_lime_cairo_show_text (HL_CFFIPointer* handle, HL_String* text) { + HL_PRIM void hl_lime_cairo_show_text (HL_CFFIPointer* handle, hl_vstring* text) { cairo_show_text ((cairo_t*)handle->ptr, (char*)hl_to_utf8 ((const uchar*)text->bytes)); @@ -2200,7 +2199,7 @@ namespace lime { } - HL_PRIM void hl_lime_cairo_text_path (HL_CFFIPointer* handle, HL_String* text) { + HL_PRIM void hl_lime_cairo_text_path (HL_CFFIPointer* handle, hl_vstring* text) { cairo_text_path ((cairo_t*)handle->ptr, (char*)hl_to_utf8 ((const uchar*)text->bytes)); diff --git a/project/src/media/openal/OpenALBindings.cpp b/project/src/media/openal/OpenALBindings.cpp index 1be2a2f52..7913f98c6 100644 --- a/project/src/media/openal/OpenALBindings.cpp +++ b/project/src/media/openal/OpenALBindings.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -2478,7 +2477,7 @@ namespace lime { } - HL_PRIM ALCdevice* hl_lime_alc_open_device (HL_String* devicename) { + HL_PRIM ALCdevice* hl_lime_alc_open_device (hl_vstring* devicename) { ALCdevice* alcDevice = alcOpenDevice (devicename ? (char*)hl_to_utf8 ((const uchar*)devicename->bytes) : 0); atexit (lime_al_atexit); diff --git a/project/src/system/ClipboardEvent.cpp b/project/src/system/ClipboardEvent.cpp index 79127c268..4757bc14c 100644 --- a/project/src/system/ClipboardEvent.cpp +++ b/project/src/system/ClipboardEvent.cpp @@ -38,7 +38,7 @@ namespace lime { } else { - HL_ClipboardEvent* eventObject = (HL_ClipboardEvent*)ClipboardEvent::eventObject->Get (); + ClipboardEvent* eventObject = (ClipboardEvent*)ClipboardEvent::eventObject->Get (); eventObject->type = event->type; diff --git a/project/src/system/SensorEvent.cpp b/project/src/system/SensorEvent.cpp index bf60c3fde..9fd9e5adb 100644 --- a/project/src/system/SensorEvent.cpp +++ b/project/src/system/SensorEvent.cpp @@ -54,7 +54,7 @@ namespace lime { } else { - HL_SensorEvent* eventObject = (HL_SensorEvent*)SensorEvent::eventObject->Get (); + SensorEvent* eventObject = (SensorEvent*)SensorEvent::eventObject->Get (); eventObject->id = event->id; eventObject->type = event->type; diff --git a/project/src/ui/DropEvent.cpp b/project/src/ui/DropEvent.cpp index 6ab03544c..9f0610252 100644 --- a/project/src/ui/DropEvent.cpp +++ b/project/src/ui/DropEvent.cpp @@ -37,12 +37,12 @@ namespace lime { value object = (value)DropEvent::eventObject->Get (); - alloc_field (object, id_file, alloc_string (event->file)); + alloc_field (object, id_file, alloc_string ((const char*)event->file)); alloc_field (object, id_type, alloc_int (event->type)); } else { - HL_DropEvent* eventObject = (HL_DropEvent*)DropEvent::eventObject->Get (); + DropEvent* eventObject = (DropEvent*)DropEvent::eventObject->Get (); // TODO // eventObject->file = event->file; diff --git a/project/src/ui/GamepadEvent.cpp b/project/src/ui/GamepadEvent.cpp index c34875c12..8bb412109 100644 --- a/project/src/ui/GamepadEvent.cpp +++ b/project/src/ui/GamepadEvent.cpp @@ -39,7 +39,7 @@ namespace lime { id_button = val_id ("button"); id_id = val_id ("id"); id_type = val_id ("type"); - id_value = val_id ("value"); + id_value = val_id ("axisValue"); init = true; } @@ -54,13 +54,13 @@ namespace lime { } else { - HL_GamepadEvent* eventObject = (HL_GamepadEvent*)GamepadEvent::eventObject->Get (); + GamepadEvent* eventObject = (GamepadEvent*)GamepadEvent::eventObject->Get (); eventObject->axis = event->axis; eventObject->button = event->button; eventObject->id = event->id; eventObject->type = event->type; - eventObject->value = event->axisValue; + eventObject->axisValue = event->axisValue; } diff --git a/project/src/ui/JoystickEvent.cpp b/project/src/ui/JoystickEvent.cpp index 208e28f65..108d30e62 100644 --- a/project/src/ui/JoystickEvent.cpp +++ b/project/src/ui/JoystickEvent.cpp @@ -40,7 +40,7 @@ namespace lime { id_id = val_id ("id"); id_index = val_id ("index"); id_type = val_id ("type"); - id_value = val_id ("value"); + id_value = val_id ("eventValue"); id_x = val_id ("x"); id_y = val_id ("y"); init = true; @@ -58,12 +58,12 @@ namespace lime { } else { - HL_JoystickEvent* eventObject = (HL_JoystickEvent*)JoystickEvent::eventObject->Get (); + JoystickEvent* eventObject = (JoystickEvent*)JoystickEvent::eventObject->Get (); eventObject->id = event->id; eventObject->index = event->index; eventObject->type = event->type; - eventObject->value = event->eventValue; + eventObject->eventValue = event->eventValue; eventObject->x = event->x; eventObject->y = event->y; diff --git a/project/src/ui/KeyEvent.cpp b/project/src/ui/KeyEvent.cpp index 7d642b938..983831a25 100644 --- a/project/src/ui/KeyEvent.cpp +++ b/project/src/ui/KeyEvent.cpp @@ -50,7 +50,7 @@ namespace lime { } else { - HL_KeyEvent* eventObject = (HL_KeyEvent*)KeyEvent::eventObject->Get (); + KeyEvent* eventObject = (KeyEvent*)KeyEvent::eventObject->Get (); eventObject->keyCode = event->keyCode; eventObject->modifier = event->modifier; diff --git a/project/src/ui/MouseEvent.cpp b/project/src/ui/MouseEvent.cpp index 7812a8c51..eaa2372eb 100644 --- a/project/src/ui/MouseEvent.cpp +++ b/project/src/ui/MouseEvent.cpp @@ -67,7 +67,7 @@ namespace lime { } else { - HL_MouseEvent* eventObject = (HL_MouseEvent*)MouseEvent::eventObject->Get (); + MouseEvent* eventObject = (MouseEvent*)MouseEvent::eventObject->Get (); eventObject->movementX = event->movementX; eventObject->movementY = event->movementY; diff --git a/project/src/ui/TextEvent.cpp b/project/src/ui/TextEvent.cpp index fc7b6108d..6c27cf786 100644 --- a/project/src/ui/TextEvent.cpp +++ b/project/src/ui/TextEvent.cpp @@ -20,6 +20,7 @@ namespace lime { length = 0; start = 0; + text = 0; windowID = 0; } @@ -51,13 +52,13 @@ namespace lime { } - alloc_field (object, id_text, alloc_string (event->text)); + alloc_field (object, id_text, alloc_string ((const char*)event->text)); alloc_field (object, id_type, alloc_int (event->type)); alloc_field (object, id_windowID, alloc_int (event->windowID)); } else { - HL_TextEvent* eventObject = (HL_TextEvent*)TextEvent::eventObject->Get (); + TextEvent* eventObject = (TextEvent*)TextEvent::eventObject->Get (); if (event->type != TEXT_INPUT) { @@ -66,8 +67,7 @@ namespace lime { } - // TODO - //eventObject->text = event->text; + eventObject->text = event->text; eventObject->type = event->type; eventObject->windowID = event->windowID; diff --git a/project/src/ui/TouchEvent.cpp b/project/src/ui/TouchEvent.cpp index dd8825fd0..8de2fa6b0 100644 --- a/project/src/ui/TouchEvent.cpp +++ b/project/src/ui/TouchEvent.cpp @@ -66,7 +66,7 @@ namespace lime { } else { - HL_TouchEvent* eventObject = (HL_TouchEvent*)TouchEvent::eventObject->Get (); + TouchEvent* eventObject = (TouchEvent*)TouchEvent::eventObject->Get (); eventObject->device = event->device; eventObject->dx = event->dx; diff --git a/project/src/ui/WindowEvent.cpp b/project/src/ui/WindowEvent.cpp index b0657a0f0..8cfe3ed9b 100644 --- a/project/src/ui/WindowEvent.cpp +++ b/project/src/ui/WindowEvent.cpp @@ -73,7 +73,7 @@ namespace lime { } else { - HL_WindowEvent* eventObject = (HL_WindowEvent*)WindowEvent::eventObject->Get (); + WindowEvent* eventObject = (WindowEvent*)WindowEvent::eventObject->Get (); eventObject->type = event->type; eventObject->windowID = event->windowID;