From 67e4b845fd89259396da44aa521b959431a634ad Mon Sep 17 00:00:00 2001 From: hermansimensen Date: Sun, 6 Aug 2023 21:58:28 +0200 Subject: [PATCH] allow zero arguments --- BeefLibs/corlib/src/WebAssembly.bf | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/BeefLibs/corlib/src/WebAssembly.bf b/BeefLibs/corlib/src/WebAssembly.bf index 70f9d6b0..5ae2ee81 100644 --- a/BeefLibs/corlib/src/WebAssembly.bf +++ b/BeefLibs/corlib/src/WebAssembly.bf @@ -109,13 +109,26 @@ class WebAssembly return new $"result = emscripten_asm_const_{JSGetResultName(typeof(TResult))}(AddStringToSection({TCall.Quote(.. scope .())}, \"em_asm\"), \"{argSigs}\", {argString});"; } + private static String JSGetCallString() where TCall : const String + { + if (TCall == null) + return ""; + return new $"result = emscripten_asm_const_{JSGetResultName(typeof(TResult))}(AddStringToSection({TCall.Quote(.. scope .())}, \"em_asm\"), \"i\");"; + } + public static TResult JSCall(TCall callString, T0 p0) where TCall : const String { TResult result = default; Compiler.Mixin(JSGetCallString()); return result; } + + public static TResult JSCall(TCall callString) where TCall : const String + { + TResult result = default; + Compiler.Mixin(JSGetCallString()); + return result; + } } - #endif