Fixes for Node.js without CFFI

This commit is contained in:
Joshua Granick
2018-01-08 14:18:29 -08:00
parent a25b7798b4
commit c9c5bf0bc5
12 changed files with 55 additions and 41 deletions

View File

@@ -103,7 +103,7 @@ class NativeApplication {
public function create (config:Config):Void { public function create (config:Config):Void {
#if !macro #if (!macro && lime_cffi)
handle = NativeCFFI.lime_application_create ( { } ); handle = NativeCFFI.lime_application_create ( { } );
#end #end
@@ -114,6 +114,7 @@ class NativeApplication {
#if !macro #if !macro
#if lime_cffi
NativeCFFI.lime_application_event_manager_register (handleApplicationEvent, applicationEventInfo); NativeCFFI.lime_application_event_manager_register (handleApplicationEvent, applicationEventInfo);
NativeCFFI.lime_clipboard_event_manager_register (handleClipboardEvent, clipboardEventInfo); NativeCFFI.lime_clipboard_event_manager_register (handleClipboardEvent, clipboardEventInfo);
NativeCFFI.lime_drop_event_manager_register (handleDropEvent, dropEventInfo); NativeCFFI.lime_drop_event_manager_register (handleDropEvent, dropEventInfo);
@@ -125,12 +126,12 @@ class NativeApplication {
NativeCFFI.lime_text_event_manager_register (handleTextEvent, textEventInfo); NativeCFFI.lime_text_event_manager_register (handleTextEvent, textEventInfo);
NativeCFFI.lime_touch_event_manager_register (handleTouchEvent, touchEventInfo); NativeCFFI.lime_touch_event_manager_register (handleTouchEvent, touchEventInfo);
NativeCFFI.lime_window_event_manager_register (handleWindowEvent, windowEventInfo); NativeCFFI.lime_window_event_manager_register (handleWindowEvent, windowEventInfo);
#if (ios || android || tvos) #if (ios || android || tvos)
NativeCFFI.lime_sensor_event_manager_register (handleSensorEvent, sensorEventInfo); NativeCFFI.lime_sensor_event_manager_register (handleSensorEvent, sensorEventInfo);
#end #end
#end
#if nodejs #if (nodejs && lime_cffi)
NativeCFFI.lime_application_init (handle); NativeCFFI.lime_application_init (handle);
@@ -176,7 +177,7 @@ class NativeApplication {
AudioManager.shutdown (); AudioManager.shutdown ();
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_application_quit (handle); NativeCFFI.lime_application_quit (handle);
#end #end
@@ -683,7 +684,7 @@ class NativeApplication {
public function setFrameRate (value:Float):Float { public function setFrameRate (value:Float):Float {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_application_set_frame_rate (handle, value); NativeCFFI.lime_application_set_frame_rate (handle, value);
#end #end
return frameRate = value; return frameRate = value;

View File

@@ -185,6 +185,8 @@ class NativeAudioSource {
private function readVorbisFileBuffer (vorbisFile:VorbisFile, length:Int):UInt8Array { private function readVorbisFileBuffer (vorbisFile:VorbisFile, length:Int):UInt8Array {
#if lime_vorbis
var buffer = new UInt8Array (length); var buffer = new UInt8Array (length);
var read = 0, total = 0, readMax; var read = 0, total = 0, readMax;
@@ -214,6 +216,12 @@ class NativeAudioSource {
return buffer; return buffer;
#else
return null;
#end
} }

View File

@@ -28,7 +28,7 @@ class NativeMouse {
__hidden = true; __hidden = true;
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_mouse_hide (); NativeCFFI.lime_mouse_hide ();
#end #end
@@ -43,7 +43,7 @@ class NativeMouse {
__hidden = false; __hidden = false;
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_mouse_show (); NativeCFFI.lime_mouse_show ();
#end #end
@@ -54,7 +54,7 @@ class NativeMouse {
public static function warp (x:Int, y:Int, window:Window):Void { public static function warp (x:Int, y:Int, window:Window):Void {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_mouse_warp (x, y, window == null ? 0 : window.backend.handle); NativeCFFI.lime_mouse_warp (x, y, window == null ? 0 : window.backend.handle);
#end #end
@@ -99,7 +99,7 @@ class NativeMouse {
} }
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_mouse_set_cursor (type); NativeCFFI.lime_mouse_set_cursor (type);
#end #end
@@ -125,7 +125,7 @@ class NativeMouse {
if (__lock != value) { if (__lock != value) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_mouse_set_lock (value); NativeCFFI.lime_mouse_set_lock (value);
#end #end

View File

@@ -53,7 +53,7 @@ class NativeRenderer {
public function create ():Void { public function create ():Void {
#if !macro #if (!macro && lime_cffi)
handle = NativeCFFI.lime_renderer_create (parent.window.backend.handle); handle = NativeCFFI.lime_renderer_create (parent.window.backend.handle);
parent.window.__scale = NativeCFFI.lime_renderer_get_scale (handle); parent.window.__scale = NativeCFFI.lime_renderer_get_scale (handle);
@@ -111,7 +111,7 @@ class NativeRenderer {
public function flip ():Void { public function flip ():Void {
#if !macro #if (!macro && lime_cffi)
if (!useHardware) { if (!useHardware) {
#if lime_cairo #if lime_cairo
@@ -135,7 +135,7 @@ class NativeRenderer {
var imageBuffer:ImageBuffer = null; var imageBuffer:ImageBuffer = null;
#if !macro #if (!macro && lime_cffi)
#if !cs #if !cs
imageBuffer = NativeCFFI.lime_renderer_read_pixels (handle, rect, new ImageBuffer (new UInt8Array (Bytes.alloc (0)))); imageBuffer = NativeCFFI.lime_renderer_read_pixels (handle, rect, new ImageBuffer (new UInt8Array (Bytes.alloc (0))));
#else #else
@@ -160,7 +160,7 @@ class NativeRenderer {
public function render ():Void { public function render ():Void {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_renderer_make_current (handle); NativeCFFI.lime_renderer_make_current (handle);
if (!useHardware) { if (!useHardware) {

View File

@@ -46,7 +46,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_window_alert (handle, message, title); NativeCFFI.lime_window_alert (handle, message, title);
#end #end
@@ -66,7 +66,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_window_close (handle); NativeCFFI.lime_window_close (handle);
#end #end
handle = null; handle = null;
@@ -132,7 +132,7 @@ class NativeWindow {
} }
#if !macro #if (!macro && lime_cffi)
handle = NativeCFFI.lime_window_create (application.backend.handle, parent.width, parent.height, flags, title); handle = NativeCFFI.lime_window_create (application.backend.handle, parent.width, parent.height, flags, title);
if (handle != null) { if (handle != null) {
@@ -153,7 +153,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_window_focus (handle); NativeCFFI.lime_window_focus (handle);
#end #end
@@ -166,7 +166,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
var index = NativeCFFI.lime_window_get_display (handle); var index = NativeCFFI.lime_window_get_display (handle);
if (index > -1) { if (index > -1) {
@@ -187,7 +187,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
var data:Dynamic = NativeCFFI.lime_window_get_display_mode (handle); var data:Dynamic = NativeCFFI.lime_window_get_display_mode (handle);
displayMode.width = data.width; displayMode.width = data.width;
displayMode.height = data.height; displayMode.height = data.height;
@@ -206,7 +206,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
var data:Dynamic = NativeCFFI.lime_window_set_display_mode (handle, value); var data:Dynamic = NativeCFFI.lime_window_set_display_mode (handle, value);
displayMode.width = data.width; displayMode.width = data.width;
displayMode.height = data.height; displayMode.height = data.height;
@@ -225,7 +225,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
return NativeCFFI.lime_window_get_enable_text_events (handle); return NativeCFFI.lime_window_get_enable_text_events (handle);
#end #end
@@ -240,7 +240,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_window_move (handle, x, y); NativeCFFI.lime_window_move (handle, x, y);
#end #end
@@ -253,7 +253,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_window_resize (handle, width, height); NativeCFFI.lime_window_resize (handle, width, height);
#end #end
@@ -266,7 +266,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_window_set_borderless (handle, value); NativeCFFI.lime_window_set_borderless (handle, value);
#end #end
@@ -280,7 +280,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_window_set_enable_text_events (handle, value); NativeCFFI.lime_window_set_enable_text_events (handle, value);
#end #end
@@ -306,7 +306,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
value = NativeCFFI.lime_window_set_fullscreen (handle, value); value = NativeCFFI.lime_window_set_fullscreen (handle, value);
parent.__width = NativeCFFI.lime_window_get_width (handle); parent.__width = NativeCFFI.lime_window_get_width (handle);
@@ -332,7 +332,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_window_set_icon (handle, image.buffer); NativeCFFI.lime_window_set_icon (handle, image.buffer);
#end #end
@@ -345,7 +345,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
return NativeCFFI.lime_window_set_maximized (handle, value); return NativeCFFI.lime_window_set_maximized (handle, value);
#end #end
@@ -360,7 +360,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
return NativeCFFI.lime_window_set_minimized (handle, value); return NativeCFFI.lime_window_set_minimized (handle, value);
#end #end
@@ -375,7 +375,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
NativeCFFI.lime_window_set_resizable (handle, value); NativeCFFI.lime_window_set_resizable (handle, value);
// TODO: remove need for workaround // TODO: remove need for workaround
@@ -394,7 +394,7 @@ class NativeWindow {
if (handle != null) { if (handle != null) {
#if !macro #if (!macro && lime_cffi)
return NativeCFFI.lime_window_set_title (handle, value); return NativeCFFI.lime_window_set_title (handle, value);
#end #end

View File

@@ -1994,7 +1994,7 @@ abstract WebGL2Context(GLRenderContext) from GLRenderContext to GLRenderContext
#if (!js || !html5 || display) #if (!js || !html5 || display)
public inline function getBufferSubData (target:Int, srcByteOffset:DataPointer, dstData:ArrayBuffer, srcOffset:Int = 0, ?length:Int):Void { public inline function getBufferSubData (target:Int, srcByteOffset:DataPointer, dstData:ArrayBuffer, srcOffset:Int = 0, ?length:Int):Void {
var size = (length != null) ? length : (dstData != null) ? dstData.length : 0; var size = (length != null) ? length : (dstData != null) ? dstData.byteLength : 0;
this.getBufferSubData (target, srcByteOffset + srcOffset, size, dstData); this.getBufferSubData (target, srcByteOffset + srcOffset, size, dstData);
} }

View File

@@ -7,7 +7,7 @@ import lime.app.Event;
#if flash #if flash
import flash.desktop.Clipboard in FlashClipboard; import flash.desktop.Clipboard in FlashClipboard;
#elseif js #elseif (js && html5)
import lime._backend.html5.HTML5Window; import lime._backend.html5.HTML5Window;
#end #end

View File

@@ -295,7 +295,7 @@ class System {
#if flash #if flash
return flash.Lib.getTimer (); return flash.Lib.getTimer ();
#elseif js #elseif (js && !nodejs)
return Std.int (Browser.window.performance.now ()); return Std.int (Browser.window.performance.now ());
#elseif (!disable_cffi && !macro) #elseif (!disable_cffi && !macro)
return cast NativeCFFI.lime_system_get_timer (); return cast NativeCFFI.lime_system_get_timer ();

View File

@@ -533,6 +533,9 @@ class AssetHelper {
if (isPackedLibrary (project, library)) { if (isPackedLibrary (project, library)) {
// TODO
#if !nodejs
if (type == "zip") type = "deflate"; if (type == "zip") type = "deflate";
// TODO: Support library.embed=true by embedding all the assets instead of packing // TODO: Support library.embed=true by embedding all the assets instead of packing
@@ -611,6 +614,8 @@ class AssetHelper {
} }
#end
} }
} }

View File

@@ -220,9 +220,7 @@ class FileHelper {
try { try {
var fileOutput:FileOutput = File.write (destination, true); File.saveContent (destination, result);
fileOutput.writeString (result);
fileOutput.close ();
} catch (e:Dynamic) { } catch (e:Dynamic) {

View File

@@ -52,7 +52,9 @@ class LogHelper {
if (verbose && e != null) { if (verbose && e != null) {
#if !cs #if js
throw e;
#elseif !cs
Lib.rethrow (e); Lib.rethrow (e);
#end #end

View File

@@ -24,7 +24,7 @@ abstract BytePointer(BytePointerData) from BytePointerData to BytePointerData {
if (buffer != null) { if (buffer != null) {
#if (js && html5) #if js
bytes = Bytes.ofData (cast buffer); bytes = Bytes.ofData (cast buffer);
#else #else
bytes = buffer; bytes = buffer;
@@ -39,7 +39,7 @@ abstract BytePointer(BytePointerData) from BytePointerData to BytePointerData {
} else { } else {
#if (js && html5) #if js
this.bytes = Bytes.ofData (cast bufferView.buffer); this.bytes = Bytes.ofData (cast bufferView.buffer);
#else #else
this.bytes = bufferView.buffer; this.bytes = bufferView.buffer;