diff --git a/.gitignore b/.gitignore index e9dc46c..4d06f56 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ Nu.framework libNu.a examples/*/*.app xcuserdata +*.xcscmblueprint diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..762f422 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "libffi"] + path = libffi + url = https://github.com/ksjogo/libffi.git + branch = master diff --git a/Xcode/Info.plist b/Xcode/Info.plist index 2ed73e7..c86810c 100644 --- a/Xcode/Info.plist +++ b/Xcode/Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile CFBundleIdentifier - nu.programming.framework + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Xcode/Nu.xcodeproj/project.pbxproj b/Xcode/Nu.xcodeproj/project.pbxproj index 947c09a..1b206cc 100644 --- a/Xcode/Nu.xcodeproj/project.pbxproj +++ b/Xcode/Nu.xcodeproj/project.pbxproj @@ -9,126 +9,84 @@ /* Begin PBXBuildFile section */ 2217EBB81CCD89E60082837B /* NuMarkupOperator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBB61CCD89E60082837B /* NuMarkupOperator.h */; }; 2217EBB91CCD89E60082837B /* NuMarkupOperator.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBB71CCD89E60082837B /* NuMarkupOperator.m */; }; - 2217EBBA1CCD8AAC0082837B /* NuMarkupOperator.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBB71CCD89E60082837B /* NuMarkupOperator.m */; }; 2217EBBE1CCD8BDF0082837B /* NuSymbol.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBBC1CCD8BDF0082837B /* NuSymbol.h */; }; 2217EBBF1CCD8BDF0082837B /* NuSymbol.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBBD1CCD8BDF0082837B /* NuSymbol.m */; }; - 2217EBC01CCD8BDF0082837B /* NuSymbol.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBBD1CCD8BDF0082837B /* NuSymbol.m */; }; 2217EBC31CCD8CE30082837B /* NuTestHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBC11CCD8CE30082837B /* NuTestHelper.h */; }; 2217EBC41CCD8CE30082837B /* NuTestHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBC21CCD8CE30082837B /* NuTestHelper.m */; }; - 2217EBC51CCD8CE30082837B /* NuTestHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBC21CCD8CE30082837B /* NuTestHelper.m */; }; 2217EBC81CCD8DF00082837B /* NuSwizzles.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBC61CCD8DF00082837B /* NuSwizzles.h */; }; 2217EBC91CCD8DF00082837B /* NuSwizzles.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBC71CCD8DF00082837B /* NuSwizzles.m */; }; - 2217EBCA1CCD8DF00082837B /* NuSwizzles.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBC71CCD8DF00082837B /* NuSwizzles.m */; }; 2217EBCD1CCD8E760082837B /* NuSuper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBCB1CCD8E760082837B /* NuSuper.h */; }; 2217EBCE1CCD8E760082837B /* NuSuper.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBCC1CCD8E760082837B /* NuSuper.m */; }; - 2217EBCF1CCD8E760082837B /* NuSuper.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBCC1CCD8E760082837B /* NuSuper.m */; }; 2217EBD21CCD8F960082837B /* NuStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBD01CCD8F960082837B /* NuStack.h */; }; 2217EBD31CCD8F960082837B /* NuStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBD11CCD8F960082837B /* NuStack.m */; }; - 2217EBD41CCD8F960082837B /* NuStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBD11CCD8F960082837B /* NuStack.m */; }; 2217EBD71CCD90310082837B /* NuParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBD51CCD90310082837B /* NuParser.h */; }; 2217EBD81CCD90310082837B /* NuParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBD61CCD90310082837B /* NuParser.m */; }; - 2217EBD91CCD90310082837B /* NuParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBD61CCD90310082837B /* NuParser.m */; }; 2217EBDC1CCD915B0082837B /* NuRegex.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBDA1CCD915B0082837B /* NuRegex.h */; }; 2217EBDD1CCD915B0082837B /* NuRegex.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBDB1CCD915B0082837B /* NuRegex.m */; }; - 2217EBDE1CCD915B0082837B /* NuRegex.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBDB1CCD915B0082837B /* NuRegex.m */; }; 2217EBE11CCD921B0082837B /* NuReference.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBDF1CCD921B0082837B /* NuReference.h */; }; 2217EBE21CCD921B0082837B /* NuReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBE01CCD921B0082837B /* NuReference.m */; }; - 2217EBE31CCD921B0082837B /* NuReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBE01CCD921B0082837B /* NuReference.m */; }; 2217EBE61CCD92AC0082837B /* NuProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBE41CCD92AC0082837B /* NuProperty.h */; }; 2217EBE71CCD92AC0082837B /* NuProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBE51CCD92AC0082837B /* NuProperty.m */; }; - 2217EBE81CCD92AC0082837B /* NuProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBE51CCD92AC0082837B /* NuProperty.m */; }; 2217EBEB1CCD9DFE0082837B /* NuProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBE91CCD9DFE0082837B /* NuProfiler.h */; }; 2217EBEC1CCD9DFE0082837B /* NuProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBEA1CCD9DFE0082837B /* NuProfiler.m */; }; - 2217EBED1CCD9DFE0082837B /* NuProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBEA1CCD9DFE0082837B /* NuProfiler.m */; }; 2217EBF01CCD9E7F0082837B /* NuPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBEE1CCD9E7F0082837B /* NuPointer.h */; }; 2217EBF11CCD9E7F0082837B /* NuPointer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBEF1CCD9E7F0082837B /* NuPointer.m */; }; - 2217EBF21CCD9E7F0082837B /* NuPointer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBEF1CCD9E7F0082837B /* NuPointer.m */; }; 2217EBF51CCDA0420082837B /* NuOperators.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBF31CCDA0420082837B /* NuOperators.h */; }; 2217EBF61CCDA0420082837B /* NuOperators.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBF41CCDA0420082837B /* NuOperators.m */; }; - 2217EBF71CCDA0420082837B /* NuOperators.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBF41CCDA0420082837B /* NuOperators.m */; }; 2217EBFA1CCDA27A0082837B /* NSObject+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBF81CCDA27A0082837B /* NSObject+Nu.h */; }; 2217EBFB1CCDA27A0082837B /* NSObject+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBF91CCDA27A0082837B /* NSObject+Nu.m */; }; - 2217EBFC1CCDA27A0082837B /* NSObject+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBF91CCDA27A0082837B /* NSObject+Nu.m */; }; 2217EBFF1CCDA3300082837B /* NuObjCRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EBFD1CCDA3300082837B /* NuObjCRuntime.h */; }; 2217EC001CCDA3300082837B /* NuObjCRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBFE1CCDA3300082837B /* NuObjCRuntime.m */; }; - 2217EC011CCDA3300082837B /* NuObjCRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBFE1CCDA3300082837B /* NuObjCRuntime.m */; }; 2217EC041CCDA3870082837B /* NuMethod.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC021CCDA3870082837B /* NuMethod.h */; }; 2217EC051CCDA3870082837B /* NuMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC031CCDA3870082837B /* NuMethod.m */; }; - 2217EC061CCDA3870082837B /* NuMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC031CCDA3870082837B /* NuMethod.m */; }; 2217EC091CCDA4990082837B /* NuMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC071CCDA4990082837B /* NuMacro.h */; }; 2217EC0A1CCDA4990082837B /* NuMacro.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC081CCDA4990082837B /* NuMacro.m */; }; - 2217EC0B1CCDA4990082837B /* NuMacro.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC081CCDA4990082837B /* NuMacro.m */; }; 2217EC0E1CCDA5390082837B /* NuHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC0C1CCDA5390082837B /* NuHandler.h */; }; 2217EC0F1CCDA5390082837B /* NuHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC0D1CCDA5390082837B /* NuHandler.m */; }; - 2217EC101CCDA5390082837B /* NuHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC0D1CCDA5390082837B /* NuHandler.m */; }; 2217EC131CCDA65F0082837B /* NuBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC111CCDA65F0082837B /* NuBlock.h */; }; 2217EC141CCDA65F0082837B /* NuBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC121CCDA65F0082837B /* NuBlock.m */; }; - 2217EC151CCDA65F0082837B /* NuBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC121CCDA65F0082837B /* NuBlock.m */; }; 2217EC181CCDA7350082837B /* NuCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC161CCDA7350082837B /* NuCell.h */; }; 2217EC191CCDA7350082837B /* NuCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC171CCDA7350082837B /* NuCell.m */; }; - 2217EC1A1CCDA7350082837B /* NuCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC171CCDA7350082837B /* NuCell.m */; }; 2217EC1D1CCDA8340082837B /* NuClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC1B1CCDA8340082837B /* NuClass.h */; }; 2217EC1E1CCDA8340082837B /* NuClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC1C1CCDA8340082837B /* NuClass.m */; }; - 2217EC1F1CCDA8340082837B /* NuClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC1C1CCDA8340082837B /* NuClass.m */; }; 2217EC221CCDA9A00082837B /* NuMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC201CCDA9A00082837B /* NuMath.h */; }; 2217EC231CCDA9A00082837B /* NuMath.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC211CCDA9A00082837B /* NuMath.m */; }; - 2217EC241CCDA9A00082837B /* NuMath.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC211CCDA9A00082837B /* NuMath.m */; }; 2217EC271CCDAA850082837B /* NSString+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC251CCDAA850082837B /* NSString+Nu.h */; }; 2217EC281CCDAA850082837B /* NSString+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC261CCDAA850082837B /* NSString+Nu.m */; }; - 2217EC291CCDAA850082837B /* NSString+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC261CCDAA850082837B /* NSString+Nu.m */; }; 2217EC2C1CCDAB700082837B /* NSDictionary+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC2A1CCDAB700082837B /* NSDictionary+Nu.h */; }; 2217EC2D1CCDAB700082837B /* NSDictionary+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC2B1CCDAB700082837B /* NSDictionary+Nu.m */; }; - 2217EC2E1CCDAB700082837B /* NSDictionary+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC2B1CCDAB700082837B /* NSDictionary+Nu.m */; }; 2217EC311CCDAC600082837B /* NSBundle+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC2F1CCDAC600082837B /* NSBundle+Nu.h */; }; 2217EC321CCDAC600082837B /* NSBundle+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC301CCDAC600082837B /* NSBundle+Nu.m */; }; - 2217EC331CCDAC600082837B /* NSBundle+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC301CCDAC600082837B /* NSBundle+Nu.m */; }; 2217EC361CCDAD3B0082837B /* NuEnumerable.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC341CCDAD3B0082837B /* NuEnumerable.h */; }; 2217EC371CCDAD3B0082837B /* NuEnumerable.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC351CCDAD3B0082837B /* NuEnumerable.m */; }; - 2217EC381CCDAD3B0082837B /* NuEnumerable.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC351CCDAD3B0082837B /* NuEnumerable.m */; }; 2217EC3B1CCDAE010082837B /* NuException.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC391CCDAE010082837B /* NuException.h */; }; 2217EC3C1CCDAE010082837B /* NuException.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC3A1CCDAE010082837B /* NuException.m */; }; - 2217EC3D1CCDAE010082837B /* NuException.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC3A1CCDAE010082837B /* NuException.m */; }; 2217EC401CCDAED00082837B /* NSArray+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC3E1CCDAED00082837B /* NSArray+Nu.h */; }; 2217EC411CCDAED00082837B /* NSArray+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC3F1CCDAED00082837B /* NSArray+Nu.m */; }; - 2217EC421CCDAED00082837B /* NSArray+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC3F1CCDAED00082837B /* NSArray+Nu.m */; }; 2217EC451CCDAF2A0082837B /* NSSet+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC431CCDAF2A0082837B /* NSSet+Nu.h */; }; 2217EC461CCDAF2A0082837B /* NSSet+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC441CCDAF2A0082837B /* NSSet+Nu.m */; }; - 2217EC471CCDAF2A0082837B /* NSSet+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC441CCDAF2A0082837B /* NSSet+Nu.m */; }; 2217EC4A1CCDAFE00082837B /* NSNull+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC481CCDAFE00082837B /* NSNull+Nu.h */; }; 2217EC4B1CCDAFE00082837B /* NSNull+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC491CCDAFE00082837B /* NSNull+Nu.m */; }; - 2217EC4C1CCDAFE00082837B /* NSNull+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC491CCDAFE00082837B /* NSNull+Nu.m */; }; 2217EC4F1CCDB0770082837B /* NSNumber+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC4D1CCDB0770082837B /* NSNumber+Nu.h */; }; 2217EC501CCDB0770082837B /* NSNumber+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC4E1CCDB0770082837B /* NSNumber+Nu.m */; }; - 2217EC511CCDB0770082837B /* NSNumber+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC4E1CCDB0770082837B /* NSNumber+Nu.m */; }; 2217EC541CCDB0D40082837B /* NSData+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC521CCDB0D40082837B /* NSData+Nu.h */; }; 2217EC551CCDB0D40082837B /* NSData+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC531CCDB0D40082837B /* NSData+Nu.m */; }; - 2217EC561CCDB0D40082837B /* NSData+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC531CCDB0D40082837B /* NSData+Nu.m */; }; 2217EC591CCDB1240082837B /* NSDate+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC571CCDB1240082837B /* NSDate+Nu.h */; }; 2217EC5A1CCDB1240082837B /* NSDate+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC581CCDB1240082837B /* NSDate+Nu.m */; }; - 2217EC5B1CCDB1240082837B /* NSDate+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC581CCDB1240082837B /* NSDate+Nu.m */; }; 2217EC5E1CCDB19C0082837B /* NSFileManager+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC5C1CCDB19C0082837B /* NSFileManager+Nu.h */; }; 2217EC5F1CCDB19C0082837B /* NSFileManager+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC5D1CCDB19C0082837B /* NSFileManager+Nu.m */; }; - 2217EC601CCDB19C0082837B /* NSFileManager+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC5D1CCDB19C0082837B /* NSFileManager+Nu.m */; }; 2217EC631CCDB2610082837B /* NSMethodSignature+Nu.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC611CCDB2610082837B /* NSMethodSignature+Nu.h */; }; 2217EC641CCDB2610082837B /* NSMethodSignature+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC621CCDB2610082837B /* NSMethodSignature+Nu.m */; }; - 2217EC651CCDB2610082837B /* NSMethodSignature+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC621CCDB2610082837B /* NSMethodSignature+Nu.m */; }; 2217EC681CCDBF390082837B /* NuBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 2217EC661CCDBF390082837B /* NuBridge.h */; }; 2217EC691CCDBF390082837B /* NuBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC671CCDBF390082837B /* NuBridge.m */; }; - 2217EC6A1CCDBF390082837B /* NuBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC671CCDBF390082837B /* NuBridge.m */; }; - 225F62CD13B04256002DD16B /* ffi.S in Sources */ = {isa = PBXBuildFile; fileRef = 225F62C413B04256002DD16B /* ffi.S */; }; - 225F62D313B04256002DD16B /* ffi.c in Sources */ = {isa = PBXBuildFile; fileRef = 225F62CA13B04256002DD16B /* ffi.c */; }; 22716B131CCDC9FD00E7ACDD /* NuBridgedFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 22716B111CCDC9FD00E7ACDD /* NuBridgedFunction.h */; }; 22716B141CCDC9FD00E7ACDD /* NuBridgedFunction.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B121CCDC9FD00E7ACDD /* NuBridgedFunction.m */; }; - 22716B151CCDC9FD00E7ACDD /* NuBridgedFunction.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B121CCDC9FD00E7ACDD /* NuBridgedFunction.m */; }; 22716B181CCDCB6F00E7ACDD /* NuBridgedConstant.h in Headers */ = {isa = PBXBuildFile; fileRef = 22716B161CCDCB6F00E7ACDD /* NuBridgedConstant.h */; }; 22716B191CCDCB6F00E7ACDD /* NuBridgedConstant.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B171CCDCB6F00E7ACDD /* NuBridgedConstant.m */; }; - 22716B1A1CCDCB6F00E7ACDD /* NuBridgedConstant.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B171CCDCB6F00E7ACDD /* NuBridgedConstant.m */; }; 22716B1D1CCDCC0F00E7ACDD /* NuBridgedBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 22716B1B1CCDCC0F00E7ACDD /* NuBridgedBlock.h */; }; 22716B1E1CCDCC0F00E7ACDD /* NuBridgedBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B1C1CCDCC0F00E7ACDD /* NuBridgedBlock.m */; }; - 22716B1F1CCDCC0F00E7ACDD /* NuBridgedBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B1C1CCDCC0F00E7ACDD /* NuBridgedBlock.m */; }; 22716B221CCDCCD900E7ACDD /* NuBridgeSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 22716B201CCDCCD900E7ACDD /* NuBridgeSupport.h */; }; 22716B231CCDCCD900E7ACDD /* NuBridgeSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B211CCDCCD900E7ACDD /* NuBridgeSupport.m */; }; - 22716B241CCDCCD900E7ACDD /* NuBridgeSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B211CCDCCD900E7ACDD /* NuBridgeSupport.m */; }; 2283074411DDBEA700A5C690 /* Nu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Nu.framework */; }; 22B3B3B613B033D400B3AB31 /* test.html in Resources */ = {isa = PBXBuildFile; fileRef = 22B3B38813B033D400B3AB31 /* test.html */; }; 22B3B3B713B033D400B3AB31 /* test_array.nu in Resources */ = {isa = PBXBuildFile; fileRef = 22B3B38913B033D400B3AB31 /* test_array.nu */; }; @@ -210,7 +168,6 @@ 22B3B41613B033EE00B3AB31 /* test.nu in Resources */ = {isa = PBXBuildFile; fileRef = 22B3B3F513B033EE00B3AB31 /* test.nu */; }; 22B3B41713B033EE00B3AB31 /* test.nu in Resources */ = {isa = PBXBuildFile; fileRef = 22B3B3F513B033EE00B3AB31 /* test.nu */; }; 22B3B47313B0359300B3AB31 /* Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 22B3B41D13B0359300B3AB31 /* Nu.m */; }; - 22B3B47413B0359300B3AB31 /* Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 22B3B41D13B0359300B3AB31 /* Nu.m */; }; 22B3B50313B0386600B3AB31 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B3B50213B0386600B3AB31 /* UIKit.framework */; }; 22B3B50513B0388C00B3AB31 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B3B50413B0388C00B3AB31 /* Foundation.framework */; }; 22B3B50713B038D000B3AB31 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B3B50613B038D000B3AB31 /* Foundation.framework */; }; @@ -218,6 +175,49 @@ 22EE2C0413A4731600895861 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 22EE2C0213A4731600895861 /* InfoPlist.strings */; }; 22EE2C0613A4731600895861 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 22EE2C0513A4731600895861 /* main.m */; }; 22EE2C0A13A4731600895861 /* NuAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 22EE2C0913A4731600895861 /* NuAppDelegate.m */; }; + 43B5D4101D3668A600D1E1FD /* libNuTouch.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 43B5D4021D36686B00D1E1FD /* libNuTouch.a */; }; + 43DCFCB31D369D8200CB6E63 /* libffi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 43DCFCB21D369D8200CB6E63 /* libffi.a */; }; + 43DCFCB91D37938100CB6E63 /* NSArray+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC3F1CCDAED00082837B /* NSArray+Nu.m */; }; + 43DCFCBB1D37938100CB6E63 /* NSBundle+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC301CCDAC600082837B /* NSBundle+Nu.m */; }; + 43DCFCBD1D37938100CB6E63 /* NSData+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC531CCDB0D40082837B /* NSData+Nu.m */; }; + 43DCFCBF1D37938100CB6E63 /* NSDate+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC581CCDB1240082837B /* NSDate+Nu.m */; }; + 43DCFCC11D37938100CB6E63 /* NSDictionary+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC2B1CCDAB700082837B /* NSDictionary+Nu.m */; }; + 43DCFCC31D37938100CB6E63 /* NSFileManager+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC5D1CCDB19C0082837B /* NSFileManager+Nu.m */; }; + 43DCFCC51D37938100CB6E63 /* NSMethodSignature+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC621CCDB2610082837B /* NSMethodSignature+Nu.m */; }; + 43DCFCC71D37938200CB6E63 /* NSNull+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC491CCDAFE00082837B /* NSNull+Nu.m */; }; + 43DCFCC91D37938200CB6E63 /* NSNumber+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC4E1CCDB0770082837B /* NSNumber+Nu.m */; }; + 43DCFCCB1D37938200CB6E63 /* NSObject+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBF91CCDA27A0082837B /* NSObject+Nu.m */; }; + 43DCFCCD1D37938200CB6E63 /* NSSet+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC441CCDAF2A0082837B /* NSSet+Nu.m */; }; + 43DCFCCF1D37938200CB6E63 /* NSString+Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC261CCDAA850082837B /* NSString+Nu.m */; }; + 43DCFCD11D37938200CB6E63 /* Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 22B3B41D13B0359300B3AB31 /* Nu.m */; }; + 43DCFCD31D37938200CB6E63 /* NuBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC121CCDA65F0082837B /* NuBlock.m */; }; + 43DCFCD51D37938200CB6E63 /* NuBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC671CCDBF390082837B /* NuBridge.m */; }; + 43DCFCD71D37938200CB6E63 /* NuCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC171CCDA7350082837B /* NuCell.m */; }; + 43DCFCD91D37938200CB6E63 /* NuClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC1C1CCDA8340082837B /* NuClass.m */; }; + 43DCFCDB1D37938200CB6E63 /* NuEnumerable.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC351CCDAD3B0082837B /* NuEnumerable.m */; }; + 43DCFCDD1D37938200CB6E63 /* NuException.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC3A1CCDAE010082837B /* NuException.m */; }; + 43DCFCDF1D37938200CB6E63 /* NuHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC0D1CCDA5390082837B /* NuHandler.m */; }; + 43DCFCE21D37938200CB6E63 /* NuMacro.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC081CCDA4990082837B /* NuMacro.m */; }; + 43DCFCE41D37938200CB6E63 /* NuMarkupOperator.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBB71CCD89E60082837B /* NuMarkupOperator.m */; }; + 43DCFCE61D37938200CB6E63 /* NuMath.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC211CCDA9A00082837B /* NuMath.m */; }; + 43DCFCE81D37938200CB6E63 /* NuMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EC031CCDA3870082837B /* NuMethod.m */; }; + 43DCFCEA1D37938200CB6E63 /* NuObjCRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBFE1CCDA3300082837B /* NuObjCRuntime.m */; }; + 43DCFCEC1D37938200CB6E63 /* NuOperators.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBF41CCDA0420082837B /* NuOperators.m */; }; + 43DCFCEE1D37938200CB6E63 /* NuParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBD61CCD90310082837B /* NuParser.m */; }; + 43DCFCF01D37938200CB6E63 /* NuPointer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBEF1CCD9E7F0082837B /* NuPointer.m */; }; + 43DCFCF21D37938200CB6E63 /* NuProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBEA1CCD9DFE0082837B /* NuProfiler.m */; }; + 43DCFCF41D37938200CB6E63 /* NuProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBE51CCD92AC0082837B /* NuProperty.m */; }; + 43DCFCF61D37938200CB6E63 /* NuReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBE01CCD921B0082837B /* NuReference.m */; }; + 43DCFCF81D37938200CB6E63 /* NuRegex.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBDB1CCD915B0082837B /* NuRegex.m */; }; + 43DCFCFA1D37938200CB6E63 /* NuStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBD11CCD8F960082837B /* NuStack.m */; }; + 43DCFCFC1D37938200CB6E63 /* NuSuper.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBCC1CCD8E760082837B /* NuSuper.m */; }; + 43DCFCFE1D37938200CB6E63 /* NuSwizzles.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBC71CCD8DF00082837B /* NuSwizzles.m */; }; + 43DCFD001D37938200CB6E63 /* NuSymbol.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBBD1CCD8BDF0082837B /* NuSymbol.m */; }; + 43DCFD021D37938200CB6E63 /* NuTestHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 2217EBC21CCD8CE30082837B /* NuTestHelper.m */; }; + 43DCFD041D37938200CB6E63 /* NuBridgedFunction.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B121CCDC9FD00E7ACDD /* NuBridgedFunction.m */; }; + 43DCFD061D37938200CB6E63 /* NuBridgedConstant.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B171CCDCB6F00E7ACDD /* NuBridgedConstant.m */; }; + 43DCFD081D37938200CB6E63 /* NuBridgedBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B1C1CCDCC0F00E7ACDD /* NuBridgedBlock.m */; }; + 43DCFD0A1D37938200CB6E63 /* NuBridgeSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 22716B211CCDCCD900E7ACDD /* NuBridgeSupport.m */; }; 4F43427C1420476C00AC1BFD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F43427B1420476C00AC1BFD /* main.m */; }; 56E07744170B028400FF0A4B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 56E07743170B028400FF0A4B /* Default-568h@2x.png */; }; 8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; }; @@ -231,8 +231,35 @@ remoteGlobalIDString = 8DC2EF4F0486A6940098B216; remoteInfo = Nu; }; + 433CE5691D38EA4100EE7273 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 433CE5641D38EA4100EE7273 /* libffi.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = DB13B1661849DF1E0010F42D; + remoteInfo = "libffi-iOS"; + }; + 433CE56B1D38EA4100EE7273 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 433CE5641D38EA4100EE7273 /* libffi.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = DB13B1911849DF510010F42D; + remoteInfo = "libffi-Mac"; + }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 43B5D4001D36686B00D1E1FD /* Copy Files */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + name = "Copy Files"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 2217EBB61CCD89E60082837B /* NuMarkupOperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NuMarkupOperator.h; sourceTree = ""; }; @@ -308,9 +335,6 @@ 2217EC621CCDB2610082837B /* NSMethodSignature+Nu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMethodSignature+Nu.m"; sourceTree = ""; }; 2217EC661CCDBF390082837B /* NuBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NuBridge.h; sourceTree = ""; }; 2217EC671CCDBF390082837B /* NuBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NuBridge.m; sourceTree = ""; }; - 225F62BE13B04256002DD16B /* ffi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi.h; sourceTree = ""; }; - 225F62C413B04256002DD16B /* ffi.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = ffi.S; sourceTree = ""; }; - 225F62CA13B04256002DD16B /* ffi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi.c; sourceTree = ""; }; 22716B111CCDC9FD00E7ACDD /* NuBridgedFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NuBridgedFunction.h; sourceTree = ""; }; 22716B121CCDC9FD00E7ACDD /* NuBridgedFunction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NuBridgedFunction.m; sourceTree = ""; }; 22716B161CCDCB6F00E7ACDD /* NuBridgedConstant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NuBridgedConstant.h; sourceTree = ""; }; @@ -396,6 +420,9 @@ 22EE2C0813A4731600895861 /* NuAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NuAppDelegate.h; sourceTree = ""; }; 22EE2C0913A4731600895861 /* NuAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NuAppDelegate.m; sourceTree = ""; }; 32DBCF5E0370ADEE00C91783 /* Nu_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Nu_Prefix.pch; sourceTree = ""; }; + 433CE5641D38EA4100EE7273 /* libffi.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libffi.xcodeproj; path = ../libffi/libffi.xcodeproj; sourceTree = ""; }; + 43B5D4021D36686B00D1E1FD /* libNuTouch.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libNuTouch.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 43DCFCB21D369D8200CB6E63 /* libffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libffi.a; path = "../libffi/build/Debug-iphoneos/libffi.a"; sourceTree = ""; }; 4F43427B1420476C00AC1BFD /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ../main/main.m; sourceTree = ""; }; 56E07743170B028400FF0A4B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -415,11 +442,20 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 43B5D4101D3668A600D1E1FD /* libNuTouch.a in Frameworks */, 22B3B50513B0388C00B3AB31 /* Foundation.framework in Frameworks */, 22B3B50313B0386600B3AB31 /* UIKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; + 43B5D3FF1D36686B00D1E1FD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 43DCFCB31D369D8200CB6E63 /* libffi.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8DC2EF560486A6940098B216 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -437,6 +473,7 @@ 8DC2EF5B0486A6940098B216 /* Nu.framework */, 2283073111DDBE3100A5C690 /* nush */, 22EE2BF413A4731600895861 /* NuApp.app */, + 43B5D4021D36686B00D1E1FD /* libNuTouch.a */, ); name = Products; sourceTree = ""; @@ -444,11 +481,11 @@ 0867D691FE84028FC02AAC07 /* Nu */ = { isa = PBXGroup; children = ( + 433CE5641D38EA4100EE7273 /* libffi.xcodeproj */, 56E07743170B028400FF0A4B /* Default-568h@2x.png */, 22B3B41C13B0359300B3AB31 /* objc */, 22B3B3E413B033EE00B3AB31 /* nu */, 22B3B38713B033D400B3AB31 /* test */, - 225F62B913B04256002DD16B /* libffi */, 22B3B50B13B03CF400B3AB31 /* Targets */, 034768DFFF38A50411DB9C8B /* Products */, ); @@ -492,17 +529,6 @@ path = ..; sourceTree = ""; }; - 225F62B913B04256002DD16B /* libffi */ = { - isa = PBXGroup; - children = ( - 225F62BE13B04256002DD16B /* ffi.h */, - 225F62C413B04256002DD16B /* ffi.S */, - 225F62CA13B04256002DD16B /* ffi.c */, - ); - name = libffi; - path = ../libffi; - sourceTree = ""; - }; 22B3B38713B033D400B3AB31 /* test */ = { isa = PBXGroup; children = ( @@ -684,6 +710,7 @@ 22B3B50B13B03CF400B3AB31 /* Targets */ = { isa = PBXGroup; children = ( + 43DCFCB41D369D9400CB6E63 /* NuTouch */, 0867D69AFE84028FC02AAC07 /* Nu.framework */, 22B3B50913B03B6600B3AB31 /* nush */, 22EE2BFF13A4731600895861 /* NuApp */, @@ -713,6 +740,23 @@ name = "Supporting Files"; sourceTree = ""; }; + 433CE5651D38EA4100EE7273 /* Products */ = { + isa = PBXGroup; + children = ( + 433CE56A1D38EA4100EE7273 /* libffi.a */, + 433CE56C1D38EA4100EE7273 /* ffi.dylib */, + ); + name = Products; + sourceTree = ""; + }; + 43DCFCB41D369D9400CB6E63 /* NuTouch */ = { + isa = PBXGroup; + children = ( + 43DCFCB21D369D8200CB6E63 /* libffi.a */, + ); + name = NuTouch; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -800,6 +844,23 @@ productReference = 22EE2BF413A4731600895861 /* NuApp.app */; productType = "com.apple.product-type.application"; }; + 43B5D4011D36686B00D1E1FD /* NuTouch */ = { + isa = PBXNativeTarget; + buildConfigurationList = 43B5D4081D36686B00D1E1FD /* Build configuration list for PBXNativeTarget "NuTouch" */; + buildPhases = ( + 43DCFCB51D37934200CB6E63 /* Sources */, + 43B5D3FF1D36686B00D1E1FD /* Frameworks */, + 43B5D4001D36686B00D1E1FD /* Copy Files */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = NuTouch; + productName = NuTouch; + productReference = 43B5D4021D36686B00D1E1FD /* libNuTouch.a */; + productType = "com.apple.product-type.library.static"; + }; 8DC2EF4F0486A6940098B216 /* Nu */ = { isa = PBXNativeTarget; buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "Nu" */; @@ -825,7 +886,12 @@ 0867D690FE84028FC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0450; + LastUpgradeCheck = 0720; + TargetAttributes = { + 43B5D4011D36686B00D1E1FD = { + CreatedOnToolsVersion = 7.2.1; + }; + }; }; buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "Nu" */; compatibilityVersion = "Xcode 3.2"; @@ -841,15 +907,39 @@ mainGroup = 0867D691FE84028FC02AAC07 /* Nu */; productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 433CE5651D38EA4100EE7273 /* Products */; + ProjectRef = 433CE5641D38EA4100EE7273 /* libffi.xcodeproj */; + }, + ); projectRoot = ""; targets = ( 8DC2EF4F0486A6940098B216 /* Nu */, 2283073011DDBE3100A5C690 /* nush */, 22EE2BF313A4731600895861 /* NuApp */, + 43B5D4011D36686B00D1E1FD /* NuTouch */, ); }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + 433CE56A1D38EA4100EE7273 /* libffi.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libffi.a; + remoteRef = 433CE5691D38EA4100EE7273 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 433CE56C1D38EA4100EE7273 /* ffi.dylib */ = { + isa = PBXReferenceProxy; + fileType = "compiled.mach-o.dylib"; + path = ffi.dylib; + remoteRef = 433CE56B1D38EA4100EE7273 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXResourcesBuildPhase section */ 22EE2BF213A4731600895861 /* Resources */ = { isa = PBXResourcesBuildPhase; @@ -963,51 +1053,56 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2217EBFC1CCDA27A0082837B /* NSObject+Nu.m in Sources */, - 2217EBBA1CCD8AAC0082837B /* NuMarkupOperator.m in Sources */, - 2217EBDE1CCD915B0082837B /* NuRegex.m in Sources */, - 2217EC331CCDAC600082837B /* NSBundle+Nu.m in Sources */, - 2217EC561CCDB0D40082837B /* NSData+Nu.m in Sources */, - 22716B1A1CCDCB6F00E7ACDD /* NuBridgedConstant.m in Sources */, 22EE2C0613A4731600895861 /* main.m in Sources */, - 2217EC061CCDA3870082837B /* NuMethod.m in Sources */, - 2217EBCA1CCD8DF00082837B /* NuSwizzles.m in Sources */, 22EE2C0A13A4731600895861 /* NuAppDelegate.m in Sources */, - 2217EC1F1CCDA8340082837B /* NuClass.m in Sources */, - 22B3B47413B0359300B3AB31 /* Nu.m in Sources */, - 2217EC651CCDB2610082837B /* NSMethodSignature+Nu.m in Sources */, - 2217EBE81CCD92AC0082837B /* NuProperty.m in Sources */, - 2217EBC51CCD8CE30082837B /* NuTestHelper.m in Sources */, - 2217EC6A1CCDBF390082837B /* NuBridge.m in Sources */, - 2217EC151CCDA65F0082837B /* NuBlock.m in Sources */, - 2217EC601CCDB19C0082837B /* NSFileManager+Nu.m in Sources */, - 2217EC2E1CCDAB700082837B /* NSDictionary+Nu.m in Sources */, - 2217EC5B1CCDB1240082837B /* NSDate+Nu.m in Sources */, - 2217EC381CCDAD3B0082837B /* NuEnumerable.m in Sources */, - 2217EBCF1CCD8E760082837B /* NuSuper.m in Sources */, - 22716B1F1CCDCC0F00E7ACDD /* NuBridgedBlock.m in Sources */, - 2217EBF21CCD9E7F0082837B /* NuPointer.m in Sources */, - 2217EC241CCDA9A00082837B /* NuMath.m in Sources */, - 2217EC011CCDA3300082837B /* NuObjCRuntime.m in Sources */, - 2217EBD41CCD8F960082837B /* NuStack.m in Sources */, - 225F62CD13B04256002DD16B /* ffi.S in Sources */, - 2217EBE31CCD921B0082837B /* NuReference.m in Sources */, - 2217EC4C1CCDAFE00082837B /* NSNull+Nu.m in Sources */, - 22716B241CCDCCD900E7ACDD /* NuBridgeSupport.m in Sources */, - 2217EBD91CCD90310082837B /* NuParser.m in Sources */, - 2217EC511CCDB0770082837B /* NSNumber+Nu.m in Sources */, - 2217EC0B1CCDA4990082837B /* NuMacro.m in Sources */, - 2217EBF71CCDA0420082837B /* NuOperators.m in Sources */, - 2217EC291CCDAA850082837B /* NSString+Nu.m in Sources */, - 2217EC3D1CCDAE010082837B /* NuException.m in Sources */, - 2217EBED1CCD9DFE0082837B /* NuProfiler.m in Sources */, - 2217EBC01CCD8BDF0082837B /* NuSymbol.m in Sources */, - 22716B151CCDC9FD00E7ACDD /* NuBridgedFunction.m in Sources */, - 225F62D313B04256002DD16B /* ffi.c in Sources */, - 2217EC471CCDAF2A0082837B /* NSSet+Nu.m in Sources */, - 2217EC421CCDAED00082837B /* NSArray+Nu.m in Sources */, - 2217EC1A1CCDA7350082837B /* NuCell.m in Sources */, - 2217EC101CCDA5390082837B /* NuHandler.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 43DCFCB51D37934200CB6E63 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 43DCFCB91D37938100CB6E63 /* NSArray+Nu.m in Sources */, + 43DCFCBB1D37938100CB6E63 /* NSBundle+Nu.m in Sources */, + 43DCFCBD1D37938100CB6E63 /* NSData+Nu.m in Sources */, + 43DCFCBF1D37938100CB6E63 /* NSDate+Nu.m in Sources */, + 43DCFCC11D37938100CB6E63 /* NSDictionary+Nu.m in Sources */, + 43DCFCC31D37938100CB6E63 /* NSFileManager+Nu.m in Sources */, + 43DCFCC51D37938100CB6E63 /* NSMethodSignature+Nu.m in Sources */, + 43DCFCC71D37938200CB6E63 /* NSNull+Nu.m in Sources */, + 43DCFCC91D37938200CB6E63 /* NSNumber+Nu.m in Sources */, + 43DCFCCB1D37938200CB6E63 /* NSObject+Nu.m in Sources */, + 43DCFCCD1D37938200CB6E63 /* NSSet+Nu.m in Sources */, + 43DCFCCF1D37938200CB6E63 /* NSString+Nu.m in Sources */, + 43DCFCD11D37938200CB6E63 /* Nu.m in Sources */, + 43DCFCD31D37938200CB6E63 /* NuBlock.m in Sources */, + 43DCFCD51D37938200CB6E63 /* NuBridge.m in Sources */, + 43DCFCD71D37938200CB6E63 /* NuCell.m in Sources */, + 43DCFCD91D37938200CB6E63 /* NuClass.m in Sources */, + 43DCFCDB1D37938200CB6E63 /* NuEnumerable.m in Sources */, + 43DCFCDD1D37938200CB6E63 /* NuException.m in Sources */, + 43DCFCDF1D37938200CB6E63 /* NuHandler.m in Sources */, + 43DCFCE21D37938200CB6E63 /* NuMacro.m in Sources */, + 43DCFCE41D37938200CB6E63 /* NuMarkupOperator.m in Sources */, + 43DCFCE61D37938200CB6E63 /* NuMath.m in Sources */, + 43DCFCE81D37938200CB6E63 /* NuMethod.m in Sources */, + 43DCFCEA1D37938200CB6E63 /* NuObjCRuntime.m in Sources */, + 43DCFCEC1D37938200CB6E63 /* NuOperators.m in Sources */, + 43DCFCEE1D37938200CB6E63 /* NuParser.m in Sources */, + 43DCFCF01D37938200CB6E63 /* NuPointer.m in Sources */, + 43DCFCF21D37938200CB6E63 /* NuProfiler.m in Sources */, + 43DCFCF41D37938200CB6E63 /* NuProperty.m in Sources */, + 43DCFCF61D37938200CB6E63 /* NuReference.m in Sources */, + 43DCFCF81D37938200CB6E63 /* NuRegex.m in Sources */, + 43DCFCFA1D37938200CB6E63 /* NuStack.m in Sources */, + 43DCFCFC1D37938200CB6E63 /* NuSuper.m in Sources */, + 43DCFCFE1D37938200CB6E63 /* NuSwizzles.m in Sources */, + 43DCFD001D37938200CB6E63 /* NuSymbol.m in Sources */, + 43DCFD021D37938200CB6E63 /* NuTestHelper.m in Sources */, + 43DCFD041D37938200CB6E63 /* NuBridgedFunction.m in Sources */, + 43DCFD061D37938200CB6E63 /* NuBridgedConstant.m in Sources */, + 43DCFD081D37938200CB6E63 /* NuBridgedBlock.m in Sources */, + 43DCFD0A1D37938200CB6E63 /* NuBridgeSupport.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1112,6 +1207,7 @@ INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Frameworks"; LIBRARY_SEARCH_PATHS = ""; + PRODUCT_BUNDLE_IDENTIFIER = nu.programming.framework; PRODUCT_NAME = Nu; WRAPPER_EXTENSION = framework; }; @@ -1138,6 +1234,7 @@ INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Frameworks"; LIBRARY_SEARCH_PATHS = ""; + PRODUCT_BUNDLE_IDENTIFIER = nu.programming.framework; PRODUCT_NAME = Nu; WRAPPER_EXTENSION = framework; }; @@ -1146,7 +1243,7 @@ 1DEB91B208733DA50010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = unsupported; GCC_OPTIMIZATION_LEVEL = 0; @@ -1171,7 +1268,6 @@ 1DEB91B308733DA50010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = unsupported; GCC_PRECOMPILE_PREFIX_HEADER = NO; @@ -1241,7 +1337,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = NO; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; @@ -1263,11 +1358,14 @@ HEADER_SEARCH_PATHS = ( /usr/local/include, "$(SRCROOT)/../objc", + ../libffi/darwin_common/include, + ../libffi/darwin_ios/include, ); INFOPLIST_FILE = "NuApp/NuApp-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = ""; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.radtastical.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1279,7 +1377,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = NO; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; @@ -1299,12 +1396,15 @@ HEADER_SEARCH_PATHS = ( /usr/local/include, "$(SRCROOT)/../objc", + ../libffi/darwin_common/include, + ../libffi/darwin_ios/include, ); INFOPLIST_FILE = "NuApp/NuApp-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; - OTHER_LDFLAGS = ""; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.radtastical.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1313,6 +1413,88 @@ }; name = Release; }; + 43B5D4091D36686B00D1E1FD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = NO; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + HEADER_SEARCH_PATHS = ( + ../libffi/darwin_common/include, + ../libffi/darwin_ios/include, + ); + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 43B5D40A1D36686B00D1E1FD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = NO; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + HEADER_SEARCH_PATHS = ( + ../libffi/darwin_common/include, + ../libffi/darwin_ios/include, + ); + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -1352,6 +1534,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 43B5D4081D36686B00D1E1FD /* Build configuration list for PBXNativeTarget "NuTouch" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 43B5D4091D36686B00D1E1FD /* Debug */, + 43B5D40A1D36686B00D1E1FD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 0867D690FE84028FC02AAC07 /* Project object */; diff --git a/Xcode/NuApp/NuApp-Info.plist b/Xcode/NuApp/NuApp-Info.plist index 1c822bd..da76972 100644 --- a/Xcode/NuApp/NuApp-Info.plist +++ b/Xcode/NuApp/NuApp-Info.plist @@ -11,7 +11,7 @@ CFBundleIconFile CFBundleIdentifier - com.radtastical.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -26,6 +26,8 @@ 1.0 LSRequiresIPhoneOS + UIRequiresFullScreen + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/Xcode/NuApp/NuAppDelegate.m b/Xcode/NuApp/NuAppDelegate.m index 3d737b7..a14f3ca 100644 --- a/Xcode/NuApp/NuAppDelegate.m +++ b/Xcode/NuApp/NuAppDelegate.m @@ -9,17 +9,29 @@ #import "NuAppDelegate.h" #import "Nu.h" +#import "NuBlock.h" +#import "NuBridgedBlock.h" + +#import + +@class ViewController; @implementation NuAppDelegate @synthesize window; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; - self.window.backgroundColor = [UIColor greenColor]; - self.window.rootViewController = [[UIViewController alloc] init]; + CGRect frame = [[UIScreen mainScreen] bounds]; + self.window = [[[UIWindow alloc] initWithFrame:frame] autorelease]; [self.window makeKeyAndVisible]; - + UIViewController *viewController = [[UIViewController alloc] init]; + self.window.rootViewController = viewController; + UIView *view = [[UIView alloc] initWithFrame:frame]; + viewController.view = view; + UILabel *label = [[UILabel alloc] initWithFrame:frame]; + label.textAlignment = NSTextAlignmentCenter; + [view addSubview:label]; + NuInit(); [[Nu sharedParser] parseEval:@"(load \"nu\")"]; @@ -45,7 +57,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( } [regex release]; NSLog(@"running tests"); - [[Nu sharedParser] parseEval:@"(NuTestCase runAllTests)"]; + int failures = [[[Nu sharedParser] parseEval:@"(NuTestCase runAllTests)"] intValue]; + + NSString* script = @"(do () (puts \"cBlock Work!\"))"; + id parsed = [[Nu sharedParser] parse:script]; + NuBlock* block = [[Nu sharedParser] eval:parsed]; + void (^cblock)() = [NuBridgedBlock cBlockWithNuBlock:block signature:@"v"]; + cblock(); + + if (failures == 0) { + view.backgroundColor = [UIColor greenColor]; + label.text = @"Everything Nu!"; + } else { + view.backgroundColor = [UIColor redColor]; + label.text = [NSString stringWithFormat:@"%d failures!",failures]; + } NSLog(@"ok"); return YES; } diff --git a/libffi b/libffi new file mode 160000 index 0000000..7d504f7 --- /dev/null +++ b/libffi @@ -0,0 +1 @@ +Subproject commit 7d504f7a8e33f6da27941f5dc5d889fe60b8b9c8 diff --git a/libffi/LICENSE b/libffi/LICENSE deleted file mode 100644 index 064f4fa..0000000 --- a/libffi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -libffi - Copyright (c) 1996-2008 Red Hat, Inc and others. -See source files for details. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -``Software''), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/libffi/README.markdown b/libffi/README.markdown deleted file mode 100644 index cd44964..0000000 --- a/libffi/README.markdown +++ /dev/null @@ -1,28 +0,0 @@ -libffi for the iPhone -= - -**[libffi](http://sourceware.org/libffi/)** allows calling any C-function or ObjC method at runtime. - -**libffi-iphone** is a stripped down version of libffi, tailored just for the iPhone. **libffi-iphone** includes source code for both the iPhone simulator and the iPhone itself. - -Calling functions -- -Works just like libffi. - -Creating ffi closures, new functions created and called at runtime -- -ffi closures don't work on the iPhone, as mprotect is disabled. - -You can however retarget existing functions if you have a function pool. See [Tim Burks' post about Nu's method pool](http://stackoverflow.com/questions/219653/ruby-on-iphone), see [JSCocoa's Burks Pool](http://github.com/parmanoir/jscocoa/blob/master/JSCocoa/iPhone/BurksPool.m) for another implementation. - -To retarget an ObjC pool method, use the method's hidden _cmd argument (the current selector) and [self class]. This will tell you which method of which class is being called. - -License -- -**libffi-iphone** uses **libffi**'s license. - -Hey -- -Problems, questions
-Patrick Geiller
-[parmanoir@gmail.com](mailto:parmanoir@gmail.com) diff --git a/libffi/ffi.S b/libffi/ffi.S deleted file mode 100644 index c89514d..0000000 --- a/libffi/ffi.S +++ /dev/null @@ -1,759 +0,0 @@ -#import "TargetConditionals.h" - -/* This file is mangled from the original to compile using Apple's AS, not GAS */ -#if !TARGET_IPHONE_SIMULATOR - -#define __SOFTFP__ - -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 1998, 2008 Red Hat, Inc. - - ARM Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include "ffi.h" -#ifdef HAVE_MACHINE_ASM_H -#include -#else -#ifdef __USER_LABEL_PREFIX__ -#define CONCAT1(a, b) CONCAT2(a, b) -#define CONCAT2(a, b) a ## b - -/* Use the right prefix for global labels. */ -#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x) -#else -#define CNAME(x) x -#endif -#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x): -#endif - -#ifdef __ELF__ -#define LSYM(x) .x -#else -#define LSYM(x) x -#endif - -/* We need a better way of testing for this, but for now, this is all - we can do. */ -@ This selects the minimum architecture level required. -#define __ARM_ARCH__ 3 - -#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) -# undef __ARM_ARCH__ -# define __ARM_ARCH__ 4 -#endif - -#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \ - || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \ - || defined(__ARM_ARCH_5TEJ__) -# undef __ARM_ARCH__ -# define __ARM_ARCH__ 5 -#endif - -#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ - || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \ - || defined(__ARM_ARCH_6ZK__) -# undef __ARM_ARCH__ -# define __ARM_ARCH__ 6 -#endif - -#if __ARM_ARCH__ >= 5 -# define call_reg(x) blx x -#elif defined (__ARM_ARCH_4T__) -# define call_reg(x) mov lr, pc ; bx x -# if defined(__thumb__) || defined(__THUMB_INTERWORK__) -# define __INTERWORKING__ -# endif -#else -# define call_reg(x) mov lr, pc ; mov pc, x -#endif - -/* Conditionally compile unwinder directives. */ -#ifdef __ARM_EABI__ -#define UNWIND -#else -#define UNWIND @ -#endif - -/* -#if defined(__thumb__) && !defined(__THUMB_INTERWORK__) -.macro ARM_FUNC_START name - .text - .align 0 - .thumb - .thumb_func - ENTRY(\name) - bx pc - nop - .arm - UNWIND .fnstart -_L__\name: -.endm -#else -.macro ARM_FUNC_START name - .text - .align 0 - .arm - ENTRY(\name) - UNWIND .fnstart -.endm -#endif -*/ -/* -.macro RETLDM regs=, cond=, dirn=ia -#if defined (__INTERWORKING__) - .ifc "\regs","" - ldr\cond lr, [sp], #4 - .else - ldm\cond\dirn sp!, {\regs, lr} - .endif - bx\cond lr -#else - .ifc "\regs","" - ldr\cond pc, [sp], #4 - .else - ldm\cond\dirn sp!, {\regs, pc} - .endif -#endif -.endm -*/ - - @ r0: ffi_prep_args - @ r1: &ecif - @ r2: cif->bytes - @ r3: fig->flags - @ sp+0: ecif.rvalue - @ sp+4: fn - - .text - .align 4 - .globl _ffi_call_SYSV -_ffi_call_SYSV: - UNWIND .fnstart - @ Save registers - stmfd sp!, {r0-r3, fp, lr} - UNWIND .save {r0-r3, fp, lr} - mov fp, sp - - UNWIND .setfp fp, sp - - @ Make room for all of the new args. - sub sp, fp, r2 - - @ Place all of the ffi_prep_args in position - mov ip, r0 - mov r0, sp - @ r1 already set - - @ Call ffi_prep_args(stack, &ecif) - call_reg(ip) - - @ move first 4 parameters in registers - ldmia sp, {r0-r3} - - @ and adjust stack - ldr ip, [fp, #8] - cmp ip, #16 - movhs ip, #16 - add sp, sp, ip - - @ call (fn) (...) - ldr ip, [fp, #28] - call_reg(ip) - - @ Remove the space we pushed for the args - mov sp, fp - - @ Load r2 with the pointer to storage for the return value - ldr r2, [sp, #24] - - @ Load r3 with the return type code - ldr r3, [sp, #12] - - @ If the return value pointer is NULL, assume no return value. - cmp r2, #0 - beq LSYM(Lepilogue) - -@ return INT - cmp r3, #FFI_TYPE_INT -#ifdef __SOFTFP__ - cmpne r3, #FFI_TYPE_FLOAT -#endif - streq r0, [r2] - beq LSYM(Lepilogue) - - @ return INT64 - cmp r3, #FFI_TYPE_SINT64 -#ifdef __SOFTFP__ - cmpne r3, #FFI_TYPE_DOUBLE -#endif - stmiaeq r2, {r0, r1} - -#ifndef __SOFTFP__ - beq LSYM(Lepilogue) - -@ return FLOAT - cmp r3, #FFI_TYPE_FLOAT - stfeqs f0, [r2] - beq LSYM(Lepilogue) - -@ return DOUBLE or LONGDOUBLE - cmp r3, #FFI_TYPE_DOUBLE - stfeqd f0, [r2] -#endif - -LSYM(Lepilogue): - ldmia sp!, {r0-r3,fp, pc} - - -.ffi_call_SYSV_end: - UNWIND .fnend -// .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) - -/* - unsigned int FFI_HIDDEN - ffi_closure_SYSV_inner (closure, respp, args) - ffi_closure *closure; - void **respp; - void *args; -*/ - - .text - .align 0 - .globl _ffi_closure_SYSV -_ffi_closure_SYSV: - - UNWIND .pad #16 - add ip, sp, #16 - stmfd sp!, {ip, lr} - UNWIND .save {r0, lr} - add r2, sp, #8 -// .pad #16 - sub sp, sp, #16 - str sp, [sp, #8] - add r1, sp, #8 - bl _ffi_closure_SYSV_inner - - cmp r0, #FFI_TYPE_INT - beq .Lretint - - cmp r0, #FFI_TYPE_FLOAT -#ifdef __SOFTFP__ - beq .Lretint -#else - beq .Lretfloat -#endif - - cmp r0, #FFI_TYPE_DOUBLE -#ifdef __SOFTFP__ - beq .Lretlonglong -#else - beq .Lretdouble -#endif - - cmp r0, #FFI_TYPE_LONGDOUBLE -#ifdef __SOFTFP__ - beq .Lretlonglong -#else - beq .Lretlongdouble -#endif - - cmp r0, #FFI_TYPE_SINT64 - beq .Lretlonglong -.Lclosure_epilogue: - add sp, sp, #16 - ldmfd sp, {sp, pc} -.Lretint: - ldr r0, [sp] - b .Lclosure_epilogue -.Lretlonglong: - ldr r0, [sp] - ldr r1, [sp, #4] - b .Lclosure_epilogue - -#ifndef __SOFTFP__ -.Lretfloat: - ldfs f0, [sp] - b .Lclosure_epilogue -.Lretdouble: - ldfd f0, [sp] - b .Lclosure_epilogue -.Lretlongdouble: - ldfd f0, [sp] - b .Lclosure_epilogue -#endif - -.ffi_closure_SYSV_end: - UNWIND .fnend -// .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) - -#if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",%progbits -#endif - - - -#endif - - -#if TARGET_IPHONE_SIMULATOR - -/* ----------------------------------------------------------------------- - darwin.S - Copyright (c) 1996, 1998, 2001, 2002, 2003, 2005 Red Hat, Inc. - Copyright (C) 2008 Free Software Foundation, Inc. - - X86 Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#ifndef __x86_64__ - -#define LIBFFI_ASM -#include "ffi.h" - -.text - -.globl _ffi_prep_args - - .align 4 -.globl _ffi_call_SYSV - -_ffi_call_SYSV: -.LFB1: - pushl %ebp -.LCFI0: - movl %esp,%ebp -.LCFI1: - subl $8,%esp - /* Make room for all of the new args. */ - movl 16(%ebp),%ecx - subl %ecx,%esp - - movl %esp,%eax - - /* Place all of the ffi_prep_args in position */ - subl $8,%esp - pushl 12(%ebp) - pushl %eax - call *8(%ebp) - - /* Return stack to previous state and call the function */ - addl $16,%esp - - call *28(%ebp) - - /* Load %ecx with the return type code */ - movl 20(%ebp),%ecx - - /* Protect %esi. We're going to pop it in the epilogue. */ - pushl %esi - - /* If the return value pointer is NULL, assume no return value. */ - cmpl $0,24(%ebp) - jne 0f - - /* Even if there is no space for the return value, we are - obliged to handle floating-point values. */ - cmpl $FFI_TYPE_FLOAT,%ecx - jne noretval - fstp %st(0) - - jmp epilogue -0: - .align 4 - call 1f -.Lstore_table: - .long noretval-.Lstore_table /* FFI_TYPE_VOID */ - .long retint-.Lstore_table /* FFI_TYPE_INT */ - .long retfloat-.Lstore_table /* FFI_TYPE_FLOAT */ - .long retdouble-.Lstore_table /* FFI_TYPE_DOUBLE */ - .long retlongdouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */ - .long retuint8-.Lstore_table /* FFI_TYPE_UINT8 */ - .long retsint8-.Lstore_table /* FFI_TYPE_SINT8 */ - .long retuint16-.Lstore_table /* FFI_TYPE_UINT16 */ - .long retsint16-.Lstore_table /* FFI_TYPE_SINT16 */ - .long retint-.Lstore_table /* FFI_TYPE_UINT32 */ - .long retint-.Lstore_table /* FFI_TYPE_SINT32 */ - .long retint64-.Lstore_table /* FFI_TYPE_UINT64 */ - .long retint64-.Lstore_table /* FFI_TYPE_SINT64 */ - .long retstruct-.Lstore_table /* FFI_TYPE_STRUCT */ - .long retint-.Lstore_table /* FFI_TYPE_POINTER */ - .long retstruct1b-.Lstore_table /* FFI_TYPE_SMALL_STRUCT_1B */ - .long retstruct2b-.Lstore_table /* FFI_TYPE_SMALL_STRUCT_2B */ -1: - pop %esi - add (%esi, %ecx, 4), %esi - jmp *%esi - - /* Sign/zero extend as appropriate. */ -retsint8: - movsbl %al, %eax - jmp retint - -retsint16: - movswl %ax, %eax - jmp retint - -retuint8: - movzbl %al, %eax - jmp retint - -retuint16: - movzwl %ax, %eax - jmp retint - -retfloat: - /* Load %ecx with the pointer to storage for the return value */ - movl 24(%ebp),%ecx - fstps (%ecx) - jmp epilogue - -retdouble: - /* Load %ecx with the pointer to storage for the return value */ - movl 24(%ebp),%ecx - fstpl (%ecx) - jmp epilogue - -retlongdouble: - /* Load %ecx with the pointer to storage for the return value */ - movl 24(%ebp),%ecx - fstpt (%ecx) - jmp epilogue - -retint64: - /* Load %ecx with the pointer to storage for the return value */ - movl 24(%ebp),%ecx - movl %eax,0(%ecx) - movl %edx,4(%ecx) - jmp epilogue - -retstruct1b: - /* Load %ecx with the pointer to storage for the return value */ - movl 24(%ebp),%ecx - movb %al,0(%ecx) - jmp epilogue - -retstruct2b: - /* Load %ecx with the pointer to storage for the return value */ - movl 24(%ebp),%ecx - movw %ax,0(%ecx) - jmp epilogue - -retint: - /* Load %ecx with the pointer to storage for the return value */ - movl 24(%ebp),%ecx - movl %eax,0(%ecx) - -retstruct: - /* Nothing to do! */ - -noretval: -epilogue: - popl %esi - movl %ebp,%esp - popl %ebp - ret - -.LFE1: -.ffi_call_SYSV_end: - - .align 4 -FFI_HIDDEN (ffi_closure_SYSV) -.globl _ffi_closure_SYSV - -_ffi_closure_SYSV: -.LFB2: - pushl %ebp -.LCFI2: - movl %esp, %ebp -.LCFI3: - subl $40, %esp - leal -24(%ebp), %edx - movl %edx, -12(%ebp) /* resp */ - leal 8(%ebp), %edx - movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */ - leal -12(%ebp), %edx - movl %edx, (%esp) /* &resp */ - movl %ebx, 8(%esp) -.LCFI7: - call L_ffi_closure_SYSV_inner$stub - movl 8(%esp), %ebx - movl -12(%ebp), %ecx - cmpl $FFI_TYPE_INT, %eax - je .Lcls_retint - - /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16, - FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */ - cmpl $FFI_TYPE_UINT64, %eax - jge 0f - cmpl $FFI_TYPE_UINT8, %eax - jge .Lcls_retint - -0: cmpl $FFI_TYPE_FLOAT, %eax - je .Lcls_retfloat - cmpl $FFI_TYPE_DOUBLE, %eax - je .Lcls_retdouble - cmpl $FFI_TYPE_LONGDOUBLE, %eax - je .Lcls_retldouble - cmpl $FFI_TYPE_SINT64, %eax - je .Lcls_retllong - cmpl $FFI_TYPE_SMALL_STRUCT_1B, %eax - je .Lcls_retstruct1b - cmpl $FFI_TYPE_SMALL_STRUCT_2B, %eax - je .Lcls_retstruct2b - cmpl $FFI_TYPE_STRUCT, %eax - je .Lcls_retstruct -.Lcls_epilogue: - movl %ebp, %esp - popl %ebp - ret -.Lcls_retint: - movl (%ecx), %eax - jmp .Lcls_epilogue -.Lcls_retfloat: - flds (%ecx) - jmp .Lcls_epilogue -.Lcls_retdouble: - fldl (%ecx) - jmp .Lcls_epilogue -.Lcls_retldouble: - fldt (%ecx) - jmp .Lcls_epilogue -.Lcls_retllong: - movl (%ecx), %eax - movl 4(%ecx), %edx - jmp .Lcls_epilogue -.Lcls_retstruct1b: - movsbl (%ecx), %eax - jmp .Lcls_epilogue -.Lcls_retstruct2b: - movswl (%ecx), %eax - jmp .Lcls_epilogue -.Lcls_retstruct: - lea -8(%ebp),%esp - movl %ebp, %esp - popl %ebp - ret $4 -.LFE2: - - -#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3) -#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4) -#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4) -#define CIF_FLAGS_OFFSET 20 - - .align 4 -FFI_HIDDEN (ffi_closure_raw_SYSV) -.globl _ffi_closure_raw_SYSV - -_ffi_closure_raw_SYSV: -.LFB3: - pushl %ebp -.LCFI4: - movl %esp, %ebp -.LCFI5: - pushl %esi -.LCFI6: - subl $36, %esp - movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */ - movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */ - movl %edx, 12(%esp) /* user_data */ - leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */ - movl %edx, 8(%esp) /* raw_args */ - leal -24(%ebp), %edx - movl %edx, 4(%esp) /* &res */ - movl %esi, (%esp) /* cif */ - call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */ - movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */ - cmpl $FFI_TYPE_INT, %eax - je .Lrcls_retint - - /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16, - FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */ - cmpl $FFI_TYPE_UINT64, %eax - jge 0f - cmpl $FFI_TYPE_UINT8, %eax - jge .Lrcls_retint -0: - cmpl $FFI_TYPE_FLOAT, %eax - je .Lrcls_retfloat - cmpl $FFI_TYPE_DOUBLE, %eax - je .Lrcls_retdouble - cmpl $FFI_TYPE_LONGDOUBLE, %eax - je .Lrcls_retldouble - cmpl $FFI_TYPE_SINT64, %eax - je .Lrcls_retllong -.Lrcls_epilogue: - addl $36, %esp - popl %esi - popl %ebp - ret -.Lrcls_retint: - movl -24(%ebp), %eax - jmp .Lrcls_epilogue -.Lrcls_retfloat: - flds -24(%ebp) - jmp .Lrcls_epilogue -.Lrcls_retdouble: - fldl -24(%ebp) - jmp .Lrcls_epilogue -.Lrcls_retldouble: - fldt -24(%ebp) - jmp .Lrcls_epilogue -.Lrcls_retllong: - movl -24(%ebp), %eax - movl -20(%ebp), %edx - jmp .Lrcls_epilogue -.LFE3: - -.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5 -L_ffi_closure_SYSV_inner$stub: - .indirect_symbol _ffi_closure_SYSV_inner - hlt ; hlt ; hlt ; hlt ; hlt - - -.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support -EH_frame1: - .set L$set$0,LECIE1-LSCIE1 - .long L$set$0 -LSCIE1: - .long 0x0 - .byte 0x1 - .ascii "zR\0" - .byte 0x1 - .byte 0x7c - .byte 0x8 - .byte 0x1 - .byte 0x10 - .byte 0xc - .byte 0x5 - .byte 0x4 - .byte 0x88 - .byte 0x1 - .align 2 -LECIE1: -.globl _ffi_call_SYSV.eh -_ffi_call_SYSV.eh: -LSFDE1: - .set L$set$1,LEFDE1-LASFDE1 - .long L$set$1 -LASFDE1: - .long LASFDE1-EH_frame1 - .long .LFB1-. - .set L$set$2,.LFE1-.LFB1 - .long L$set$2 - .byte 0x0 - .byte 0x4 - .set L$set$3,.LCFI0-.LFB1 - .long L$set$3 - .byte 0xe - .byte 0x8 - .byte 0x84 - .byte 0x2 - .byte 0x4 - .set L$set$4,.LCFI1-.LCFI0 - .long L$set$4 - .byte 0xd - .byte 0x4 - .align 2 -LEFDE1: -.globl _ffi_closure_SYSV.eh -_ffi_closure_SYSV.eh: -LSFDE2: - .set L$set$5,LEFDE2-LASFDE2 - .long L$set$5 -LASFDE2: - .long LASFDE2-EH_frame1 - .long .LFB2-. - .set L$set$6,.LFE2-.LFB2 - .long L$set$6 - .byte 0x0 - .byte 0x4 - .set L$set$7,.LCFI2-.LFB2 - .long L$set$7 - .byte 0xe - .byte 0x8 - .byte 0x84 - .byte 0x2 - .byte 0x4 - .set L$set$8,.LCFI3-.LCFI2 - .long L$set$8 - .byte 0xd - .byte 0x4 - .align 2 -LEFDE2: - -.globl _ffi_closure_raw_SYSV.eh -_ffi_closure_raw_SYSV.eh: -LSFDE3: - .set L$set$10,LEFDE3-LASFDE3 - .long L$set$10 -LASFDE3: - .long LASFDE3-EH_frame1 - .long .LFB3-. - .set L$set$11,.LFE3-.LFB3 - .long L$set$11 - .byte 0x0 - .byte 0x4 - .set L$set$12,.LCFI4-.LFB3 - .long L$set$12 - .byte 0xe - .byte 0x8 - .byte 0x84 - .byte 0x2 - .byte 0x4 - .set L$set$13,.LCFI5-.LCFI4 - .long L$set$13 - .byte 0xd - .byte 0x4 - .byte 0x4 - .set L$set$14,.LCFI6-.LCFI5 - .long L$set$14 - .byte 0x85 - .byte 0x3 - .align 2 -LEFDE3: - -#endif /* ifndef __x86_64__ */ - -#endif \ No newline at end of file diff --git a/libffi/ffi.c b/libffi/ffi.c deleted file mode 100644 index bb22942..0000000 --- a/libffi/ffi.c +++ /dev/null @@ -1,1257 +0,0 @@ -/* ----------------------------------------------------------------------- - types.c - Copyright (c) 1996, 1998 Red Hat, Inc. - - Predefined ffi_types needed by libffi. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -/* Hide the basic type definitions from the header file, so that we - can redefine them here as "const". */ -#define LIBFFI_HIDE_BASIC_TYPES - -#include "ffi.h" -#include -#include - -/* ----------------------------------------------------------------------- - ffi_common.h - Copyright (c) 1996 Red Hat, Inc. - Copyright (C) 2007 Free Software Foundation, Inc - - Common internal definitions and macros. Only necessary for building - libffi. - ----------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#endif - -void bcopy(const void *s1, void *s2, size_t n); -#define memcpy(d, s, n) bcopy ((s), (d), (n)) - -#if defined(FFI_DEBUG) -#include -#endif - -#ifdef FFI_DEBUG - void ffi_assert(char *expr, char *file, int line); - void ffi_stop_here(void); - void ffi_type_test(ffi_type *a, char *file, int line); - -#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__)) -#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l))) -#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__) -#else -#define FFI_ASSERT(x) -#define FFI_ASSERT_AT(x, f, l) -#define FFI_ASSERT_VALID_TYPE(x) -#endif - -#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1) -#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a) - - /* Perform machine dependent cif processing */ - ffi_status ffi_prep_cif_machdep(ffi_cif *cif); - - /* Extended cif, used in callback from assembly routine */ - typedef struct - { - ffi_cif *cif; - void *rvalue; - void **avalue; - } extended_cif; - - /* Terse sized type definitions. */ - typedef unsigned int UINT8 __attribute__((__mode__(__QI__))); - typedef signed int SINT8 __attribute__((__mode__(__QI__))); - typedef unsigned int UINT16 __attribute__((__mode__(__HI__))); - typedef signed int SINT16 __attribute__((__mode__(__HI__))); - typedef unsigned int UINT32 __attribute__((__mode__(__SI__))); - typedef signed int SINT32 __attribute__((__mode__(__SI__))); - typedef unsigned int UINT64 __attribute__((__mode__(__DI__))); - typedef signed int SINT64 __attribute__((__mode__(__DI__))); - - typedef float FLOAT32; - - void ffi_prep_args(char *stack, extended_cif *ecif); - -#ifdef __cplusplus -} -#endif - -/* Type definitions */ - -#define FFI_TYPEDEF(name, type, id) \ -struct struct_align_##name { \ - char c; \ - type x; \ -}; \ -const ffi_type ffi_type_##name = { \ - sizeof(type), \ - offsetof(struct struct_align_##name, x), \ - id, NULL \ -} - -/* Size and alignment are fake here. They must not be 0. */ -const ffi_type ffi_type_void = { - 1, 1, FFI_TYPE_VOID, NULL -}; - -FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8); -FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8); -FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16); -FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16); -FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32); -FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32); -FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64); -FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64); -FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER); -FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT); -FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE); - -/* ----------------------------------------------------------------------- - raw_api.c - Copyright (c) 1999, 2008 Red Hat, Inc. - - Author: Kresten Krab Thorup - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -/* This file defines generic functions for use with the raw api. */ - -#include - -size_t -ffi_raw_size (ffi_cif *cif) -{ - size_t result = 0; - int i; - - ffi_type **at = cif->arg_types; - - for (i = cif->nargs-1; i >= 0; i--, at++) - { - if ((*at)->type == FFI_TYPE_STRUCT) - result += ALIGN (sizeof (void*), FFI_SIZEOF_ARG); - else - result += ALIGN ((*at)->size, FFI_SIZEOF_ARG); - } - - return result; -} - - -void -ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args) -{ - unsigned i; - ffi_type **tp = cif->arg_types; - - /* assume little endian */ - for (i = 0; i < cif->nargs; i++, tp++, args++) - { - if ((*tp)->type == FFI_TYPE_STRUCT) - { - *args = (raw++)->ptr; - } - else - { - *args = (void*) raw; - raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*); - } - } -} - -void -ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw) -{ - unsigned i; - ffi_type **tp = cif->arg_types; - - for (i = 0; i < cif->nargs; i++, tp++, args++) - { - switch ((*tp)->type) - { - case FFI_TYPE_UINT8: - (raw++)->uint = *(UINT8*) (*args); - break; - - case FFI_TYPE_SINT8: - (raw++)->sint = *(SINT8*) (*args); - break; - - case FFI_TYPE_UINT16: - (raw++)->uint = *(UINT16*) (*args); - break; - - case FFI_TYPE_SINT16: - (raw++)->sint = *(SINT16*) (*args); - break; - -#if FFI_SIZEOF_ARG >= 4 - case FFI_TYPE_UINT32: - (raw++)->uint = *(UINT32*) (*args); - break; - - case FFI_TYPE_SINT32: - (raw++)->sint = *(SINT32*) (*args); - break; -#endif - - case FFI_TYPE_STRUCT: - (raw++)->ptr = *args; - break; - - case FFI_TYPE_POINTER: - (raw++)->ptr = **(void***) args; - break; - - default: - memcpy ((void*) raw->data, (void*)*args, (*tp)->size); - raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; - } - } -} - -#if !FFI_NATIVE_RAW_API - - -/* This is a generic definition of ffi_raw_call, to be used if the - * native system does not provide a machine-specific implementation. - * Having this, allows code to be written for the raw API, without - * the need for system-specific code to handle input in that format; - * these following couple of functions will handle the translation forth - * and back automatically. */ - -void ffi_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *raw) -{ - void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); - ffi_raw_to_ptrarray (cif, raw, avalue); - ffi_call (cif, fn, rvalue, avalue); -} - -#if FFI_CLOSURES /* base system provides closures */ - -static void -ffi_translate_args (ffi_cif *cif, void *rvalue, - void **avalue, void *user_data) -{ - ffi_raw *raw = (ffi_raw*)alloca (ffi_raw_size (cif)); - ffi_raw_closure *cl = (ffi_raw_closure*)user_data; - - ffi_ptrarray_to_raw (cif, avalue, raw); - (*cl->fun) (cif, rvalue, raw, cl->user_data); -} - -ffi_status -ffi_prep_raw_closure_loc (ffi_raw_closure* cl, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc) -{ - ffi_status status; - - status = ffi_prep_closure_loc ((ffi_closure*) cl, - cif, - &ffi_translate_args, - codeloc, - codeloc); - if (status == FFI_OK) - { - cl->fun = fun; - cl->user_data = user_data; - } - - return status; -} - -#endif /* FFI_CLOSURES */ -#endif /* !FFI_NATIVE_RAW_API */ - -#if FFI_CLOSURES - -/* Again, here is the generic version of ffi_prep_raw_closure, which - * will install an intermediate "hub" for translation of arguments from - * the pointer-array format, to the raw format */ - -ffi_status -ffi_prep_raw_closure (ffi_raw_closure* cl, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data) -{ - return ffi_prep_raw_closure_loc (cl, cif, fun, user_data, cl); -} - -#endif /* FFI_CLOSURES */ - -/* ----------------------------------------------------------------------- - prep_cif.c - Copyright (c) 1996, 1998, 2007 Red Hat, Inc. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -/* Round up to FFI_SIZEOF_ARG. */ - -#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG) - -/* Perform machine independent initialization of aggregate type - specifications. */ - -static ffi_status initialize_aggregate(ffi_type *arg) -{ - ffi_type **ptr; - - FFI_ASSERT(arg != NULL); - - FFI_ASSERT(arg->elements != NULL); - FFI_ASSERT(arg->size == 0); - FFI_ASSERT(arg->alignment == 0); - - ptr = &(arg->elements[0]); - - while ((*ptr) != NULL) - { - if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK)) - return FFI_BAD_TYPEDEF; - - /* Perform a sanity check on the argument type */ - FFI_ASSERT_VALID_TYPE(*ptr); - - arg->size = ALIGN(arg->size, (*ptr)->alignment); - arg->size += (*ptr)->size; - - arg->alignment = (arg->alignment > (*ptr)->alignment) ? - arg->alignment : (*ptr)->alignment; - - ptr++; - } - - /* Structure size includes tail padding. This is important for - structures that fit in one register on ABIs like the PowerPC64 - Linux ABI that right justify small structs in a register. - It's also needed for nested structure layout, for example - struct A { long a; char b; }; struct B { struct A x; char y; }; - should find y at an offset of 2*sizeof(long) and result in a - total size of 3*sizeof(long). */ - arg->size = ALIGN (arg->size, arg->alignment); - - if (arg->size == 0) - return FFI_BAD_TYPEDEF; - else - return FFI_OK; -} - -#ifndef __CRIS__ -/* The CRIS ABI specifies structure elements to have byte - alignment only, so it completely overrides this functions, - which assumes "natural" alignment and padding. */ - -/* Perform machine independent ffi_cif preparation, then call - machine dependent routine. */ - -ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, - ffi_type *rtype, ffi_type **atypes) -{ - unsigned bytes = 0; - unsigned int i; - ffi_type **ptr; - - FFI_ASSERT(cif != NULL); - FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI)); - - cif->abi = abi; - cif->arg_types = atypes; - cif->nargs = nargs; - cif->rtype = rtype; - - cif->flags = 0; - - /* Initialize the return type if necessary */ - if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK)) - return FFI_BAD_TYPEDEF; - - /* Perform a sanity check on the return type */ - FFI_ASSERT_VALID_TYPE(cif->rtype); - - /* x86-64 stack space allocation is handled in prep_machdep. */ -#if !defined __x86_64__ - /* Make space for the return structure pointer */ - if (cif->rtype->type == FFI_TYPE_STRUCT -#ifdef X86_DARWIN - && (cif->rtype->size > 8) -#endif - ) - bytes = STACK_ARG_SIZE(sizeof(void*)); -#endif - - for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) - { - - /* Initialize any uninitialized aggregate type definitions */ - if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK)) - return FFI_BAD_TYPEDEF; - - /* Perform a sanity check on the argument type, do this - check after the initialization. */ - FFI_ASSERT_VALID_TYPE(*ptr); - -#if !defined __x86_64__ - { - /* Add any padding if necessary */ - if (((*ptr)->alignment - 1) & bytes) - bytes = ALIGN(bytes, (*ptr)->alignment); - - bytes += STACK_ARG_SIZE((*ptr)->size); - } -#endif - } - - cif->bytes = bytes; - - /* Perform machine dependent cif processing */ - return ffi_prep_cif_machdep(cif); -} -#endif /* not __CRIS__ */ - -#if FFI_CLOSURES - -ffi_status -ffi_prep_closure (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data) -{ - return ffi_prep_closure_loc (closure, cif, fun, user_data, closure); -} - -#endif - -#if !TARGET_IPHONE_SIMULATOR - -#ifdef __arm__ -extern void __clear_cache (void *beg, void *end); -#endif - -//extern void __clear_cache (void *start, void *end) { -// sys_icache_invalidate(start, end-start); -//} - -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 1998, 2008 Red Hat, Inc. - - ARM Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ - -void ffi_prep_args(char *stack, extended_cif *ecif) -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - - argp = stack; - - if ( ecif->cif->flags == FFI_TYPE_STRUCT ) { - *(void **) argp = ecif->rvalue; - argp += 4; - } - - p_argv = ecif->avalue; - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - (i != 0); - i--, p_arg++) - { - size_t z; - - /* Align if necessary */ - if (((*p_arg)->alignment - 1) & (unsigned) argp) { - argp = (char *) ALIGN(argp, (*p_arg)->alignment); - } - - if ((*p_arg)->type == FFI_TYPE_STRUCT) - argp = (char *) ALIGN(argp, 4); - - z = (*p_arg)->size; - if (z < sizeof(int)) - { - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); - break; - - case FFI_TYPE_STRUCT: - memcpy(argp, *p_argv, (*p_arg)->size); - break; - - default: - FFI_ASSERT(0); - } - } - else if (z == sizeof(int)) - { - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - } - else - { - memcpy(argp, *p_argv, z); - } - p_argv++; - argp += z; - } - - return; -} - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - /* Round the stack up to a multiple of 8 bytes. This isn't needed - everywhere, but it is on some platforms, and it doesn't harm anything - when it isn't needed. */ - cif->bytes = (cif->bytes + 7) & ~7; - - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - cif->flags = (unsigned) cif->rtype->type; - break; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags = (unsigned) FFI_TYPE_SINT64; - break; - - case FFI_TYPE_STRUCT: - if (cif->rtype->size <= 4) - /* A Composite Type not larger than 4 bytes is returned in r0. */ - cif->flags = (unsigned)FFI_TYPE_INT; - else - /* A Composite Type larger than 4 bytes, or whose size cannot - be determined statically ... is stored in memory at an - address passed [in r0]. */ - cif->flags = (unsigned)FFI_TYPE_STRUCT; - break; - - default: - cif->flags = FFI_TYPE_INT; - break; - } - - return FFI_OK; -} - -extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, - unsigned, unsigned, unsigned *, void (*fn)(void)); - -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - int small_struct = (cif->flags == FFI_TYPE_INT - && cif->rtype->type == FFI_TYPE_STRUCT); - - ecif.cif = cif; - ecif.avalue = avalue; - - unsigned int temp; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - - if ((rvalue == NULL) && - (cif->flags == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca(cif->rtype->size); - } - else if (small_struct) - ecif.rvalue = &temp; - else - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue, - fn); - - break; - default: - FFI_ASSERT(0); - break; - } - if (small_struct) - memcpy (rvalue, &temp, cif->rtype->size); -} - -/** private members **/ - -static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, - void** args, ffi_cif* cif); - -void ffi_closure_SYSV (ffi_closure *); - -/* This function is jumped to by the trampoline */ -unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *); - -unsigned int -ffi_closure_SYSV_inner (closure, respp, args) - ffi_closure *closure; - void **respp; - void *args; -{ - // our various things... - ffi_cif *cif; - void **arg_area; - - cif = closure->cif; - arg_area = (void**) alloca (cif->nargs * sizeof (void*)); - - /* this call will initialize ARG_AREA, such that each - * element in that array points to the corresponding - * value on the stack; and if the function returns - * a structure, it will re-set RESP to point to the - * structure return address. */ - - ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif); - - (closure->fun) (cif, *respp, arg_area, closure->user_data); - - return cif->flags; -} - -/*@-exportheader@*/ -static void -ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, - void **avalue, ffi_cif *cif) -/*@=exportheader@*/ -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - - argp = stack; - - if ( cif->flags == FFI_TYPE_STRUCT ) { - *rvalue = *(void **) argp; - argp += 4; - } - - p_argv = avalue; - - for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) - { - size_t z; - - size_t alignment = (*p_arg)->alignment; - if (alignment < 4) - alignment = 4; - /* Align if necessary */ - if ((alignment - 1) & (unsigned) argp) { - argp = (char *) ALIGN(argp, alignment); - } - - z = (*p_arg)->size; - - /* because we're little endian, this is what it turns into. */ - - *p_argv = (void*) argp; - - p_argv++; - argp += z; - } - - return; -} - -/* How to make a trampoline. */ - -#ifdef __arm__ - -// __clear_cache seems to be missing on iOS5, so we omit it. Danger, Will Robinson. - -#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ -({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ - unsigned int __fun = (unsigned int)(FUN); \ - unsigned int __ctx = (unsigned int)(CTX); \ - *(unsigned int*) &__tramp[0] = 0xe92d000f; /* stmfd sp!, {r0-r3} */ \ - *(unsigned int*) &__tramp[4] = 0xe59f0000; /* ldr r0, [pc] */ \ - *(unsigned int*) &__tramp[8] = 0xe59ff000; /* ldr pc, [pc] */ \ - *(unsigned int*) &__tramp[12] = __ctx; \ - *(unsigned int*) &__tramp[16] = __fun; \ - }) - -#else - -#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ -({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ - unsigned int __fun = (unsigned int)(FUN); \ - unsigned int __ctx = (unsigned int)(CTX); \ - *(unsigned int*) &__tramp[0] = 0xe92d000f; /* stmfd sp!, {r0-r3} */ \ - *(unsigned int*) &__tramp[4] = 0xe59f0000; /* ldr r0, [pc] */ \ - *(unsigned int*) &__tramp[8] = 0xe59ff000; /* ldr pc, [pc] */ \ - *(unsigned int*) &__tramp[12] = __ctx; \ - *(unsigned int*) &__tramp[16] = __fun; \ - __clear_cache((&__tramp[0]), (&__tramp[19])); \ -}) - -#endif - - -/* the cif must already be prep'ed */ - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - FFI_ASSERT (cif->abi == FFI_SYSV); - - FFI_INIT_TRAMPOLINE (&closure->tramp[0], \ - &ffi_closure_SYSV, \ - codeloc); - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} - -#endif - -#import "TargetConditionals.h" -#if TARGET_IPHONE_SIMULATOR - - -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc. - Copyright (c) 2002 Ranjit Mathew - Copyright (c) 2002 Bo Thorsen - Copyright (c) 2002 Roger Sayle - Copyright (C) 2008 Free Software Foundation, Inc. - - x86 Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#ifndef __x86_64__ - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ - -void ffi_prep_args(char *stack, extended_cif *ecif) -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - - argp = stack; - - if (ecif->cif->flags == FFI_TYPE_STRUCT) - { - *(void **) argp = ecif->rvalue; - argp += 4; - } - - p_argv = ecif->avalue; - - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - i != 0; - i--, p_arg++) - { - size_t z; - - /* Align if necessary */ - if ((sizeof(int) - 1) & (unsigned) argp) - argp = (char *) ALIGN(argp, sizeof(int)); - - z = (*p_arg)->size; - if (z < sizeof(int)) - { - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); - break; - - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); - break; - - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); - break; - - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); - break; - - case FFI_TYPE_SINT32: - *(signed int *) argp = (signed int)*(SINT32 *)(* p_argv); - break; - - case FFI_TYPE_UINT32: - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - break; - - case FFI_TYPE_STRUCT: - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - break; - - default: - FFI_ASSERT(0); - } - } - else - { - memcpy(argp, *p_argv, z); - } - p_argv++; - argp += z; - } - - return; -} - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - /* Set the return type flag */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: -#ifdef X86 - case FFI_TYPE_STRUCT: -#endif -#if defined(X86) || defined(X86_DARWIN) - case FFI_TYPE_UINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT8: - case FFI_TYPE_SINT16: -#endif - - case FFI_TYPE_SINT64: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: -//## case FFI_TYPE_LONGDOUBLE: - cif->flags = (unsigned) cif->rtype->type; - break; - - case FFI_TYPE_UINT64: - cif->flags = FFI_TYPE_SINT64; - break; - -#ifndef X86 - case FFI_TYPE_STRUCT: - if (cif->rtype->size == 1) - { - cif->flags = FFI_TYPE_SMALL_STRUCT_1B; /* same as char size */ - } - else if (cif->rtype->size == 2) - { - cif->flags = FFI_TYPE_SMALL_STRUCT_2B; /* same as short size */ - } - else if (cif->rtype->size == 4) - { - cif->flags = FFI_TYPE_INT; /* same as int type */ - } - else if (cif->rtype->size == 8) - { - cif->flags = FFI_TYPE_SINT64; /* same as int64 type */ - } - else - { - cif->flags = FFI_TYPE_STRUCT; - } - break; -#endif - - default: - cif->flags = FFI_TYPE_INT; - break; - } - -#ifdef X86_DARWIN - cif->bytes = (cif->bytes + 15) & ~0xF; -#endif - - return FFI_OK; -} - -extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, - unsigned, unsigned, unsigned *, void (*fn)(void)); - - -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - - if ((rvalue == NULL) && - (cif->flags == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca(cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue, - fn); - break; - default: - FFI_ASSERT(0); - break; - } -} - - -/** private members **/ - -static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, - void** args, ffi_cif* cif); -void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *) - __attribute__ ((regparm(1))); -unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *) - __attribute__ ((regparm(1))); -void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *) - __attribute__ ((regparm(1))); - -/* This function is jumped to by the trampoline */ - -unsigned int FFI_HIDDEN -ffi_closure_SYSV_inner (closure, respp, args) - ffi_closure *closure; - void **respp; - void *args; -{ - /* our various things... */ - ffi_cif *cif; - void **arg_area; - - cif = closure->cif; - arg_area = (void**) alloca (cif->nargs * sizeof (void*)); - - /* this call will initialize ARG_AREA, such that each - * element in that array points to the corresponding - * value on the stack; and if the function returns - * a structure, it will re-set RESP to point to the - * structure return address. */ - - ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif); - - (closure->fun) (cif, *respp, arg_area, closure->user_data); - - return cif->flags; -} - -static void -ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue, - ffi_cif *cif) -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - - argp = stack; - - if ( cif->flags == FFI_TYPE_STRUCT ) { - *rvalue = *(void **) argp; - argp += 4; - } - - p_argv = avalue; - - for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) - { - size_t z; - - /* Align if necessary */ - if ((sizeof(int) - 1) & (unsigned) argp) { - argp = (char *) ALIGN(argp, sizeof(int)); - } - - z = (*p_arg)->size; - - /* because we're little endian, this is what it turns into. */ - - *p_argv = (void*) argp; - - p_argv++; - argp += z; - } - - return; -} - -/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */ - -#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ -({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ - unsigned int __fun = (unsigned int)(FUN); \ - unsigned int __ctx = (unsigned int)(CTX); \ - unsigned int __dis = __fun - (__ctx + 10); \ - *(unsigned char*) &__tramp[0] = 0xb8; \ - *(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \ - *(unsigned char *) &__tramp[5] = 0xe9; \ - *(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \ - }) - -#define FFI_INIT_TRAMPOLINE_STDCALL(TRAMP,FUN,CTX,SIZE) \ -({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ - unsigned int __fun = (unsigned int)(FUN); \ - unsigned int __ctx = (unsigned int)(CTX); \ - unsigned int __dis = __fun - (__ctx + 10); \ - unsigned short __size = (unsigned short)(SIZE); \ - *(unsigned char*) &__tramp[0] = 0xb8; \ - *(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \ - *(unsigned char *) &__tramp[5] = 0xe8; \ - *(unsigned int*) &__tramp[6] = __dis; /* call __fun */ \ - *(unsigned char *) &__tramp[10] = 0xc2; \ - *(unsigned short*) &__tramp[11] = __size; /* ret __size */ \ - }) - -/* the cif must already be prep'ed */ - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - if (cif->abi == FFI_SYSV) - { - FFI_INIT_TRAMPOLINE (&closure->tramp[0], - &ffi_closure_SYSV, - (void*)codeloc); - } - else - { - return FFI_BAD_ABI; - } - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} - -/* ------- Native raw API support -------------------------------- */ - -ffi_status -ffi_prep_raw_closure_loc (ffi_raw_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc) -{ - int i; - - if (cif->abi != FFI_SYSV) { - return FFI_BAD_ABI; - } - - // we currently don't support certain kinds of arguments for raw - // closures. This should be implemented by a separate assembly language - // routine, since it would require argument processing, something we - // don't do now for performance. - - for (i = cif->nargs-1; i >= 0; i--) - { - FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT); - FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE); - } - - - FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV, - codeloc); - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} - -static void -ffi_prep_args_raw(char *stack, extended_cif *ecif) -{ - memcpy (stack, ecif->avalue, ecif->cif->bytes); -} - -/* we borrow this routine from libffi (it must be changed, though, to - * actually call the function passed in the first argument. as of - * libffi-1.20, this is not the case.) - */ - -extern void -ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, unsigned, - unsigned, unsigned *, void (*fn)(void)); - -void -ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue) -{ - extended_cif ecif; - void **avalue = (void **)fake_avalue; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - - if ((rvalue == NULL) && - (cif->rtype->type == FFI_TYPE_STRUCT)) - { - ecif.rvalue = alloca(cif->rtype->size); - } - else - ecif.rvalue = rvalue; - - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags, - ecif.rvalue, fn); - break; - default: - FFI_ASSERT(0); - break; - } -} - -#endif /* __x86_64__ */ - -#endif \ No newline at end of file diff --git a/libffi/ffi.h b/libffi/ffi.h deleted file mode 100644 index c9c5042..0000000 --- a/libffi/ffi.h +++ /dev/null @@ -1,952 +0,0 @@ -#include "TargetConditionals.h" - -/* Define this if you want extra debugging. */ -#undef FFI_DEBUG - -#ifdef LIBFFI_ASM -#define FFI_HIDDEN(name) -#else -#define FFI_HIDDEN -#endif - -#if defined (X86_64) && defined (__i386__) -#undef X86_64 -#define X86 -#endif - -#if TARGET_IPHONE_SIMULATOR - -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. - Copyright (C) 2008 Free Software Foundation, Inc. - - Target configuration macros for x86 and x86-64. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - ----------------------------------------------------------------------- */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -/* ---- System specific configurations ----------------------------------- */ - -#if defined (X86_64) && defined (__i386__) -#undef X86_64 -#define X86 -#endif - -/* ---- Generic type definitions ----------------------------------------- */ - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - - /* ---- Intel x86 and AMD x86-64 - */ -#if (defined(__i386__) || defined(__x86_64__)) - FFI_SYSV, - FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */ -#ifdef __i386__ - FFI_DEFAULT_ABI = FFI_SYSV, -#else - FFI_DEFAULT_ABI = FFI_UNIX64, -#endif -#endif - - FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) -#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) - -#if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) -#define FFI_TRAMPOLINE_SIZE 24 -#define FFI_NATIVE_RAW_API 0 -#else -#define FFI_TRAMPOLINE_SIZE 10 -#define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ -#endif - -#endif - - - -#else - - -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. - Target configuration macros for ARM. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - ----------------------------------------------------------------------- */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_DEFAULT_ABI = FFI_SYSV, - FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 20 -#define FFI_NATIVE_RAW_API 0 - -#endif - - - -#endif - - - - - -#if TARGET_IPHONE_SIMULATOR - -/* -----------------------------------------------------------------*-C-*- - libffi @VERSION@ - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - ----------------------------------------------------------------------- */ - -/* ------------------------------------------------------------------- - The basic API is described in the README file. - - The raw API is designed to bypass some of the argument packing - and unpacking on architectures for which it can be avoided. - - The closure API allows interpreted functions to be packaged up - inside a C function pointer, so that they can be called as C functions, - with no understanding on the client side that they are interpreted. - It can also be used in other cases in which it is necessary to package - up a user specified parameter and a function pointer as a single - function pointer. - - The closure API must be implemented in order to get its functionality, - e.g. for use by gij. Routines are provided to emulate the raw API - if the underlying platform doesn't allow faster implementation. - - More details on the raw and cloure API can be found in: - - http://gcc.gnu.org/ml/java/1999-q3/msg00138.html - - and - - http://gcc.gnu.org/ml/java/1999-q3/msg00174.html - -------------------------------------------------------------------- */ - -#ifndef LIBFFI_H -#define LIBFFI_H - -#ifdef __cplusplus -extern "C" { -#endif - - /* Specify which architecture libffi is configured for. */ -#ifndef X86_DARWIN -#define X86_DARWIN -#endif - - /* ---- System configuration information --------------------------------- */ - - -#ifndef LIBFFI_ASM - -#include -#include - - /* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). - But we can find it either under the correct ANSI name, or under GNU - C's internal name. */ -#ifdef LONG_LONG_MAX -# define FFI_LONG_LONG_MAX LONG_LONG_MAX -#else -# ifdef LLONG_MAX -# define FFI_LONG_LONG_MAX LLONG_MAX -# else -# ifdef __GNUC__ -# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ -# endif -# endif -#endif - - /* The closure code assumes that this works on pointers, i.e. a size_t */ - /* can hold a pointer. */ - - typedef struct _ffi_type - { - size_t size; - unsigned short alignment; - unsigned short type; - struct _ffi_type **elements; - } ffi_type; - -#ifndef LIBFFI_HIDE_BASIC_TYPES -#if SCHAR_MAX == 127 -# define ffi_type_uchar ffi_type_uint8 -# define ffi_type_schar ffi_type_sint8 -#else -#error "char size not supported" -#endif - -#if SHRT_MAX == 32767 -# define ffi_type_ushort ffi_type_uint16 -# define ffi_type_sshort ffi_type_sint16 -#elif SHRT_MAX == 2147483647 -# define ffi_type_ushort ffi_type_uint32 -# define ffi_type_sshort ffi_type_sint32 -#else -#error "short size not supported" -#endif - -#if INT_MAX == 32767 -# define ffi_type_uint ffi_type_uint16 -# define ffi_type_sint ffi_type_sint16 -#elif INT_MAX == 2147483647 -# define ffi_type_uint ffi_type_uint32 -# define ffi_type_sint ffi_type_sint32 -#elif INT_MAX == 9223372036854775807 -# define ffi_type_uint ffi_type_uint64 -# define ffi_type_sint ffi_type_sint64 -#else -#error "int size not supported" -#endif - -#if LONG_MAX == 2147483647 -# if FFI_LONG_LONG_MAX != 9223372036854775807 -#error "no 64-bit data type supported" -# endif -#elif LONG_MAX != 9223372036854775807 -#error "long size not supported" -#endif - -#if LONG_MAX == 2147483647 -# define ffi_type_ulong ffi_type_uint32 -# define ffi_type_slong ffi_type_sint32 -#elif LONG_MAX == 9223372036854775807 -# define ffi_type_ulong ffi_type_uint64 -# define ffi_type_slong ffi_type_sint64 -#else -#error "long size not supported" -#endif - - /* These are defined in types.c */ - extern ffi_type ffi_type_void; - extern ffi_type ffi_type_uint8; - extern ffi_type ffi_type_sint8; - extern ffi_type ffi_type_uint16; - extern ffi_type ffi_type_sint16; - extern ffi_type ffi_type_uint32; - extern ffi_type ffi_type_sint32; - extern ffi_type ffi_type_uint64; - extern ffi_type ffi_type_sint64; - extern ffi_type ffi_type_float; - extern ffi_type ffi_type_double; - extern ffi_type ffi_type_pointer; - -#if 1 /* @HAVE_LONG_DOUBLE@ */ - extern ffi_type ffi_type_longdouble; -#else -#define ffi_type_longdouble ffi_type_double -#endif -#endif /* LIBFFI_HIDE_BASIC_TYPES */ - - typedef enum { - FFI_OK = 0, - FFI_BAD_TYPEDEF, - FFI_BAD_ABI - } ffi_status; - - typedef unsigned FFI_TYPE; - - typedef struct { - ffi_abi abi; - unsigned nargs; - ffi_type **arg_types; - ffi_type *rtype; - unsigned bytes; - unsigned flags; -#ifdef FFI_EXTRA_CIF_FIELDS - FFI_EXTRA_CIF_FIELDS; -#endif - } ffi_cif; - - /* ---- Definitions for the raw API -------------------------------------- */ - -#ifndef FFI_SIZEOF_ARG -# if LONG_MAX == 2147483647 -# define FFI_SIZEOF_ARG 4 -# elif LONG_MAX == 9223372036854775807 -# define FFI_SIZEOF_ARG 8 -# endif -#endif - -#ifndef FFI_SIZEOF_JAVA_RAW -# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG -#endif - - typedef union { - ffi_sarg sint; - ffi_arg uint; - float flt; - char data[FFI_SIZEOF_ARG]; - void* ptr; - } ffi_raw; - -#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 - /* This is a special case for mips64/n32 ABI (and perhaps others) where - sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ - typedef union { - signed int sint; - unsigned int uint; - float flt; - char data[FFI_SIZEOF_JAVA_RAW]; - void* ptr; - } ffi_java_raw; -#else - typedef ffi_raw ffi_java_raw; -#endif - - - void ffi_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_raw *avalue); - - void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); - void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); - size_t ffi_raw_size (ffi_cif *cif); - - /* This is analogous to the raw API, except it uses Java parameter */ - /* packing, even on 64-bit machines. I.e. on 64-bit machines */ - /* longs and doubles are followed by an empty 64-bit word. */ - - void ffi_java_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_java_raw *avalue); - - void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); - void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); - size_t ffi_java_raw_size (ffi_cif *cif); - - /* ---- Definitions for closures ----------------------------------------- */ - -#if FFI_CLOSURES - - typedef struct { - char tramp[FFI_TRAMPOLINE_SIZE]; - ffi_cif *cif; - void (*fun)(ffi_cif*,void*,void**,void*); - void *user_data; - } ffi_closure __attribute__((aligned (8))); - - void *ffi_closure_alloc (size_t size, void **code); - void ffi_closure_free (void *); - - ffi_status - ffi_prep_closure (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data); - - ffi_status - ffi_prep_closure_loc (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void*codeloc); - - typedef struct { - char tramp[FFI_TRAMPOLINE_SIZE]; - - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* if this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the transaltion, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_raw*,void*); - void *user_data; - - } ffi_raw_closure; - - typedef struct { - char tramp[FFI_TRAMPOLINE_SIZE]; - - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* if this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the transaltion, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); - void *user_data; - - } ffi_java_raw_closure; - - ffi_status - ffi_prep_raw_closure (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data); - - ffi_status - ffi_prep_raw_closure_loc (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc); - - ffi_status - ffi_prep_java_raw_closure (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data); - - ffi_status - ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data, - void *codeloc); - -#endif /* FFI_CLOSURES */ - - /* ---- Public interface definition -------------------------------------- */ - - ffi_status ffi_prep_cif(ffi_cif *cif, - ffi_abi abi, - unsigned int nargs, - ffi_type *rtype, - ffi_type **atypes); - - void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue); - - /* Useful for eliminating compiler warnings */ -#define FFI_FN(f) ((void (*)(void))f) - - /* ---- Definitions shared with assembly code ---------------------------- */ - -#endif - - /* If these change, update src/mips/ffitarget.h. */ -#define FFI_TYPE_VOID 0 -#define FFI_TYPE_INT 1 -#define FFI_TYPE_FLOAT 2 -#define FFI_TYPE_DOUBLE 3 -#if 0 /* @HAVE_LONG_DOUBLE@ */ -#define FFI_TYPE_LONGDOUBLE 4 -#else -#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE -#endif -#define FFI_TYPE_UINT8 5 -#define FFI_TYPE_SINT8 6 -#define FFI_TYPE_UINT16 7 -#define FFI_TYPE_SINT16 8 -#define FFI_TYPE_UINT32 9 -#define FFI_TYPE_SINT32 10 -#define FFI_TYPE_UINT64 11 -#define FFI_TYPE_SINT64 12 -#define FFI_TYPE_STRUCT 13 -#define FFI_TYPE_POINTER 14 - - /* This should always refer to the last type code (for sanity checks) */ -#define FFI_TYPE_LAST FFI_TYPE_POINTER - -#ifdef __cplusplus -} -#endif - -#endif - - - -#else - -/* -----------------------------------------------------------------*-C-*- - libffi @VERSION@ - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - ----------------------------------------------------------------------- */ - -/* ------------------------------------------------------------------- - The basic API is described in the README file. - - The raw API is designed to bypass some of the argument packing - and unpacking on architectures for which it can be avoided. - - The closure API allows interpreted functions to be packaged up - inside a C function pointer, so that they can be called as C functions, - with no understanding on the client side that they are interpreted. - It can also be used in other cases in which it is necessary to package - up a user specified parameter and a function pointer as a single - function pointer. - - The closure API must be implemented in order to get its functionality, - e.g. for use by gij. Routines are provided to emulate the raw API - if the underlying platform doesn't allow faster implementation. - - More details on the raw and cloure API can be found in: - - http://gcc.gnu.org/ml/java/1999-q3/msg00138.html - - and - - http://gcc.gnu.org/ml/java/1999-q3/msg00174.html - -------------------------------------------------------------------- */ - -#ifndef LIBFFI_H -#define LIBFFI_H - -#ifdef __cplusplus -extern "C" { -#endif - - /* Specify which architecture libffi is configured for. */ -#ifndef armv6 -#define armv6 -#endif - - /* ---- System configuration information --------------------------------- */ - - -#ifndef LIBFFI_ASM - -#include -#include - - /* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). - But we can find it either under the correct ANSI name, or under GNU - C's internal name. */ -#ifdef LONG_LONG_MAX -# define FFI_LONG_LONG_MAX LONG_LONG_MAX -#else -# ifdef LLONG_MAX -# define FFI_LONG_LONG_MAX LLONG_MAX -# else -# ifdef __GNUC__ -# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ -# endif -# endif -#endif - - /* The closure code assumes that this works on pointers, i.e. a size_t */ - /* can hold a pointer. */ - - typedef struct _ffi_type - { - size_t size; - unsigned short alignment; - unsigned short type; - struct _ffi_type **elements; - } ffi_type; - -#ifndef LIBFFI_HIDE_BASIC_TYPES -#if SCHAR_MAX == 127 -# define ffi_type_uchar ffi_type_uint8 -# define ffi_type_schar ffi_type_sint8 -#else -#error "char size not supported" -#endif - -#if SHRT_MAX == 32767 -# define ffi_type_ushort ffi_type_uint16 -# define ffi_type_sshort ffi_type_sint16 -#elif SHRT_MAX == 2147483647 -# define ffi_type_ushort ffi_type_uint32 -# define ffi_type_sshort ffi_type_sint32 -#else -#error "short size not supported" -#endif - -#if INT_MAX == 32767 -# define ffi_type_uint ffi_type_uint16 -# define ffi_type_sint ffi_type_sint16 -#elif INT_MAX == 2147483647 -# define ffi_type_uint ffi_type_uint32 -# define ffi_type_sint ffi_type_sint32 -#elif INT_MAX == 9223372036854775807 -# define ffi_type_uint ffi_type_uint64 -# define ffi_type_sint ffi_type_sint64 -#else -#error "int size not supported" -#endif - -#if LONG_MAX == 2147483647 -# if FFI_LONG_LONG_MAX != 9223372036854775807 -#error "no 64-bit data type supported" -# endif -#elif LONG_MAX != 9223372036854775807 -#error "long size not supported" -#endif - -#if LONG_MAX == 2147483647 -# define ffi_type_ulong ffi_type_uint32 -# define ffi_type_slong ffi_type_sint32 -#elif LONG_MAX == 9223372036854775807 -# define ffi_type_ulong ffi_type_uint64 -# define ffi_type_slong ffi_type_sint64 -#else -#error "long size not supported" -#endif - - /* These are defined in types.c */ - extern ffi_type ffi_type_void; - extern ffi_type ffi_type_uint8; - extern ffi_type ffi_type_sint8; - extern ffi_type ffi_type_uint16; - extern ffi_type ffi_type_sint16; - extern ffi_type ffi_type_uint32; - extern ffi_type ffi_type_sint32; - extern ffi_type ffi_type_uint64; - extern ffi_type ffi_type_sint64; - extern ffi_type ffi_type_float; - extern ffi_type ffi_type_double; - extern ffi_type ffi_type_pointer; - -#if 0 // @HAVE_LONG_DOUBLE@ - extern ffi_type ffi_type_longdouble; -#else -#define ffi_type_longdouble ffi_type_double -#endif -#endif /* LIBFFI_HIDE_BASIC_TYPES */ - - typedef enum { - FFI_OK = 0, - FFI_BAD_TYPEDEF, - FFI_BAD_ABI - } ffi_status; - - typedef unsigned FFI_TYPE; - - typedef struct { - ffi_abi abi; - unsigned nargs; - ffi_type **arg_types; - ffi_type *rtype; - unsigned bytes; - unsigned flags; -#ifdef FFI_EXTRA_CIF_FIELDS - FFI_EXTRA_CIF_FIELDS; -#endif - } ffi_cif; - - /* ---- Definitions for the raw API -------------------------------------- */ - -#ifndef FFI_SIZEOF_ARG -# if LONG_MAX == 2147483647 -# define FFI_SIZEOF_ARG 4 -# elif LONG_MAX == 9223372036854775807 -# define FFI_SIZEOF_ARG 8 -# endif -#endif - -#ifndef FFI_SIZEOF_JAVA_RAW -# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG -#endif - - typedef union { - ffi_sarg sint; - ffi_arg uint; - float flt; - char data[FFI_SIZEOF_ARG]; - void* ptr; - } ffi_raw; - -#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 - /* This is a special case for mips64/n32 ABI (and perhaps others) where - sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ - typedef union { - signed int sint; - unsigned int uint; - float flt; - char data[FFI_SIZEOF_JAVA_RAW]; - void* ptr; - } ffi_java_raw; -#else - typedef ffi_raw ffi_java_raw; -#endif - - - void ffi_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_raw *avalue); - - void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); - void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); - size_t ffi_raw_size (ffi_cif *cif); - - /* This is analogous to the raw API, except it uses Java parameter */ - /* packing, even on 64-bit machines. I.e. on 64-bit machines */ - /* longs and doubles are followed by an empty 64-bit word. */ - - void ffi_java_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_java_raw *avalue); - - void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); - void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); - size_t ffi_java_raw_size (ffi_cif *cif); - - /* ---- Definitions for closures ----------------------------------------- */ - -#if FFI_CLOSURES - - typedef struct { - char tramp[FFI_TRAMPOLINE_SIZE]; - ffi_cif *cif; - void (*fun)(ffi_cif*,void*,void**,void*); - void *user_data; - } ffi_closure __attribute__((aligned (8))); - - void *ffi_closure_alloc (size_t size, void **code); - void ffi_closure_free (void *); - - ffi_status - ffi_prep_closure (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data); - - ffi_status - ffi_prep_closure_loc (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void*codeloc); - - typedef struct { - char tramp[FFI_TRAMPOLINE_SIZE]; - - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* if this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the transaltion, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_raw*,void*); - void *user_data; - - } ffi_raw_closure; - - typedef struct { - char tramp[FFI_TRAMPOLINE_SIZE]; - - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* if this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the transaltion, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); - void *user_data; - - } ffi_java_raw_closure; - - ffi_status - ffi_prep_raw_closure (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data); - - ffi_status - ffi_prep_raw_closure_loc (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc); - - ffi_status - ffi_prep_java_raw_closure (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data); - - ffi_status - ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data, - void *codeloc); - -#endif /* FFI_CLOSURES */ - - /* ---- Public interface definition -------------------------------------- */ - - ffi_status ffi_prep_cif(ffi_cif *cif, - ffi_abi abi, - unsigned int nargs, - ffi_type *rtype, - ffi_type **atypes); - - void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue); - - /* Useful for eliminating compiler warnings */ -#define FFI_FN(f) ((void (*)(void))f) - - /* ---- Definitions shared with assembly code ---------------------------- */ - -#endif - - /* If these change, update src/mips/ffitarget.h. */ -#define FFI_TYPE_VOID 0 -#define FFI_TYPE_INT 1 -#define FFI_TYPE_FLOAT 2 -#define FFI_TYPE_DOUBLE 3 -#if 0 // @HAVE_LONG_DOUBLE@ -#define FFI_TYPE_LONGDOUBLE 4 -#else -#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE -#endif -#define FFI_TYPE_UINT8 5 -#define FFI_TYPE_SINT8 6 -#define FFI_TYPE_UINT16 7 -#define FFI_TYPE_SINT16 8 -#define FFI_TYPE_UINT32 9 -#define FFI_TYPE_SINT32 10 -#define FFI_TYPE_UINT64 11 -#define FFI_TYPE_SINT64 12 -#define FFI_TYPE_STRUCT 13 -#define FFI_TYPE_POINTER 14 - - /* This should always refer to the last type code (for sanity checks) */ -#define FFI_TYPE_LAST FFI_TYPE_POINTER - -#ifdef __cplusplus -} -#endif - -#endif - - -#endif diff --git a/objc/NSArray+Nu.m b/objc/NSArray+Nu.m index 6c72d60..a3a7e1b 100644 --- a/objc/NSArray+Nu.m +++ b/objc/NSArray+Nu.m @@ -142,17 +142,17 @@ - (void) addObjectsFromList:(id)list - (void) addPossiblyNullObject:(id)anObject { - [self addObject:((anObject == nil) ? (id)[NSNull null] : anObject)]; + [self addObject:((anObject == nil) ? Nu__null : anObject)]; } - (void) insertPossiblyNullObject:(id)anObject atIndex:(int)index { - [self insertObject:((anObject == nil) ? (id)[NSNull null] : anObject) atIndex:index]; + [self insertObject:((anObject == nil) ? Nu__null : anObject) atIndex:index]; } - (void) replaceObjectAtIndex:(int)index withPossiblyNullObject:(id)anObject { - [self replaceObjectAtIndex:index withObject:((anObject == nil) ? (id)[NSNull null] : anObject)]; + [self replaceObjectAtIndex:index withObject:((anObject == nil) ? Nu__null : anObject)]; } - (void) sortUsingBlock:(NuBlock *) block @@ -160,4 +160,4 @@ - (void) sortUsingBlock:(NuBlock *) block [self sortUsingFunction:sortedArrayUsingBlockHelper context:block]; } -@end \ No newline at end of file +@end diff --git a/objc/NSBundle+Nu.m b/objc/NSBundle+Nu.m index 8660f1c..c952257 100644 --- a/objc/NSBundle+Nu.m +++ b/objc/NSBundle+Nu.m @@ -59,7 +59,7 @@ - (id) loadNuFile:(NSString *) nuFileName withContext:(NSMutableDictionary *) co if (string) { NuSymbolTable *symbolTable = [context objectForKey:SYMBOLS_KEY]; id parser = [context lookupObjectForKey:[symbolTable symbolWithString:@"_parser"]]; - id body = [parser parse:string asIfFromFilename:[fileName cStringUsingEncoding:NSUTF8StringEncoding]]; + id body = [parser parse:string asIfFromFilename:[fileName UTF8String]]; [body evalWithContext:context]; return [symbolTable symbolWithString:@"t"]; } diff --git a/objc/NSData+Nu.m b/objc/NSData+Nu.m index 2301334..bd2e464 100644 --- a/objc/NSData+Nu.m +++ b/objc/NSData+Nu.m @@ -48,11 +48,11 @@ + (NSData *) dataWithShellCommand:(NSString *) command standardInput:(id) input else { fullCommand = [NSString stringWithFormat:@"%@ > %@", command, outputFileName]; } - const char *commandString = [[fullCommand stringValue] cStringUsingEncoding:NSUTF8StringEncoding]; + const char *commandString = [fullCommand UTF8String]; int result = system(commandString) >> 8; // this needs an explanation if (!result) returnValue = [NSData dataWithContentsOfFile:outputFileName]; - system([[NSString stringWithFormat:@"rm -f %@ %@", inputFileName, outputFileName] cStringUsingEncoding:NSUTF8StringEncoding]); + system([[NSString stringWithFormat:@"rm -f %@ %@", inputFileName, outputFileName] UTF8String]); } free(input_template); free(output_template); diff --git a/objc/NSDictionary+Nu.m b/objc/NSDictionary+Nu.m index f134ea7..14d95b6 100644 --- a/objc/NSDictionary+Nu.m +++ b/objc/NSDictionary+Nu.m @@ -22,7 +22,7 @@ + (NSDictionary *) dictionaryWithList:(id) list key = [key labelName]; } id value = [[cursor cdr] car]; - if (!value || [value isEqual:[NSNull null]]) { + if (!value || [value isEqual:Nu__null]) { [d removeObjectForKey:key]; } else { [d setValue:value forKey:key]; @@ -133,7 +133,7 @@ - (id) lookupObjectForKey:(id)key - (void) setPossiblyNullObject:(id) anObject forKey:(id) aKey { - [self setObject:((anObject == nil) ? (id)[NSNull null] : anObject) forKey:aKey]; + [self setObject:((anObject == nil) ? Nu__null : anObject) forKey:aKey]; } @end diff --git a/objc/NSFileManager+Nu.m b/objc/NSFileManager+Nu.m index 040afd1..7757bf7 100644 --- a/objc/NSFileManager+Nu.m +++ b/objc/NSFileManager+Nu.m @@ -27,7 +27,7 @@ + (id) creationTimeForFileNamed:(NSString *) filename { if (!filename) return nil; - const char *path = [[filename stringByExpandingTildeInPath] cStringUsingEncoding:NSUTF8StringEncoding]; + const char *path = [[filename stringByExpandingTildeInPath] UTF8String]; struct stat sb; int result = stat(path, &sb); if (result == -1) { @@ -41,7 +41,7 @@ + (id) modificationTimeForFileNamed:(NSString *) filename { if (!filename) return nil; - const char *path = [[filename stringByExpandingTildeInPath] cStringUsingEncoding:NSUTF8StringEncoding]; + const char *path = [[filename stringByExpandingTildeInPath] UTF8String]; struct stat sb; int result = stat(path, &sb); if (result == -1) { @@ -54,7 +54,7 @@ + (int) directoryExistsNamed:(NSString *) filename { if (!filename) return NO; - const char *path = [[filename stringByExpandingTildeInPath] cStringUsingEncoding:NSUTF8StringEncoding]; + const char *path = [[filename stringByExpandingTildeInPath] UTF8String]; struct stat sb; int result = stat(path, &sb); if (result == -1) { @@ -67,7 +67,7 @@ + (int) fileExistsNamed:(NSString *) filename { if (!filename) return NO; - const char *path = [[filename stringByExpandingTildeInPath] cStringUsingEncoding:NSUTF8StringEncoding]; + const char *path = [[filename stringByExpandingTildeInPath] UTF8String]; struct stat sb; int result = stat(path, &sb); if (result == -1) { diff --git a/objc/NSNull+Nu.m b/objc/NSNull+Nu.m index 89b6200..63f3e0e 100644 --- a/objc/NSNull+Nu.m +++ b/objc/NSNull+Nu.m @@ -28,7 +28,7 @@ - (NSUInteger) count - (NSMutableArray *) array { - return [NSMutableArray array]; + return @[]; } - (NSString *) stringValue @@ -41,9 +41,9 @@ - (BOOL) isEqual:(id) other return ((self == other) || (other == 0)) ? 1l : 0l; } -- (const char *) cStringUsingEncoding:(NSStringEncoding) encoding +- (const char *) UTF8String { - return [[self stringValue] cStringUsingEncoding:encoding]; + return [[self stringValue] UTF8String]; } @end diff --git a/objc/NSNumber+Nu.m b/objc/NSNumber+Nu.m index 3f94132..189291c 100644 --- a/objc/NSNumber+Nu.m +++ b/objc/NSNumber+Nu.m @@ -23,7 +23,7 @@ - (id) times:(id) block @try { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [args setCar:[NSNumber numberWithInt:i]]; + [args setCar:@(i)]; [block evalWithArguments:args context:Nu__null]; [pool release]; } @@ -56,7 +56,7 @@ - (id) downTo:(id) number do:(id) block for (i = startValue; i >= finalValue; i--) { @try { - [args setCar:[NSNumber numberWithInt:i]]; + [args setCar:@(i)]; [block evalWithArguments:args context:Nu__null]; } @catch (NuBreakException *exception) { @@ -85,7 +85,7 @@ - (id) upTo:(id) number do:(id) block for (i = startValue; i <= finalValue; i++) { @try { - [args setCar:[NSNumber numberWithInt:i]]; + [args setCar:@(i)]; [block evalWithArguments:args context:Nu__null]; } @catch (NuBreakException *exception) { diff --git a/objc/NSObject+Nu.h b/objc/NSObject+Nu.h index ab1af90..a8d676a 100644 --- a/objc/NSObject+Nu.h +++ b/objc/NSObject+Nu.h @@ -95,4 +95,6 @@ /*! Property list helper. Return the binary property list representation of the object. */ - (NSData *) binaryPropertyListRepresentation; +- (NSString *) stringValue; + @end diff --git a/objc/NSObject+Nu.m b/objc/NSObject+Nu.m index 54c9846..e25b703 100644 --- a/objc/NSObject+Nu.m +++ b/objc/NSObject+Nu.m @@ -13,6 +13,7 @@ #import "NuMethod.h" #import "NuClass.h" #import "NuCell.h" +#import "NSString+Nu.h" @protocol NuCanSetAction - (void) setAction:(SEL) action; @@ -98,7 +99,7 @@ - (NuSelectorCache *) lookupSymbol:(NuSymbol *)childSymbol if (!child) { child = [[[NuSelectorCache alloc] initWithSymbol:childSymbol parent:self] autorelease]; NSString *selectorString = [child selectorName]; - [child setSelector:sel_registerName([selectorString cStringUsingEncoding:NSUTF8StringEncoding])]; + [child setSelector:sel_registerName([selectorString UTF8String])]; [children setValue:child forKey:(id)childSymbol]; } return child; @@ -175,7 +176,7 @@ - (id) sendMessage:(id)cdr withContext:(NSMutableDictionary *)context cursor = [cursor cdr]; } } - // sel = sel_getUid([selectorString cStringUsingEncoding:NSUTF8StringEncoding]); + // sel = sel_getUid([selectorString UTF8String]); sel = [selectorCache selector]; } @@ -297,14 +298,14 @@ - (id) handleUnknownMessage:(id) message withContext:(NSMutableDictionary *) con cursor = [cursor cdr]; } } - // sel = sel_getUid([selectorString cStringUsingEncoding:NSUTF8StringEncoding]); + // sel = sel_getUid([selectorString UTF8String]); sel = [selectorCache selector]; } // If the object responds to methodSignatureForSelector:, we should create and forward an invocation to it. NSMethodSignature *methodSignature = sel ? [self methodSignatureForSelector:sel] : 0; if (methodSignature) { - id result = [NSNull null]; + id result = Nu__null; // Create an invocation to forward. NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature]; [invocation setTarget:self]; @@ -330,7 +331,7 @@ - (id) handleUnknownMessage:(id) message withContext:(NSMutableDictionary *) con [invocation getReturnValue:buffer]; result = get_nu_value_from_objc_value(buffer, [methodSignature methodReturnType]); } @catch (id exception) { - result = [NSNull null]; + result = Nu__null; } free(buffer); } @@ -379,8 +380,14 @@ - (id) handleUnknownMessage:(id) message withContext:(NSMutableDictionary *) con - (id) valueForIvar:(NSString *) name { - Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]); - if (!v) { + Ivar v = class_getInstanceVariable([self class], [name UTF8String]); + + if (!v) { + //check if a _variable was synthesized + v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] UTF8String]); + } + + if (!v) { // look for sparse ivar storage NSMutableDictionary *sparseIvars = [self associatedObjectForKey:@"__nuivars"]; if (sparseIvars) { @@ -401,8 +408,14 @@ - (id) valueForIvar:(NSString *) name - (BOOL) hasValueForIvar:(NSString *) name { - Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]); - if (!v) { + Ivar v = class_getInstanceVariable([self class], [name UTF8String]); + + if (!v) { + //check if a _variable was synthesized + v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] UTF8String]); + } + + if (!v) { // look for sparse ivar storage NSMutableDictionary *sparseIvars = [self associatedObjectForKey:@"__nuivars"]; if (sparseIvars) { @@ -424,8 +437,12 @@ - (BOOL) hasValueForIvar:(NSString *) name - (void) setValue:(id) value forIvar:(NSString *)name { - Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]); - if (!v) { + Ivar v = class_getInstanceVariable([self class], [name UTF8String]); + if (!v) { + //check if a _variable was synthesized + v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] UTF8String]); + } + if (!v) { NSMutableDictionary *sparseIvars = [self associatedObjectForKey:@"__nuivars"]; if (!sparseIvars) { sparseIvars = [[[NSMutableDictionary alloc] init] autorelease]; @@ -507,8 +524,12 @@ + (NSArray *) instanceVariableNames + (NSString *) signatureForIvar:(NSString *)name { - Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]); - return [NSString stringWithCString:ivar_getTypeEncoding(v) encoding:NSUTF8StringEncoding]; + Ivar v = class_getInstanceVariable([self class], [name UTF8String]); + if (!v) { + //check if a _variable was synthesized + v = class_getInstanceVariable([self class], [[@"_" stringByAppendingString:name] UTF8String]); + } + return [NSString stringWithCString:ivar_getTypeEncoding(v) encoding:NSUTF8StringEncoding]; } + (id) inheritedByClass:(NuClass *) newClass @@ -519,7 +540,7 @@ + (id) inheritedByClass:(NuClass *) newClass + (id) createSubclassNamed:(NSString *) subclassName { Class c = [self class]; - const char *name = [subclassName cStringUsingEncoding:NSUTF8StringEncoding]; + const char *name = [subclassName UTF8String]; // does the class already exist? Class s = objc_getClass(name); @@ -559,7 +580,7 @@ + (BOOL) copyInstanceMethod:(NSString *) methodName fromClass:(NuClass *)prototy { Class thisClass = [self class]; Class otherClass = [prototypeClass wrappedClass]; - const char *method_name_str = [methodName cStringUsingEncoding:NSUTF8StringEncoding]; + const char *method_name_str = [methodName UTF8String]; SEL selector = sel_registerName(method_name_str); BOOL result = nu_copyInstanceMethod(thisClass, otherClass, selector); return result; @@ -644,7 +665,7 @@ - (id) set:(NuCell *) propertyList id value = [[cursor cdr] car]; id label = ([key isKindOfClass:[NuSymbol class]] && [key isLabel]) ? [key labelName] : key; if ([label isEqualToString:@"action"] && [self respondsToSelector:@selector(setAction:)]) { - SEL selector = sel_registerName([value cStringUsingEncoding:NSUTF8StringEncoding]); + SEL selector = sel_registerName([value UTF8String]); [(id) self setAction:selector]; } else { diff --git a/objc/NSSet+Nu.m b/objc/NSSet+Nu.m index 5cd6e91..87348db 100644 --- a/objc/NSSet+Nu.m +++ b/objc/NSSet+Nu.m @@ -50,7 +50,7 @@ @implementation NSMutableSet(Nu) - (void) addPossiblyNullObject:(id)anObject { - [self addObject:((anObject == nil) ? (id)[NSNull null] : anObject)]; + [self addObject:((anObject == nil) ? Nu__null : anObject)]; } @end diff --git a/objc/NSString+Nu.m b/objc/NSString+Nu.m index f2056b9..429fa43 100644 --- a/objc/NSString+Nu.m +++ b/objc/NSString+Nu.m @@ -36,7 +36,7 @@ - (id) initWithString:(NSString *) s - (id) nextObject { if (index < [string length]) { - return [NSNumber numberWithInt:[string characterAtIndex:index++]]; + return @([string characterAtIndex:index++]); } else { return nil; } @@ -249,4 +249,4 @@ - (void) appendCharacter:(unichar) c [self appendFormat:@"%C", c]; } -@end \ No newline at end of file +@end diff --git a/objc/Nu.m b/objc/Nu.m index 69eb5a6..fcaeef0 100644 --- a/objc/Nu.m +++ b/objc/Nu.m @@ -138,7 +138,7 @@ int NuMain(int argc, const char *argv[]) NSString *main_nu = [NSString stringWithContentsOfFile:main_path encoding:NSUTF8StringEncoding error:NULL]; if (main_nu) { NuParser *parser = [Nu sharedParser]; - id script = [parser parse:main_nu asIfFromFilename:[main_nu cStringUsingEncoding:NSUTF8StringEncoding]]; + id script = [parser parse:main_nu asIfFromFilename:[main_nu UTF8String]]; [parser eval:script]; [parser release]; return 0; @@ -214,7 +214,7 @@ int NuMain(int argc, const char *argv[]) } @catch (NuException* nuException) { - printf("%s\n", [[nuException dump] cStringUsingEncoding:NSUTF8StringEncoding]); + printf("%s\n", [[nuException dump] UTF8String]); } @catch (id exception) { @@ -249,7 +249,7 @@ void NuInit() initialized = YES; @autoreleasepool { // as a convenience, we set a file static variable to nil. - Nu__null = [NSNull null]; + Nu__null = Nu__null; // add enumeration to collection classes [NSArray include: [NuClass classWithClass:[NuEnumerable class]]]; @@ -298,7 +298,7 @@ void NuInit() id _nunull() { - return [NSNull null]; + return Nu__null; } id _nustring(const unsigned char *string) @@ -402,7 +402,7 @@ + (BOOL) loadNuFile:(NSString *) fileName fromBundleWithIdentifier:(NSString *) NSString *fileNu = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL]; if (fileNu) { NuParser *parser = [Nu sharedParser]; - id script = [parser parse:fileNu asIfFromFilename:[filePath cStringUsingEncoding:NSUTF8StringEncoding]]; + id script = [parser parse:fileNu asIfFromFilename:[filePath UTF8String]]; if (!context) context = [parser context]; [script evalWithContext:context]; success = YES; diff --git a/objc/NuBridge.m b/objc/NuBridge.m index eed3cfb..db5cc91 100644 --- a/objc/NuBridge.m +++ b/objc/NuBridge.m @@ -86,7 +86,7 @@ NSMutableDictionary *nu_block_table = nil; -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__arm64__) #define NSRECT_SIGNATURE0 "{_NSRect={_NSPoint=dd}{_NSSize=dd}}" #define NSRECT_SIGNATURE1 "{_NSRect=\"origin\"{_NSPoint=\"x\"d\"y\"d}\"size\"{_NSSize=\"width\"d\"height\"d}}" @@ -154,8 +154,8 @@ static void initialize_ffi_types(void) ffi_type_nspoint.alignment = 0; ffi_type_nspoint.type = FFI_TYPE_STRUCT; ffi_type_nspoint.elements = malloc(3 * sizeof(ffi_type*)); -#ifdef __x86_64__ - ffi_type_nspoint.elements[0] = &ffi_type_double; +#if defined(__x86_64__) || defined(__arm64__) + ffi_type_nspoint.elements[0] = &ffi_type_double; ffi_type_nspoint.elements[1] = &ffi_type_double; #else ffi_type_nspoint.elements[0] = &ffi_type_float; @@ -167,8 +167,8 @@ static void initialize_ffi_types(void) ffi_type_nssize.alignment = 0; ffi_type_nssize.type = FFI_TYPE_STRUCT; ffi_type_nssize.elements = malloc(3 * sizeof(ffi_type*)); -#ifdef __x86_64__ - ffi_type_nssize.elements[0] = &ffi_type_double; +#if defined(__x86_64__) || defined(__arm64__) + ffi_type_nssize.elements[0] = &ffi_type_double; ffi_type_nssize.elements[1] = &ffi_type_double; #else ffi_type_nssize.elements[0] = &ffi_type_float; @@ -188,8 +188,8 @@ static void initialize_ffi_types(void) ffi_type_nsrange.alignment = 0; ffi_type_nsrange.type = FFI_TYPE_STRUCT; ffi_type_nsrange.elements = malloc(3 * sizeof(ffi_type*)); -#ifdef __x86_64__ - ffi_type_nsrange.elements[0] = &ffi_type_uint64; +#if defined(__x86_64__) || defined(__arm64__) + ffi_type_nsrange.elements[0] = &ffi_type_uint64; ffi_type_nsrange.elements[1] = &ffi_type_uint64; #else ffi_type_nsrange.elements[0] = &ffi_type_uint; @@ -229,8 +229,8 @@ static char get_typeChar_from_typeString(const char *typeString) case 's': return &ffi_type_sshort; case 'I': return &ffi_type_uint; case 'i': return &ffi_type_sint; -#ifdef __x86_64__ - case 'L': return &ffi_type_ulong; +#if defined(__x86_64__) || defined(__arm64__) + case 'L': return &ffi_type_ulong; case 'l': return &ffi_type_slong; #else case 'L': return &ffi_type_uint; @@ -483,7 +483,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type case 'c': #endif { - if (nu_value == [NSNull null]) { + if (nu_value == Nu__null) { *((int *) objc_value) = 0; return NO; } @@ -512,7 +512,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type #endif case 'L': { - if (nu_value == [NSNull null]) { + if (nu_value == Nu__null) { *((unsigned long *) objc_value) = 0; return NO; } @@ -521,7 +521,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type } case 'l': { - if (nu_value == [NSNull null]) { + if (nu_value == Nu__null) { *((long *) objc_value) = 0; return NO; } @@ -530,7 +530,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type } case 'Q': { - if (nu_value == [NSNull null]) { + if (nu_value == Nu__null) { *((unsigned long long *) objc_value) = 0; return NO; } @@ -539,7 +539,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type } case 'q': { - if (nu_value == [NSNull null]) { + if (nu_value == Nu__null) { *((long long *) objc_value) = 0; return NO; } @@ -556,6 +556,15 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type *((float *) objc_value) = (float) [nu_value doubleValue]; return NO; } + case 'B': + { + // if (nu_value == Nu__null) { + // *((BOOL *) objc_value) = (BOOL) 0; + // } else { + *((BOOL *) objc_value) = (BOOL) [nu_value boolValue]; + //} + return NO; + } case 'v': { return NO; @@ -563,11 +572,11 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type case ':': { // selectors must be strings (symbols could be ok too...) - if (!nu_value || (nu_value == [NSNull null])) { + if (!nu_value || (nu_value == Nu__null)) { *((SEL *) objc_value) = 0; return NO; } - const char *selectorName = [nu_value cStringUsingEncoding:NSUTF8StringEncoding]; + const char *selectorName = [nu_value UTF8String]; if (selectorName) { *((SEL *) objc_value) = sel_registerName(selectorName); return NO; @@ -588,7 +597,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type !strcmp(typeString, CGRECT_SIGNATURE2) ) { NSRect *rect = (NSRect *) objc_value; - id cursor = nu_value; + id cursor = nu_value; rect->origin.x = (CGFloat) [[cursor car] doubleValue]; cursor = [cursor cdr]; rect->origin.y = (CGFloat) [[cursor car] doubleValue]; cursor = [cursor cdr]; rect->size.width = (CGFloat) [[cursor car] doubleValue]; cursor = [cursor cdr]; @@ -638,7 +647,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type case '^': { - if (!nu_value || (nu_value == [NSNull null])) { + if (!nu_value || (nu_value == Nu__null)) { *((char ***) objc_value) = NULL; return NO; } @@ -650,7 +659,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type char **array = (char **) malloc (array_size * sizeof(char *)); int i; for (i = 0; i < array_size; i++) { - array[i] = strdup([[nu_value objectAtIndex:i] cStringUsingEncoding:NSUTF8StringEncoding]); + array[i] = strdup([[nu_value objectAtIndex:i] UTF8String]); } *((char ***) objc_value) = array; return NO; @@ -681,7 +690,7 @@ int set_objc_value_from_nu_value(void *objc_value, id nu_value, const char *type case '*': { - *((char **) objc_value) = (char*)[[nu_value stringValue] cStringUsingEncoding:NSUTF8StringEncoding]; + *((char **) objc_value) = (char*)[[nu_value stringValue] UTF8String]; return NO; } @@ -710,12 +719,12 @@ id get_nu_value_from_objc_value(void *objc_value, const char *typeString) switch(typeChar) { case 'v': { - return [NSNull null]; + return Nu__null; } case '@': { id result = *((id *)objc_value); - return result ? result : (id)[NSNull null]; + return result ? result : Nu__null; } case '#': { @@ -737,7 +746,7 @@ id get_nu_value_from_objc_value(void *objc_value, const char *typeString) #endif case 'i': { - return [NSNumber numberWithInt:*((int *)objc_value)]; + return @(*((int *)objc_value)); } #ifndef __ppc__ case 'C': @@ -818,10 +827,10 @@ id get_nu_value_from_objc_value(void *objc_value, const char *typeString) NSRange *range = (NSRange *)objc_value; NuCell *list = [[[NuCell alloc] init] autorelease]; id cursor = list; - [cursor setCar:[NSNumber numberWithInteger:range->location]]; + [cursor setCar:@(range->location)]; [cursor setCdr:[[[NuCell alloc] init] autorelease]]; cursor = [cursor cdr]; - [cursor setCar:[NSNumber numberWithInteger:range->length]]; + [cursor setCar:@(range->length)]; return list; } else if ( @@ -865,15 +874,15 @@ id get_nu_value_from_objc_value(void *objc_value, const char *typeString) case 'B': { if (*((unsigned int *)objc_value) == 0) - return [NSNull null]; + return @0; else - return [NSNumber numberWithInt:1]; + return @1; } case '^': { if (!strcmp(typeString, "^v")) { if (*((unsigned long *)objc_value) == 0) - return [NSNull null]; + return Nu__null; else { id nupointer = [[[NuPointer alloc] init] autorelease]; [nupointer setPointer:*((void **)objc_value)]; @@ -890,15 +899,15 @@ id get_nu_value_from_objc_value(void *objc_value, const char *typeString) // CGImageRef is one. As we find others, we can add them here. else if (!strcmp(typeString, "^{CGImage=}")) { id result = *((id *)objc_value); - return result ? result : (id)[NSNull null]; + return result ? result : Nu__null; } else if (!strcmp(typeString, "^{CGColor=}")) { id result = *((id *)objc_value); - return result ? result : (id)[NSNull null]; + return result ? result : Nu__null; } else { if (*((unsigned long *)objc_value) == 0) - return [NSNull null]; + return Nu__null; else { id nupointer = [[[NuPointer alloc] init] autorelease]; [nupointer setPointer:*((void **)objc_value)]; @@ -906,11 +915,11 @@ id get_nu_value_from_objc_value(void *objc_value, const char *typeString) return nupointer; } } - return [NSNull null]; + return Nu__null; } default: NSLog (@"UNIMPLEMENTED: unable to wrap object of type %s", typeString); - return [NSNull null]; + return Nu__null; } } @@ -959,7 +968,7 @@ id nu_calling_objc_method_handler(id target, Method m, NSMutableArray *args) // ensure that methods declared to return void always return void. char return_type_buffer[BUFSIZE]; method_getReturnType(m, return_type_buffer, BUFSIZE); - return (!strcmp(return_type_buffer, "v")) ? (id)[NSNull null] : result; + return (!strcmp(return_type_buffer, "v")) ? Nu__null : result; } id result; @@ -967,7 +976,7 @@ id nu_calling_objc_method_handler(id target, Method m, NSMutableArray *args) NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; SEL s = method_getName(m); - result = [NSNull null]; + result = Nu__null; // dynamically construct the method call @@ -1184,10 +1193,12 @@ static void objc_calling_nu_method_handler(ffi_cif* cif, void* returnvalue, void static IMP construct_method_handler(SEL sel, NuBlock *block, const char *signature) { char **userdata = generate_userdata(sel, block, signature); - IMP imp = [NuHandlerWarehouse handlerWithSelector:sel block:block signature:signature userdata:userdata]; +#if !TARGET_OS_IPHONE + IMP imp = [NuHandlerWarehouse handlerWithSelector:sel block:block signature:signature userdata:userdata]; if (imp) { return imp; } +#endif int argument_count = 0; while (userdata[argument_count] != 0) argument_count++; #if 0 @@ -1211,8 +1222,13 @@ static IMP construct_method_handler(SEL sel, NuBlock *block, const char *signatu NSLog(@"unable to prepare closure for signature %s (ffi_prep_cif failed)", signature); return NULL; } - ffi_closure *closure = (ffi_closure *)mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - if (closure == (ffi_closure *) -1) { +#if TARGET_OS_IPHONE + void* funcPtr; + ffi_closure *closure = ffi_closure_alloc(sizeof(ffi_closure), &funcPtr); +#else + ffi_closure *closure = (ffi_closure *)mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); +#endif + if (closure == (ffi_closure *) -1) { NSLog(@"unable to prepare closure for signature %s (mmap failed with error %d)", signature, errno); return NULL; } @@ -1220,21 +1236,29 @@ static IMP construct_method_handler(SEL sel, NuBlock *block, const char *signatu NSLog(@"unable to prepare closure for signature %s (could not allocate memory for closure)", signature); return NULL; } - if (ffi_prep_closure(closure, cif, objc_calling_nu_method_handler, userdata) != FFI_OK) { - NSLog(@"unable to prepare closure for signature %s (ffi_prep_closure failed)", signature); - return NULL; - } - if (mprotect(closure, sizeof(closure), PROT_READ | PROT_EXEC) == -1) { - NSLog(@"unable to prepare closure for signature %s (mprotect failed with error %d)", signature, errno); - return NULL; - } - return (IMP) closure; +#if TARGET_OS_IPHONE + if (ffi_prep_closure_loc(closure, cif, objc_calling_nu_method_handler, userdata, funcPtr) != FFI_OK) { +#else + if (ffi_prep_closure(closure, cif, objc_calling_nu_method_handler, userdata) != FFI_OK) { +#endif + NSLog(@"unable to prepare closure for signature %s (ffi_prep_closure failed)", signature); + return NULL; + } +#if TARGET_OS_IPHONE + return funcPtr; +#else + if (mprotect(closure, sizeof(closure), PROT_READ | PROT_EXEC) == -1) { + NSLog(@"unable to prepare closure for signature %s (mprotect failed with error %d)", signature, errno); + return NULL; + } + return (void*)closure; +#endif } id add_method_to_class(Class c, NSString *methodName, NSString *signature, NuBlock *block) { - const char *method_name_str = [methodName cStringUsingEncoding:NSUTF8StringEncoding]; - const char *signature_str = [signature cStringUsingEncoding:NSUTF8StringEncoding]; + const char *method_name_str = [methodName UTF8String]; + const char *signature_str = [signature UTF8String]; SEL selector = sel_registerName(method_name_str); //NuSymbolTable *symbolTable = [[block context] objectForKey:SYMBOLS_KEY]; @@ -1243,7 +1267,7 @@ id add_method_to_class(Class c, NSString *methodName, NSString *signature, NuBlo IMP imp = construct_method_handler(selector, block, signature_str); if (imp == NULL) { NSLog(@"failed to construct handler for %s(%s)", method_name_str, signature_str); - return [NSNull null]; + return Nu__null; } // save the block in a hash table keyed by the imp. @@ -1251,13 +1275,10 @@ id add_method_to_class(Class c, NSString *methodName, NSString *signature, NuBlo if (!nu_block_table) nu_block_table = [[NSMutableDictionary alloc] init]; // watch for problems caused by these ugly casts... [nu_block_table setObject:block forKey:[NSNumber numberWithUnsignedLong:(unsigned long) imp]]; -#if !TARGET_OS_IPHONE - [[NSGarbageCollector defaultCollector] disableCollectorForPointer: block]; -#endif // insert the method handler in the class method table nu_class_replaceMethod(c, selector, imp, signature_str); //NSLog(@"setting handler for %s(%s) in class %s", method_name_str, signature_str, class_getName(c)); - return [NSNull null]; + return Nu__null; } @@ -1347,7 +1368,7 @@ static void prepare_symbols(NuSymbolTable *symbolTable) [modifiers addObject:@"r"]; } else if (cursor_car == void_symbol) { - if (![cursor cdr] || ([cursor cdr] == [NSNull null])) { + if (![cursor cdr] || ([cursor cdr] == Nu__null)) { if (modifiers) [signature appendString:[[modifiers sortedArrayUsingSelector:@selector(compare:)] componentsJoinedByString:@""]]; [signature appendString:@"v"]; @@ -1360,7 +1381,7 @@ static void prepare_symbols(NuSymbolTable *symbolTable) } } else if (cursor_car == id_symbol) { - if (![cursor cdr] || ([cursor cdr] == [NSNull null])) { + if (![cursor cdr] || ([cursor cdr] == Nu__null)) { if (modifiers) [signature appendString:[[modifiers sortedArrayUsingSelector:@selector(compare:)] componentsJoinedByString:@""]]; [signature appendString:@"@"]; @@ -1457,17 +1478,17 @@ id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDictionary *co { NuSymbolTable *symbolTable = [context objectForKey:SYMBOLS_KEY]; - id returnType = [NSNull null]; + id returnType = Nu__null; id selector = [[[NuCell alloc] init] autorelease]; - id argumentTypes = [NSNull null]; - id argumentNames = [NSNull null]; + id argumentTypes = Nu__null; + id argumentNames = Nu__null; id isSymbol = [symbolTable symbolWithString:@"is"]; id cursor = cdr; id selector_cursor = nil; id argumentTypes_cursor = nil; id argumentNames_cursor = nil; - if (cursor && (cursor != [NSNull null]) && ([cursor car] != isSymbol)) { + if (cursor && (cursor != Nu__null) && ([cursor car] != isSymbol)) { // scan the return type if (![[cursor car] atom]) { returnType = [cursor car] ; @@ -1477,10 +1498,10 @@ id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDictionary *co // The return type specifier must be a list (in parens). If it is missing, leave it as null. returnType = Nu__null; } - if (cursor && (cursor != [NSNull null])) { + if (cursor && (cursor != Nu__null)) { [selector setCar:[cursor car]]; // scan a part of the selector cursor = [cursor cdr]; - if (cursor && (cursor != [NSNull null])) { + if (cursor && (cursor != Nu__null)) { if ([cursor car] != isSymbol) { argumentTypes = [[[NuCell alloc] init] autorelease]; argumentNames = [[[NuCell alloc] init] autorelease]; @@ -1489,10 +1510,10 @@ id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDictionary *co [argumentTypes setCar:[cursor car]]; cursor = [cursor cdr]; } - if (cursor && (cursor != [NSNull null])) { + if (cursor && (cursor != Nu__null)) { [argumentNames setCar:[cursor car]]; cursor = [cursor cdr]; - if (cursor && (cursor != [NSNull null])) { + if (cursor && (cursor != Nu__null)) { selector_cursor = selector; argumentTypes_cursor = argumentTypes; argumentNames_cursor = argumentNames; @@ -1503,7 +1524,7 @@ id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDictionary *co } } // scan each remaining part of the selector - while (cursor && (cursor != [NSNull null]) && ([cursor car] != isSymbol)) { + while (cursor && (cursor != Nu__null) && ([cursor car] != isSymbol)) { [selector_cursor setCdr:[[[NuCell alloc] init] autorelease]]; [argumentTypes_cursor setCdr:[[[NuCell alloc] init] autorelease]]; [argumentNames_cursor setCdr:[[[NuCell alloc] init] autorelease]]; @@ -1513,20 +1534,20 @@ id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDictionary *co [selector_cursor setCar:[cursor car]]; cursor = [cursor cdr]; - if (cursor && (cursor != [NSNull null])) { + if (cursor && (cursor != Nu__null)) { if (![[cursor car] atom]) { // the argument type specifier must be a list. If it is missing, we'll use a default. [argumentTypes_cursor setCar:[cursor car]]; cursor = [cursor cdr]; } - if (cursor && (cursor != [NSNull null])) { + if (cursor && (cursor != Nu__null)) { [argumentNames_cursor setCar:[cursor car]]; cursor = [cursor cdr]; } } } - if (cursor && (cursor != [NSNull null])) { + if (cursor && (cursor != Nu__null)) { //NSLog(@"selector: %@", [selector stringValue]); //NSLog(@"argument names: %@", [argumentNames stringValue]); //NSLog(@"argument types:%@", [argumentTypes stringValue]); @@ -1538,7 +1559,7 @@ id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDictionary *co // combine the selectors into the method name NSMutableString *methodName = [[[NSMutableString alloc] init] autorelease]; selector_cursor = selector; - while (selector_cursor && (selector_cursor != [NSNull null])) { + while (selector_cursor && (selector_cursor != Nu__null)) { [methodName appendString:[[selector_cursor car] stringValue]]; selector_cursor = [selector_cursor cdr]; } @@ -1547,7 +1568,7 @@ id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDictionary *co if ((returnType == Nu__null) || ([argumentTypes length] < [argumentNames length])) { // look up the signature - SEL selector = sel_registerName([methodName cStringUsingEncoding:NSUTF8StringEncoding]); + SEL selector = sel_registerName([methodName UTF8String]); NSMethodSignature *methodSignature = [classToExtend instanceMethodSignatureForSelector:selector]; if (!methodSignature) @@ -1574,7 +1595,7 @@ id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDictionary *co // then describe the arguments argumentTypes_cursor = argumentTypes; - while (argumentTypes_cursor && (argumentTypes_cursor != [NSNull null])) { + while (argumentTypes_cursor && (argumentTypes_cursor != Nu__null)) { id typeIdentifier = [argumentTypes_cursor car]; [signature appendString:signature_for_identifier(typeIdentifier, symbolTable)]; argumentTypes_cursor = [argumentTypes_cursor cdr]; diff --git a/objc/NuBridgeSupport.m b/objc/NuBridgeSupport.m index ef11781..0294191 100644 --- a/objc/NuBridgeSupport.m +++ b/objc/NuBridgeSupport.m @@ -8,6 +8,8 @@ #import "NuBridgeSupport.h" #import "NuInternals.h" +#import "NSFileManager+Nu.h" + #pragma mark - NuBridgeSupport.m @@ -29,7 +31,7 @@ @implementation NuBridgeSupport + (void)importLibrary:(NSString *) libraryPath { //NSLog(@"importing library %@", libraryPath); - dlopen([libraryPath cStringUsingEncoding:NSUTF8StringEncoding], RTLD_LAZY | RTLD_GLOBAL); + dlopen([libraryPath UTF8String], RTLD_LAZY | RTLD_GLOBAL); } + (void)importFramework:(NSString *) framework fromPath:(NSString *) path intoDictionary:(NSMutableDictionary *) BridgeSupport @@ -74,7 +76,7 @@ + (void)importFramework:(NSString *) framework fromPath:(NSString *) path intoDi forKey:[[node attributeForName:@"name"] stringValue]]; } else if ([[node name] isEqual:@"enum"]) { - [enums setValue:[NSNumber numberWithInt:[[[node attributeForName:@"value"] stringValue] intValue]] + [enums setValue:@([[[node attributeForName:@"value"] stringValue] intValue]) forKey:[[node attributeForName:@"name"] stringValue]]; } else if ([[node name] isEqual:@"function"]) { @@ -175,4 +177,4 @@ + (NSString *) stringValue } @end -#endif \ No newline at end of file +#endif diff --git a/objc/NuBridgedBlock.m b/objc/NuBridgedBlock.m index d38d5dd..d8273c3 100644 --- a/objc/NuBridgedBlock.m +++ b/objc/NuBridgedBlock.m @@ -60,12 +60,12 @@ -(void)dealloc //the caller gets ownership of the block static id make_cblock (NuBlock *nuBlock, NSString *signature) { - void *funcptr = construct_block_handler(nuBlock, [signature UTF8String]); + void(*funcptr)(void) = construct_block_handler(nuBlock, [signature UTF8String]); int i = 0xFFFF; void(^cBlock)(void)=[^(void){printf("%i",i);} copy]; -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__arm64__) /* this is what happens when a block is called on x86 64 mov %rax,-0x18(%rbp) //the pointer to the block object is in rax mov -0x18(%rbp),%rax @@ -74,7 +74,7 @@ static id make_cblock (NuBlock *nuBlock, NSString *signature) callq *%rax */ //2*(sizeof(void*)) = 0x10 - *((void **)(id)cBlock + 2) = (void *)funcptr; + *((void **)(id)cBlock + 2) = (void *)funcptr; #else /* this is what happens when a block is called on x86 32 mov %eax,-0x14(%ebp) //the pointer to the block object is in eax @@ -192,8 +192,13 @@ static void objc_calling_nu_block_handler(ffi_cif* cif, void* returnvalue, void* NSLog(@"unable to prepare closure for signature %s (ffi_prep_cif failed)", signature); return NULL; } - ffi_closure *closure = (ffi_closure *)mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - if (closure == (ffi_closure *) -1) { +#if TARGET_OS_IPHONE + void* funcPtr; + ffi_closure *closure = ffi_closure_alloc(sizeof(ffi_closure), &funcPtr); +#else + ffi_closure *closure = (ffi_closure *)mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); +#endif + if (closure == (ffi_closure *) -1) { NSLog(@"unable to prepare closure for signature %s (mmap failed with error %d)", signature, errno); return NULL; } @@ -201,15 +206,23 @@ static void objc_calling_nu_block_handler(ffi_cif* cif, void* returnvalue, void* NSLog(@"unable to prepare closure for signature %s (could not allocate memory for closure)", signature); return NULL; } +#if TARGET_OS_IPHONE + if (ffi_prep_closure_loc(closure, cif, objc_calling_nu_block_handler, userdata, funcPtr) != FFI_OK) { +#else if (ffi_prep_closure(closure, cif, objc_calling_nu_block_handler, userdata) != FFI_OK) { +#endif NSLog(@"unable to prepare closure for signature %s (ffi_prep_closure failed)", signature); return NULL; } +#if TARGET_OS_IPHONE + return funcPtr; +#else if (mprotect(closure, sizeof(closure), PROT_READ | PROT_EXEC) == -1) { NSLog(@"unable to prepare closure for signature %s (mprotect failed with error %d)", signature, errno); return NULL; } return (void*)closure; +#endif } #endif //__BLOCKS__ \ No newline at end of file diff --git a/objc/NuBridgedConstant.m b/objc/NuBridgedConstant.m index bf1eea0..ba845b4 100644 --- a/objc/NuBridgedConstant.m +++ b/objc/NuBridgedConstant.m @@ -14,7 +14,7 @@ @implementation NuBridgedConstant + (id) constantWithName:(NSString *) name signature:(NSString *) signature { - const char *constant_name = [name cStringUsingEncoding:NSUTF8StringEncoding]; + const char *constant_name = [name UTF8String]; void *constant = dlsym(RTLD_DEFAULT, constant_name); if (!constant) { NSLog(@"%s", dlerror()); @@ -22,7 +22,7 @@ + (id) constantWithName:(NSString *) name signature:(NSString *) signature NSLog(@"In Xcode, check the 'Preserve Private External Symbols' checkbox."); return nil; } - return get_nu_value_from_objc_value(constant, [signature cStringUsingEncoding:NSUTF8StringEncoding]); + return get_nu_value_from_objc_value(constant, [signature UTF8String]); } @end diff --git a/objc/NuBridgedFunction.m b/objc/NuBridgedFunction.m index 8feb3d6..afce34f 100644 --- a/objc/NuBridgedFunction.m +++ b/objc/NuBridgedFunction.m @@ -29,8 +29,8 @@ - (void) dealloc - (NuBridgedFunction *) initWithName:(NSString *)n signature:(NSString *)s { - name = strdup([n cStringUsingEncoding:NSUTF8StringEncoding]); - signature = strdup([s cStringUsingEncoding:NSUTF8StringEncoding]); + name = strdup([n UTF8String]); + signature = strdup([s UTF8String]); function = dlsym(RTLD_DEFAULT, name); if (!function) { [NSException raise:@"NuCantFindBridgedFunction" @@ -43,7 +43,7 @@ - (NuBridgedFunction *) initWithName:(NSString *)n signature:(NSString *)s + (NuBridgedFunction *) functionWithName:(NSString *)name signature:(NSString *)signature { - const char *function_name = [name cStringUsingEncoding:NSUTF8StringEncoding]; + const char *function_name = [name UTF8String]; void *function = dlsym(RTLD_DEFAULT, function_name); if (!function) { [NSException raise:@"NuCantFindBridgedFunction" @@ -90,7 +90,7 @@ - (id) evalWithArguments:(id) cdr context:(NSMutableDictionary *) context int status = ffi_prep_cif(cif, FFI_DEFAULT_ABI, argument_count, result_type, argument_types); if (status != FFI_OK) { NSLog (@"failed to prepare cif structure"); - return [NSNull null]; + return Nu__null; } id arg_cursor = cdr; diff --git a/objc/NuCell.m b/objc/NuCell.m index 1176c9a..7f7e929 100644 --- a/objc/NuCell.m +++ b/objc/NuCell.m @@ -345,7 +345,7 @@ - (id) eachWithIndex:(id) block int i = 0; while (cursor && (cursor != Nu__null)) { [args setCar:[cursor car]]; - [[args cdr] setCar:[NSNumber numberWithInt:i]]; + [[args cdr] setCar:@(i)]; [block evalWithArguments:args context:Nu__null]; cursor = [cursor cdr]; i++; diff --git a/objc/NuClass.m b/objc/NuClass.m index 35432a5..49f3276 100644 --- a/objc/NuClass.m +++ b/objc/NuClass.m @@ -29,7 +29,7 @@ @implementation NuClass + (NuClass *) classWithName:(NSString *)string { - const char *name = [string cStringUsingEncoding:NSUTF8StringEncoding]; + const char *name = [string UTF8String]; Class class = objc_getClass(name); if (class) { return [[[self alloc] initWithClass:class] autorelease]; @@ -51,7 +51,7 @@ + (NuClass *) classWithClass:(Class) class - (id) initWithClassNamed:(NSString *) string { - const char *name = [string cStringUsingEncoding:NSUTF8StringEncoding]; + const char *name = [string UTF8String]; Class class = objc_getClass(name); return [self initWithClass: class]; } @@ -159,7 +159,7 @@ - (NSComparisonResult) compare:(NuClass *) anotherClass - (NuMethod *) classMethodWithName:(NSString *) methodName { - const char *methodNameString = [methodName cStringUsingEncoding:NSUTF8StringEncoding]; + const char *methodNameString = [methodName UTF8String]; NuMethod *method = Nu__null; unsigned int method_count; Method *method_list = class_copyMethodList(object_getClass([self wrappedClass]), &method_count); @@ -175,7 +175,7 @@ - (NuMethod *) classMethodWithName:(NSString *) methodName - (NuMethod *) instanceMethodWithName:(NSString *) methodName { - const char *methodNameString = [methodName cStringUsingEncoding:NSUTF8StringEncoding]; + const char *methodNameString = [methodName UTF8String]; NuMethod *method = Nu__null; unsigned int method_count; Method *method_list = class_copyMethodList([self wrappedClass], &method_count); @@ -204,7 +204,7 @@ - (id) addClassMethod:(NSString *)methodName signature:(NSString *)signature bod - (id) addInstanceVariable:(NSString *)variableName signature:(NSString *)signature { //NSLog(@"adding instance variable %@", variableName); - nu_class_addInstanceVariable_withSignature(c, [variableName cStringUsingEncoding:NSUTF8StringEncoding], [signature cStringUsingEncoding:NSUTF8StringEncoding]); + nu_class_addInstanceVariable_withSignature(c, [variableName UTF8String], [signature UTF8String]); return Nu__null; } @@ -239,6 +239,9 @@ - (void) registerClass if (isRegistered == NO) { objc_registerClassPair(c); isRegistered = YES; + if ([class_getSuperclass(self->c) respondsToSelector:@selector(inheritedByClass:)]) { + [class_getSuperclass(self->c) inheritedByClass:self]; + } } } @@ -260,13 +263,13 @@ - (NSArray *) instanceVariableNames { - (BOOL) addPropertyWithName:(NSString *) name { const objc_property_attribute_t attributes[10]; unsigned int attributeCount = 0; - return class_addProperty(c, [name cStringUsingEncoding:NSUTF8StringEncoding], + return class_addProperty(c, [name UTF8String], attributes, attributeCount); } - (NuProperty *) propertyWithName:(NSString *) name { - objc_property_t property = class_getProperty(c, [name cStringUsingEncoding:NSUTF8StringEncoding]); + objc_property_t property = class_getProperty(c, [name UTF8String]); return [NuProperty propertyWithProperty:(objc_property_t) property]; } diff --git a/objc/NuEnumerable.m b/objc/NuEnumerable.m index 84d7f19..1933a8e 100644 --- a/objc/NuEnumerable.m +++ b/objc/NuEnumerable.m @@ -59,7 +59,7 @@ - (id) eachWithIndex:(NuBlock *) block @try { [args setCar:object]; - [[args cdr] setCar:[NSNumber numberWithInt:i]]; + [[args cdr] setCar:@(i)]; [block evalWithArguments:args context:nil]; } @catch (NuBreakException *exception) { @@ -157,7 +157,7 @@ - (NSArray *) mapWithIndex:(id) callable int i = 0; while ((object = [enumerator nextObject])) { [args setCar:object]; - [[args cdr] setCar:[NSNumber numberWithInt:i]]; + [[args cdr] setCar:@(i)]; [results addObject:[callable evalWithArguments:args context:nil]]; i++; } diff --git a/objc/NuHandler.h b/objc/NuHandler.h index db3ca5e..06b40f5 100644 --- a/objc/NuHandler.h +++ b/objc/NuHandler.h @@ -6,6 +6,9 @@ // // +#if !TARGET_OS_IPHONE + + #import @class NuBlock; @@ -18,6 +21,7 @@ struct nu_handler_description char **description; }; + /*! @class NuHandlerWarehouse @abstract Internal class used to store and vend method implementations on platforms that don't allow them to be constructed at runtime. @@ -32,4 +36,4 @@ static void nu_handler(void *return_value, id receiver, va_list ap); - +#endif diff --git a/objc/NuHandler.m b/objc/NuHandler.m index 1510b21..472e92c 100644 --- a/objc/NuHandler.m +++ b/objc/NuHandler.m @@ -4,7 +4,7 @@ // // Created by Tim Burks on 4/24/16. // - +#if !TARGET_OS_IPHONE #import "NuHandler.h" #import "NuCell.h" #import "NuInternals.h" @@ -164,8 +164,8 @@ static IMP handler_returning_void(void *userdata) { }); } -#define MAKE_HANDLER_WITH_TYPE(type) \ -static IMP handler_returning_ ## type (void* userdata) \ +#define MAKE_HANDLER_WITH_TYPE_AND_SUFFIX(type, suffix) \ +static IMP handler_returning_ ## suffix (void* userdata) \ { \ return imp_implementationWithBlock(^(id receiver, ...) { \ struct nu_handler_description description; \ @@ -178,12 +178,21 @@ static IMP handler_returning_void(void *userdata) { return result; \ }); \ } +#define MAKE_HANDLER_WITH_TYPE(type) MAKE_HANDLER_WITH_TYPE_AND_SUFFIX(type, type) MAKE_HANDLER_WITH_TYPE(id) MAKE_HANDLER_WITH_TYPE(int) -MAKE_HANDLER_WITH_TYPE(bool) MAKE_HANDLER_WITH_TYPE(float) MAKE_HANDLER_WITH_TYPE(double) +MAKE_HANDLER_WITH_TYPE_AND_SUFFIX(bool,bool) //bool is not passed right to the inner macro? + +/** + * Newly added for 64bit + * Do we need Q and L as well? + */ +MAKE_HANDLER_WITH_TYPE(long) +MAKE_HANDLER_WITH_TYPE_AND_SUFFIX(long long,long_long) + #ifdef DARWIN MAKE_HANDLER_WITH_TYPE(CGRect) MAKE_HANDLER_WITH_TYPE(CGPoint) @@ -231,6 +240,12 @@ + (IMP) handlerWithSelector:(SEL)sel block:(NuBlock *)block signature:(const cha else if ([returnType isEqualToString:@"d"]) { return handler_returning_double(userdata); } + else if ([returnType isEqualToString:@"l"]) { + return handler_returning_long(userdata); + } + else if ([returnType isEqualToString:@"q"]) { + return handler_returning_long_long(userdata); + } #ifdef DARWIN else if ([returnType isEqualToString:@"{CGRect={CGPoint=ff}{CGSize=ff}}"]) { return handler_returning_CGRect(userdata); @@ -282,3 +297,4 @@ + (IMP) handlerWithSelector:(SEL)sel block:(NuBlock *)block signature:(const cha } @end +#endif \ No newline at end of file diff --git a/objc/NuInternals.h b/objc/NuInternals.h index d1e603e..40aa552 100644 --- a/objc/NuInternals.h +++ b/objc/NuInternals.h @@ -26,7 +26,7 @@ extern NSMutableDictionary *nu_block_table; -id Nu__null; +extern id Nu__null; // Execution contexts are NSMutableDictionaries that are keyed by // symbols. Here we define two string keys that allow us to store diff --git a/objc/NuMacro.m b/objc/NuMacro.m index f6b49c4..020eea6 100644 --- a/objc/NuMacro.m +++ b/objc/NuMacro.m @@ -138,7 +138,7 @@ - (id) body:(NuCell *) oldBody withGensymPrefix:(NSString *) prefix symbolTable: - (id) expandUnquotes:(id) oldBody withContext:(NSMutableDictionary *) context { NuSymbolTable *symbolTable = [context objectForKey:SYMBOLS_KEY]; - if (oldBody == [NSNull null]) + if (oldBody == Nu__null) return oldBody; id unquote = [symbolTable symbolWithString:@"unquote"]; id car = [oldBody car]; diff --git a/objc/NuMarkupOperator.m b/objc/NuMarkupOperator.m index c1477cb..b390055 100644 --- a/objc/NuMarkupOperator.m +++ b/objc/NuMarkupOperator.m @@ -101,7 +101,7 @@ - (id) initWithTag:(NSString *) _tag prefix:(NSString *) _prefix contents:(id) _ prefix = @""; } [prefix retain]; - contents = _contents ? _contents : [NSNull null]; + contents = _contents ? _contents : Nu__null; [contents retain]; empty = [voidHTMLElements containsObject:tag]; return self; @@ -146,27 +146,27 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context } for (int i = 0; i < 2; i++) { id cursor = (i == 0) ? contents : cdr; - while (cursor && (cursor != [NSNull null])) { + while (cursor && (cursor != Nu__null)) { id item = [cursor car]; if ([item isKindOfClass:[NuSymbol class]] && [item isLabel]) { cursor = [cursor cdr]; - if (cursor && (cursor != [NSNull null])) { + if (cursor && (cursor != Nu__null)) { id value = [[cursor car] evalWithContext:context]; id attributeName = [[item labelName] stringByReplacingOccurrencesOfString:@"=" withString:@":"]; - if ([value isEqual:[NSNull null]]) { + if ([value isEqual:Nu__null]) { // omit attributes that are "false" } else if ([value isEqual:t_symbol]) { // boolean attributes with "true" are written without values [attributes appendFormat:@" %@", attributeName]; } else { - id stringValue = [value isEqual:[NSNull null]] ? @"" : [value stringValue]; + id stringValue = [value isEqual:Nu__null] ? @"" : [value stringValue]; [attributes appendFormat:@" %@=\"%@\"", attributeName, stringValue]; } } } else { id evaluatedItem = [item evalWithContext:context]; - if (!evaluatedItem || (evaluatedItem == [NSNull null])) { + if (!evaluatedItem || (evaluatedItem == Nu__null)) { // do nothing } else if ([evaluatedItem isKindOfClass:[NSString class]]) { @@ -174,7 +174,7 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context } else if ([evaluatedItem isKindOfClass:[NSArray class]]) { NSArray *evaluatedArray = (NSArray *) evaluatedItem; - int max = [evaluatedArray count]; + NSUInteger max = [evaluatedArray count]; for (int i = 0; i < max; i++) { id objectAtIndex = [evaluatedArray objectAtIndex:i]; [body appendString:[objectAtIndex stringValue]]; @@ -184,7 +184,7 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context [body appendString:[evaluatedItem stringValue]]; } } - if (cursor && (cursor != [NSNull null])) + if (cursor && (cursor != Nu__null)) cursor = [cursor cdr]; } } diff --git a/objc/NuMethod.m b/objc/NuMethod.m index b5eee66..65752b5 100644 --- a/objc/NuMethod.m +++ b/objc/NuMethod.m @@ -32,7 +32,7 @@ - (id) initWithMethod:(Method) method - (NSString *) name { - return m ? [NSString stringWithCString:(sel_getName(method_getName(m))) encoding:NSUTF8StringEncoding] : (NSString *) [NSNull null]; + return m ? [NSString stringWithCString:(sel_getName(method_getName(m))) encoding:NSUTF8StringEncoding] : (NSString *) Nu__null; } - (int) argumentCount diff --git a/objc/NuOperators.m b/objc/NuOperators.m index 8e380ea..b400942 100644 --- a/objc/NuOperators.m +++ b/objc/NuOperators.m @@ -17,6 +17,8 @@ #import "NuBridge.h" #import "NuBridgedFunction.h" #import "NuClass.h" +#include +#import "NSString+Nu.h" #if TARGET_OS_IPHONE #import @@ -1266,7 +1268,7 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context product %= [[[cursor car] evalWithContext:context] intValue]; cursor = [cursor cdr]; } - return [NSNumber numberWithInt:product]; + return @(product); } @end @@ -1509,7 +1511,7 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context } else { #endif - printf("%s\n", [string cStringUsingEncoding:NSUTF8StringEncoding]); + printf("%s\n", [string UTF8String]); #if !TARGET_OS_IPHONE } #endif @@ -1556,7 +1558,7 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context } else { #endif - printf("%s", [string cStringUsingEncoding:NSUTF8StringEncoding]); + printf("%s", [string UTF8String]); #if !TARGET_OS_IPHONE } #endif @@ -1632,7 +1634,7 @@ id loadNuLibraryFile(NSString *nuFileName, id parser, id context, id symbolTable NSString *string = [NSString stringWithContentsOfFile:fullPath]; id value = Nu__null; if (string) { - id body = [parser parse:string asIfFromFilename:[fullPath cStringUsingEncoding:NSUTF8StringEncoding]]; + id body = [parser parse:string asIfFromFilename:[fullPath UTF8String]]; value = [body evalWithContext:context]; return [symbolTable symbolWithString:@"t"]; } @@ -1695,7 +1697,7 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context if (fileName) { NSString *string = [NSString stringWithContentsOfFile:fileName encoding:NSUTF8StringEncoding error:NULL]; if (string) { - id body = [parser parse:string asIfFromFilename:[fileName cStringUsingEncoding:NSUTF8StringEncoding]]; + id body = [parser parse:string asIfFromFilename:[fileName UTF8String]]; [body evalWithContext:context]; return [symbolTable symbolWithString:@"t"]; } @@ -1749,7 +1751,7 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context id arg_values = [[NuCell alloc] init]; id cursor = [cdr car]; - if ((cursor != [NSNull null]) && [[cursor car] atom]) { + if ((cursor != Nu__null) && [[cursor car] atom]) { [arg_names setCar:[cursor car]]; [arg_values setCar:[[cursor cdr] car]]; } @@ -1809,14 +1811,10 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context #if defined(__x86_64__) || TARGET_OS_IPHONE - newClass = objc_allocateClassPair(parentClass, [[className stringValue] cStringUsingEncoding:NSUTF8StringEncoding], 0); + newClass = objc_allocateClassPair(parentClass, [[className stringValue] UTF8String], 0); childClass = [NuClass classWithClass:newClass]; [childClass setRegistered:NO]; //NSLog(@"created class %@", [childClass name]); - // it seems dangerous to call this here. Maybe it's better to wait until the new class is registered. - if ([parentClass respondsToSelector:@selector(inheritedByClass:)]) { - [parentClass inheritedByClass:childClass]; - } if (!childClass) { // This class may have already been defined previously @@ -1922,8 +1920,8 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context cursor = [cursor cdr]; NSString *signature = signature_for_identifier(variableType, symbolTable); nu_class_addInstanceVariable_withSignature(classToExtend, - [[variableName stringValue] cStringUsingEncoding:NSUTF8StringEncoding], - [signature cStringUsingEncoding:NSUTF8StringEncoding]); + [[variableName stringValue] UTF8String], + [signature UTF8String]); //NSLog(@"adding ivar %@ with signature %@", [variableName stringValue], signature); } return Nu__null; @@ -1961,15 +1959,21 @@ @interface Nu_system_operator : NuOperator {} @implementation Nu_system_operator - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context { - id cursor = cdr; +#if TARGET_OS_IPHONE + NSLog(@"System operator currently not supported on iOS"); + //FIXME: Use NSTask + return @1; +#else + id cursor = cdr; NSMutableString *command = [NSMutableString string]; - while (cursor && (cursor != [NSNull null])) { + while (cursor && (cursor != Nu__null)) { [command appendString:[[[cursor car] evalWithContext:context] stringValue]]; cursor = [cursor cdr]; } - const char *commandString = [command cStringUsingEncoding:NSUTF8StringEncoding]; + const char *commandString = [command UTF8String]; int result = system(commandString) >> 8; // this needs an explanation - return [NSNumber numberWithInt:result]; + return @(result); +#endif } @end @@ -2006,7 +2010,7 @@ - (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context else { [NSException raise: @"NuArityError" format:@"sleep expects 1 argument, got 0"]; } - return [NSNumber numberWithInt:result]; + return @(result); } @end @@ -2390,7 +2394,7 @@ void load_builtins(NuSymbolTable *symbolTable) // set some commonly-used globals [(NuSymbol *) [symbolTable symbolWithString:@"NSUTF8StringEncoding"] - setValue:[NSNumber numberWithInt:NSUTF8StringEncoding]]; + setValue:@(NSUTF8StringEncoding)]; [(NuSymbol *) [symbolTable symbolWithString:@"NSLog"] // let's make this an operator someday setValue:[NuBridgedFunction functionWithName:@"NSLog" signature:@"v@"]]; diff --git a/objc/NuParser.m b/objc/NuParser.m index 80469f9..db383dd 100644 --- a/objc/NuParser.m +++ b/objc/NuParser.m @@ -14,6 +14,7 @@ #import "NSDictionary+Nu.h" #import "NuException.h" #import "NuCell.h" +#include #define PARSE_NORMAL 0 #define PARSE_COMMENT 1 @@ -46,7 +47,7 @@ - (int) state; - (NuCell *) root; - (NuStack *) opens; - (NSString *) stringValue; -- (const char *) cStringUsingEncoding:(NSStringEncoding) encoding; +- (const char *) UTF8String; - (id) init; - (void) openList; - (void) closeList; @@ -60,7 +61,7 @@ - (int) interact; static id atomWithString(NSString *string, NuSymbolTable *symbolTable) { - const char *cstring = [string cStringUsingEncoding:NSUTF8StringEncoding]; + const char *cstring = [string UTF8String]; char *endptr; // If the string can be converted to a long, it's an NSNumber. long lvalue = strtol(cstring, &endptr, 0); @@ -221,9 +222,9 @@ - (NSString *) stringValue return [self description]; } -- (const char *) cStringUsingEncoding:(NSStringEncoding) encoding +- (const char *) UTF8String { - return [[self stringValue] cStringUsingEncoding:encoding]; + return [[self stringValue] UTF8String]; } - (void) reset @@ -251,7 +252,7 @@ - (void) reset - (id) init { - if (Nu__null == 0) Nu__null = [NSNull null]; + if (Nu__null == 0) Nu__null = Nu__null; if ((self = [super init])) { filenum = -1; @@ -278,7 +279,7 @@ - (id) init - (void) close { // break this retain cycle so the parser can be deleted. - [context setPossiblyNullObject:[NSNull null] forKey:[symbolTable symbolWithString:@"_parser"]]; + [context setPossiblyNullObject:Nu__null forKey:[symbolTable symbolWithString:@"_parser"]]; } - (void) dealloc @@ -404,10 +405,10 @@ - (void) closeListCell --depth; if (addToCar) { - [current setCar:[NSNull null]]; + [current setCar:Nu__null]; } else { - [current setCdr:[NSNull null]]; + [current setCdr:Nu__null]; current = [stack pop]; } addToCar = false; @@ -556,7 +557,7 @@ static NSUInteger nu_parse_escape_sequences(NSString *string, NSUInteger i, NSUI -(id) parse:(NSString*)string { - if (!string) return [NSNull null]; // don't crash, at least. + if (!string) return Nu__null; // don't crash, at least. column = 0; if (state != PARSE_REGEX) @@ -574,7 +575,7 @@ -(id) parse:(NSString*)string switch(stri) { case '(': ParserDebug(@"Parser: ( %d on line %d", column, linenum); - [opens push:[NSNumber numberWithInt:column]]; + [opens push:@(column)]; parens++; if ([partial length] == 0) { [self openList]; @@ -651,7 +652,7 @@ -(id) parse:(NSString*)string // try to parse a character literal. // if that doesn't work, then interpret the quote as the quote operator. bool isACharacterLiteral = false; - int characterLiteralValue; + int characterLiteralValue = 0; if (i + 2 < imax) { if ([string characterAtIndex:i+1] != '\\') { if ([string characterAtIndex:i+2] == '\'') { @@ -693,13 +694,19 @@ -(id) parse:(NSString*)string } } if (isACharacterLiteral) { - [self addAtom:[NSNumber numberWithInt:characterLiteralValue]]; + [self addAtom:@(characterLiteralValue)]; } else { [self quoteNextElement]; } break; } + case '~': + { + [self quasiquoteEvalNextElement]; + [self quoteNextElement]; + break; + } case '`': { [self quasiquoteNextElement]; @@ -933,7 +940,7 @@ -(id) parse:(NSString*)string [partial retain]; } if ([self incomplete]) { - return [NSNull null]; + return Nu__null; } else { NuCell *expressions = root; @@ -1031,22 +1038,22 @@ - (int) interact progn = [[self parse:[NSString stringWithCString:line encoding:NSUTF8StringEncoding]] retain]; } @catch (NuException* nuException) { - printf("%s\n", [[nuException dump] cStringUsingEncoding:NSUTF8StringEncoding]); + printf("%s\n", [[nuException dump] UTF8String]); [self reset]; } @catch (id exception) { printf("%s: %s\n", - [[exception name] cStringUsingEncoding:NSUTF8StringEncoding], - [[exception reason] cStringUsingEncoding:NSUTF8StringEncoding]); + [[exception name] UTF8String], + [[exception reason] UTF8String]); [self reset]; } - if (progn && (progn != [NSNull null])) { + if (progn && (progn != Nu__null)) { id cursor = [progn cdr]; - while (cursor && (cursor != [NSNull null])) { - if ([cursor car] != [NSNull null]) { + while (cursor && (cursor != Nu__null)) { + if ([cursor car] != Nu__null) { id expression = [cursor car]; - //printf("evaluating %s\n", [[expression stringValue] cStringUsingEncoding:NSUTF8StringEncoding]); + //printf("evaluating %s\n", [[expression stringValue] UTF8String]); @try { @@ -1059,16 +1066,16 @@ - (int) interact else { stringToDisplay = [result stringValue]; } - printf("%s\n", [stringToDisplay cStringUsingEncoding:NSUTF8StringEncoding]); + printf("%s\n", [stringToDisplay UTF8String]); } } @catch (NuException* nuException) { - printf("%s\n", [[nuException dump] cStringUsingEncoding:NSUTF8StringEncoding]); + printf("%s\n", [[nuException dump] UTF8String]); } @catch (id exception) { printf("%s: %s\n", - [[exception name] cStringUsingEncoding:NSUTF8StringEncoding], - [[exception reason] cStringUsingEncoding:NSUTF8StringEncoding]); + [[exception name] UTF8String], + [[exception reason] UTF8String]); } } cursor = [cursor cdr]; diff --git a/objc/NuPointer.m b/objc/NuPointer.m index 95d9e31..a558702 100644 --- a/objc/NuPointer.m +++ b/objc/NuPointer.m @@ -57,7 +57,7 @@ - (void) allocateSpaceForTypeString:(NSString *) s if (thePointerIsMine) free(pointer); [self setTypeString:s]; - const char *type = [s cStringUsingEncoding:NSUTF8StringEncoding]; + const char *type = [s UTF8String]; while (*type && (*type != '^')) type++; if (*type) @@ -77,7 +77,7 @@ - (void) dealloc - (id) value { - const char *type = [typeString cStringUsingEncoding:NSUTF8StringEncoding]; + const char *type = [typeString UTF8String]; while (*type && (*type != '^')) type++; if (*type) diff --git a/objc/NuSuper.m b/objc/NuSuper.m index 58af9f9..906ea8a 100644 --- a/objc/NuSuper.m +++ b/objc/NuSuper.m @@ -39,7 +39,7 @@ + (NuSuper *) superWithObject:(id) o ofClass:(Class) c - (id) evalWithArguments:(id)cdr context:(NSMutableDictionary *)context { // By themselves, Objective-C objects evaluate to themselves. - if (!cdr || (cdr == [NSNull null])) + if (!cdr || (cdr == Nu__null)) return object; //NSLog(@"messaging super with %@", [cdr stringValue]); @@ -50,15 +50,15 @@ - (id) evalWithArguments:(id)cdr context:(NSMutableDictionary *)context id selector = [cursor car]; NSMutableString *selectorString = [NSMutableString stringWithString:[selector stringValue]]; cursor = [cursor cdr]; - while (cursor && (cursor != [NSNull null])) { + while (cursor && (cursor != Nu__null)) { [args addObject:[[cursor car] evalWithContext:context]]; cursor = [cursor cdr]; - if (cursor && (cursor != [NSNull null])) { + if (cursor && (cursor != Nu__null)) { [selectorString appendString:[[cursor car] stringValue]]; cursor = [cursor cdr]; } } - SEL sel = sel_getUid([selectorString cStringUsingEncoding:NSUTF8StringEncoding]); + SEL sel = sel_getUid([selectorString UTF8String]); // we're going to send the message to the handler of its superclass instead of one defined for its class. Class c = class_getSuperclass(class); @@ -77,4 +77,4 @@ - (id) evalWithArguments:(id)cdr context:(NSMutableDictionary *)context return result; } -@end \ No newline at end of file +@end diff --git a/objc/NuSwizzles.m b/objc/NuSwizzles.m index 5791fb3..4e00083 100644 --- a/objc/NuSwizzles.m +++ b/objc/NuSwizzles.m @@ -20,7 +20,7 @@ @implementation NSCFDictionarySwizzles - (void)nuSetObject:(id)anObject forKey:(id)aKey { - [self nuSetObject:((anObject == nil) ? (id)[NSNull null] : anObject) forKey:aKey]; + [self nuSetObject:((anObject == nil) ? (id)Nu__null : anObject) forKey:aKey]; } @end @@ -32,17 +32,17 @@ @implementation NSCFArraySwizzles - (void)nuAddObject:(id)anObject { - [self nuAddObject:((anObject == nil) ? (id)[NSNull null] : anObject)]; + [self nuAddObject:((anObject == nil) ? (id)Nu__null : anObject)]; } - (void)nuInsertObject:(id)anObject atIndex:(int)index { - [self nuInsertObject:((anObject == nil) ? (id)[NSNull null] : anObject) atIndex:index]; + [self nuInsertObject:((anObject == nil) ? (id)Nu__null : anObject) atIndex:index]; } - (void)nuReplaceObjectAtIndex:(int)index withObject:(id)anObject { - [self nuReplaceObjectAtIndex:index withObject:((anObject == nil) ? (id)[NSNull null] : anObject)]; + [self nuReplaceObjectAtIndex:index withObject:((anObject == nil) ? Nu__null : anObject)]; } @end @@ -54,7 +54,7 @@ @implementation NSCFSetSwizzles - (void)nuAddObject:(id)anObject { - [self nuAddObject:((anObject == nil) ? (id)[NSNull null] : anObject)]; + [self nuAddObject:((anObject == nil) ? Nu__null : anObject)]; } @end diff --git a/objc/NuSymbol.m b/objc/NuSymbol.m index b4c1df1..cc64b88 100644 --- a/objc/NuSymbol.m +++ b/objc/NuSymbol.m @@ -101,7 +101,7 @@ @implementation NuSymbol - (void) _setStringValue:(NSString *) string { self->stringValue = [string copy]; - const char *cstring = [string cStringUsingEncoding:NSUTF8StringEncoding]; + const char *cstring = [string UTF8String]; NSUInteger len = strlen(cstring); self->isLabel = (cstring[len - 1] == ':'); self->isGensym = (len > 2) && (cstring[0] == '_') && (cstring[1] == '_'); @@ -142,7 +142,7 @@ - (NSString *) stringValue - (int) intValue { - return (value == [NSNull null]) ? 0 : 1; + return (value == Nu__null) ? 0 : 1; } - (bool) isGensym @@ -179,10 +179,10 @@ - (id) evalWithContext:(NSMutableDictionary *)context if (c == '@') { NuSymbolTable *symbolTable = [context objectForKey:SYMBOLS_KEY]; id object = [context lookupObjectForKey:[symbolTable symbolWithString:@"self"]]; - if (!object) return [NSNull null]; + if (!object) return Nu__null; id ivarName = [[self stringValue] substringFromIndex:1]; id result = [object valueForIvar:ivarName]; - return result ? result : (id) [NSNull null]; + return result ? result : Nu__null; } // Next, try to find the symbol in the local evaluation context. @@ -217,7 +217,7 @@ - (id) evalWithContext:(NSMutableDictionary *)context // Undefined globals evaluate to null. if (c == '$') - return [NSNull null]; + return Nu__null; // Now we try looking in the bridge support dictionaries. NuSymbolTable *symbolTable = [context objectForKey:SYMBOLS_KEY]; @@ -262,7 +262,7 @@ - (id) evalWithContext:(NSMutableDictionary *)context } } [NSException raise:@"NuUndefinedSymbol" format:@"%@", errorDescription]; - return [NSNull null]; + return Nu__null; } - (NSComparisonResult) compare:(NuSymbol *) anotherSymbol diff --git a/objc/NuTestHelper.m b/objc/NuTestHelper.m index b5adcba..ee6a6e0 100644 --- a/objc/NuTestHelper.m +++ b/objc/NuTestHelper.m @@ -115,17 +115,11 @@ - (void) finalize + (void) resetDeallocationCount { -#if !TARGET_OS_IPHONE - [[NSGarbageCollector defaultCollector] collectExhaustively]; -#endif deallocationCount = 0; } + (int) deallocationCount { -#if !TARGET_OS_IPHONE - [[NSGarbageCollector defaultCollector] collectExhaustively]; -#endif return deallocationCount; } @@ -147,4 +141,4 @@ + (NSRange) getNSRangeFromProxy:(id) proxy { return [proxy NSRangeValue]; } -@end \ No newline at end of file +@end diff --git a/test/test_quasiquote.nu b/test/test_quasiquote.nu index ac331e5..4ef0114 100644 --- a/test/test_quasiquote.nu +++ b/test/test_quasiquote.nu @@ -36,7 +36,14 @@ (assert_throws "NuQuasiquoteEvalOutsideQuasiquote" (do () (,(+ 1 1))))) - + + (- (id) testShielding is + (macro shielded (name) + `(macro ,name (inner) + `(+ 2 ~,inner))) + (shielded shield) + (assert_equal (shield 5) 7)) + (- (id) testSplicing is ; Single element (assert_equal '(1) `(,@(list 1)))