JSValueRef toCYON(CYGetProperty(context, object, toCYON_s));
if (CYIsCallable(context, toCYON)) {
JSValueRef value(CYCallAsFunction(context, (JSObjectRef) toCYON, object, 0, NULL));
+ _assert(value != NULL);
return CYPoolCString(pool, context, value);
}
static JSObjectRef CYMakeFunctor(JSContextRef context, JSObjectRef function, const char *type) {
Closure_privateData *internal(CYMakeFunctor_(context, function, type, &FunctionClosure_));
- return JSObjectMake(context, Functor_, internal);
+ JSObjectRef object(JSObjectMake(context, Functor_, internal));
+ // XXX: see above notes about needing to leak
+ JSValueProtect(CYGetJSContext(context), object);
+ return object;
}
JSObjectRef CYGetCachedObject(JSContextRef context, JSStringRef name) {
#include <objc/objc-api.h>
#endif
-#include "ObjectiveC/Internal.hpp"
-
#ifdef __APPLE__
#include "Struct.hpp"
#endif
#include <Foundation/Foundation.h>
+#include "ObjectiveC/Internal.hpp"
+
#include <objc/Protocol.h>
#include "cycript.hpp"
throw CYJSError(context, CYCastJSValue(context, error));
} }
-static bool CYObjectiveC_PoolFFI(apr_pool_t *pool, JSContextRef context, sig::Type *type, ffi_type *ffi, void *data, JSValueRef value) { CYPoolTry {
+static bool CYObjectiveC_PoolFFI(apr_pool_t *pool, JSContextRef context, sig::Type *type, ffi_type *ffi, void *data, JSValueRef value) { @try {
switch (type->primitive) {
case sig::object_P:
case sig::typename_P:
}
return true;
-} CYPoolCatch(false) return /*XXX*/ NULL; }
+} @catch (NSException *error ) {
+ throw CYJSError(context, CYCastJSValue(context, error));
+} }
static JSValueRef CYObjectiveC_FromFFI(JSContextRef context, sig::Type *type, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) { CYPoolTry {
switch (type->primitive) {
static IMP CYMakeMessage(JSContextRef context, JSValueRef value, const char *type) {
JSObjectRef function(CYCastJSObject(context, value));
Closure_privateData *internal(CYMakeFunctor_(context, function, type, &MessageClosure_));
+ // XXX: see notes in Library.cpp about needing to leak
return reinterpret_cast<IMP>(internal->GetValue());
}
CYPoolTry/Catch now carefully save the exception after it /no longer needs the exception/... uhh... wtf?
throw CYJSError should probably be replaced with CYThrow() across the board
figure out what to do about global context refs: I really really want to retain the bastards
+the concept of NULL pooling is entirely incorrect and sad... bad... evil... need to work on this... really