uintptr_t mask((1 << length) - 1);
return CYCastJSValue(context, (field >> shift) & mask);
} else {
- Type_privateData type(pool, ivar_getTypeEncoding(ivar));
- return CYFromFFI(context, type.type_, type.GetFFI(), data);
+ auto type(new(pool) Type_privateData(ivar_getTypeEncoding(ivar)));
+ return CYFromFFI(context, type->type_, type->GetFFI(), data);
}
}
uintptr_t mask((1 << length) - 1);
field = field & ~(mask << shift) | (uintptr_t(CYCastDouble(context, value)) & mask) << shift;
} else {
- Type_privateData type(pool, ivar_getTypeEncoding(ivar));
- CYPoolFFI(&pool, context, type.type_, type.GetFFI(), reinterpret_cast<uint8_t *>(self) + ivar_getOffset(ivar), value);
+ auto type(new(pool) Type_privateData(ivar_getTypeEncoding(ivar)));
+ CYPoolFFI(&pool, context, type->type_, type->GetFFI(), reinterpret_cast<uint8_t *>(self) + ivar_getOffset(ivar), value);
return true;
}
}
if (!CYIsClass(value))
CYThrow("non-Class object cannot be used as Type");
- // XXX: this is a very silly implementation
-
- std::ostringstream type;
- type << "@\"";
- type << class_getName(value);
- type << "\"";
-
- CYPoolTry {
- return CYMakeType(context, type.str().c_str());
- } CYPoolCatch(NULL)
+ sig::Type type;
+ memset(&type, 0, sizeof(type));
+ type.primitive = sig::object_P;
+ type.name = class_getName(value);
+ return CYMakeType(context, &type);
} CYCatch(NULL) return /*XXX*/ NULL; }
static JSValueRef Selector_callAsFunction_toString(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
CYPool &pool(CYGetGlobalPool());
- Object_type = new(pool) Type_privateData("@");
- Selector_type = new(pool) Type_privateData(":");
+ Object_type = new(pool) Type_privateData(sig::object_P);
+ Selector_type = new(pool) Type_privateData(sig::selector_P);
NSArray_ = objc_getClass("NSArray");
NSBlock_ = objc_getClass("NSBlock");
CYSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, Selector, prototype_s)), Function_prototype);
} CYPoolCatch() }
-static CYHooks CYObjectiveCHooks = {
+static CYHook CYObjectiveCHook = {
&CYObjectiveC_ExecuteStart,
&CYObjectiveC_ExecuteEnd,
&CYObjectiveC_CallFunction,
&CYObjectiveC_FromFFI,
};
-struct CYObjectiveC {
- CYObjectiveC() {
- hooks_ = &CYObjectiveCHooks;
- // XXX: evil magic juju to make this actually take effect on a Mac when compiled with autoconf/libtool doom!
- _assert(hooks_ != NULL);
- }
-} CYObjectiveC;
+CYRegisterHook CYObjectiveC(&CYObjectiveCHook);
extern "C" void CydgetSetupContext(JSGlobalContextRef context) { CYObjectiveTry_ {
CYSetupContext(context);