diff --git a/Mocha/MochaRuntime.m b/Mocha/MochaRuntime.m index 8886d24..9b499b1 100644 --- a/Mocha/MochaRuntime.m +++ b/Mocha/MochaRuntime.m @@ -1028,50 +1028,32 @@ JSValueRef Mocha_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef p // Enums else if ([symbol isKindOfClass:[MOBridgeSupportEnum class]]) { - NSNumber *value = [(MOBridgeSupportEnum *)symbol value]; - double doubleValue = 0; - + NSNumber *value = [(MOBridgeSupportEnum *)symbol value]; #if __LP64__ NSNumber *value64 = [(MOBridgeSupportEnum *)symbol value64]; - if (value != nil) { - doubleValue = [value doubleValue]; - } - else if (value64 != nil) { + if (value64 != nil) { doubleValue = [value doubleValue]; } else { - NSException *e = [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"No value for enum: %@", symbol] userInfo:nil]; - if (exception != NULL) { - *exception = [runtime JSValueForObject:e]; +#endif + if (value != nil) { + doubleValue = [value doubleValue]; } - return NULL; - } -#else - if (value != nil) { - doubleValue = [value doubleValue]; - } - else { - NSException *e = [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"No value for enum: %@", symbol] userInfo:nil]; - if (exception != NULL) { - *exception = [runtime JSValueForObject:e]; + else { + NSException *e = [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"No value for enum: %@", symbol] userInfo:nil]; + if (exception != NULL) { + *exception = [runtime JSValueForObject:e]; + } + return NULL; } - return NULL; +#if __LP64__ } #endif - return JSValueMakeNumber(ctx, doubleValue); } } - // Describe ourselves - if ([propertyName isEqualToString:@"toString"] || [propertyName isEqualToString:@"valueOf"]) { - JSStringRef scriptJS = JSStringCreateWithUTF8CString("return '(Mocha global object)'"); - JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSStringRelease(scriptJS); - return fn; - } - return NULL; } diff --git a/Mocha/Objects/MOJavaScriptObject.m b/Mocha/Objects/MOJavaScriptObject.m index 00b2b73..34ebfb4 100644 --- a/Mocha/Objects/MOJavaScriptObject.m +++ b/Mocha/Objects/MOJavaScriptObject.m @@ -35,7 +35,7 @@ - (void)setJSObject:(JSObjectRef)JSObject JSContext:(JSContextRef)JSContext { JSValueUnprotect(_JSContext, _JSObject); } _JSObject = JSObject; - _JSContext = _JSContext; + _JSContext = JSContext; if (_JSObject != NULL) { JSValueProtect(_JSContext, _JSObject); } diff --git a/Mocha/Utilities/MOFunctionArgument.h b/Mocha/Utilities/MOFunctionArgument.h index a1e0537..5010286 100644 --- a/Mocha/Utilities/MOFunctionArgument.h +++ b/Mocha/Utilities/MOFunctionArgument.h @@ -41,11 +41,8 @@ // Storage @property (readonly) ffi_type *ffiType; @property (readonly) void** storage; -@property (readonly) void** rawStoragePointer; @property (copy, readonly) NSString *typeDescription; -- (void *)allocateStorage; - // Values - (JSValueRef)getValueAsJSValueInContext:(JSContextRef)ctx; - (void)setValueAsJSValue:(JSValueRef)value context:(JSContextRef)ctx; diff --git a/Mocha/Utilities/MOFunctionArgument.m b/Mocha/Utilities/MOFunctionArgument.m index a320dae..1259b88 100644 --- a/Mocha/Utilities/MOFunctionArgument.m +++ b/Mocha/Utilities/MOFunctionArgument.m @@ -23,6 +23,13 @@ #import +@interface MOFunctionArgument () + +- (void *)allocateStorage; + +@end + + @implementation MOFunctionArgument { char _typeEncoding; void* _storage; @@ -180,10 +187,6 @@ - (void**)storage { return _storage; } -- (void**)rawStoragePointer { - return _storage; -} - - (void *)allocateStorage { if (!_typeEncoding) { @throw [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"No type encoding set in %@", self] userInfo:nil];