Fixes for Haxe Java target

This commit is contained in:
Joshua Granick
2014-12-05 11:15:15 -08:00
parent 672ec78891
commit 00b2486416
17 changed files with 72 additions and 32 deletions

View File

@@ -418,7 +418,7 @@ class Application extends Module {
}
@:noCompletion private function __triggerFrame (?_):Void {
@:noCompletion private function __triggerFrame (?__):Void {
__eventInfo.deltaTime = 16; //TODO
__dispatch ();

View File

@@ -292,7 +292,9 @@ class Image {
case "png":
#if (sys && (!disable_cffi || !format))
#if java
#elseif (sys && (!disable_cffi || !format))
return lime_image_encode (buffer, 0, quality);
@@ -331,7 +333,9 @@ class Image {
case "jpg", "jpeg":
#if (sys && (!disable_cffi || !format))
#if java
#elseif (sys && (!disable_cffi || !format))
return lime_image_encode (buffer, 1, quality);

View File

@@ -136,7 +136,7 @@ class System {
if (disableCFFI) {
return Reflect.makeVarArgs (function (_) return {});
return Reflect.makeVarArgs (function (__) return {});
}

View File

@@ -24,7 +24,7 @@ import haxe.io.BytesData;
#end
public function new<T> (lengthOrBuffer:T, byteOffset:UInt = 0, length:Null<Int> = null) {
public function new #if !java <T> #end (lengthOrBuffer:#if !java T #else Dynamic #end, byteOffset:UInt = 0, length:Null<Int> = null) {
if (Std.is (lengthOrBuffer, Int)) {

View File

@@ -54,7 +54,7 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
#end
#if (!html5 && !disable_cffi)
#if (!html5 && !disable_cffi && !java)
private static function __init__ () {
var factory = function (length:Int) { return new ByteArray (length); };
@@ -127,10 +127,10 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
var bytes = untyped __dollar__smake (allocated);
super (size, bytes);
#else
var data = new BytesData ();
var data = new BytesData (#if java size #end);
#if cpp
NativeArray.setSize (data, size);
#else
#elseif neko
if (size > 0) untyped data[size - 1] = 0;
#end
super (size, data);
@@ -246,7 +246,7 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
}
#else
if (b == null)
b = new BytesData ();
b = new BytesData (#if java len #end);
if (b.length < len) {
@@ -698,8 +698,10 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
#if cpp
untyped b.__unsafe_set (position++, byte);
#else
#elseif neko
untyped __dollar__sset (b, position++, byte & 0xff);
#else
b[position++] = byte & 0xff;
#end
}
@@ -721,10 +723,10 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
this.position += 1;
#else
ensureElem (position, true);
#if cpp
b[position++] = untyped value;
#else
#if neko
untyped __dollar__sset (b, position++, value & 0xff);
#else
b[position++] = value & 0xFF;
#end
#end

View File

@@ -12,14 +12,14 @@ typedef Float32Array = js.html.Float32Array;
public var length (default, null):Int;
public function new<T> (bufferOrArray:T, start:Int = 0, length:Null<Int> = null) {
public function new #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, start:Int = 0, length:Null<Int> = null) {
#if (openfl && neko && !lime_legacy)
if (Std.is (bufferOrArray, openfl.Vector.VectorData)) {
var vector:openfl.Vector<Float> = cast bufferOrArray;
var floats:Array<Float> = vector;
this.length = (length != null) ? length : floats.length - start;
this.length = (length != #if java 0 #else null #end) ? length : floats.length - start;
super (this.length << 2);
@@ -51,7 +51,7 @@ typedef Float32Array = js.html.Float32Array;
} else if (Std.is (bufferOrArray, Array)) {
var floats:Array<Float> = cast bufferOrArray;
this.length = (length != null) ? length : floats.length - start;
this.length = (length != #if java 0 #else null #end) ? length : floats.length - start;
super (this.length << 2);
@@ -72,7 +72,7 @@ typedef Float32Array = js.html.Float32Array;
} else if (Std.is (bufferOrArray, Float32Array)) {
var floats:Float32Array = cast bufferOrArray;
this.length = (length != null) ? length : floats.length - start;
this.length = (length != #if java 0 #else null #end) ? length : floats.length - start;
super (this.length << 2);
@@ -92,7 +92,7 @@ typedef Float32Array = js.html.Float32Array;
} else {
super (bufferOrArray, start, (length != null) ? length << 2 : null);
super (bufferOrArray, start, #if java length #else (length != null ) ? length << 2 : null #end);
if ((byteLength & 0x03) > 0) {
@@ -113,7 +113,7 @@ typedef Float32Array = js.html.Float32Array;
}
public function set<T> (bufferOrArray:T, offset:Int = 0):Void {
public function set #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, offset:Int = 0):Void {
if (Std.is (bufferOrArray, Array)) {

View File

@@ -12,7 +12,7 @@ typedef Int16Array = js.html.Int16Array;
public var length (default, null):Int;
public function new<T> (bufferOrArray:T, start:Int = 0, length:Null<Int> = null) {
public function new #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, start:Int = 0, length:Null<Int> = null) {
if (Std.is (bufferOrArray, Int)) {
@@ -85,7 +85,7 @@ typedef Int16Array = js.html.Int16Array;
}
public function set<T> (bufferOrArray:T, offset:Int = 0):Void {
public function set #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, offset:Int = 0):Void {
if (Std.is (bufferOrArray, Array)) {

View File

@@ -12,7 +12,7 @@ typedef Int32Array = js.html.Int32Array;
public var length (default, null):Int;
public function new<T> (bufferOrArray:T, start:Int = 0, length:Null<Int> = null) {
public function new #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, start:Int = 0, length:Null<Int> = null) {
if (Std.is (bufferOrArray, Int)) {
@@ -85,7 +85,7 @@ typedef Int32Array = js.html.Int32Array;
}
public function set<T> (bufferOrArray:T, offset:Int = 0):Void {
public function set #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, offset:Int = 0):Void {
if (Std.is (bufferOrArray, Array)) {

View File

@@ -12,7 +12,7 @@ typedef Int8Array = js.html.Int8Array;
public var length (default, null):Int;
public function new<T> (bufferOrArray:T, start:Int = 0, length:Null<Int> = null) {
public function new #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, start:Int = 0, length:Null<Int> = null) {
if (Std.is (bufferOrArray, Int)) {
@@ -72,7 +72,7 @@ typedef Int8Array = js.html.Int8Array;
}
public function set<T> (bufferOrArray:T, offset:Int = 0):Void {
public function set #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, offset:Int = 0):Void {
if (Std.is(bufferOrArray, Array)) {

View File

@@ -12,7 +12,7 @@ typedef UInt16Array = js.html.Uint16Array;
public var length (default, null):Int;
public function new<T> (bufferOrArray:T, start:Int = 0, length:Null<Int> = null) {
public function new #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, start:Int = 0, length:Null<Int> = null) {
if (Std.is (bufferOrArray, Int)) {
@@ -85,7 +85,7 @@ typedef UInt16Array = js.html.Uint16Array;
}
public function set<T> (bufferOrArray:T, offset:Int = 0):Void {
public function set #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, offset:Int = 0):Void {
if (Std.is (bufferOrArray, Array)) {

View File

@@ -12,7 +12,7 @@ typedef UInt32Array = js.html.Uint32Array;
public var length (default, null) : Int;
public function new<T> (bufferOrArray:T, start:Int = 0, length:Null<Int> = null) {
public function new #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, start:Int = 0, length:Null<Int> = null) {
if (Std.is (bufferOrArray, Int)) {
@@ -85,7 +85,7 @@ typedef UInt32Array = js.html.Uint32Array;
}
public function set<T> (bufferOrArray:T, offset:Int = 0):Void {
public function set #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, offset:Int = 0):Void {
if (Std.is (bufferOrArray, Array)) {

View File

@@ -12,7 +12,7 @@ typedef UInt8Array = js.html.Uint8Array;
public var length (default, null):Int;
public function new<T> (bufferOrArray:T, start:Int = 0, length:Null<Int> = null) {
public function new #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, start:Int = 0, length:Null<Int> = null) {
if (Std.is (bufferOrArray, Int)) {
@@ -73,7 +73,7 @@ typedef UInt8Array = js.html.Uint8Array;
}
public function set<T> (bufferOrArray:T, offset:Int = 0):Void {
public function set #if !java <T> #end (bufferOrArray:#if !java T #else Dynamic #end, offset:Int = 0):Void {
if (Std.is (bufferOrArray, Array)) {

View File

@@ -0,0 +1,5 @@
-main ApplicationMain ::HAXE_FLAGS::
-cp ::BUILD_DIR::/java/haxe
-java ::BUILD_DIR::/java/obj
--macro keep("::APP_MAIN::")
-debug

View File

@@ -0,0 +1,5 @@
-main ApplicationMain ::HAXE_FLAGS::
-cp ::BUILD_DIR::/java/haxe
-java ::BUILD_DIR::/java/obj
--macro keep("::APP_MAIN::")
-D final

View File

@@ -0,0 +1,4 @@
-main ApplicationMain ::HAXE_FLAGS::
-cp ::BUILD_DIR::/java/haxe
-java ::BUILD_DIR::/java/obj
--macro keep("::APP_MAIN::")

View File

@@ -51,6 +51,10 @@ class MacPlatform extends PlatformTarget {
targetType = "neko";
} else if (project.targetFlags.exists ("java")) {
targetType = "java";
} else if (project.targetFlags.exists ("nodejs")) {
targetType = "nodejs";
@@ -104,6 +108,13 @@ class MacPlatform extends PlatformTarget {
NekoHelper.createExecutable (project.templatePaths, "Mac" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath);
NekoHelper.copyLibraries (project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory);
} else if (targetType == "java") {
ProcessHelper.runCommand ("", "haxe", [ hxml ]);
ProcessHelper.runCommand (targetDirectory + "/obj", "haxelib", [ "run", "hxjava", "hxjava_build.txt", "--haxe-version", "3103" ]);
FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".jar", PathHelper.combine (executableDirectory, project.app.file + ".jar"));
NekoHelper.copyLibraries (project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory);
} else if (targetType == "nodejs") {
ProcessHelper.runCommand ("", "haxe", [ hxml ]);
@@ -142,7 +153,7 @@ class MacPlatform extends PlatformTarget {
}
if (PlatformHelper.hostPlatform != Platform.WINDOWS && targetType != "nodejs") {
if (PlatformHelper.hostPlatform != Platform.WINDOWS && targetType != "nodejs" && targetType != "java") {
ProcessHelper.runCommand ("", "chmod", [ "755", executablePath ]);
@@ -225,6 +236,10 @@ class MacPlatform extends PlatformTarget {
NodeJSHelper.run (project, executableDirectory + "/ApplicationMain.js", arguments);
} else if (targetType == "java") {
ProcessHelper.runCommand (executableDirectory, "java", [ "-jar", project.app.file + ".jar" ].concat (arguments));
} else if (project.target == PlatformHelper.hostPlatform) {
arguments = arguments.concat ([ "-livereload" ]);

View File

@@ -79,6 +79,11 @@ class ProjectXMLParser extends HXProject {
defines.set ("native", "1");
defines.set ("neko", "1");
} else if (targetFlags.exists ("java")) {
defines.set ("native", "1");
defines.set ("java", "1");
} else if (targetFlags.exists ("nodejs")) {
defines.set ("native", "1");