Permalink
Browse files

Various bug fixes.

  • Loading branch information...
1 parent e8e770f commit e04ddcb9e44c68e8bbc0397f990ca8091872b9de @logancollins committed Aug 8, 2012
View
@@ -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;
}
@@ -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);
}
@@ -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;
@@ -23,6 +23,13 @@
#import <objc/runtime.h>
+@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];

0 comments on commit e04ddcb

Please sign in to comment.