-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy path_CJavaScriptKit+I64.h
29 lines (23 loc) · 1000 Bytes
/
_CJavaScriptKit+I64.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef _CJavaScriptBigIntSupport_h
#define _CJavaScriptBigIntSupport_h
#include <_CJavaScriptKit.h>
#if __wasm32__
# define IMPORT_JS_FUNCTION(name, returns, args) \
__attribute__((__import_module__("javascript_kit"), __import_name__(#name))) extern returns name args;
#else
# define IMPORT_JS_FUNCTION(name, returns, args) \
static inline returns name args { \
abort(); \
}
#endif
/// Converts the provided Int64 or UInt64 to a BigInt.
///
/// @param value The value to convert.
/// @param is_signed Whether to treat the value as a signed integer or not.
IMPORT_JS_FUNCTION(swjs_i64_to_bigint, JavaScriptObjectRef, (const long long value, bool is_signed))
/// Converts the provided BigInt to an Int64 or UInt64.
///
/// @param ref The target JavaScript object.
/// @param is_signed Whether to treat the return value as a signed integer or not.
IMPORT_JS_FUNCTION(swjs_bigint_to_i64, long long, (const JavaScriptObjectRef ref, bool is_signed))
#endif /* _CJavaScriptBigIntSupport_h */