- (bool) cy$hasProperty:(NSString *)name;
- (NSObject *) cy$getProperty:(NSString *)name;
+- (JSValueRef) cy$getProperty:(NSString *)name inContext:(JSContextRef)context;
- (bool) cy$setProperty:(NSString *)name to:(NSObject *)value;
- (bool) cy$deleteProperty:(NSString *)name;
- (void) cy$getPropertyNames:(JSPropertyNameAccumulatorRef)names inContext:(JSContextRef)context;
}
- (NSObject *) cy$getProperty:(NSString *)name {
- if ([name isEqualToString:@"length"]) {
- NSUInteger count([self count]);
-#ifdef __APPLE__
- return [NSNumber numberWithUnsignedInteger:count];
-#else
- return [NSNumber numberWithUnsignedInt:count];
-#endif
- }
-
size_t index(CYGetIndex(name));
if (index == _not(size_t) || index >= [self count])
return [super cy$getProperty:name];
return [self objectAtIndex:index];
}
+- (JSValueRef) cy$getProperty:(NSString *)name inContext:(JSContextRef)context {
+ CYObjectiveTry_(context) {
+ if ([name isEqualToString:@"length"])
+ return CYCastJSValue(context, [self count]);
+ } CYObjectiveCatch
+
+ return [super cy$getProperty:name inContext:context];
+}
+
- (void) cy$getPropertyNames:(JSPropertyNameAccumulatorRef)names inContext:(JSContextRef)context {
[super cy$getPropertyNames:names inContext:context];
return nil;
}
+- (JSValueRef) cy$getProperty:(NSString *)name inContext:(JSContextRef)context { CYObjectiveTry_(context) {
+ if (NSObject *value = [self cy$getProperty:name])
+ return CYCastJSValue(context, value);
+ return NULL;
+} CYObjectiveCatch }
+
- (bool) cy$setProperty:(NSString *)name to:(NSObject *)value {
return false;
}
return value;
CYPoolTry {
- if (NSObject *data = [self cy$getProperty:name])
- return CYCastJSValue(context, data);
+ if (JSValueRef value = [self cy$getProperty:name inContext:context])
+ return value;
} CYPoolCatch(NULL)
const char *string(CYPoolCString(pool, context, name));