Skip to content
Browse files

Woot! Stuff is sort of working again.

  • Loading branch information...
1 parent ef7a79d commit 7d0c4561a7c5d4cc7218f81ea912f942cf86b947 @ccgus committed Oct 29, 2011
View
26 experimental/experimental.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 45;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -735,8 +735,11 @@
/* Begin PBXProject section */
2A37F4A9FDCFA73011CA2CEA /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "experimental" */;
- compatibilityVersion = "Xcode 3.1";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -915,9 +918,9 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
- PREBINDING = NO;
- SDKROOT = macosx10.6;
+ SDKROOT = macosx;
};
name = Debug;
};
@@ -933,8 +936,8 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- PREBINDING = NO;
- SDKROOT = macosx10.6;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
+ SDKROOT = macosx;
};
name = Release;
};
@@ -947,7 +950,6 @@
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_ENABLE_OBJC_GC = supported;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -966,7 +968,6 @@
"-framework",
AppKit,
);
- PREBINDING = NO;
PRODUCT_NAME = JSTalk;
};
name = Debug;
@@ -979,7 +980,6 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_ENABLE_OBJC_GC = supported;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -997,7 +997,6 @@
"-lexpat",
"-lffi",
);
- PREBINDING = NO;
PRODUCT_NAME = JSTalk;
ZERO_LINK = NO;
};
@@ -1009,7 +1008,6 @@
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -1024,9 +1022,8 @@
"-framework",
AppKit,
);
- PREBINDING = NO;
PRODUCT_NAME = jstalk;
- SDKROOT = macosx10.7;
+ SDKROOT = macosx;
};
name = Debug;
};
@@ -1035,7 +1032,6 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = YES;
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = src/JSTalk_Prefix.pch;
@@ -1048,8 +1044,8 @@
"-framework",
AppKit,
);
- PREBINDING = NO;
PRODUCT_NAME = jstalk;
+ SDKROOT = macosx;
ZERO_LINK = NO;
};
name = Release;
View
2 experimental/src/JSTBridge.m
@@ -313,8 +313,6 @@ - (JSValueRef)propertyForObject:(JSObjectRef)jsObject named:(JSStringRef)jsPrope
JSValueRef returnJSObject = 0x00;
JSTRuntimeInfo *info = [JSTBridgeSupportLoader runtimeInfoForSymbol:propertyName];
- debug(@"propertyName: %@", propertyName);
-
if ([propertyName isEqualToString:@"jst_msgSend"]) {
if (!_jstMsgSendFunction) {
View
2 experimental/src/JSTFunction.h
@@ -25,8 +25,6 @@
JSTBridge *_bridge;
Method _objcMethod;
BOOL _askedForFFIArgsForEncoding;
- //id _forcedObjcTarget;
- //NSString *_forcedObjcSelector;
ffi_type **_encodedArgsForUnbridgedMsgSend;
}
View
142 experimental/src/JSTFunction.m
@@ -31,7 +31,7 @@ static void DeallocateClosure(void *closure) {
}
@interface JSTFunction ()
-- (Method)objcMethod;
+- (void)lookupObjcMethod;
@end
@implementation JSTFunction
@@ -346,8 +346,6 @@ - (void)checkForMsgSendMethodRuntimeInfo {
instanceInfo = [JSTBridgeSupportLoader runtimeInfoForSymbol:classString];
}
- debug(@"instanceInfo: '%@'", instanceInfo);
-
if (isClassMethod) { // are we dealing with an Class method?
_msgSendMethodRuntimeInfo = [instanceInfo runtimeInfoForClassMethodName:sel];
}
@@ -357,8 +355,6 @@ - (void)checkForMsgSendMethodRuntimeInfo {
debug(@"_msgSendMethodRuntimeInfo: %@", _msgSendMethodRuntimeInfo);
- // we should check for the return type and stuff. For now, we're just dealing with simple return values.
- _callAddress = &objc_msgSend;
/*
if (!_msgSendMethodRuntimeInfo) {
@@ -375,11 +371,7 @@ - (void)checkForMsgSendMethodRuntimeInfo {
}
-- (Method)objcMethod {
-
- if (_objcMethod) {
- return _objcMethod;
- }
+- (void)lookupObjcMethod {
JSTAssert((_callAddress == &objc_msgSend));
JSTAssert(_argumentCount > 1);
@@ -393,8 +385,6 @@ - (Method)objcMethod {
else {
_objcMethod = class_getInstanceMethod(object_getClass(target), sel);
}
-
- return _objcMethod;
}
-(ffi_type*)encodingsForStructure:(NSString*)typeEncoding {
@@ -441,7 +431,8 @@ -(ffi_type*)setupReturnType {
}
}
else {
- const char *c = method_getTypeEncoding([self objcMethod]);
+ JSTAssert(_objcMethod);
+ const char *c = method_getTypeEncoding(_objcMethod);
if (c) {
retType = [self _ffiArgForEncode:c];
}
@@ -485,93 +476,87 @@ -(ffi_type*)setValue:(void**)argVals atIndex:(int)idx {
void **foo = [self _allocate:(sizeof(void*))];
- if (idx == 0) { // this is the target
- *foo = JSTNSObjectFromValue(_bridge, argument);
- argVals[idx] = foo;
- return &ffi_type_pointer;
- }
- else if (idx == 1) { // arg 2 is always a selector
- *foo = JSTSelectorFromValue(_bridge, argument);
-
- debug(@"selector: '%@'", NSStringFromSelector(*foo));
-
- argVals[idx] = foo;
- return &ffi_type_pointer;
- }
+ ffi_type *retType = 0x00;
+ char *argType = method_copyArgumentType(_objcMethod, idx);
- if (_msgSendMethodRuntimeInfo) {
-
- // FIXME: this is lame.
- // FIXME: Why shouldn't we just fall back on the _objcMethod stuff?
- //[self objcMethod];
- }
+ JSTAssert(argType);
- if (!_encodedArgsForUnbridgedMsgSend) {
+ debug(@"argType: %s at index %d", argType, idx);
+
+ if (strcmp(argType, @encode(id)) == 0) {
+ *foo = JSTNSObjectFromValue(_bridge, argument);
+ argVals[idx] = foo;
+ retType = &ffi_type_pointer;
+ //debug(@"object at index %d: %@", idx, *foo);
+ }
+ else if (strcmp(argType, @encode(SEL)) == 0) {
- JSTAssert(_objcMethod);
- const char *c = method_getTypeEncoding(_objcMethod);
- JSTAssert(c);
+ //debug(@"sel at index %d: %@", idx, NSStringFromSelector(JSTSelectorFromValue(_bridge, argument)));
- debug(@"c: %s", c);
+ *foo = JSTSelectorFromValue(_bridge, argument);
- int argCount;
- _encodedArgsForUnbridgedMsgSend = [self _argsWithEncodeString:c getCount:&argCount];
+ argVals[idx] = foo;
+ retType = &ffi_type_pointer;
- /*
- if (argCount != _argumentCount) {
- NSLog(@"WHOA WHOA WHOA THE ARGUMENT COUNT IS OFF! encoding says %d but we were passed %d. Runtime says it should be %d", (int)argCount, (int)_argumentCount, method_getNumberOfArguments(_objcMethod));
- JSTAssert(false);
- }
- */
}
-
- assert(_encodedArgsForUnbridgedMsgSend);
-
- ffi_type *retType = _encodedArgsForUnbridgedMsgSend[idx];
-
- if (retType == &ffi_type_pointer) {
- *foo = JSTNSObjectFromValue(_bridge, argument);
- argVals[idx] = foo;
+ else if (strcmp(argType, @encode(BOOL)) == 0) {
+ void **storage = [self _allocate:(sizeof(void*))];
+ *storage = (void*)((uint32_t)JSTLongFromValue(_bridge, argument));
+ argVals[idx] = storage;
+ retType = &ffi_type_sint8; // is this right?
}
- else if (retType == &ffi_type_sint32) {
+ else if (strcmp(argType, @encode(int32_t)) == 0) {
*foo = (void*)((int32_t)JSTLongFromValue(_bridge, argument));
argVals[idx] = foo;
+ retType = &ffi_type_sint32;
}
- else if (retType == &ffi_type_uint32) {
+ else if (strcmp(argType, @encode(uint32_t)) == 0) {
void **storage = [self _allocate:(sizeof(void*))];
*storage = (void*)((uint32_t)JSTLongFromValue(_bridge, argument));
argVals[idx] = storage;
+ retType = &ffi_type_uint32;
}
- else if (retType == &ffi_type_uint64) {
+ else if (strcmp(argType, @encode(int64_t)) == 0) {
+ void **storage = [self _allocate:(sizeof(void*))];
+ *storage = (void*)((int64_t)JSTLongFromValue(_bridge, argument));
+ argVals[idx] = storage;
+ retType = &ffi_type_sint64;
+ }
+ else if (strcmp(argType, @encode(uint64_t)) == 0) {
void **storage = [self _allocate:(sizeof(void*))];
*storage = (void*)((uint64_t)JSTLongFromValue(_bridge, argument));
argVals[idx] = storage;
+ retType = &ffi_type_uint64;
}
- else if (retType == &ffi_type_float) {
+ else if (strcmp(argType, @encode(float)) == 0) {
float **floatStorage = [self _allocate:(sizeof(float*))];
*(float*)floatStorage = (float)JSTDoubleFromValue(_bridge, argument);
argVals[idx] = floatStorage;
+ retType = &ffi_type_float;
}
- else if (retType == &ffi_type_double) {
+ else if (strcmp(argType, @encode(double)) == 0) {
double **floatStorage = [self _allocate:(sizeof(double*))];
*(double*)floatStorage = (double)JSTDoubleFromValue(_bridge, argument);
argVals[idx] = floatStorage;
+ retType = &ffi_type_double;
}
- else if (retType == &ffi_type_longdouble) {
+ else if (strcmp(argType, @encode(long double)) == 0) {
long double **floatStorage = [self _allocate:(sizeof(long double*))];
*(long double*)floatStorage = JSTDoubleFromValue(_bridge, argument);
- debug(@"*(long double*)floatStorage: %Lf", *(long double*)floatStorage);
+ //debug(@"*(long double*)floatStorage: %Lf", *(long double*)floatStorage);
argVals[idx] = floatStorage;
+ retType = &ffi_type_longdouble;
}
else {
- debug(@"retType: '%@'", JSTStringForFFIType(retType));
- debug(@"not sure what to do with this guy!");
- assert(false);
+ NSLog(@"Unknown argument type at index %d: '%s'", (idx - 2), argType);
}
+ free(argType);
+
return retType;
}
+ /*
else {
if (_runtimeInfo) {
@@ -634,7 +619,8 @@ -(ffi_type*)setValue:(void**)argVals atIndex:(int)idx {
else {
JSTAssert(false);
}
- }
+ }
+ */
return 0x00;
}
@@ -643,11 +629,17 @@ -(ffi_type*)setValue:(void**)argVals atIndex:(int)idx {
- (JSValueRef)call:(JSValueRef*)exception {
if (_isJSTMsgSend) {
+
+ // we should check for the return type and stuff. For now, we're just dealing with simple return values.
+ _callAddress = &objc_msgSend;
+
+ [self lookupObjcMethod];
[self checkForMsgSendMethodRuntimeInfo];
+
+ JSTAssert(method_getNumberOfArguments(_objcMethod) == _argumentCount);
+
}
- debug(@"Calling %@", _functionName);
-
BOOL success = YES;
ffi_type **argTypes = _argumentCount ? malloc(_argumentCount * sizeof(ffi_type*)) : 0x00;
void **argVals = _argumentCount ? malloc(_argumentCount * sizeof(void*)) : 0x00;
@@ -677,6 +669,7 @@ - (JSValueRef)call:(JSValueRef*)exception {
void *returnValue;
@try {
+ debug(@"calling");
ffi_call(&cif, _callAddress, &returnValue, argVals);
}
@catch (NSException * e) {
@@ -737,8 +730,21 @@ - (JSValueRef)call:(JSValueRef*)exception {
JSTAssert(retJS);
}
- [_allocations release];
- _allocations = 0x00;
+ if (_isJSTMsgSend) {
+ // this class is reusable.
+ [_allocations release];
+ _allocations = 0x00;
+
+ [_runtimeInfo release];
+ _runtimeInfo = 0x00;
+
+ [_msgSendMethodRuntimeInfo release];
+ _msgSendMethodRuntimeInfo = 0x00;
+
+ _objcMethod = 0x00;
+ }
+
+
return retJS;
}
View
2 experimental/src/JSTalk.m
@@ -237,6 +237,8 @@ - (id)executeString:(NSString*)str {
// quick helper function.
//[_bridge evalJSString:@"function print(s) { objc_msgSend(jstalk, \"print:\", s); }" withPath:nil];
+ debug(@"str: %@", str);
+
resultRef = [_bridge evalJSString:str withPath:nil];
}

0 comments on commit 7d0c456

Please sign in to comment.
Something went wrong with that request. Please try again.