Fixed hashlink?

I cant test on mac since FATAL ERROR : Failed to load library ssl.hdll
and with define no_ssl
IMUL(stack,cpu)
JIT ERROR 0 (jit.c line 613)
This commit is contained in:
Ne_Eo
2024-11-09 00:58:00 +01:00
parent f54c485d0c
commit 74ce1756dc
4 changed files with 47 additions and 52 deletions
+1 -1
View File
@@ -134,7 +134,7 @@
<haxedef name="USE_ADAPTED_ASSETS" unless="web" /> <haxedef name="USE_ADAPTED_ASSETS" unless="web" />
<!-- Comment this out to disable support for custom ndlls. !--> <!-- Comment this out to disable support for custom ndlls. !-->
<haxedef name="NDLLS_SUPPORTED" unless="web || iphonesim" /> <haxedef name="NDLLS_SUPPORTED" unless="web || iphonesim || hl" />
<!-- Comment this out to disable support for Away3D Flixel Intergration (reduces compile times)--> <!-- Comment this out to disable support for Away3D Flixel Intergration (reduces compile times)-->
<define name="THREE_D_SUPPORT" /> <define name="THREE_D_SUPPORT" />
@@ -2,8 +2,8 @@ package funkin.backend.system.github;
#if GITHUB_API #if GITHUB_API
import haxe.Json; import haxe.Json;
import haxe.Exception;
#end #end
import haxe.Exception;
// TODO: Document further and perhaps make this a Haxelib. // TODO: Document further and perhaps make this a Haxelib.
class GitHub { class GitHub {
@@ -42,26 +42,12 @@ class HashLinkFixer {
var cl = clRef.get(); var cl = clRef.get();
if (cl.isAbstract || cl.isExtern || cl.isInterface) return fields; if (cl.isAbstract || cl.isExtern || cl.isInterface) return fields;
if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith("_HSX") && !cl.name.endsWith("_HSC") && !cl.name.endsWith("_HLFHelper")) { if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith("_HSX") && !cl.name.endsWith("_HSC")) {
var metas = cl.meta.get();
if(cl.params.length > 0) if(cl.params.length > 0)
return fields; return fields;
if(cl.module == "EReg") return fields; // private typedef in same class
if(cl.module == "hl.Format") return fields; // enum in same class
var definedFields = []; var definedFields = [];
var helperClass = macro class {
};
helperClass.pos = cl.pos;
var module = cl.module + "_HLFHelper";
var hcClassName = cl.name + "_HLFHelper";
for(f in fields.copy()) { for(f in fields.copy()) {
if (f == null) if (f == null)
continue; continue;
@@ -70,10 +56,12 @@ class HashLinkFixer {
if(definedFields.contains(f.name)) continue; // no duplicate fields if(definedFields.contains(f.name)) continue; // no duplicate fields
var hlNativeMeta = null;
var hasHlNative = false; var hasHlNative = false;
for(m in f.meta) for(m in f.meta)
if (m.name == ":hlNative") { if (m.name == ":hlNative") {
hasHlNative = true; hasHlNative = true;
hlNativeMeta = m;
break; break;
} }
@@ -92,16 +80,39 @@ class HashLinkFixer {
var overrideExpr:Expr; var overrideExpr:Expr;
var returns:Bool = !fun.ret.match(TPath({name: "Void"})); var returns:Bool = !fun.ret.match(TPath({name: "Void"}));
var printer = new haxe.macro.Printer();
if(cl.module == "hl.Gc" && fun.ret == null) returns = false; // fix since they dont explicitly set :Void
if(cl.module == "hl.Format" && fun.ret == null) returns = false; // fix since they dont explicitly set :Void
var name = 'hlf_${f.name}'; var name = 'hlf_${f.name}';
var arguments = fun.args == null ? [] : [for(a in fun.args) macro $i{a.name}]; var arguments = fun.args == null ? [] : [for(a in fun.args) macro $i{a.name}];
var funcExpr:Expr = returns ? { var funcExpr:Expr = macro @:privateAccess $i{name}($a{arguments});
//macro return $i{name}($a{arguments}); if(returns) funcExpr = macro return $funcExpr;
macro return @:privateAccess $i{hcClassName}.$name($a{arguments});
} : { var cleanMeta = f.meta.copy().filter(function(m) return m.name != ":hlNative");
macro @:privateAccess $i{hcClassName}.$name($a{arguments}); var hasBareMeta = hlNativeMeta.params.length == 0;
};
var meta = f.meta.copy();
switch hlNativeMeta {
case {params: []}:
meta = [{name: ":hlNative", params: [macro "std", macro $v{f.name}], pos: Context.currentPos()}].concat(cleanMeta);
case {params: [_.expr => EConst(CString(name))]}:
meta = [{name: ":hlNative", params: [macro "std", macro $v{name}], pos: Context.currentPos()}].concat(cleanMeta);
case {params: [_.expr => EConst(CFloat(version))]}:
var curVersion = Context.definedValue("hl_ver");
if(curVersion == null) curVersion = "";
if(version > curVersion) {
meta = cleanMeta;
if(f.meta.filter((m) -> m.name == ":noExpr").length > 0)
Context.error("Missing function body", f.pos);
funcExpr = fun.expr; // restore to default behaviour
} else {
meta = [{name: ":hlNative", params: [macro "std", macro $v{f.name}], pos: Context.currentPos()}].concat(cleanMeta);
}
default:
}
var fiel:Field = { var fiel:Field = {
name: name, name: name,
@@ -109,50 +120,32 @@ class HashLinkFixer {
kind: FFun({ kind: FFun({
ret: fun.ret, ret: fun.ret,
params: fun.params.copy(), params: fun.params.copy(),
expr: fun.expr, expr: funcExpr,
args: fun.args.copy() args: fun.args.copy()
}), }),
access: f.access.copy(), access: f.access.copy().filter(function(a) return a != APublic && a != APrivate).concat([APrivate]),
meta: f.meta.copy() meta: meta
}; };
helperClass.fields.push(fiel); fields.push(fiel);
definedFields.push(f.name); definedFields.push(f.name);
// Remove meta from original function
for(m in f.meta.copy()) for(m in f.meta.copy())
if (m.name == ":hlNative") { if (m.name == ":hlNative") {
f.meta.remove(m); f.meta.remove(m);
} }
fun.expr = funcExpr;
default: default:
} }
} }
helperClass.pack = cl.pack.copy(); /*if(definedFields.length > 0) {
helperClass.pos = cl.pos;
helperClass.name = hcClassName;
if(definedFields.length > 0) {
trace(cl.module); trace(cl.module);
/*for(m in metas.copy()) { var printer = new haxe.macro.Printer();
trace(" " + m.name); for(field in fields) if(field.name.startsWith("hlf_"))
if(m.name == ":coreApi") { Sys.println(printer.printField(field));
metas.remove(m); }*/
}
}*/
var imports = Context.getLocalImports().copy();
Context.defineModule(module, [helperClass], imports);
Context.getLocalImports().push({
path: [for(m in module.split(".")) {
name: m,
pos: Context.currentPos()
}],
mode: INormal
});
}
} }
return fields; return fields;
+3 -1
View File
@@ -165,6 +165,7 @@ class DiscordUtil
#end #end
} }
#if cpp
@:noCompletion public static function fixString(str:String) @:noCompletion public static function fixString(str:String)
{ {
return new cpp.ConstCharStar(cast(str, String)); return new cpp.ConstCharStar(cast(str, String));
@@ -174,6 +175,7 @@ class DiscordUtil
{ {
return cast(str, String); return cast(str, String);
} }
#end
public static function changePresenceAdvanced(data:DPresence) public static function changePresenceAdvanced(data:DPresence)
{ {
@@ -469,7 +471,7 @@ typedef DPresence =
var ?matchSecret:String; /* max 128 bytes */ var ?matchSecret:String; /* max 128 bytes */
var ?joinSecret:String; /* max 128 bytes */ var ?joinSecret:String; /* max 128 bytes */
var ?spectateSecret:String; /* max 128 bytes */ var ?spectateSecret:String; /* max 128 bytes */
var ?instance:OneOfTwo<Int, cpp.Int8>; var ?instance:#if cpp OneOfTwo<Int, cpp.Int8> #else Int #end;
var ?button1Label:String; /* max 32 bytes */ var ?button1Label:String; /* max 32 bytes */
var ?button1Url:String; /* max 512 bytes */ var ?button1Url:String; /* max 512 bytes */
var ?button2Label:String; /* max 32 bytes */ var ?button2Label:String; /* max 32 bytes */