|
4 | 4 |
|
5 | 5 | #include <_CJavaScriptKit.h> |
6 | 6 |
|
| 7 | +#if __wasm32__ |
| 8 | +# define IMPORT_JS_FUNCTION(name, returns, args) \ |
| 9 | +__attribute__((__import_module__("javascript_kit"), __import_name__(#name))) extern returns name args; |
| 10 | +#else |
| 11 | +# define IMPORT_JS_FUNCTION(name, returns, args) \ |
| 12 | + static inline returns name args { \ |
| 13 | + abort(); \ |
| 14 | + } |
| 15 | +#endif |
| 16 | + |
7 | 17 | /// Converts the provided Int64 or UInt64 to a BigInt. |
8 | 18 | /// |
9 | 19 | /// @param value The value to convert. |
10 | 20 | /// @param is_signed Whether to treat the value as a signed integer or not. |
11 | | -#if __wasi__ |
12 | | -__attribute__((__import_module__("javascript_kit"), |
13 | | - __import_name__("swjs_i64_to_bigint"))) |
14 | | -#endif |
15 | | -extern JavaScriptObjectRef _i64_to_bigint(const long long value, bool is_signed); |
| 21 | +IMPORT_JS_FUNCTION(swjs_i64_to_bigint, JavaScriptObjectRef, (const long long value, bool is_signed)) |
16 | 22 |
|
17 | 23 | /// Converts the provided BigInt to an Int64 or UInt64. |
18 | 24 | /// |
19 | 25 | /// @param ref The target JavaScript object. |
20 | 26 | /// @param is_signed Whether to treat the return value as a signed integer or not. |
21 | | -#if __wasi__ |
22 | | -__attribute__((__import_module__("javascript_kit"), |
23 | | - __import_name__("swjs_bigint_to_i64"))) |
24 | | -#endif |
25 | | -extern long long _bigint_to_i64(const JavaScriptObjectRef ref, bool is_signed); |
| 27 | +IMPORT_JS_FUNCTION(swjs_bigint_to_i64, long long, (const JavaScriptObjectRef ref, bool is_signed)) |
26 | 28 |
|
27 | 29 | #endif /* _CJavaScriptBigIntSupport_h */ |
0 commit comments