Skip to content

Commit 74ce175

Browse files
committed
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)
1 parent f54c485 commit 74ce175

File tree

4 files changed

+47
-52
lines changed

4 files changed

+47
-52
lines changed

project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<haxedef name="USE_ADAPTED_ASSETS" unless="web" />
135135

136136
<!-- Comment this out to disable support for custom ndlls. !-->
137-
<haxedef name="NDLLS_SUPPORTED" unless="web || iphonesim" />
137+
<haxedef name="NDLLS_SUPPORTED" unless="web || iphonesim || hl" />
138138

139139
<!-- Comment this out to disable support for Away3D Flixel Intergration (reduces compile times)-->
140140
<define name="THREE_D_SUPPORT" />

source/funkin/backend/system/github/GitHub.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package funkin.backend.system.github;
22

33
#if GITHUB_API
44
import haxe.Json;
5-
import haxe.Exception;
65
#end
6+
import haxe.Exception;
77

88
// TODO: Document further and perhaps make this a Haxelib.
99
class GitHub {

source/funkin/backend/system/macros/HashLinkFixer.hx

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,12 @@ class HashLinkFixer {
4242
var cl = clRef.get();
4343

4444
if (cl.isAbstract || cl.isExtern || cl.isInterface) return fields;
45-
if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith("_HSX") && !cl.name.endsWith("_HSC") && !cl.name.endsWith("_HLFHelper")) {
46-
var metas = cl.meta.get();
47-
45+
if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith("_HSX") && !cl.name.endsWith("_HSC")) {
4846
if(cl.params.length > 0)
4947
return fields;
5048

51-
if(cl.module == "EReg") return fields; // private typedef in same class
52-
if(cl.module == "hl.Format") return fields; // enum in same class
53-
5449
var definedFields = [];
5550

56-
var helperClass = macro class {
57-
58-
};
59-
60-
helperClass.pos = cl.pos;
61-
62-
var module = cl.module + "_HLFHelper";
63-
var hcClassName = cl.name + "_HLFHelper";
64-
6551
for(f in fields.copy()) {
6652
if (f == null)
6753
continue;
@@ -70,10 +56,12 @@ class HashLinkFixer {
7056

7157
if(definedFields.contains(f.name)) continue; // no duplicate fields
7258

59+
var hlNativeMeta = null;
7360
var hasHlNative = false;
7461
for(m in f.meta)
7562
if (m.name == ":hlNative") {
7663
hasHlNative = true;
64+
hlNativeMeta = m;
7765
break;
7866
}
7967

@@ -92,67 +80,72 @@ class HashLinkFixer {
9280
var overrideExpr:Expr;
9381
var returns:Bool = !fun.ret.match(TPath({name: "Void"}));
9482

83+
var printer = new haxe.macro.Printer();
84+
if(cl.module == "hl.Gc" && fun.ret == null) returns = false; // fix since they dont explicitly set :Void
85+
if(cl.module == "hl.Format" && fun.ret == null) returns = false; // fix since they dont explicitly set :Void
86+
9587
var name = 'hlf_${f.name}';
9688

9789
var arguments = fun.args == null ? [] : [for(a in fun.args) macro $i{a.name}];
9890

99-
var funcExpr:Expr = returns ? {
100-
//macro return $i{name}($a{arguments});
101-
macro return @:privateAccess $i{hcClassName}.$name($a{arguments});
102-
} : {
103-
macro @:privateAccess $i{hcClassName}.$name($a{arguments});
104-
};
91+
var funcExpr:Expr = macro @:privateAccess $i{name}($a{arguments});
92+
if(returns) funcExpr = macro return $funcExpr;
93+
94+
var cleanMeta = f.meta.copy().filter(function(m) return m.name != ":hlNative");
95+
var hasBareMeta = hlNativeMeta.params.length == 0;
96+
97+
var meta = f.meta.copy();
98+
switch hlNativeMeta {
99+
case {params: []}:
100+
meta = [{name: ":hlNative", params: [macro "std", macro $v{f.name}], pos: Context.currentPos()}].concat(cleanMeta);
101+
case {params: [_.expr => EConst(CString(name))]}:
102+
meta = [{name: ":hlNative", params: [macro "std", macro $v{name}], pos: Context.currentPos()}].concat(cleanMeta);
103+
case {params: [_.expr => EConst(CFloat(version))]}:
104+
var curVersion = Context.definedValue("hl_ver");
105+
if(curVersion == null) curVersion = "";
106+
if(version > curVersion) {
107+
meta = cleanMeta;
108+
if(f.meta.filter((m) -> m.name == ":noExpr").length > 0)
109+
Context.error("Missing function body", f.pos);
110+
funcExpr = fun.expr; // restore to default behaviour
111+
} else {
112+
meta = [{name: ":hlNative", params: [macro "std", macro $v{f.name}], pos: Context.currentPos()}].concat(cleanMeta);
113+
}
114+
default:
115+
}
105116

106117
var fiel:Field = {
107118
name: name,
108119
pos: Context.currentPos(),
109120
kind: FFun({
110121
ret: fun.ret,
111122
params: fun.params.copy(),
112-
expr: fun.expr,
123+
expr: funcExpr,
113124
args: fun.args.copy()
114125
}),
115-
access: f.access.copy(),
116-
meta: f.meta.copy()
126+
access: f.access.copy().filter(function(a) return a != APublic && a != APrivate).concat([APrivate]),
127+
meta: meta
117128
};
118-
helperClass.fields.push(fiel);
129+
fields.push(fiel);
119130
definedFields.push(f.name);
120131

132+
// Remove meta from original function
121133
for(m in f.meta.copy())
122134
if (m.name == ":hlNative") {
123135
f.meta.remove(m);
124136
}
125137

126-
fun.expr = funcExpr;
127138
default:
128139
}
129140
}
130141

131-
helperClass.pack = cl.pack.copy();
132-
helperClass.pos = cl.pos;
133-
helperClass.name = hcClassName;
134-
135-
if(definedFields.length > 0) {
142+
/*if(definedFields.length > 0) {
136143
trace(cl.module);
137144
138-
/*for(m in metas.copy()) {
139-
trace(" " + m.name);
140-
if(m.name == ":coreApi") {
141-
metas.remove(m);
142-
}
143-
}*/
144-
145-
var imports = Context.getLocalImports().copy();
146-
Context.defineModule(module, [helperClass], imports);
147-
148-
Context.getLocalImports().push({
149-
path: [for(m in module.split(".")) {
150-
name: m,
151-
pos: Context.currentPos()
152-
}],
153-
mode: INormal
154-
});
155-
}
145+
var printer = new haxe.macro.Printer();
146+
for(field in fields) if(field.name.startsWith("hlf_"))
147+
Sys.println(printer.printField(field));
148+
}*/
156149
}
157150

158151
return fields;

source/funkin/backend/utils/DiscordUtil.hx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class DiscordUtil
165165
#end
166166
}
167167

168+
#if cpp
168169
@:noCompletion public static function fixString(str:String)
169170
{
170171
return new cpp.ConstCharStar(cast(str, String));
@@ -174,6 +175,7 @@ class DiscordUtil
174175
{
175176
return cast(str, String);
176177
}
178+
#end
177179

178180
public static function changePresenceAdvanced(data:DPresence)
179181
{
@@ -469,7 +471,7 @@ typedef DPresence =
469471
var ?matchSecret:String; /* max 128 bytes */
470472
var ?joinSecret:String; /* max 128 bytes */
471473
var ?spectateSecret:String; /* max 128 bytes */
472-
var ?instance:OneOfTwo<Int, cpp.Int8>;
474+
var ?instance:#if cpp OneOfTwo<Int, cpp.Int8> #else Int #end;
473475
var ?button1Label:String; /* max 32 bytes */
474476
var ?button1Url:String; /* max 512 bytes */
475477
var ?button2Label:String; /* max 32 bytes */

0 commit comments

Comments
 (0)