#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#include <JavaScriptCore/JSStringRefCF.h>
-#include <WebKit/WebScriptObject.h>
#include <objc/runtime.h>
#endif
};
#endif
-#ifndef __APPLE__
@interface CYWebUndefined : NSObject {
}
@end
#define WebUndefined CYWebUndefined
-#endif
/* Bridge: CYJSObject {{{ */
@interface CYJSObject : NSMutableDictionary {
- (NSString *) cy$toCYON:(bool)objective { CYObjectiveTry {
CYPool pool;
- JSValueRef exception(NULL);
const char *cyon(CYPoolCCYON(pool, context_, object_));
- CYThrow(context_, exception);
if (cyon == NULL)
return [super cy$toCYON:objective];
else
return false;
}
-static JSValueRef Messages_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
+static JSValueRef Messages_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
Messages *internal(reinterpret_cast<Messages *>(JSObjectGetPrivate(object)));
Class _class(internal->GetValue());
return CYMakeMessage(context, sel, method_getImplementation(method), method_getTypeEncoding(method));
return NULL;
-}
+} CYCatch(NULL) }
-static bool Messages_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) {
+static bool Messages_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { CYTry {
Messages *internal(reinterpret_cast<Messages *>(JSObjectGetPrivate(object)));
Class _class(internal->GetValue());
}
return true;
-}
+} CYCatch(false) }
#if 0 && OBJC_API_VERSION < 2
-static bool Messages_deleteProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
+static bool Messages_deleteProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
Messages *internal(reinterpret_cast<Messages *>(JSObjectGetPrivate(object)));
Class _class(internal->GetValue());
}
return false;
-}
+} CYCatch(false) }
#endif
static void Messages_getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef names) {
Internal_getPropertyNames_(_class, names);
}
-static JSValueRef Internal_callAsFunction_$cya(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
+static JSValueRef Internal_callAsFunction_$cya(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
Internal *internal(reinterpret_cast<Internal *>(JSObjectGetPrivate(object)));
return internal->GetOwner();
-}
+} CYCatch(NULL) }
static JSValueRef ObjectiveC_Classes_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
CYPool pool;
#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 ||
);
}
#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;
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};
return CYSendMessage(pool, context, self, _class, _cmd, count - 2, arguments + 2, uninitialized, exception);
} CYCatch(NULL) }
-static JSValueRef Selector_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
+static JSValueRef Selector_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
JSValueRef setup[count + 2];
setup[0] = _this;
setup[1] = object;
memcpy(setup + 2, arguments, sizeof(JSValueRef) * count);
return $objc_msgSend(context, NULL, NULL, count + 2, setup, exception);
-}
+} CYCatch(NULL) }
-static JSValueRef Message_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
+static JSValueRef Message_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
CYPool pool;
Message_privateData *internal(reinterpret_cast<Message_privateData *>(JSObjectGetPrivate(object)));
setup[1] = &internal->sel_;
return CYCallFunction(pool, context, 2, setup, count, arguments, false, exception, &internal->signature_, &internal->cif_, internal->GetValue());
-}
+} CYCatch(NULL) }
static JSObjectRef Super_new(JSContextRef context, JSObjectRef object, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
if (count != 2)
return CYMakeInstance(context, self, false);
} CYCatch(NULL) }
-static JSValueRef CYValue_getProperty_value(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
+static JSValueRef CYValue_getProperty_value(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
CYValue *internal(reinterpret_cast<CYValue *>(JSObjectGetPrivate(object)));
return CYCastJSValue(context, reinterpret_cast<uintptr_t>(internal->value_));
-}
+} CYCatch(NULL) }
-static JSValueRef CYValue_callAsFunction_$cya(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
+static JSValueRef CYValue_callAsFunction_$cya(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
CYValue *internal(reinterpret_cast<CYValue *>(JSObjectGetPrivate(_this)));
Type_privateData *typical(internal->GetType());
}
return CYMakePointer(context, &internal->value_, _not(size_t), type, ffi, object);
-}
+} CYCatch(NULL) }
-static JSValueRef Instance_getProperty_constructor(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
+static JSValueRef Instance_getProperty_constructor(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(object)));
return Instance::Make(context, (id) object_getClass(internal->GetValue()));
-}
+} CYCatch(NULL) }
static JSValueRef Instance_getProperty_prototype(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(object)));
return CYGetClassPrototype(context, self);
} CYCatch(NULL) }
-static JSValueRef Instance_getProperty_messages(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
+static JSValueRef Instance_getProperty_messages(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(object)));
id self(internal->GetValue());
if (!CYIsClass(self))
return CYJSUndefined(context);
return Messages::Make(context, (Class) self);
-}
+} CYCatch(NULL) }
static JSValueRef Instance_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
if (!CYJSValueIsNSObject(context, _this))
return CYCastJSValue(context, sel_getName(internal->GetValue()));
} CYCatch(NULL) }
-static JSValueRef Selector_callAsFunction_toJSON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
+static JSValueRef Selector_callAsFunction_toJSON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
return Selector_callAsFunction_toString(context, object, _this, count, arguments, exception);
-}
+} CYCatch(NULL) }
static JSValueRef Selector_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
Selector_privateData *internal(reinterpret_cast<Selector_privateData *>(JSObjectGetPrivate(_this)));