From: Jay Freeman (saurik) Date: Sun, 3 Jun 2012 19:25:18 +0000 (-0700) Subject: Add Objective-C @ prefix to CYONified primitives. X-Git-Tag: v0.9.455~19 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/5b1f57ee9241221a5c4a40a6d0cb50fa4ccf679e?ds=inline Add Objective-C @ prefix to CYONified primitives. --- diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index 05ed9ce..adeee5b 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -681,7 +681,7 @@ NSObject *CYCopyNSObject(apr_pool_t *pool, JSContextRef context, JSValueRef valu - (NSString *) cy$toCYON { NSMutableString *json([[[NSMutableString alloc] init] autorelease]); - [json appendString:@"["]; + [json appendString:@"@["]; bool comma(false); #ifdef __APPLE__ @@ -766,7 +766,7 @@ NSObject *CYCopyNSObject(apr_pool_t *pool, JSContextRef context, JSValueRef valu } - (NSString *) cy$toCYON { - return [self boolValue] ? @"true" : @"false"; + return [self boolValue] ? @"@true" : @"@false"; } - (JSValueRef) cy$JSValueInContext:(JSContextRef)context { CYObjectiveTry_(context) { @@ -781,7 +781,7 @@ NSObject *CYCopyNSObject(apr_pool_t *pool, JSContextRef context, JSValueRef valu - (NSString *) cy$toCYON { NSMutableString *json([[[NSMutableString alloc] init] autorelease]); - [json appendString:@"{"]; + [json appendString:@"@{"]; bool comma(false); #ifdef __APPLE__ @@ -922,7 +922,7 @@ NSObject *CYCopyNSObject(apr_pool_t *pool, JSContextRef context, JSValueRef valu } - (NSString *) cy$toCYON { - return [self cy$JSType] != kJSTypeBoolean ? [self stringValue] : [self boolValue] ? @"true" : @"false"; + return [self cy$JSType] != kJSTypeBoolean ? [NSString stringWithFormat:@"@%@", self] : [self boolValue] ? @"@true" : @"@false"; } - (JSValueRef) cy$JSValueInContext:(JSContextRef)context { CYObjectiveTry_(context) { @@ -943,7 +943,7 @@ NSObject *CYCopyNSObject(apr_pool_t *pool, JSContextRef context, JSValueRef valu } - (NSString *) cy$toCYON { - return @"null"; + return @"@null"; } @end @@ -1022,6 +1022,7 @@ NSObject *CYCopyNSObject(apr_pool_t *pool, JSContextRef context, JSValueRef valu - (NSString *) cy$toCYON { std::ostringstream str; + str << '@'; CYUTF8String string(CYCastUTF8String(self)); CYStringify(str, string.data, string.size); std::string value(str.str());