static JSClassRef ObjectInstance_;
static JSClassRef StringInstance_;
-static JSClassRef *Instances_[] = {
- &Instance_,
- &ArrayInstance_,
- &ObjectInstance_,
- &StringInstance_,
-};
-
static JSClassRef Internal_;
static JSClassRef Message_;
static JSClassRef Messages_;
static Type_privateData *Object_type;
static Type_privateData *Selector_type;
-static bool CYValueIsObjectOfClassInstance(JSContextRef context, JSValueRef value) {
- for (size_t i(0); i != sizeof(Instances_) / sizeof(Instances_[0]); ++i)
- if (JSValueIsObjectOfClass(context, value, *Instances_[i]))
- return true;
- return false;
-}
-
Type_privateData *Instance::GetType() const {
return Object_type;
}
- (NSObject *) cy$toJSON:(NSString *)key;
- (NSString *) cy$toCYON;
-- (NSString *) cy$toKey;
- (bool) cy$hasProperty:(NSString *)name;
- (NSObject *) cy$getProperty:(NSString *)name;
}
NSObject *CYCastNSObject(apr_pool_t *pool, JSContextRef context, JSObjectRef object) {
- if (!CYValueIsObjectOfClassInstance(context, object))
+ if (!JSValueIsObjectOfClass(context, object, Instance_))
return CYCastNSObject_(pool, context, object);
else {
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(object)));
[json appendString:@","];
else
comma = true;
- [json appendString:[key cy$toKey]];
+ [json appendString:CYCastNSCYON(key)];
[json appendString:@":"];
NSObject *object([self objectForKey:key]);
[json appendString:CYCastNSCYON(object)];
return [[self cy$toJSON:@""] cy$toCYON];
}
-- (NSString *) cy$toKey {
- return [self cy$toCYON];
-}
-
- (bool) cy$hasProperty:(NSString *)name {
return false;
}
return CYCastNSString(NULL, CYUTF8String(value.c_str(), value.size()));
}
-- (NSString *) cy$toKey {
- if (CYIsKey(CYCastUTF8String(self)))
- return self;
- return [self cy$toCYON];
-}
-
- (bool) cy$hasProperty:(NSString *)name {
if ([name isEqualToString:@"length"])
return true;
if (!CYIsClass(_class))
return false;
- if (CYValueIsObjectOfClassInstance(context, instance)) {
+ if (JSValueIsObjectOfClass(context, instance, Instance_)) {
Instance *linternal(reinterpret_cast<Instance *>(JSObjectGetPrivate((JSObjectRef) instance)));
// XXX: this isn't always safe
return [linternal->GetValue() isKindOfClass:_class];
self = internal->GetValue();
_class = internal->class_;;
uninitialized = false;
- } else if (CYValueIsObjectOfClassInstance(context, arguments[0])) {
+ } else if (JSValueIsObjectOfClass(context, arguments[0], Instance_)) {
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate((JSObjectRef) arguments[0])));
self = internal->GetValue();
_class = nil;
}
static JSValueRef Instance_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- if (!CYValueIsObjectOfClassInstance(context, _this))
+ if (!JSValueIsObjectOfClass(context, _this, Instance_))
return NULL;
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(_this)));
} CYCatch }
static JSValueRef Instance_callAsFunction_toJSON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- if (!CYValueIsObjectOfClassInstance(context, _this))
+ if (!JSValueIsObjectOfClass(context, _this, Instance_))
return NULL;
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(_this)));
} CYCatch return /*XXX*/ NULL; }
static JSValueRef Instance_callAsFunction_valueOf(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- if (!CYValueIsObjectOfClassInstance(context, _this))
+ if (!JSValueIsObjectOfClass(context, _this, Instance_))
return NULL;
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(_this)));
} CYCatch return /*XXX*/ NULL; }
static JSValueRef Instance_callAsFunction_toPointer(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- if (!CYValueIsObjectOfClassInstance(context, _this))
+ if (!JSValueIsObjectOfClass(context, _this, Instance_))
return NULL;
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(_this)));
} CYCatch return /*XXX*/ NULL; }
static JSValueRef Instance_callAsFunction_toString(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- if (!CYValueIsObjectOfClassInstance(context, _this))
+ if (!JSValueIsObjectOfClass(context, _this, Instance_))
return NULL;
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(_this)));