More bindings

This commit is contained in:
Joshua Granick
2018-05-25 09:43:20 -07:00
parent f2dddf5847
commit 4d2e8febe3
2 changed files with 194 additions and 5 deletions

View File

@@ -19,6 +19,10 @@ import cpp.Float32;
typedef Float32 = Float;
#end
// #if hl
// typedef TNative_Application = hl.Abstract<"Application">;
// #end
#if !lime_debug
@:fileXml('tags="haxe,release"')
@:noDebug
@@ -185,11 +189,11 @@ class NativeCFFI {
#if hl
@:hlNative("lime", "lime_application_create") private static function lime_application_create ():CFFIPointer { return null; }
@:cffi private static function lime_application_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void;
@:cffi private static function lime_application_exec (handle:Dynamic):Int;
@:cffi private static function lime_application_init (handle:Dynamic):Void;
@:cffi private static function lime_application_quit (handle:Dynamic):Int;
@:cffi private static function lime_application_set_frame_rate (handle:Dynamic, value:Float):Void;
@:cffi private static function lime_application_update (handle:Dynamic):Bool;
@:hlNative("lime", "lime_application_exec") private static function lime_application_exec (handle:CFFIPointer):Int { return 0; }
@:hlNative("lime", "lime_application_init") private static function lime_application_init (handle:CFFIPointer):Void {}
@:hlNative("lime", "lime_application_quit") private static function lime_application_quit (handle:CFFIPointer):Int { return 0; }
@:hlNative("lime", "lime_application_set_frame_rate") private static function lime_application_set_frame_rate (handle:CFFIPointer, value:Float):Void {}
@:hlNative("lime", "lime_application_update") private static function lime_application_update (handle:CFFIPointer):Bool { return false; }
@:cffi private static function lime_audio_load (data:Dynamic, buffer:Dynamic):Dynamic;
@:cffi private static function lime_bytes_from_data_pointer (data:Float, length:Int):Dynamic;
@:cffi private static function lime_bytes_get_data_pointer (data:Dynamic):Float;

View File

@@ -164,6 +164,14 @@ namespace lime {
}
HL_PRIM int hl_lime_application_exec (HL_CFFIPointer* application) {
Application* app = (Application*)application->ptr;
return app->Exec ();
}
void lime_application_init (value application) {
Application* app = (Application*)val_data (application);
@@ -172,6 +180,14 @@ namespace lime {
}
HL_PRIM void hl_lime_application_init (HL_CFFIPointer* application) {
Application* app = (Application*)application->ptr;
app->Init ();
}
int lime_application_quit (value application) {
Application* app = (Application*)val_data (application);
@@ -180,6 +196,14 @@ namespace lime {
}
HL_PRIM int hl_lime_application_quit (HL_CFFIPointer* application) {
Application* app = (Application*)application->ptr;
return app->Quit ();
}
void lime_application_set_frame_rate (value application, double frameRate) {
Application* app = (Application*)val_data (application);
@@ -188,6 +212,14 @@ namespace lime {
}
HL_PRIM void hl_lime_application_set_frame_rate (HL_CFFIPointer* application, double frameRate) {
Application* app = (Application*)application->ptr;
app->SetFrameRate (frameRate);
}
bool lime_application_update (value application) {
Application* app = (Application*)val_data (application);
@@ -196,6 +228,14 @@ namespace lime {
}
HL_PRIM bool hl_lime_application_update (HL_CFFIPointer* application) {
Application* app = (Application*)application->ptr;
return app->Update ();
}
value lime_audio_load (value data, value buffer) {
Resource resource;
@@ -1757,6 +1797,14 @@ namespace lime {
}
HL_PRIM void hl_lime_window_alert (HL_CFFIPointer* window, vbyte* message, vbyte* title) {
Window* targetWindow = (Window*)window->ptr;
targetWindow->Alert ((const char*)message, (const char*)title);
}
void lime_window_close (value window) {
Window* targetWindow = (Window*)val_data (window);
@@ -1765,6 +1813,14 @@ namespace lime {
}
HL_PRIM void hl_lime_window_close (HL_CFFIPointer* window) {
Window* targetWindow = (Window*)window->ptr;
targetWindow->Close ();
}
value lime_window_create (value application, int width, int height, int flags, HxString title) {
Window* window = CreateWindow ((Application*)val_data (application), width, height, flags, title.c_str ());
@@ -1773,6 +1829,14 @@ namespace lime {
}
HL_PRIM HL_CFFIPointer* hl_lime_window_create (HL_CFFIPointer* application, int width, int height, int flags, vbyte* title) {
Window* window = CreateWindow ((Application*)application->ptr, width, height, flags, (const char*)title);
return HLCFFIPointer (window, gc_window);
}
void lime_window_event_manager_register (value callback, value eventObject) {
WindowEvent::callback = new AutoGCRoot (callback);
@@ -1789,6 +1853,14 @@ namespace lime {
}
HL_PRIM void hl_lime_window_focus (HL_CFFIPointer* window) {
Window* targetWindow = (Window*)window->ptr;
targetWindow->Focus ();
}
int lime_window_get_display (value window) {
Window* targetWindow = (Window*)val_data (window);
@@ -1797,6 +1869,14 @@ namespace lime {
}
HL_PRIM int hl_lime_window_get_display (HL_CFFIPointer* window) {
Window* targetWindow = (Window*)window->ptr;
return targetWindow->GetDisplay ();
}
value lime_window_get_display_mode (value window) {
Window* targetWindow = (Window*)val_data (window);
@@ -1815,6 +1895,14 @@ namespace lime {
}
HL_PRIM bool hl_lime_window_get_enable_text_events (HL_CFFIPointer* window) {
Window* targetWindow = (Window*)window->ptr;
return targetWindow->GetEnableTextEvents ();
}
int lime_window_get_height (value window) {
Window* targetWindow = (Window*)val_data (window);
@@ -1823,6 +1911,14 @@ namespace lime {
}
HL_PRIM int hl_lime_window_get_height (HL_CFFIPointer* window) {
Window* targetWindow = (Window*)window->ptr;
return targetWindow->GetHeight ();
}
int32_t lime_window_get_id (value window) {
Window* targetWindow = (Window*)val_data (window);
@@ -1831,6 +1927,14 @@ namespace lime {
}
HL_PRIM int32_t hl_lime_window_get_id (HL_CFFIPointer* window) {
Window* targetWindow = (Window*)window->ptr;
return (int32_t)targetWindow->GetID ();
}
int lime_window_get_width (value window) {
Window* targetWindow = (Window*)val_data (window);
@@ -1839,6 +1943,14 @@ namespace lime {
}
HL_PRIM int hl_lime_window_get_width (HL_CFFIPointer* window) {
Window* targetWindow = (Window*)window->ptr;
return targetWindow->GetWidth ();
}
int lime_window_get_x (value window) {
Window* targetWindow = (Window*)val_data (window);
@@ -1847,6 +1959,14 @@ namespace lime {
}
HL_PRIM int hl_lime_window_get_x (HL_CFFIPointer* window) {
Window* targetWindow = (Window*)window->ptr;
return targetWindow->GetX ();
}
int lime_window_get_y (value window) {
Window* targetWindow = (Window*)val_data (window);
@@ -1855,6 +1975,14 @@ namespace lime {
}
HL_PRIM int hl_lime_window_get_y (HL_CFFIPointer* window) {
Window* targetWindow = (Window*)window->ptr;
return targetWindow->GetY ();
}
void lime_window_move (value window, int x, int y) {
Window* targetWindow = (Window*)val_data (window);
@@ -1863,6 +1991,14 @@ namespace lime {
}
HL_PRIM void hl_lime_window_move (HL_CFFIPointer* window, int x, int y) {
Window* targetWindow = (Window*)window->ptr;
targetWindow->Move (x, y);
}
void lime_window_resize (value window, int width, int height) {
Window* targetWindow = (Window*)val_data (window);
@@ -1871,6 +2007,14 @@ namespace lime {
}
HL_PRIM void hl_lime_window_resize (HL_CFFIPointer* window, int width, int height) {
Window* targetWindow = (Window*)window->ptr;
targetWindow->Resize (width, height);
}
bool lime_window_set_borderless (value window, bool borderless) {
Window* targetWindow = (Window*)val_data (window);
@@ -1879,6 +2023,14 @@ namespace lime {
}
HL_PRIM bool hl_lime_window_set_borderless (HL_CFFIPointer* window, bool borderless) {
Window* targetWindow = (Window*)window->ptr;
return targetWindow->SetBorderless (borderless);
}
value lime_window_set_display_mode (value window, value displayMode) {
Window* targetWindow = (Window*)val_data (window);
@@ -1898,6 +2050,14 @@ namespace lime {
}
HL_PRIM void hl_lime_window_set_enable_text_events (HL_CFFIPointer* window, bool enabled) {
Window* targetWindow = (Window*)window->ptr;
targetWindow->SetEnableTextEvents (enabled);
}
bool lime_window_set_fullscreen (value window, bool fullscreen) {
Window* targetWindow = (Window*)val_data (window);
@@ -2160,9 +2320,34 @@ namespace lime {
#define TIMAGEBUFFER _OBJ (_I32 TARRAYBUFFERVIEW _I32 _I32 _BOOL _BOOL _I32 _DYN _DYN _DYN _DYN _DYN _DYN)
#define TRECTANGLE _OBJ (_F64 _F64 _F64 _F64)
#define TIMAGE _OBJ (TIMAGEBUFFER _BOOL _I32 _I32 _I32 TRECTANGLE _ENUM _I32 _I32 _F64 _F64)
// #define TNATIVE_APPLICATION _ABSTRACT (Application)
DEFINE_HL_PRIM (TCFFIPOINTER, lime_application_create, _NO_ARG);
// DEFINE_PRIME2v (lime_application_event_manager_register);
DEFINE_HL_PRIM (_I32, lime_application_exec, TCFFIPOINTER);
DEFINE_HL_PRIM (_VOID, lime_application_init, TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_application_quit, TCFFIPOINTER);
DEFINE_HL_PRIM (_VOID, lime_application_set_frame_rate, TCFFIPOINTER _F64);
DEFINE_HL_PRIM (_BOOL, lime_application_update, TCFFIPOINTER);
DEFINE_HL_PRIM (_VOID, lime_image_data_util_fill_rect, TIMAGE TRECTANGLE _I32 _I32);
DEFINE_HL_PRIM (_VOID, lime_window_alert, TCFFIPOINTER _BYTES _BYTES);
DEFINE_HL_PRIM (_VOID, lime_window_close, TCFFIPOINTER);
DEFINE_HL_PRIM (TCFFIPOINTER, lime_window_create, TCFFIPOINTER _I32 _I32 _I32 _BYTES);
// DEFINE_PRIME2v (_VOID, lime_window_event_manager_register, TCFFIPOINTER );
DEFINE_HL_PRIM (_VOID, lime_window_focus, TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_window_get_display, TCFFIPOINTER);
// DEFINE_PRIME1 (lime_window_get_display_mode);
DEFINE_HL_PRIM (_BOOL, lime_window_get_enable_text_events, TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_window_get_height, TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_window_get_id, TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_window_get_width, TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_window_get_x, TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_window_get_y, TCFFIPOINTER);
DEFINE_HL_PRIM (_VOID, lime_window_move, TCFFIPOINTER _I32);
DEFINE_HL_PRIM (_VOID, lime_window_resize, TCFFIPOINTER _I32);
DEFINE_HL_PRIM (_BOOL, lime_window_set_borderless, TCFFIPOINTER _BOOL);
// DEFINE_PRIME2 (lime_window_set_display_mode, TCFFIPOINTER );
DEFINE_HL_PRIM (_VOID, lime_window_set_enable_text_events, TCFFIPOINTER _BOOL);
}