return Pointer::Make(context, pointer, type, context, owner);
}
-static JSObjectRef CYMakeFunctor(JSContextRef context, void (*function)(), bool variadic, const sig::Signature &signature) {
+static JSValueRef CYMakeFunctor(JSContextRef context, void (*function)(), bool variadic, const sig::Signature &signature) {
+ if (function == NULL)
+ return CYJSNull(context);
return JSObjectMake(context, Functor_, new cy::Functor(function, variadic, signature));
}
+// XXX: remove this, as it is really stupid
static JSObjectRef CYMakeFunctor(JSContextRef context, const char *symbol, const char *encoding) {
void (*function)()(reinterpret_cast<void (*)()>(CYCastSymbol(symbol)));
if (function == NULL)
return CYCastJSObject(context, CYGetCachedValue(context, name));
}
-static JSObjectRef CYMakeFunctor(JSContextRef context, JSValueRef value, bool variadic, const sig::Signature &signature) {
+static JSValueRef CYMakeFunctor(JSContextRef context, JSValueRef value, bool variadic, const sig::Signature &signature) {
JSObjectRef Function(CYGetCachedObject(context, CYJSString("Function")));
bool function(_jsccall(JSValueIsInstanceOfConstructor, context, value, Function));
return pointer;
} CYCatch(NULL) }
+// XXX: I don't even think the user should be allowed to do this
static JSObjectRef Functor_new(JSContextRef context, JSObjectRef object, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
if (count != 2)
throw CYJSError(context, "incorrect number of arguments to Functor constructor");
const char *encoding(CYPoolCString(pool, context, arguments[1]));
sig::Signature signature;
sig::Parse(pool, &signature, encoding, &Structor_);
- return CYMakeFunctor(context, arguments[0], false, signature);
+ // XXX: this can try to return null, and I guess then it just fails
+ return CYCastJSObject(context, CYMakeFunctor(context, arguments[0], false, signature));
} CYCatch(NULL) }
static JSValueRef CArray_callAsFunction_toPointer(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
}
static JSValueRef JavaMethod_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- CYJavaMethod *internal(reinterpret_cast<CYJavaMethod *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaMethod::Get(context, object));
CYJavaObject *self(CYGetJavaObject(context, _this));
CYJavaEnv jni(self->value_);
} CYCatch(NULL) }
static JSValueRef JavaStaticMethod_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- CYJavaMethod *internal(reinterpret_cast<CYJavaMethod *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaStaticMethod::Get(context, object));
CYJavaClass *table(CYGetJavaTable(context, _this));
CYJavaEnv jni(table->value_);
} CYCatch(NULL) }
static JSObjectRef JavaClass_callAsConstructor(JSContextRef context, JSObjectRef object, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- CYJavaClass *table(reinterpret_cast<CYJavaClass *>(JSObjectGetPrivate(object)));
+ auto table(CYJavaClass::Get(context, object));
CYJavaEnv jni(table->value_);
jclass _class(table->value_);
} CYCatch(NULL) }
static bool JavaStaticInterior_hasProperty(JSContextRef context, JSObjectRef object, JSStringRef property) {
- CYJavaStaticInterior *internal(reinterpret_cast<CYJavaStaticInterior *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaStaticInterior::Get(context, object));
CYJavaClass *table(internal->table_);
CYPool pool;
auto name(CYPoolUTF8String(pool, context, property));
}
static JSValueRef JavaStaticInterior_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- CYJavaStaticInterior *internal(reinterpret_cast<CYJavaStaticInterior *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaStaticInterior::Get(context, object));
CYJavaClass *table(internal->table_);
CYJavaEnv jni(table->value_);
CYPool pool;
} CYCatch(NULL) }
static bool JavaStaticInterior_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { CYTry {
- CYJavaStaticInterior *internal(reinterpret_cast<CYJavaStaticInterior *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaStaticInterior::Get(context, object));
CYJavaClass *table(internal->table_);
CYJavaEnv jni(table->value_);
CYPool pool;
} CYCatch(false) }
static void JavaStaticInterior_getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef names) {
- CYJavaStaticInterior *internal(reinterpret_cast<CYJavaStaticInterior *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaStaticInterior::Get(context, object));
CYJavaClass *table(internal->table_);
for (const auto &field : table->static_)
JSPropertyNameAccumulatorAddName(names, CYJSString(field.first));
}
static JSValueRef JavaClass_getProperty_class(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- CYJavaClass *table(reinterpret_cast<CYJavaClass *>(JSObjectGetPrivate(object)));
+ auto table(CYJavaClass::Get(context, object));
return CYCastJSValue(context, table->value_);
} CYCatch(NULL) }
static bool JavaInterior_hasProperty(JSContextRef context, JSObjectRef object, JSStringRef property) {
- CYJavaInterior *internal(reinterpret_cast<CYJavaInterior *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaInterior::Get(context, object));
CYJavaClass *table(internal->table_);
CYPool pool;
auto name(CYPoolUTF8String(pool, context, property));
}
static JSValueRef JavaInterior_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- CYJavaInterior *internal(reinterpret_cast<CYJavaInterior *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaInterior::Get(context, object));
CYJavaEnv jni(internal->value_);
CYJavaClass *table(internal->table_);
CYPool pool;
} CYCatch(NULL) }
static bool JavaInterior_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { CYTry {
- CYJavaInterior *internal(reinterpret_cast<CYJavaInterior *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaInterior::Get(context, object));
CYJavaEnv jni(internal->value_);
CYJavaClass *table(internal->table_);
CYPool pool;
} CYCatch(false) }
static void JavaInterior_getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef names) {
- CYJavaInterior *internal(reinterpret_cast<CYJavaInterior *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaInterior::Get(context, object));
CYJavaClass *table(internal->table_);
for (const auto &field : table->instance_)
JSPropertyNameAccumulatorAddName(names, CYJSString(field.first));
}
static JSValueRef JavaObject_getProperty_constructor(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- CYJavaObject *internal(reinterpret_cast<CYJavaObject *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaObject::Get(context, object));
CYJavaEnv jni(internal->value_);
return CYGetJavaClass(context, jni.GetObjectClass(internal->value_));
} CYCatch(NULL) }
static JSValueRef JavaClass_getProperty_$cyi(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- CYJavaClass *internal(reinterpret_cast<CYJavaClass *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaClass::Get(context, object));
return CYJavaStaticInterior::Make(context, internal->value_, internal);
} CYCatch(NULL) }
static JSValueRef JavaObject_getProperty_$cyi(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- CYJavaObject *internal(reinterpret_cast<CYJavaObject *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaObject::Get(context, object));
return CYJavaInterior::Make(context, internal->value_, internal->table_);
} CYCatch(NULL) }
static JSValueRef JavaClass_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- CYJavaClass *internal(reinterpret_cast<CYJavaClass *>(JSObjectGetPrivate(_this)));
+ auto internal(CYJavaClass::Get(context, _this));
CYJavaEnv jni(internal->value_);
auto Class$(jni.FindClass("java/lang/Class"));
auto Class$getCanonicalName(jni.GetMethodID(Class$, "getCanonicalName", "()Ljava/lang/String;"));
} CYCatch(NULL) }
static JSValueRef JavaArray_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- CYJavaArray *internal(reinterpret_cast<CYJavaArray *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaArray::Get(context, object));
CYJavaEnv jni(internal->value_);
if (JSStringIsEqual(property, length_s))
return CYCastJSValue(context, jni.GetArrayLength(internal->value_));
} CYCatch(NULL) }
static bool JavaArray_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { CYTry {
- CYJavaArray *internal(reinterpret_cast<CYJavaArray *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaArray::Get(context, object));
CYJavaEnv jni(internal->value_);
CYPool pool;
} CYCatch(false) }
static JSValueRef JavaPackage_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- CYJavaPackage *internal(reinterpret_cast<CYJavaPackage *>(JSObjectGetPrivate(_this)));
+ auto internal(CYJavaPackage::Get(context, _this));
std::ostringstream name;
for (auto &package : internal->package_)
name << package << '.';
}
static JSValueRef CYJavaPackage_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- CYJavaPackage *internal(reinterpret_cast<CYJavaPackage *>(JSObjectGetPrivate(object)));
+ auto internal(CYJavaPackage::Get(context, object));
CYJavaPackage::Path package(internal->package_);
CYPool pool;