X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/1560b2c8f7d30fa6b96625ae0fd30c75d4354871..69d4f99aa28c0e60cf762583c2e94aa76f2bdec0:/ObjectiveC/Library.mm diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index 44307e2..3a34f3e 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -32,7 +32,6 @@ #ifdef __APPLE__ #include #include -#include #include #endif @@ -185,15 +184,11 @@ Type_ CYPoolRelease(CYPool *pool, Type_ object) { /* }}} */ /* Objective-C Strings {{{ */ const char *CYPoolCString(CYPool &pool, JSContextRef context, NSString *value) { - if (pool == NULL) - return [value UTF8String]; - else { - size_t size([value maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1); - char *string(new(pool) char[size]); - if (![value getCString:string maxLength:size encoding:NSUTF8StringEncoding]) - throw CYJSError(context, "[NSString getCString:maxLength:encoding:] == NO"); - return string; - } + size_t size([value maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1); + char *string(new(pool) char[size]); + if (![value getCString:string maxLength:size encoding:NSUTF8StringEncoding]) + throw CYJSError(context, "[NSString getCString:maxLength:encoding:] == NO"); + return string; } JSStringRef CYCopyJSString(JSContextRef context, NSString *value) { @@ -574,7 +569,6 @@ struct PropertyAttributes { }; #endif -#ifndef __APPLE__ @interface CYWebUndefined : NSObject { } @@ -592,7 +586,6 @@ struct PropertyAttributes { @end #define WebUndefined CYWebUndefined -#endif /* Bridge: CYJSObject {{{ */ @interface CYJSObject : NSMutableDictionary { @@ -2172,10 +2165,13 @@ static int struct_forward_array[] = { #define OBJC_MAX_STRUCT_BY_VALUE 1 static int struct_forward_array[] = { 0, 0 }; +#elif defined(__arm64__) +#define CY_NO_STRET #else #error missing objc-runtime-info #endif +#ifndef CY_NO_STRET static bool stret(ffi_type *ffi_type) { return ffi_type->type == FFI_TYPE_STRUCT && ( ffi_type->size > OBJC_MAX_STRUCT_BY_VALUE || @@ -2183,6 +2179,7 @@ static bool stret(ffi_type *ffi_type) { ); } #endif +#endif JSValueRef CYSendMessage(CYPool &pool, JSContextRef context, id self, Class _class, SEL _cmd, size_t count, const JSValueRef arguments[], bool initialize, JSValueRef *exception) { CYTry { const char *type; @@ -2238,9 +2235,11 @@ JSValueRef CYSendMessage(CYPool &pool, JSContextRef context, id self, Class _cla if (imp == NULL) { #ifdef __APPLE__ +#ifndef CY_NO_STRET if (stret(cif.rtype)) imp = class_getMethodImplementation_stret(_class, _cmd); else +#endif imp = class_getMethodImplementation(_class, _cmd); #else objc_super super = {self, _class};