diff --git a/lime/Assets.hx b/lime/Assets.hx index 1912caf39..9c80fbdea 100644 --- a/lime/Assets.hx +++ b/lime/Assets.hx @@ -1159,6 +1159,56 @@ class Assets { } + + macro public static function embedBytes ():Array { + + var fields = embedData (":file"); + + if (fields != null) { + + var constructor = macro { + + var bytes = haxe.Resource.getBytes (resourceName); + + super (bytes.length, bytes.b); + + }; + + var args = [ { name: "length", opt: false, type: macro :Int }, { name: "bytesData", opt: false, type: macro :haxe.io.BytesData } ]; + fields.push ({ name: "new", access: [ APublic ], kind: FFun({ args: args, expr: constructor, params: [], ret: null }), pos: Context.currentPos () }); + + } + + return fields; + + } + + + macro public static function embedByteArray ():Array { + + var fields = embedData (":file"); + + if (fields != null) { + + var constructor = macro { + + super (); + + var bytes = haxe.Resource.getBytes (resourceName); + __fromBytes (bytes); + + }; + + var args = [ { name: "length", opt: true, type: macro :Int, value: macro 0 } ]; + fields.push ({ name: "new", access: [ APublic ], kind: FFun({ args: args, expr: constructor, params: [], ret: null }), pos: Context.currentPos () }); + + } + + return fields; + + } + + #if lime_console private static function embedData (metaName:String, encode:Bool = false):Array { @@ -1275,30 +1325,6 @@ class Assets { #end - macro public static function embedFile ():Array { - - var fields = embedData (":file"); - - if (fields != null) { - - var constructor = macro { - - var bytes = haxe.Resource.getBytes (resourceName); - - super (bytes.length, bytes.b); - - }; - - var args = [ { name: "length", opt: false, type: macro :Int }, { name: "bytesData", opt: false, type: macro :haxe.io.BytesData } ]; - fields.push ({ name: "new", access: [ APublic ], kind: FFun({ args: args, expr: constructor, params: [], ret: null }), pos: Context.currentPos () }); - - } - - return fields; - - } - - macro public static function embedFont ():Array { var fields = null; diff --git a/lime/utils/Bytes.hx b/lime/utils/Bytes.hx index 62a882ff8..012941a53 100644 --- a/lime/utils/Bytes.hx +++ b/lime/utils/Bytes.hx @@ -8,7 +8,7 @@ import haxe.io.BytesData; @:build(lime.system.CFFI.build()) #end -@:autoBuild(lime.Assets.embedFile()) +@:autoBuild(lime.Assets.embedBytes()) class Bytes extends HaxeBytes {