mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-12-08 19:38:45 +00:00
初始化
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <JavaScriptCore/JavaScriptCore.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
NSString *JSValueToNSString( JSContextRef ctx, JSValueRef v );
|
||||
JSValueRef NSStringToJSValue( JSContextRef ctx, NSString *string );
|
||||
double JSValueToNumberFast( JSContextRef ctx, JSValueRef v );
|
||||
void JSValueUnprotectSafe( JSContextRef ctx, JSValueRef v );
|
||||
JSValueRef NSObjectToJSValue( JSContextRef ctx, NSObject *obj );
|
||||
NSObject *JSValueToNSObject( JSContextRef ctx, JSValueRef value );
|
||||
|
||||
static inline void *JSValueGetPrivate(JSValueRef v) {
|
||||
// On 64bit systems we can not safely call JSObjectGetPrivate with any
|
||||
// JSValueRef. Doing so with immediate values (numbers, null, bool,
|
||||
// undefined) will crash the app. So we check for these first.
|
||||
|
||||
#if __LP64__
|
||||
return !((int64_t)v & 0xffff000000000002ll)
|
||||
? JSObjectGetPrivate((JSObjectRef)v)
|
||||
: NULL;
|
||||
#else
|
||||
return JSObjectGetPrivate((JSObjectRef)v);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user