Merge branch 'develop' of https://github.com/openfl/lime into develop

This commit is contained in:
Joshua Granick
2018-02-27 12:55:03 -08:00
16 changed files with 105 additions and 35 deletions

View File

@@ -481,6 +481,26 @@ class FileHelper {
}
public static function replaceText (source:String, replaceString:String, replacement:String) {
if (FileSystem.exists (source)) {
var output = File.getContent (source);
var index = output.indexOf (replaceString);
if (index > -1) {
output = output.substr (0, index) + replacement + output.substr (index + replaceString.length);
File.saveContent (source, output);
}
}
}
public static function isNewer (source:String, destination:String):Bool {
if (source == null || !FileSystem.exists (source)) {

View File

@@ -12,6 +12,7 @@ import lime.project.Asset;
import lime.project.Haxelib;
import lime.project.HXProject;
import lime.project.Platform;
import lime.project.Version;
import sys.FileSystem;
import sys.io.File;
@@ -25,6 +26,31 @@ import cpp.vm.Thread;
class HTML5Helper {
public static function encodeSourceMappingURL (sourceFile:String) {
// This is only required for projects with url-unsafe characters built with a Haxe version prior to 4.0.0
var filename = Path.withoutDirectory (sourceFile);
if (filename != StringTools.urlEncode (filename)) {
var output = ProcessHelper.runProcess ("", "haxe", [ "-version" ], true, true, true, false, true);
var haxeVer:Version = StringTools.trim (output);
if (haxeVer < ("4.0.0" : Version)) {
var replaceString = "//# sourceMappingURL=" + filename + ".map";
var replacement = "//# sourceMappingURL=" + StringTools.urlEncode (filename) + ".map";
FileHelper.replaceText (sourceFile, replaceString, replacement);
}
}
}
public static function generateFontData (project:HXProject, font:Asset):String {
var sourcePath = font.sourcePath;
@@ -214,9 +240,11 @@ class HTML5Helper {
if (FileSystem.exists (tempFile + ".map")) {
// closure does not include a sourceMappingURL in the created .js, we do it here
#if !nodejs
var f = File.append (tempFile);
f.writeString ("//# sourceMappingURL=" + Path.withoutDirectory (sourceFile) + ".map");
f.writeString ("//# sourceMappingURL=" + StringTools.urlEncode (Path.withoutDirectory (sourceFile)) + ".map");
f.close ();
#end
File.copy (tempFile + ".map", sourceFile + ".map");
FileSystem.deleteFile (tempFile + ".map");

View File

@@ -203,21 +203,10 @@ class ModuleHelper {
public static function patchFile (outputPath:String):Void {
if (FileSystem.exists (outputPath)) {
var output = File.getContent (outputPath);
var replaceString = "var $hxClasses = {}";
var index = output.indexOf (replaceString);
if (index > -1) {
output = output.substr (0, index) + "if (!$hx_exports.$hxClasses) $hx_exports.$hxClasses = {};\nvar $hxClasses = $hx_exports.$hxClasses" + output.substr (index + replaceString.length);
File.saveContent (outputPath, output);
}
}
var replaceString = "var $hxClasses = {}";
var replacement = "if (!$hx_exports.$hxClasses) $hx_exports.$hxClasses = {};\nvar $hxClasses = $hx_exports.$hxClasses";
FileHelper.replaceText (outputPath, replaceString, replacement);
}

View File

@@ -380,13 +380,13 @@ class ProcessHelper {
}
result = process.exitCode ();
process.close ();
output = buffer.getBytes ().toString ();
if (output == "") {
var error = process.stderr.readAll ().toString ();
process.close ();
if (result != 0 || error != "") {
@@ -422,6 +422,10 @@ class ProcessHelper {
}*/
} else {
process.close ();
}
}

View File

@@ -60,6 +60,8 @@ class HTML5Platform extends PlatformTarget {
if (noOutput) return;
HTML5Helper.encodeSourceMappingURL (targetDirectory + "/bin/" + project.app.file + ".js");
if (project.targetFlags.exists ("webgl")) {
FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain.js", outputFile);

View File

@@ -22,7 +22,8 @@ package lime.utils;
this = new js.html.Float32Array( elements );
} else if(array != null) {
this = new js.html.Float32Array( untyped array );
#if openfl } else if(vector != null) { this = new js.html.Float32Array( untyped untyped (vector).__array ); #end
#if (openfl && commonjs) } else if(vector != null) { this = new js.html.Float32Array( untyped (vector) );
#elseif openfl } else if(vector != null) { this = new js.html.Float32Array( untyped untyped (vector).data.__array ); #end
} else if(view != null) {
this = new js.html.Float32Array( untyped view );
} else if(buffer != null) {
@@ -81,7 +82,7 @@ public static var hello:Int;
this = new ArrayBufferView( elements, Float32 );
} else if(array != null) {
this = new ArrayBufferView(0, Float32).initArray(array);
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Float32).initArray(untyped (vector).__array); #end
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Float32).initArray(untyped (vector).data.__array); #end
} else if(view != null) {
this = new ArrayBufferView(0, Float32).initTypedArray(view);
} else if(buffer != null) {

View File

@@ -21,7 +21,8 @@ package lime.utils;
this = new js.html.Float64Array( elements );
} else if(array != null) {
this = new js.html.Float64Array( untyped array );
#if openfl } else if(vector != null) { this = new js.html.Float64Array( untyped untyped (vector).__array ); #end
#if (openfl && commonjs) } else if(vector != null) { this = new js.html.Float64Array( untyped (vector) );
#elseif openfl } else if(vector != null) { this = new js.html.Float64Array( untyped untyped (vector).data.__array ); #end
} else if(view != null) {
this = new js.html.Float64Array( untyped view );
} else if(buffer != null) {
@@ -79,7 +80,7 @@ package lime.utils;
this = new ArrayBufferView( elements, Float64 );
} else if(array != null) {
this = new ArrayBufferView(0, Float64).initArray(array);
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Float64).initArray(untyped (vector).__array); #end
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Float64).initArray(untyped (vector).data.__array); #end
} else if(view != null) {
this = new ArrayBufferView(0, Float64).initTypedArray(view);
} else if(buffer != null) {

View File

@@ -21,7 +21,8 @@ package lime.utils;
this = new js.html.Int16Array( elements );
} else if(array != null) {
this = new js.html.Int16Array( untyped array );
#if openfl } else if(vector != null) { this = new js.html.Int16Array( untyped untyped (vector).__array ); #end
#if (openfl && commonjs) } else if(vector != null) { this = new js.html.Int16Array( untyped (vector) );
#elseif openfl } else if(vector != null) { this = new js.html.Int16Array( untyped untyped (vector).data.__array ); #end
} else if(view != null) {
this = new js.html.Int16Array( untyped view );
} else if(buffer != null) {
@@ -79,7 +80,7 @@ package lime.utils;
this = new ArrayBufferView( elements, Int16 );
} else if(array != null) {
this = new ArrayBufferView(0, Int16).initArray(array);
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Int16).initArray(untyped (vector).__array); #end
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Int16).initArray(untyped (vector).data.__array); #end
} else if(view != null) {
this = new ArrayBufferView(0, Int16).initTypedArray(view);
} else if(buffer != null) {

View File

@@ -21,7 +21,8 @@ package lime.utils;
this = new js.html.Int32Array( elements );
} else if(array != null) {
this = new js.html.Int32Array( untyped array );
#if openfl } else if(vector != null) { this = new js.html.Int32Array( untyped untyped (vector).__array ); #end
#if (openfl && commonjs) } else if(vector != null) { this = new js.html.Int32Array( untyped (vector) );
#elseif openfl } else if(vector != null) { this = new js.html.Int32Array( untyped untyped (vector).data.__array ); #end
} else if(view != null) {
this = new js.html.Int32Array( untyped view );
} else if(buffer != null) {
@@ -79,7 +80,7 @@ package lime.utils;
this = new ArrayBufferView( elements, Int32 );
} else if(array != null) {
this = new ArrayBufferView(0, Int32).initArray(array);
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Int32).initArray(untyped (vector).__array); #end
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Int32).initArray(untyped (vector).data.__array); #end
} else if(view != null) {
this = new ArrayBufferView(0, Int32).initTypedArray(view);
} else if(buffer != null) {

View File

@@ -21,7 +21,8 @@ package lime.utils;
this = new js.html.Int8Array( elements );
} else if(array != null) {
this = new js.html.Int8Array( untyped array );
#if openfl } else if(vector != null) { this = new js.html.Int8Array( untyped untyped (vector).__array ); #end
#if (openfl && commonjs) } else if(vector != null) { this = new js.html.Int8Array( untyped (vector) );
#elseif openfl } else if(vector != null) { this = new js.html.Int8Array( untyped untyped (vector).data.__array ); #end
} else if(view != null) {
this = new js.html.Int8Array( untyped view );
} else if(buffer != null) {
@@ -77,7 +78,7 @@ package lime.utils;
this = new ArrayBufferView( elements, Int8 );
} else if(array != null) {
this = new ArrayBufferView(0, Int8).initArray(array);
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Int8).initArray(untyped (vector).__array); #end
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Int8).initArray(untyped (vector).data.__array); #end
} else if(view != null) {
this = new ArrayBufferView(0, Int8).initTypedArray(view);
} else if(buffer != null) {

View File

@@ -21,7 +21,8 @@ package lime.utils;
this = new js.html.Uint16Array( elements );
} else if(array != null) {
this = new js.html.Uint16Array( untyped array );
#if openfl } else if(vector != null) { this = new js.html.Uint16Array( untyped untyped (vector).__array ); #end
#if (openfl && commonjs) } else if(vector != null) { this = new js.html.Uint16Array( untyped (vector) );
#elseif openfl } else if(vector != null) { this = new js.html.Uint16Array( untyped untyped (vector).data.__array ); #end
} else if(view != null) {
this = new js.html.Uint16Array( untyped view );
} else if(buffer != null) {
@@ -79,7 +80,7 @@ package lime.utils;
this = new ArrayBufferView( elements, Uint16 );
} else if(array != null) {
this = new ArrayBufferView(0, Uint16).initArray(array);
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Uint16).initArray(untyped (vector).__array); #end
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Uint16).initArray(untyped (vector).data.__array); #end
} else if(view != null) {
this = new ArrayBufferView(0, Uint16).initTypedArray(view);
} else if(buffer != null) {

View File

@@ -21,7 +21,8 @@ package lime.utils;
this = new js.html.Uint32Array( elements );
} else if(array != null) {
this = new js.html.Uint32Array( untyped array );
#if openfl } else if(vector != null) { this = new js.html.Uint32Array( untyped untyped (vector).__array ); #end
#if (openfl && commonjs) } else if(vector != null) { this = new js.html.Uint32Array( untyped (vector) );
#elseif openfl } else if(vector != null) { this = new js.html.Uint32Array( untyped untyped (vector).data.__array ); #end
} else if(view != null) {
this = new js.html.Uint32Array( untyped view );
} else if(buffer != null) {
@@ -79,7 +80,7 @@ package lime.utils;
this = new ArrayBufferView( elements, Uint32 );
} else if(array != null) {
this = new ArrayBufferView(0, Uint32).initArray(array);
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Uint32).initArray(untyped (vector).__array); #end
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Uint32).initArray(untyped (vector).data.__array); #end
} else if(view != null) {
this = new ArrayBufferView(0, Uint32).initTypedArray(view);
} else if(buffer != null) {

View File

@@ -21,7 +21,8 @@ package lime.utils;
this = new js.html.Uint8Array( elements );
} else if(array != null) {
this = new js.html.Uint8Array( untyped array );
#if openfl } else if(vector != null) { this = new js.html.Uint8Array( untyped untyped (vector).__array ); #end
#if (openfl && commonjs) } else if(vector != null) { this = new js.html.Uint8Array( untyped (vector) );
#elseif openfl } else if(vector != null) { this = new js.html.Uint8Array( untyped untyped (vector).data.__array ); #end
} else if(view != null) {
this = new js.html.Uint8Array( untyped view );
} else if(buffer != null) {
@@ -79,7 +80,7 @@ package lime.utils;
this = new ArrayBufferView( elements, Uint8 );
} else if(array != null) {
this = new ArrayBufferView(0, Uint8).initArray(array);
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Uint8).initArray(untyped (vector).__array); #end
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Uint8).initArray(untyped (vector).data.__array); #end
} else if(view != null) {
this = new ArrayBufferView(0, Uint8).initTypedArray(view);
} else if(buffer != null) {

View File

@@ -21,7 +21,8 @@ package lime.utils;
this = new js.html.Uint8ClampedArray( elements );
} else if(array != null) {
this = new js.html.Uint8ClampedArray( untyped array );
#if openfl } else if(vector != null) { this = new js.html.Uint8ClampedArray( untyped untyped (vector).__array ); #end
#if (openfl && commonjs) } else if(vector != null) { this = new js.html.Uint8ClampedArray( untyped (vector) );
#elseif openfl } else if(vector != null) { this = new js.html.Uint8ClampedArray( untyped untyped (vector).data.__array ); #end
} else if(view != null) {
this = new js.html.Uint8ClampedArray( untyped view );
} else if(buffer != null) {
@@ -88,7 +89,7 @@ package lime.utils;
this = new ArrayBufferView( elements, Uint8Clamped );
} else if(array != null) {
this = new ArrayBufferView(0, Uint8Clamped).initArray(array);
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Uint8Clamped).initArray(untyped (vector).__array); #end
#if openfl } else if(vector != null) { this = new ArrayBufferView(0, Uint8Clamped).initArray(untyped (vector).data.__array); #end
} else if(view != null) {
this = new ArrayBufferView(0, Uint8Clamped).initTypedArray(view);
} else if(buffer != null) {

View File

@@ -183,6 +183,13 @@ namespace lime {
}
void GLAPIENTRY gl_debug_callback (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam) {
puts (message);
}
void lime_gl_active_texture (int texture) {
glActiveTexture (texture);
@@ -1156,6 +1163,16 @@ namespace lime {
if (!init) {
if (strcmp (name.__s, "KHR_debug") == 0) {
#ifdef LIME_GLES
glDebugMessageCallbackKHR ((GLDEBUGPROCARB)gl_debug_callback, NULL);
#elif !defined(HX_MACOS)
glDebugMessageCallback ((GLDEBUGPROCARB)gl_debug_callback, NULL);
#endif
}
init = true;
kind_share (&functionKind, "function");

View File

@@ -355,6 +355,7 @@ namespace lime {
if (method && !val_is_null (method)) {
Bytes* _writeBytes = writeBytes[callback];
if (!_writeBytes) return 0;
_writeBytes->Resize (size * nmemb);
memcpy (_writeBytes->Data (), ptr, size * nmemb);