return CYGetOffset(CYPoolCString(pool, context, value), index);
}
+// XXX: this is a horrible back added for CFType
+void *CYCastPointerEx_(JSContextRef context, JSObjectRef value) {
+ JSObjectRef object((JSObjectRef) value);
+ if (JSValueIsObjectOfClass(context, value, CYPrivate<Pointer>::Class_)) {
+ Pointer *internal(reinterpret_cast<Pointer *>(JSObjectGetPrivate(object)));
+ return internal->value_;
+ }
+
+ JSValueRef toPointer(CYGetProperty(context, object, toPointer_s));
+ if (CYIsCallable(context, toPointer)) {
+ JSValueRef value(CYCallAsFunction(context, (JSObjectRef) toPointer, object, 0, NULL));
+ _assert(value != NULL);
+ return CYCastPointer_(context, value);
+ }
+
+ return NULL;
+}
+
void *CYCastPointer_(JSContextRef context, JSValueRef value, bool *guess) {
if (value == NULL)
return NULL;
JSValueRef CYJSUndefined(JSContextRef context);
JSValueRef CYJSNull(JSContextRef context);
+void *CYCastPointerEx_(JSContextRef context, JSObjectRef value);
+
+template <typename Type_>
+_finline Type_ CYCastPointerEx(JSContextRef context, JSObjectRef value) {
+ return reinterpret_cast<Type_>(CYCastPointerEx_(context, value));
+}
+
void *CYCastPointer_(JSContextRef context, JSValueRef value, bool *guess = NULL);
template <typename Type_>
return internal->value_;
}
+ if (NSObject *pointer = CYCastPointerEx<NSObject *>(context, object))
+ return pointer;
+
bool array(CYJSValueIsInstanceOfCachedConstructor(context, object, Array_s));
id value(array ? [CYJSArray alloc] : [CYJSObject alloc]);
return CYPoolRelease(pool, [value initWithJSObject:object inContext:context]);