Skip to content
Browse files

Merge branch 'Mocha' of github.com:ccgus/jstalk into Mocha

  • Loading branch information...
2 parents b65f27c + b273270 commit 3736a4bc1877e3c1cb1a87b7d085404289f81cbb @ccgus committed Aug 3, 2012
Showing with 1,607 additions and 1,601 deletions.
  1. +0 −6 bin/jstcopyinmocha.sh
  2. +65 −47 jstalk.xcodeproj/project.pbxproj
  3. +43 −51 mocha/BridgeSupport/MOBridgeSupportController.m
  4. +21 −29 mocha/BridgeSupport/MOBridgeSupportLibrary.m
  5. +253 −256 mocha/BridgeSupport/MOBridgeSupportParser.m
  6. +94 −137 mocha/BridgeSupport/MOBridgeSupportSymbol.m
  7. +8 −1 mocha/MochaDefines.h
  8. +1 −1 mocha/MochaRuntime.h
  9. +247 −261 mocha/MochaRuntime.m
  10. +43 −0 mocha/Objects/MOAllocator.h
  11. +33 −0 mocha/Objects/MOAllocator.m
  12. +2 −2 mocha/Objects/MOClassDescription.h
  13. +17 −12 mocha/Objects/MOClassDescription.m
  14. +3 −8 mocha/Objects/MOClosure.m
  15. +1 −6 mocha/Objects/MOInstanceVariableDescription.m
  16. +1 −2 mocha/Objects/MOJavaScriptObject.m
  17. +1 −1 mocha/Objects/MOMethod.h
  18. +2 −7 mocha/Objects/MOMethod.m
  19. +1 −5 mocha/Objects/MOMethodDescription.m
  20. +1 −1 mocha/Objects/MOMethod_Private.h
  21. +2 −2 mocha/Objects/MOObjCRuntime.h
  22. +2 −28 mocha/Objects/MOObjCRuntime.m
  23. +19 −0 mocha/Objects/MOPointer.h
  24. +43 −0 mocha/Objects/MOPointer.m
  25. +0 −7 mocha/Objects/MOPropertyDescription.m
  26. +4 −4 mocha/Objects/MOProtocolDescription.m
  27. +1 −1 mocha/Objects/MOProtocolDescription_Private.h
  28. +1 −8 mocha/Objects/MOStruct.m
  29. +1 −27 mocha/Objects/MOUndefined.m
  30. +3 −5 mocha/Utilities/MOFunctionArgument.h
  31. +566 −535 mocha/Utilities/MOFunctionArgument.m
  32. +86 −83 mocha/Utilities/MOUtilities.m
  33. +6 −4 src/JSTExtras.m
  34. +1 −1 src/JSTListener.h
  35. +0 −1 src/JSTListener.m
  36. +4 −6 src/JSTPreprocessor.m
  37. +0 −1 src/JSTTextView.h
  38. +4 −9 src/JSTTextView.m
  39. +2 −2 src/JSTalk.h
  40. +1 −7 src/JSTalk.m
  41. +1 −5 src/MarkerLineNumberView.m
  42. +20 −26 src/NoodleLineNumberView.m
  43. +3 −6 src/TETextUtils.m
View
6 bin/jstcopyinmocha.sh
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-SRC_DIR=`cd ${0%/*}/..; pwd`
-
-
-cp $SRC_DIR/jscocoa/JSCocoa/*.m $SRC_DIR/jscocoa/JSCocoa/*.h $SRC_DIR/../jscocoafork/JSCocoa/.
View
112 jstalk.xcodeproj/project.pbxproj
@@ -89,51 +89,51 @@
CC3A9B2815BC8F390075F377 /* NSDictionary+MochaAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CCEC36A415BA5E44008D8460 /* NSDictionary+MochaAdditions.m */; };
CC3A9B2915BC8F390075F377 /* NSObject+MochaAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CCEC36A615BA5E44008D8460 /* NSObject+MochaAdditions.m */; };
CC3A9B2A15BC8F390075F377 /* NSOrderedSet+MochaAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CCEC36A815BA5E44008D8460 /* NSOrderedSet+MochaAdditions.m */; };
- CC3A9B3315BCB2E00075F377 /* TDAlternation.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D220F48BB2C007A2941 /* TDAlternation.m */; };
- CC3A9B3415BCB2E00075F377 /* TDAny.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D240F48BB2C007A2941 /* TDAny.m */; };
- CC3A9B3515BCB2E00075F377 /* TDAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D260F48BB2C007A2941 /* TDAssembly.m */; };
- CC3A9B3615BCB2E00075F377 /* TDCaseInsensitiveLiteral.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D280F48BB2C007A2941 /* TDCaseInsensitiveLiteral.m */; };
- CC3A9B3715BCB2E00075F377 /* TDChar.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D2A0F48BB2C007A2941 /* TDChar.m */; };
- CC3A9B3815BCB2E00075F377 /* TDCharacterAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D2C0F48BB2C007A2941 /* TDCharacterAssembly.m */; };
- CC3A9B3915BCB2E00075F377 /* TDCollectionParser.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D2E0F48BB2C007A2941 /* TDCollectionParser.m */; };
- CC3A9B3A15BCB2E00075F377 /* TDComment.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D300F48BB2C007A2941 /* TDComment.m */; };
- CC3A9B3B15BCB2E00075F377 /* TDCommentState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D320F48BB2C007A2941 /* TDCommentState.m */; };
- CC3A9B3C15BCB2E00075F377 /* TDDigit.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D340F48BB2C007A2941 /* TDDigit.m */; };
- CC3A9B3D15BCB2E00075F377 /* TDEmpty.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D360F48BB2C007A2941 /* TDEmpty.m */; };
- CC3A9B3E15BCB2E00075F377 /* TDLetter.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D380F48BB2C007A2941 /* TDLetter.m */; };
- CC3A9B3F15BCB2E00075F377 /* TDLiteral.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D3A0F48BB2C007A2941 /* TDLiteral.m */; };
- CC3A9B4015BCB2E00075F377 /* TDLowercaseWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D3C0F48BB2C007A2941 /* TDLowercaseWord.m */; };
- CC3A9B4115BCB2E00075F377 /* TDMultiLineCommentState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D3E0F48BB2C007A2941 /* TDMultiLineCommentState.m */; };
- CC3A9B4215BCB2E00075F377 /* TDNonReservedWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D400F48BB2C007A2941 /* TDNonReservedWord.m */; };
- CC3A9B4315BCB2E00075F377 /* TDNum.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D420F48BB2C007A2941 /* TDNum.m */; };
- CC3A9B4415BCB2E00075F377 /* TDNumberState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D440F48BB2C007A2941 /* TDNumberState.m */; };
- CC3A9B4515BCB2E00075F377 /* TDParser.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D470F48BB2C007A2941 /* TDParser.m */; };
- CC3A9B4615BCB2E00075F377 /* TDQuotedString.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D490F48BB2C007A2941 /* TDQuotedString.m */; };
- CC3A9B4715BCB2E00075F377 /* TDQuoteState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D4B0F48BB2C007A2941 /* TDQuoteState.m */; };
- CC3A9B4815BCB2E00075F377 /* TDReader.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D4D0F48BB2C007A2941 /* TDReader.m */; };
- CC3A9B4915BCB2E00075F377 /* TDRepetition.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D4F0F48BB2C007A2941 /* TDRepetition.m */; };
- CC3A9B4A15BCB2E00075F377 /* TDReservedWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D510F48BB2C007A2941 /* TDReservedWord.m */; };
- CC3A9B4B15BCB2E00075F377 /* TDScientificNumberState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D530F48BB2C007A2941 /* TDScientificNumberState.m */; };
- CC3A9B4C15BCB2E00075F377 /* TDSequence.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D550F48BB2C007A2941 /* TDSequence.m */; };
- CC3A9B4D15BCB2E00075F377 /* TDSingleLineCommentState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D590F48BB2C007A2941 /* TDSingleLineCommentState.m */; };
- CC3A9B4E15BCB2E00075F377 /* TDSpecificChar.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D5B0F48BB2C007A2941 /* TDSpecificChar.m */; };
- CC3A9B4F15BCB2E00075F377 /* TDSymbol.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D5D0F48BB2C007A2941 /* TDSymbol.m */; };
- CC3A9B5015BCB2E00075F377 /* TDSymbolNode.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D5F0F48BB2C007A2941 /* TDSymbolNode.m */; };
- CC3A9B5115BCB2E00075F377 /* TDSymbolRootNode.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D610F48BB2C007A2941 /* TDSymbolRootNode.m */; };
- CC3A9B5215BCB2E00075F377 /* TDSymbolState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D630F48BB2C007A2941 /* TDSymbolState.m */; };
- CC3A9B5315BCB2E00075F377 /* TDTerminal.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D650F48BB2C007A2941 /* TDTerminal.m */; };
- CC3A9B5415BCB2E00075F377 /* TDToken.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D670F48BB2C007A2941 /* TDToken.m */; };
- CC3A9B5515BCB2E00075F377 /* TDTokenArraySource.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D690F48BB2C007A2941 /* TDTokenArraySource.m */; };
- CC3A9B5615BCB2E00075F377 /* TDTokenAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D6B0F48BB2C007A2941 /* TDTokenAssembly.m */; };
- CC3A9B5715BCB2E00075F377 /* TDTokenizer.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D6D0F48BB2C007A2941 /* TDTokenizer.m */; };
- CC3A9B5815BCB2E00075F377 /* TDTokenizerState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D6F0F48BB2C007A2941 /* TDTokenizerState.m */; };
- CC3A9B5915BCB2E00075F377 /* TDTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D710F48BB2C007A2941 /* TDTrack.m */; };
- CC3A9B5A15BCB2E00075F377 /* TDTrackException.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D730F48BB2C007A2941 /* TDTrackException.m */; };
- CC3A9B5B15BCB2E00075F377 /* TDUppercaseWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D750F48BB2C007A2941 /* TDUppercaseWord.m */; };
- CC3A9B5C15BCB2E00075F377 /* TDWhitespaceState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D770F48BB2C007A2941 /* TDWhitespaceState.m */; };
- CC3A9B5D15BCB2E00075F377 /* TDWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D790F48BB2C007A2941 /* TDWord.m */; };
- CC3A9B5E15BCB2E00075F377 /* TDWordOrReservedState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D7B0F48BB2C007A2941 /* TDWordOrReservedState.m */; };
- CC3A9B5F15BCB2E00075F377 /* TDWordState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D7D0F48BB2C007A2941 /* TDWordState.m */; };
+ CC3A9B3315BCB2E00075F377 /* TDAlternation.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D220F48BB2C007A2941 /* TDAlternation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3415BCB2E00075F377 /* TDAny.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D240F48BB2C007A2941 /* TDAny.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3515BCB2E00075F377 /* TDAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D260F48BB2C007A2941 /* TDAssembly.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3615BCB2E00075F377 /* TDCaseInsensitiveLiteral.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D280F48BB2C007A2941 /* TDCaseInsensitiveLiteral.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3715BCB2E00075F377 /* TDChar.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D2A0F48BB2C007A2941 /* TDChar.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3815BCB2E00075F377 /* TDCharacterAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D2C0F48BB2C007A2941 /* TDCharacterAssembly.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3915BCB2E00075F377 /* TDCollectionParser.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D2E0F48BB2C007A2941 /* TDCollectionParser.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3A15BCB2E00075F377 /* TDComment.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D300F48BB2C007A2941 /* TDComment.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3B15BCB2E00075F377 /* TDCommentState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D320F48BB2C007A2941 /* TDCommentState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3C15BCB2E00075F377 /* TDDigit.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D340F48BB2C007A2941 /* TDDigit.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3D15BCB2E00075F377 /* TDEmpty.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D360F48BB2C007A2941 /* TDEmpty.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3E15BCB2E00075F377 /* TDLetter.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D380F48BB2C007A2941 /* TDLetter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B3F15BCB2E00075F377 /* TDLiteral.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D3A0F48BB2C007A2941 /* TDLiteral.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4015BCB2E00075F377 /* TDLowercaseWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D3C0F48BB2C007A2941 /* TDLowercaseWord.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4115BCB2E00075F377 /* TDMultiLineCommentState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D3E0F48BB2C007A2941 /* TDMultiLineCommentState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4215BCB2E00075F377 /* TDNonReservedWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D400F48BB2C007A2941 /* TDNonReservedWord.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4315BCB2E00075F377 /* TDNum.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D420F48BB2C007A2941 /* TDNum.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4415BCB2E00075F377 /* TDNumberState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D440F48BB2C007A2941 /* TDNumberState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4515BCB2E00075F377 /* TDParser.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D470F48BB2C007A2941 /* TDParser.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4615BCB2E00075F377 /* TDQuotedString.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D490F48BB2C007A2941 /* TDQuotedString.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4715BCB2E00075F377 /* TDQuoteState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D4B0F48BB2C007A2941 /* TDQuoteState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4815BCB2E00075F377 /* TDReader.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D4D0F48BB2C007A2941 /* TDReader.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4915BCB2E00075F377 /* TDRepetition.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D4F0F48BB2C007A2941 /* TDRepetition.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4A15BCB2E00075F377 /* TDReservedWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D510F48BB2C007A2941 /* TDReservedWord.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4B15BCB2E00075F377 /* TDScientificNumberState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D530F48BB2C007A2941 /* TDScientificNumberState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4C15BCB2E00075F377 /* TDSequence.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D550F48BB2C007A2941 /* TDSequence.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4D15BCB2E00075F377 /* TDSingleLineCommentState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D590F48BB2C007A2941 /* TDSingleLineCommentState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4E15BCB2E00075F377 /* TDSpecificChar.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D5B0F48BB2C007A2941 /* TDSpecificChar.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B4F15BCB2E00075F377 /* TDSymbol.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D5D0F48BB2C007A2941 /* TDSymbol.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5015BCB2E00075F377 /* TDSymbolNode.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D5F0F48BB2C007A2941 /* TDSymbolNode.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5115BCB2E00075F377 /* TDSymbolRootNode.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D610F48BB2C007A2941 /* TDSymbolRootNode.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5215BCB2E00075F377 /* TDSymbolState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D630F48BB2C007A2941 /* TDSymbolState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5315BCB2E00075F377 /* TDTerminal.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D650F48BB2C007A2941 /* TDTerminal.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5415BCB2E00075F377 /* TDToken.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D670F48BB2C007A2941 /* TDToken.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5515BCB2E00075F377 /* TDTokenArraySource.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D690F48BB2C007A2941 /* TDTokenArraySource.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5615BCB2E00075F377 /* TDTokenAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D6B0F48BB2C007A2941 /* TDTokenAssembly.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5715BCB2E00075F377 /* TDTokenizer.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D6D0F48BB2C007A2941 /* TDTokenizer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5815BCB2E00075F377 /* TDTokenizerState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D6F0F48BB2C007A2941 /* TDTokenizerState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5915BCB2E00075F377 /* TDTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D710F48BB2C007A2941 /* TDTrack.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5A15BCB2E00075F377 /* TDTrackException.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D730F48BB2C007A2941 /* TDTrackException.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5B15BCB2E00075F377 /* TDUppercaseWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D750F48BB2C007A2941 /* TDUppercaseWord.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5C15BCB2E00075F377 /* TDWhitespaceState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D770F48BB2C007A2941 /* TDWhitespaceState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5D15BCB2E00075F377 /* TDWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D790F48BB2C007A2941 /* TDWord.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5E15BCB2E00075F377 /* TDWordOrReservedState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D7B0F48BB2C007A2941 /* TDWordOrReservedState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ CC3A9B5F15BCB2E00075F377 /* TDWordState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D7D0F48BB2C007A2941 /* TDWordState.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
CC3A9B6315BCB82C0075F377 /* MochaRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = CCEC36AF15BA5E44008D8460 /* MochaRuntime.m */; };
CC3A9B6415BCB82E0075F377 /* Mocha.m in Sources */ = {isa = PBXBuildFile; fileRef = CCEC36AC15BA5E44008D8460 /* Mocha.m */; };
CC41432E0F25257C00E46669 /* JSTalk_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = CCC5B8CB0F1EFAAA00126722 /* JSTalk_Prefix.pch */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -234,6 +234,11 @@
CCEC370F15BA5E44008D8460 /* MOUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CCEC36D415BA5E44008D8460 /* MOUtilities.h */; };
CCEC371015BA5E44008D8460 /* MOUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = CCEC36D515BA5E44008D8460 /* MOUtilities.m */; };
CCF68F1E0F4E3E4F00925FCA /* JSTalkDocument.icns in Resources */ = {isa = PBXBuildFile; fileRef = CCF68F1D0F4E3E4F00925FCA /* JSTalkDocument.icns */; };
+ CCFF84E815CC5CD000CC42F7 /* MOPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = CCFF84E615CC5CD000CC42F7 /* MOPointer.h */; };
+ CCFF84E915CC5CD000CC42F7 /* MOPointer.m in Sources */ = {isa = PBXBuildFile; fileRef = CCFF84E715CC5CD000CC42F7 /* MOPointer.m */; };
+ CCFF84EC15CC5CDF00CC42F7 /* MOAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = CCFF84EA15CC5CDF00CC42F7 /* MOAllocator.h */; };
+ CCFF84ED15CC5CDF00CC42F7 /* MOAllocator.m in Sources */ = {isa = PBXBuildFile; fileRef = CCFF84EB15CC5CDF00CC42F7 /* MOAllocator.m */; };
+ CCFF84EE15CC5CDF00CC42F7 /* MOAllocator.m in Sources */ = {isa = PBXBuildFile; fileRef = CCFF84EB15CC5CDF00CC42F7 /* MOAllocator.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -482,6 +487,10 @@
CCEC36D415BA5E44008D8460 /* MOUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MOUtilities.h; sourceTree = "<group>"; };
CCEC36D515BA5E44008D8460 /* MOUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MOUtilities.m; sourceTree = "<group>"; };
CCF68F1D0F4E3E4F00925FCA /* JSTalkDocument.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = JSTalkDocument.icns; path = res/images/JSTalkDocument.icns; sourceTree = "<group>"; };
+ CCFF84E615CC5CD000CC42F7 /* MOPointer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MOPointer.h; sourceTree = "<group>"; };
+ CCFF84E715CC5CD000CC42F7 /* MOPointer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MOPointer.m; sourceTree = "<group>"; };
+ CCFF84EA15CC5CDF00CC42F7 /* MOAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MOAllocator.h; sourceTree = "<group>"; };
+ CCFF84EB15CC5CDF00CC42F7 /* MOAllocator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MOAllocator.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -832,6 +841,10 @@
CCEC36B115BA5E44008D8460 /* Objects */ = {
isa = PBXGroup;
children = (
+ CCFF84EA15CC5CDF00CC42F7 /* MOAllocator.h */,
+ CCFF84EB15CC5CDF00CC42F7 /* MOAllocator.m */,
+ CCFF84E615CC5CD000CC42F7 /* MOPointer.h */,
+ CCFF84E715CC5CD000CC42F7 /* MOPointer.m */,
CCEC36B215BA5E44008D8460 /* MOBox.h */,
CCEC36B315BA5E44008D8460 /* MOBox.m */,
CCEC36B415BA5E44008D8460 /* MOClassDescription.h */,
@@ -924,6 +937,8 @@
CCEC370915BA5E44008D8460 /* MOUndefined.h in Headers */,
CCEC370B15BA5E44008D8460 /* MOFunctionArgument.h in Headers */,
CCEC370F15BA5E44008D8460 /* MOUtilities.h in Headers */,
+ CCFF84E815CC5CD000CC42F7 /* MOPointer.h in Headers */,
+ CCFF84EC15CC5CDF00CC42F7 /* MOAllocator.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1165,6 +1180,8 @@
CCEC370A15BA5E44008D8460 /* MOUndefined.m in Sources */,
CCEC370C15BA5E44008D8460 /* MOFunctionArgument.m in Sources */,
CCEC371015BA5E44008D8460 /* MOUtilities.m in Sources */,
+ CCFF84E915CC5CD000CC42F7 /* MOPointer.m in Sources */,
+ CCFF84EE15CC5CDF00CC42F7 /* MOAllocator.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1255,6 +1272,7 @@
CC1C7E060F48BB2C007A2941 /* TDWord.m in Sources */,
CC1C7E070F48BB2C007A2941 /* TDWordOrReservedState.m in Sources */,
CC1C7E080F48BB2C007A2941 /* TDWordState.m in Sources */,
+ CCFF84ED15CC5CDF00CC42F7 /* MOAllocator.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1375,12 +1393,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_OBJC_GC = supported;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = src/JSTalk_Prefix.pch;
@@ -1407,11 +1425,11 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
- GCC_ENABLE_OBJC_GC = supported;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = src/JSTalk_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
View
94 mocha/BridgeSupport/MOBridgeSupportController.m
@@ -15,72 +15,64 @@
@implementation MOBridgeSupportController {
- NSMutableArray *_loadedURLs;
- NSMutableArray *_loadedLibraries;
- NSMutableDictionary *_symbols;
- MOBridgeSupportParser *_parser;
+ NSMutableArray *_loadedURLs;
+ NSMutableArray *_loadedLibraries;
+ NSMutableDictionary *_symbols;
+ MOBridgeSupportParser *_parser;
}
+ (MOBridgeSupportController *)sharedController {
- static MOBridgeSupportController *sharedController = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- sharedController = [[self alloc] init];
- });
- return sharedController;
+ static MOBridgeSupportController *sharedController = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ sharedController = [[self alloc] init];
+ });
+ return sharedController;
}
- (id)init {
- self = [super init];
- if (self) {
- _loadedURLs = [[NSMutableArray alloc] init];
- _loadedLibraries = [[NSMutableArray alloc] init];
- _symbols = [[NSMutableDictionary alloc] init];
- _parser = [[MOBridgeSupportParser alloc] init];
- }
- return self;
-}
-
-- (void)dealloc {
- [_loadedURLs release];
- [_loadedLibraries release];
- [_symbols release];
- [_parser release];
- [super dealloc];
+ self = [super init];
+ if (self) {
+ _loadedURLs = [[NSMutableArray alloc] init];
+ _loadedLibraries = [[NSMutableArray alloc] init];
+ _symbols = [[NSMutableDictionary alloc] init];
+ _parser = [[MOBridgeSupportParser alloc] init];
+ }
+ return self;
}
#pragma mark -
#pragma mark Loading
- (BOOL)isBridgeSupportLoadedForURL:(NSURL *)aURL {
- return [_loadedURLs containsObject:aURL];
+ return [_loadedURLs containsObject:aURL];
}
- (BOOL)loadBridgeSupportAtURL:(NSURL *)aURL error:(NSError **)outError {
- if ([self isBridgeSupportLoadedForURL:aURL]) {
- return YES;
- }
-
- MOBridgeSupportLibrary *library = [_parser libraryWithBridgeSupportURL:aURL error:outError];
- if (library == nil) {
- return NO;
- }
-
- [_loadedURLs addObject:aURL];
- [_loadedLibraries addObject:library];
-
- for (NSString *name in library.symbols) {
- MOBridgeSupportSymbol *symbol = [library.symbols objectForKey:name];
- if ([_symbols objectForKey:name] == nil) {
- [_symbols setObject:symbol forKey:name];
- }
- else {
- //NSLog(@"Symbol with name \"%@\" is already loaded.", name);
- }
- }
-
- return YES;
+ if ([self isBridgeSupportLoadedForURL:aURL]) {
+ return YES;
+ }
+
+ MOBridgeSupportLibrary *library = [_parser libraryWithBridgeSupportURL:aURL error:outError];
+ if (library == nil) {
+ return NO;
+ }
+
+ [_loadedURLs addObject:aURL];
+ [_loadedLibraries addObject:library];
+
+ for (NSString *name in library.symbols) {
+ MOBridgeSupportSymbol *symbol = [library.symbols objectForKey:name];
+ if ([_symbols objectForKey:name] == nil) {
+ [_symbols setObject:symbol forKey:name];
+ }
+ else {
+ //NSLog(@"Symbol with name \"%@\" is already loaded.", name);
+ }
+ }
+
+ return YES;
}
@@ -105,7 +97,7 @@ - (NSDictionary *)performQueryForSymbolsOfType:(NSArray *)classes {
}
- (id)performQueryForSymbolName:(NSString *)name {
- return [_symbols objectForKey:name];
+ return [_symbols objectForKey:name];
}
- (id)performQueryForSymbolName:(NSString *)name ofType:(Class)klass {
View
50 mocha/BridgeSupport/MOBridgeSupportLibrary.m
@@ -10,76 +10,68 @@
@implementation MOBridgeSupportLibrary {
- NSMutableArray *_dependencies;
- NSMutableDictionary *_symbols;
+ NSMutableArray *_dependencies;
+ NSMutableDictionary *_symbols;
}
@synthesize name=_name;
@synthesize URL=_URL;
- (id)init {
- self = [super init];
- if (self) {
- _dependencies = [[NSMutableArray alloc] init];
- _symbols = [[NSMutableDictionary alloc] init];
- }
- return self;
-}
-
-- (void)dealloc {
- [_name release];
- [_URL release];
- [_dependencies release];
- [_symbols release];
- [super dealloc];
+ self = [super init];
+ if (self) {
+ _dependencies = [[NSMutableArray alloc] init];
+ _symbols = [[NSMutableDictionary alloc] init];
+ }
+ return self;
}
#pragma mark -
#pragma mark Dependencies
- (NSArray *)dependencies {
- return _dependencies;
+ return _dependencies;
}
- (void)setDependencies:(NSArray *)dependencies {
- [_dependencies setArray:dependencies];
+ [_dependencies setArray:dependencies];
}
- (void)addDependency:(NSString *)dependency {
- if (![_dependencies containsObject:dependency]) {
- [_dependencies addObject:dependency];
- }
+ if (![_dependencies containsObject:dependency]) {
+ [_dependencies addObject:dependency];
+ }
}
- (void)removeDependency:(NSString *)dependency {
- if ([_dependencies containsObject:dependency]) {
- [_dependencies removeObject:dependency];
- }
+ if ([_dependencies containsObject:dependency]) {
+ [_dependencies removeObject:dependency];
+ }
}
#pragma mark -
#pragma mark Symbols
- (NSDictionary *)symbols {
- return _symbols;
+ return _symbols;
}
- (void)setSymbols:(NSDictionary *)symbols {
- [_symbols setDictionary:symbols];
+ [_symbols setDictionary:symbols];
}
- (MOBridgeSupportSymbol *)symbolWithName:(NSString *)name {
- return [_symbols objectForKey:name];
+ return [_symbols objectForKey:name];
}
- (void)setSymbol:(MOBridgeSupportSymbol *)symbol forName:(NSString *)name {
- [_symbols setObject:symbol forKey:name];
+ [_symbols setObject:symbol forKey:name];
}
- (void)removeSymbolForName:(NSString *)name {
- [_symbols removeObjectForKey:name];
+ [_symbols removeObjectForKey:name];
}
@end
View
509 mocha/BridgeSupport/MOBridgeSupportParser.m
@@ -20,45 +20,42 @@ @interface MOBridgeSupportParser () <NSXMLParserDelegate>
@implementation MOBridgeSupportParser {
- NSXMLParser *_parser;
- MOBridgeSupportLibrary *_library;
- NSMutableArray *_symbolStack;
+ NSXMLParser *_parser;
+ MOBridgeSupportLibrary *_library;
+ NSMutableArray *_symbolStack;
}
- (id)init {
- self = [super init];
- if (self) {
-
- }
- return self;
+ self = [super init];
+ if (self) {
+
+ }
+ return self;
}
- (void)dealloc {
- _parser = nil;
- _library = nil;
- _symbolStack = nil;
-
- [super dealloc];
+ _parser = nil;
+ _library = nil;
+ _symbolStack = nil;
}
- (MOBridgeSupportLibrary *)libraryWithBridgeSupportURL:(NSURL *)aURL error:(NSError **)outError {
- _parser = [[NSXMLParser alloc] initWithContentsOfURL:aURL];
- [_parser setDelegate:self];
-
- BOOL success = [_parser parse];
- if (!success) {
- [_library release];
- _library = nil;
- }
-
- NSError *error = [_parser parserError];
- if (outError != NULL) {
- *outError = error;
- }
-
- [_parser release], _parser = nil;
-
- return [_library autorelease];
+ _parser = [[NSXMLParser alloc] initWithContentsOfURL:aURL];
+ [_parser setDelegate:self];
+
+ BOOL success = [_parser parse];
+ if (!success) {
+ _library = nil;
+ }
+
+ NSError *error = [_parser parserError];
+ if (outError != NULL) {
+ *outError = error;
+ }
+
+ _parser = nil;
+
+ return _library;
}
@@ -67,253 +64,253 @@ - (MOBridgeSupportLibrary *)libraryWithBridgeSupportURL:(NSURL *)aURL error:(NSE
- (void)parserDidStartDocument:(NSXMLParser *)parser {
#if PARSER_DEBUG
- NSLog(@"Parser didStartDocument");
+ NSLog(@"Parser didStartDocument");
#endif
-
- _library = [[MOBridgeSupportLibrary alloc] init];
- _symbolStack = [[NSMutableArray alloc] init];
+
+ _library = [[MOBridgeSupportLibrary alloc] init];
+ _symbolStack = [[NSMutableArray alloc] init];
}
- (void)parserDidEndDocument:(NSXMLParser *)parser {
#if PARSER_DEBUG
- NSLog(@"Parser didEndDocument");
+ NSLog(@"Parser didEndDocument");
#endif
-
- [_symbolStack release], _symbolStack = nil;
+
+ _symbolStack = nil;
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
#if PARSER_DEBUG
- NSLog(@"Parser didStartElement: %@, attributes=%@", elementName, attributeDict);
+ NSLog(@"Parser didStartElement: %@, attributes=%@", elementName, attributeDict);
#endif
-
- if ([elementName isEqualToString:@"signatures"]) {
- // Signatures
-
- }
- else if ([elementName isEqualToString:@"depends_on"]) {
- // Dependency
- NSString *path = [attributeDict objectForKey:@"path"];
- [_library addDependency:path];
- }
- else if ([elementName isEqualToString:@"struct"]) {
- // Struct
- MOBridgeSupportStruct *symbol = [[[MOBridgeSupportStruct alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- symbol.type = [attributeDict objectForKey:@"type"];
- symbol.type64 = [attributeDict objectForKey:@"type64"];
- symbol.opaque = [[attributeDict objectForKey:@"opaque"] isEqualToString:@"true"];
- [_library setSymbol:symbol forName:symbol.name];
- }
- else if ([elementName isEqualToString:@"cftype"]) {
- // CFType
- MOBridgeSupportCFType *symbol = [[[MOBridgeSupportCFType alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- symbol.type = [attributeDict objectForKey:@"type"];
- symbol.type64 = [attributeDict objectForKey:@"type64"];
- symbol.tollFreeBridgedClassName = [attributeDict objectForKey:@"tollfree"];
- symbol.getTypeIDFunctionName = [attributeDict objectForKey:@"gettypeid_func"];
- [_library setSymbol:symbol forName:symbol.name];
- }
- else if ([elementName isEqualToString:@"opaque"]) {
- // Opaque
- MOBridgeSupportOpaque *symbol = [[[MOBridgeSupportOpaque alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- symbol.type = [attributeDict objectForKey:@"type"];
- symbol.type64 = [attributeDict objectForKey:@"type64"];
- [_library setSymbol:symbol forName:symbol.name];
- }
- else if ([elementName isEqualToString:@"constant"]) {
- // Constant
- MOBridgeSupportConstant *symbol = [[[MOBridgeSupportConstant alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- symbol.type = [attributeDict objectForKey:@"type"];
- symbol.type64 = [attributeDict objectForKey:@"type64"];
- symbol.hasMagicCookie = [[attributeDict objectForKey:@"magic_cookie"] isEqualToString:@"true"];
- [_library setSymbol:symbol forName:symbol.name];
- }
- else if ([elementName isEqualToString:@"string_constant"]) {
- // String constant
- MOBridgeSupportStringConstant *symbol = [[[MOBridgeSupportStringConstant alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- symbol.value = [attributeDict objectForKey:@"value"];
- symbol.hasNSString = [[attributeDict objectForKey:@"nsstring"] isEqualToString:@"true"];
- [_library setSymbol:symbol forName:symbol.name];
- }
- else if ([elementName isEqualToString:@"enum"]) {
- // Enum
- MOBridgeSupportEnum *symbol = [[[MOBridgeSupportEnum alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- if ([attributeDict objectForKey:@"value"]) {
- symbol.value = [NSNumber numberWithInteger:[[attributeDict objectForKey:@"value"] integerValue]];
- }
- if ([attributeDict objectForKey:@"value64"]) {
- symbol.value64 = [NSNumber numberWithInteger:[[attributeDict objectForKey:@"value64"] integerValue]];
- }
- symbol.ignored = [[attributeDict objectForKey:@"ignore"] isEqualToString:@"true"];
- symbol.suggestion = [attributeDict objectForKey:@"suggestion"];
- [_library setSymbol:symbol forName:symbol.name];
- }
- else if ([elementName isEqualToString:@"function"]) {
- // Function
- MOBridgeSupportFunction *symbol = [[[MOBridgeSupportFunction alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- symbol.variadic = [[attributeDict objectForKey:@"variadic"] isEqualToString:@"true"];
- if ([attributeDict objectForKey:@"sentinel"]) {
- symbol.sentinel = [NSNumber numberWithInteger:[[attributeDict objectForKey:@"sentinel"] integerValue]];
- }
- symbol.inlineFunction = [[attributeDict objectForKey:@"inline"] isEqualToString:@"true"];
- [_library setSymbol:symbol forName:symbol.name];
-
- [_symbolStack addObject:symbol];
- }
- else if ([elementName isEqualToString:@"function_alias"]) {
- // Function alias
- MOBridgeSupportFunctionAlias *symbol = [[[MOBridgeSupportFunctionAlias alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- symbol.original = [attributeDict objectForKey:@"original"];
- [_library setSymbol:symbol forName:symbol.name];
- }
- else if ([elementName isEqualToString:@"class"]) {
- // Class
- MOBridgeSupportClass *symbol = [[[MOBridgeSupportClass alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- [_library setSymbol:symbol forName:symbol.name];
- [_symbolStack addObject:symbol];
- }
- else if ([elementName isEqualToString:@"informal_protocol"]) {
- // Informal protocol
- MOBridgeSupportInformalProtocol *symbol = [[[MOBridgeSupportInformalProtocol alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- [_library setSymbol:symbol forName:symbol.name];
- [_symbolStack addObject:symbol];
- }
- else if ([elementName isEqualToString:@"method"]) {
- // Method
- MOBridgeSupportMethod *symbol = [[[MOBridgeSupportMethod alloc] init] autorelease];
- symbol.name = [attributeDict objectForKey:@"name"];
- if ([attributeDict objectForKey:@"selector"]) {
- symbol.selector = NSSelectorFromString([attributeDict objectForKey:@"selector"]);
- }
- symbol.type = [attributeDict objectForKey:@"type"];
- symbol.type64 = [attributeDict objectForKey:@"type64"];
- symbol.classMethod = [[attributeDict objectForKey:@"class_method"] isEqualToString:@"true"];
- symbol.variadic = [[attributeDict objectForKey:@"variadic"] isEqualToString:@"true"];
- if ([attributeDict objectForKey:@"sentinel"]) {
- symbol.sentinel = [NSNumber numberWithInteger:[[attributeDict objectForKey:@"sentinel"] integerValue]];
- }
- symbol.ignored = [[attributeDict objectForKey:@"ignore"] isEqualToString:@"true"];
- symbol.suggestion = [attributeDict objectForKey:@"suggestion"];
-
- MOBridgeSupportSymbol *currentSymbol = [_symbolStack lastObject];
- if ([currentSymbol isKindOfClass:[MOBridgeSupportClass class]]
- || [currentSymbol isKindOfClass:[MOBridgeSupportInformalProtocol class]]) {
- [(MOBridgeSupportClass *)currentSymbol addMethod:symbol];
- }
-
- [_symbolStack addObject:symbol];
- }
- else if ([elementName isEqualToString:@"arg"]) {
- // Argument
- MOBridgeSupportArgument *argument = [[[MOBridgeSupportArgument alloc] init] autorelease];
- argument.cArrayLengthInArg = [attributeDict objectForKey:@"c_array_length_in_arg"];
- argument.cArrayOfFixedLength = [[attributeDict objectForKey:@"c_array_of_fixed_length"] isEqualToString:@"true"];
- argument.cArrayDelimitedByNull = [[attributeDict objectForKey:@"c_array_delimited_by_null"] isEqualToString:@"true"];
- argument.cArrayOfVariableLength = [[attributeDict objectForKey:@"c_array_of_variable_length"] isEqualToString:@"true"];
- argument.functionPointer = [[attributeDict objectForKey:@"function_pointer"] isEqualToString:@"true"];
- argument.signature = [attributeDict objectForKey:@"sel_of_type"];
- argument.signature64 = [attributeDict objectForKey:@"sel_of_type64"];
- argument.cArrayLengthInReturnValue = [[attributeDict objectForKey:@"c_array_length_in_retval"] isEqualToString:@"true"];
- argument.acceptsNull = ![[attributeDict objectForKey:@"null_accepted"] isEqualToString:@"false"];
- argument.acceptsPrintfFormat = [[attributeDict objectForKey:@"printf_format"] isEqualToString:@"true"];
- argument.alreadyRetained = [[attributeDict objectForKey:@"already_retained"] isEqualToString:@"true"];
- argument.type = [attributeDict objectForKey:@"type"];
- argument.type64 = [attributeDict objectForKey:@"type64"];
- argument.index = [[attributeDict objectForKey:@"index"] integerValue];
-
- id currentSymbol = [_symbolStack lastObject];
- if ([currentSymbol isKindOfClass:[MOBridgeSupportMethod class]]) {
- [(MOBridgeSupportMethod *)currentSymbol addArgument:argument];
- }
+
+ if ([elementName isEqualToString:@"signatures"]) {
+ // Signatures
+
+ }
+ else if ([elementName isEqualToString:@"depends_on"]) {
+ // Dependency
+ NSString *path = [attributeDict objectForKey:@"path"];
+ [_library addDependency:path];
+ }
+ else if ([elementName isEqualToString:@"struct"]) {
+ // Struct
+ MOBridgeSupportStruct *symbol = [[MOBridgeSupportStruct alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ symbol.type = [attributeDict objectForKey:@"type"];
+ symbol.type64 = [attributeDict objectForKey:@"type64"];
+ symbol.opaque = [[attributeDict objectForKey:@"opaque"] isEqualToString:@"true"];
+ [_library setSymbol:symbol forName:symbol.name];
+ }
+ else if ([elementName isEqualToString:@"cftype"]) {
+ // CFType
+ MOBridgeSupportCFType *symbol = [[MOBridgeSupportCFType alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ symbol.type = [attributeDict objectForKey:@"type"];
+ symbol.type64 = [attributeDict objectForKey:@"type64"];
+ symbol.tollFreeBridgedClassName = [attributeDict objectForKey:@"tollfree"];
+ symbol.getTypeIDFunctionName = [attributeDict objectForKey:@"gettypeid_func"];
+ [_library setSymbol:symbol forName:symbol.name];
+ }
+ else if ([elementName isEqualToString:@"opaque"]) {
+ // Opaque
+ MOBridgeSupportOpaque *symbol = [[MOBridgeSupportOpaque alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ symbol.type = [attributeDict objectForKey:@"type"];
+ symbol.type64 = [attributeDict objectForKey:@"type64"];
+ [_library setSymbol:symbol forName:symbol.name];
+ }
+ else if ([elementName isEqualToString:@"constant"]) {
+ // Constant
+ MOBridgeSupportConstant *symbol = [[MOBridgeSupportConstant alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ symbol.type = [attributeDict objectForKey:@"type"];
+ symbol.type64 = [attributeDict objectForKey:@"type64"];
+ symbol.hasMagicCookie = [[attributeDict objectForKey:@"magic_cookie"] isEqualToString:@"true"];
+ [_library setSymbol:symbol forName:symbol.name];
+ }
+ else if ([elementName isEqualToString:@"string_constant"]) {
+ // String constant
+ MOBridgeSupportStringConstant *symbol = [[MOBridgeSupportStringConstant alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ symbol.value = [attributeDict objectForKey:@"value"];
+ symbol.hasNSString = [[attributeDict objectForKey:@"nsstring"] isEqualToString:@"true"];
+ [_library setSymbol:symbol forName:symbol.name];
+ }
+ else if ([elementName isEqualToString:@"enum"]) {
+ // Enum
+ MOBridgeSupportEnum *symbol = [[MOBridgeSupportEnum alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ if ([attributeDict objectForKey:@"value"]) {
+ symbol.value = [NSNumber numberWithInteger:[[attributeDict objectForKey:@"value"] integerValue]];
+ }
+ if ([attributeDict objectForKey:@"value64"]) {
+ symbol.value64 = [NSNumber numberWithInteger:[[attributeDict objectForKey:@"value64"] integerValue]];
+ }
+ symbol.ignored = [[attributeDict objectForKey:@"ignore"] isEqualToString:@"true"];
+ symbol.suggestion = [attributeDict objectForKey:@"suggestion"];
+ [_library setSymbol:symbol forName:symbol.name];
+ }
+ else if ([elementName isEqualToString:@"function"]) {
+ // Function
+ MOBridgeSupportFunction *symbol = [[MOBridgeSupportFunction alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ symbol.variadic = [[attributeDict objectForKey:@"variadic"] isEqualToString:@"true"];
+ if ([attributeDict objectForKey:@"sentinel"]) {
+ symbol.sentinel = [NSNumber numberWithInteger:[[attributeDict objectForKey:@"sentinel"] integerValue]];
+ }
+ symbol.inlineFunction = [[attributeDict objectForKey:@"inline"] isEqualToString:@"true"];
+ [_library setSymbol:symbol forName:symbol.name];
+
+ [_symbolStack addObject:symbol];
+ }
+ else if ([elementName isEqualToString:@"function_alias"]) {
+ // Function alias
+ MOBridgeSupportFunctionAlias *symbol = [[MOBridgeSupportFunctionAlias alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ symbol.original = [attributeDict objectForKey:@"original"];
+ [_library setSymbol:symbol forName:symbol.name];
+ }
+ else if ([elementName isEqualToString:@"class"]) {
+ // Class
+ MOBridgeSupportClass *symbol = [[MOBridgeSupportClass alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ [_library setSymbol:symbol forName:symbol.name];
+ [_symbolStack addObject:symbol];
+ }
+ else if ([elementName isEqualToString:@"informal_protocol"]) {
+ // Informal protocol
+ MOBridgeSupportInformalProtocol *symbol = [[MOBridgeSupportInformalProtocol alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ [_library setSymbol:symbol forName:symbol.name];
+ [_symbolStack addObject:symbol];
+ }
+ else if ([elementName isEqualToString:@"method"]) {
+ // Method
+ MOBridgeSupportMethod *symbol = [[MOBridgeSupportMethod alloc] init];
+ symbol.name = [attributeDict objectForKey:@"name"];
+ if ([attributeDict objectForKey:@"selector"]) {
+ symbol.selector = NSSelectorFromString([attributeDict objectForKey:@"selector"]);
+ }
+ symbol.type = [attributeDict objectForKey:@"type"];
+ symbol.type64 = [attributeDict objectForKey:@"type64"];
+ symbol.classMethod = [[attributeDict objectForKey:@"class_method"] isEqualToString:@"true"];
+ symbol.variadic = [[attributeDict objectForKey:@"variadic"] isEqualToString:@"true"];
+ if ([attributeDict objectForKey:@"sentinel"]) {
+ symbol.sentinel = [NSNumber numberWithInteger:[[attributeDict objectForKey:@"sentinel"] integerValue]];
+ }
+ symbol.ignored = [[attributeDict objectForKey:@"ignore"] isEqualToString:@"true"];
+ symbol.suggestion = [attributeDict objectForKey:@"suggestion"];
+
+ MOBridgeSupportSymbol *currentSymbol = [_symbolStack lastObject];
+ if ([currentSymbol isKindOfClass:[MOBridgeSupportClass class]]
+ || [currentSymbol isKindOfClass:[MOBridgeSupportInformalProtocol class]]) {
+ [(MOBridgeSupportClass *)currentSymbol addMethod:symbol];
+ }
+
+ [_symbolStack addObject:symbol];
+ }
+ else if ([elementName isEqualToString:@"arg"]) {
+ // Argument
+ MOBridgeSupportArgument *argument = [[MOBridgeSupportArgument alloc] init];
+ argument.cArrayLengthInArg = [attributeDict objectForKey:@"c_array_length_in_arg"];
+ argument.cArrayOfFixedLength = [[attributeDict objectForKey:@"c_array_of_fixed_length"] isEqualToString:@"true"];
+ argument.cArrayDelimitedByNull = [[attributeDict objectForKey:@"c_array_delimited_by_null"] isEqualToString:@"true"];
+ argument.cArrayOfVariableLength = [[attributeDict objectForKey:@"c_array_of_variable_length"] isEqualToString:@"true"];
+ argument.functionPointer = [[attributeDict objectForKey:@"function_pointer"] isEqualToString:@"true"];
+ argument.signature = [attributeDict objectForKey:@"sel_of_type"];
+ argument.signature64 = [attributeDict objectForKey:@"sel_of_type64"];
+ argument.cArrayLengthInReturnValue = [[attributeDict objectForKey:@"c_array_length_in_retval"] isEqualToString:@"true"];
+ argument.acceptsNull = ![[attributeDict objectForKey:@"null_accepted"] isEqualToString:@"false"];
+ argument.acceptsPrintfFormat = [[attributeDict objectForKey:@"printf_format"] isEqualToString:@"true"];
+ argument.alreadyRetained = [[attributeDict objectForKey:@"already_retained"] isEqualToString:@"true"];
+ argument.type = [attributeDict objectForKey:@"type"];
+ argument.type64 = [attributeDict objectForKey:@"type64"];
+ argument.index = [[attributeDict objectForKey:@"index"] integerValue];
+
+ id currentSymbol = [_symbolStack lastObject];
+ if ([currentSymbol isKindOfClass:[MOBridgeSupportMethod class]]) {
+ [(MOBridgeSupportMethod *)currentSymbol addArgument:argument];
+ }
else if ([currentSymbol isKindOfClass:[MOBridgeSupportFunction class]]) {
- [(MOBridgeSupportFunction *)currentSymbol addArgument:argument];
- }
+ [(MOBridgeSupportFunction *)currentSymbol addArgument:argument];
+ }
else if ([currentSymbol isKindOfClass:[MOBridgeSupportArgument class]]) {
- [(MOBridgeSupportArgument *)currentSymbol addArgument:argument];
- }
-
- [_symbolStack addObject:argument];
- }
- else if ([elementName isEqualToString:@"retval"]) {
- // Return value
- MOBridgeSupportArgument *argument = [[[MOBridgeSupportArgument alloc] init] autorelease];
- argument.cArrayLengthInArg = [attributeDict objectForKey:@"c_array_length_in_arg"];
- argument.cArrayOfFixedLength = [[attributeDict objectForKey:@"c_array_of_fixed_length"] isEqualToString:@"true"];
- argument.cArrayDelimitedByNull = [[attributeDict objectForKey:@"c_array_delimited_by_null"] isEqualToString:@"true"];
- argument.cArrayOfVariableLength = [[attributeDict objectForKey:@"c_array_of_variable_length"] isEqualToString:@"true"];
- argument.functionPointer = [[attributeDict objectForKey:@"function_pointer"] isEqualToString:@"true"];
- argument.signature = [attributeDict objectForKey:@"sel_of_type"];
- argument.signature64 = [attributeDict objectForKey:@"sel_of_type64"];
- argument.cArrayLengthInReturnValue = [[attributeDict objectForKey:@"c_array_length_in_retval"] isEqualToString:@"true"];
- argument.acceptsNull = ![[attributeDict objectForKey:@"null_accepted"] isEqualToString:@"false"];
- argument.acceptsPrintfFormat = [[attributeDict objectForKey:@"printf_format"] isEqualToString:@"true"];
- argument.alreadyRetained = [[attributeDict objectForKey:@"already_retained"] isEqualToString:@"true"];
- argument.type = [attributeDict objectForKey:@"type"];
- argument.type64 = [attributeDict objectForKey:@"type64"];
- argument.index = [[attributeDict objectForKey:@"index"] integerValue];
-
- id currentSymbol = [_symbolStack lastObject];
- if ([currentSymbol isKindOfClass:[MOBridgeSupportMethod class]]) {
- [(MOBridgeSupportMethod *)currentSymbol setReturnValue:argument];
- }
+ [(MOBridgeSupportArgument *)currentSymbol addArgument:argument];
+ }
+
+ [_symbolStack addObject:argument];
+ }
+ else if ([elementName isEqualToString:@"retval"]) {
+ // Return value
+ MOBridgeSupportArgument *argument = [[MOBridgeSupportArgument alloc] init];
+ argument.cArrayLengthInArg = [attributeDict objectForKey:@"c_array_length_in_arg"];
+ argument.cArrayOfFixedLength = [[attributeDict objectForKey:@"c_array_of_fixed_length"] isEqualToString:@"true"];
+ argument.cArrayDelimitedByNull = [[attributeDict objectForKey:@"c_array_delimited_by_null"] isEqualToString:@"true"];
+ argument.cArrayOfVariableLength = [[attributeDict objectForKey:@"c_array_of_variable_length"] isEqualToString:@"true"];
+ argument.functionPointer = [[attributeDict objectForKey:@"function_pointer"] isEqualToString:@"true"];
+ argument.signature = [attributeDict objectForKey:@"sel_of_type"];
+ argument.signature64 = [attributeDict objectForKey:@"sel_of_type64"];
+ argument.cArrayLengthInReturnValue = [[attributeDict objectForKey:@"c_array_length_in_retval"] isEqualToString:@"true"];
+ argument.acceptsNull = ![[attributeDict objectForKey:@"null_accepted"] isEqualToString:@"false"];
+ argument.acceptsPrintfFormat = [[attributeDict objectForKey:@"printf_format"] isEqualToString:@"true"];
+ argument.alreadyRetained = [[attributeDict objectForKey:@"already_retained"] isEqualToString:@"true"];
+ argument.type = [attributeDict objectForKey:@"type"];
+ argument.type64 = [attributeDict objectForKey:@"type64"];
+ argument.index = [[attributeDict objectForKey:@"index"] integerValue];
+
+ id currentSymbol = [_symbolStack lastObject];
+ if ([currentSymbol isKindOfClass:[MOBridgeSupportMethod class]]) {
+ [(MOBridgeSupportMethod *)currentSymbol setReturnValue:argument];
+ }
else if ([currentSymbol isKindOfClass:[MOBridgeSupportFunction class]]) {
- [(MOBridgeSupportFunction *)currentSymbol setReturnValue:argument];
- }
+ [(MOBridgeSupportFunction *)currentSymbol setReturnValue:argument];
+ }
else if ([currentSymbol isKindOfClass:[MOBridgeSupportArgument class]]) {
- [(MOBridgeSupportArgument *)currentSymbol setReturnValue:argument];
- }
-
- [_symbolStack addObject:argument];
- }
+ [(MOBridgeSupportArgument *)currentSymbol setReturnValue:argument];
+ }
+
+ [_symbolStack addObject:argument];
+ }
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
#if PARSER_DEBUG
- NSLog(@"Parser didEndElement: %@", elementName);
+ NSLog(@"Parser didEndElement: %@", elementName);
#endif
-
- MOBridgeSupportSymbol *currentSymbol = [_symbolStack lastObject];
- if ([elementName isEqualToString:@"class"]) {
- // Class
- if ([currentSymbol isKindOfClass:[MOBridgeSupportClass class]]) {
- [_symbolStack removeLastObject];
- }
- }
- else if ([elementName isEqualToString:@"informal_protocol"]) {
- // Informal protocol
- if ([currentSymbol isKindOfClass:[MOBridgeSupportInformalProtocol class]]) {
- [_symbolStack removeLastObject];
- }
- }
- else if ([elementName isEqualToString:@"method"]) {
- // Method
- if ([currentSymbol isKindOfClass:[MOBridgeSupportMethod class]]) {
- [_symbolStack removeLastObject];
- }
- }
- else if ([elementName isEqualToString:@"function"]) {
- // Function
- if ([currentSymbol isKindOfClass:[MOBridgeSupportFunction class]]) {
- [_symbolStack removeLastObject];
- }
- }
- else if ([elementName isEqualToString:@"arg"]
+
+ MOBridgeSupportSymbol *currentSymbol = [_symbolStack lastObject];
+ if ([elementName isEqualToString:@"class"]) {
+ // Class
+ if ([currentSymbol isKindOfClass:[MOBridgeSupportClass class]]) {
+ [_symbolStack removeLastObject];
+ }
+ }
+ else if ([elementName isEqualToString:@"informal_protocol"]) {
+ // Informal protocol
+ if ([currentSymbol isKindOfClass:[MOBridgeSupportInformalProtocol class]]) {
+ [_symbolStack removeLastObject];
+ }
+ }
+ else if ([elementName isEqualToString:@"method"]) {
+ // Method
+ if ([currentSymbol isKindOfClass:[MOBridgeSupportMethod class]]) {
+ [_symbolStack removeLastObject];
+ }
+ }
+ else if ([elementName isEqualToString:@"function"]) {
+ // Function
+ if ([currentSymbol isKindOfClass:[MOBridgeSupportFunction class]]) {
+ [_symbolStack removeLastObject];
+ }
+ }
+ else if ([elementName isEqualToString:@"arg"]
|| [elementName isEqualToString:@"retval"]) {
- // Argument
- if ([currentSymbol isKindOfClass:[MOBridgeSupportArgument class]]) {
- [_symbolStack removeLastObject];
- }
- }
+ // Argument
+ if ([currentSymbol isKindOfClass:[MOBridgeSupportArgument class]]) {
+ [_symbolStack removeLastObject];
+ }
+ }
}
@end
View
231 mocha/BridgeSupport/MOBridgeSupportSymbol.m
@@ -13,9 +13,8 @@ @implementation MOBridgeSupportSymbol
@synthesize name=_name;
-- (void)dealloc {
- [_name release];
- [super dealloc];
+- (NSString *)description {
+ return [NSString stringWithFormat:@"<%@: %p : name=%@>", [self class], self, self.name];
}
@end
@@ -27,12 +26,6 @@ @implementation MOBridgeSupportStruct
@synthesize type64=_type64;
@synthesize opaque=_opaque;
-- (void)dealloc {
- [_type release];
- [_type64 release];
- [super dealloc];
-}
-
@end
@@ -44,14 +37,6 @@ @implementation MOBridgeSupportCFType
@synthesize tollFreeBridgedClassName=_tollFreeBridgedClassName;
@synthesize getTypeIDFunctionName=_getTypeIDFunctionName;
-- (void)dealloc {
- [_type release];
- [_type64 release];
- [_tollFreeBridgedClassName release];
- [_getTypeIDFunctionName release];
- [super dealloc];
-}
-
@end
@@ -62,12 +47,6 @@ @implementation MOBridgeSupportOpaque
@synthesize hasMagicCookie=_hasMagicCookie;
-- (void)dealloc {
- [_type release];
- [_type64 release];
- [super dealloc];
-}
-
@end
@@ -78,12 +57,6 @@ @implementation MOBridgeSupportConstant
@synthesize hasMagicCookie=_hasMagicCookie;
-- (void)dealloc {
- [_type release];
- [_type64 release];
- [super dealloc];
-}
-
@end
@@ -92,11 +65,6 @@ @implementation MOBridgeSupportStringConstant
@synthesize value=_value;
@synthesize hasNSString=_hasNSString;
-- (void)dealloc {
- [_value release];
- [super dealloc];
-}
-
@end
@@ -108,13 +76,6 @@ @implementation MOBridgeSupportEnum
@synthesize ignored=_ignored;
@synthesize suggestion=_suggestion;
-- (void)dealloc {
- [_value release];
- [_value64 release];
- [_suggestion release];
- [super dealloc];
-}
-
@end
@@ -136,35 +97,57 @@ - (id)init {
return self;
}
-- (void)dealloc {
- [_sentinel release];
- [_arguments release];
- [_returnValue release];
- [super dealloc];
+- (NSString *)description {
+ NSString *returnEncoding = nil;
+ if (self.returnValue != nil) {
+#if __LP64__
+ returnEncoding = (self.returnValue.type64 ? self.returnValue.type64 : self.returnValue.type);
+#else
+ returnEncoding = self.returnValue.type;
+#endif
+ if (returnEncoding == nil) {
+ returnEncoding = @"?";
+ }
+ }
+ else {
+ returnEncoding = @"v";
+ }
+
+ NSMutableArray *argumentEncodings = [NSMutableArray arrayWithCapacity:[[self arguments] count]];
+ for (MOBridgeSupportArgument *arg in self.arguments) {
+#if __LP64__
+ NSString *encoding = (arg.type64 ? arg.type64 : arg.type);
+#else
+ NSString *encoding = arg.type;
+#endif
+ [argumentEncodings addObject:(encoding ? encoding : @"?")];
+ }
+
+ return [NSString stringWithFormat:@"<%@: %p : name=%@, variadic=%@, argTypes=%@, returnType=%@>", [self class], self, self.name, (self.variadic ? @"YES" : @"NO"), [argumentEncodings componentsJoinedByString:@","], returnEncoding];
}
#pragma mark -
#pragma mark Arguments
- (NSArray *)arguments {
- return [[_arguments copy] autorelease];
+ return [_arguments copy];
}
- (void)setArguments:(NSArray *)arguments {
- [_arguments setArray:arguments];
+ [_arguments setArray:arguments];
}
- (void)addArgument:(MOBridgeSupportArgument *)argument {
- if (![_arguments containsObject:argument]) {
- [_arguments addObject:argument];
- }
+ if (![_arguments containsObject:argument]) {
+ [_arguments addObject:argument];
+ }
}
- (void)removeArgument:(MOBridgeSupportArgument *)argument {
- if ([_arguments containsObject:argument]) {
- [_arguments removeObject:argument];
- }
+ if ([_arguments containsObject:argument]) {
+ [_arguments removeObject:argument];
+ }
}
@end
@@ -174,53 +157,43 @@ @implementation MOBridgeSupportFunctionAlias
@synthesize original=_original;
-- (void)dealloc {
- [_original release];
- [super dealloc];
-}
-
@end
@implementation MOBridgeSupportClass {
- NSMutableArray *_methods;
+ NSMutableArray *_methods;
}
- (id)init {
- self = [super init];
- if (self) {
- _methods = [[NSMutableArray alloc] init];
- }
- return self;
-}
-
-- (void)dealloc {
- [_methods release];
- [super dealloc];
+ self = [super init];
+ if (self) {
+ _methods = [[NSMutableArray alloc] init];
+ }
+ return self;
}
#pragma mark -
#pragma mark Methods
- (NSArray *)methods {
- return _methods;
+ return _methods;
}
- (void)setMethods:(NSArray *)methods {
- [_methods setArray:methods];
+ [_methods setArray:methods];
}
- (void)addMethod:(MOBridgeSupportMethod *)method {
- if (![_methods containsObject:method]) {
- [_methods addObject:method];
- }
+ if (![_methods containsObject:method]) {
+ [_methods addObject:method];
+ }
}
- (void)removeMethod:(MOBridgeSupportMethod *)method {
- if ([_methods containsObject:method]) {
- [_methods removeObject:method];
- }
+ if ([_methods containsObject:method]) {
+ [_methods removeObject:method];
+ }
}
- (MOBridgeSupportMethod *)methodWithSelector:(SEL)selector {
@@ -237,44 +210,39 @@ - (MOBridgeSupportMethod *)methodWithSelector:(SEL)selector {
@implementation MOBridgeSupportInformalProtocol {
- NSMutableArray *_methods;
+ NSMutableArray *_methods;
}
- (id)init {
- self = [super init];
- if (self) {
- _methods = [[NSMutableArray alloc] init];
- }
- return self;
-}
-
-- (void)dealloc {
- [_methods release];
- [super dealloc];
+ self = [super init];
+ if (self) {
+ _methods = [[NSMutableArray alloc] init];
+ }
+ return self;
}
#pragma mark -
#pragma mark Methods
- (NSArray *)methods {
- return _methods;
+ return _methods;
}
- (void)setMethods:(NSArray *)methods {
- [_methods setArray:methods];
+ [_methods setArray:methods];
}
- (void)addMethod:(MOBridgeSupportMethod *)method {
- if (![_methods containsObject:method]) {
- [_methods addObject:method];
- }
+ if (![_methods containsObject:method]) {
+ [_methods addObject:method];
+ }
}
- (void)removeMethod:(MOBridgeSupportMethod *)method {
- if ([_methods containsObject:method]) {
- [_methods removeObject:method];
- }
+ if ([_methods containsObject:method]) {
+ [_methods removeObject:method];
+ }
}
- (MOBridgeSupportMethod *)methodWithSelector:(SEL)selector {
@@ -291,7 +259,7 @@ - (MOBridgeSupportMethod *)methodWithSelector:(SEL)selector {
@implementation MOBridgeSupportMethod {
- NSMutableArray *_arguments;
+ NSMutableArray *_arguments;
}
@synthesize selector=_selector;
@@ -310,45 +278,35 @@ @implementation MOBridgeSupportMethod {
@synthesize suggestion=_suggestion;
- (id)init {
- self = [super init];
- if (self) {
- _arguments = [[NSMutableArray alloc] init];
- }
- return self;
-}
-
-- (void)dealloc {
- [_type release];
- [_type64 release];
- [_arguments release];
- [_returnValue release];
- [_sentinel release];
- [_suggestion release];
- [super dealloc];
+ self = [super init];
+ if (self) {
+ _arguments = [[NSMutableArray alloc] init];
+ }
+ return self;
}
#pragma mark -
#pragma mark Arguments
- (NSArray *)arguments {
- return [[_arguments copy] autorelease];
+ return [_arguments copy];
}
- (void)setArguments:(NSArray *)arguments {
- [_arguments setArray:arguments];
+ [_arguments setArray:arguments];
}
- (void)addArgument:(MOBridgeSupportArgument *)argument {
- if (![_arguments containsObject:argument]) {
- [_arguments addObject:argument];
- }
+ if (![_arguments containsObject:argument]) {
+ [_arguments addObject:argument];
+ }
}
- (void)removeArgument:(MOBridgeSupportArgument *)argument {
- if ([_arguments containsObject:argument]) {
- [_arguments removeObject:argument];
- }
+ if ([_arguments containsObject:argument]) {
+ [_arguments removeObject:argument];
+ }
}
@end
@@ -390,38 +348,37 @@ - (id)init {
return self;
}
-- (void)dealloc {
- [_type release];
- [_type64 release];
- [_typeModifier release];
- [_signature release];
- [_signature64 release];
- [_cArrayLengthInArg release];
- [super dealloc];
+- (NSString *)description {
+ if (self.typeModifier != nil) {
+ return [NSString stringWithFormat:@"<%@: %p : type=%@, typeModifier=%@>", [self class], self, (self.type64 ? self.type64 : self.type), self.typeModifier];
+ }
+ else {
+ return [NSString stringWithFormat:@"<%@: %p : type=%@>", [self class], self, (self.type64 ? self.type64 : self.type)];
+ }
}
#pragma mark -
#pragma mark Arguments
- (NSArray *)arguments {
- return [[_arguments copy] autorelease];
+ return [_arguments copy];
}
- (void)setArguments:(NSArray *)arguments {
- [_arguments setArray:arguments];
+ [_arguments setArray:arguments];
}
- (void)addArgument:(MOBridgeSupportArgument *)argument {
- if (![_arguments containsObject:argument]) {
- [_arguments addObject:argument];
- }
+ if (![_arguments containsObject:argument]) {
+ [_arguments addObject:argument];
+ }
}
- (void)removeArgument:(MOBridgeSupportArgument *)argument {
- if ([_arguments containsObject:argument]) {
- [_arguments removeObject:argument];
- }
+ if ([_arguments containsObject:argument]) {
+ [_arguments removeObject:argument];
+ }
}
@end
View
9 mocha/MochaDefines.h
@@ -8,5 +8,12 @@
#define MOCHA_EXTERN extern __attribute__((visibility("default")))
-#define MOCHA_STATIC_INLINE static inline __attribute__((visibility("default")))
+#define MOCHA_INLINE static inline __attribute__((visibility("default")))
+#if (__has_feature(objc_fixed_enum))
+#define MOCHA_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define MOCHA_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
+#else
+#define MOCHA_ENUM(_type, _name) _type _name; enum
+#define MOCHA_OPTIONS(_type, _name) _type _name; enum
+#endif
View
2 mocha/MochaRuntime.h
@@ -57,7 +57,7 @@
*
* @result An object conforming to the MochaDelegate protocol
*/
-@property (assign) id <MochaDelegate> delegate;
+@property (unsafe_unretained) id <MochaDelegate> delegate;
/*!
View
508 mocha/MochaRuntime.m
@@ -54,7 +54,7 @@
static JSValueRef MOBoxedObject_convertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef *exception);
static bool MOBoxedObject_hasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef *exception);
-static JSValueRef MOFunction_callAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception);
+static JSValueRef MOFunction_callAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception);
NSString * const MORuntimeException = @"MORuntimeException";
@@ -215,11 +215,6 @@ - (void)dealloc {
[self cleanUp];
JSGlobalContextRelease(_ctx);
-
- [_exportedObjects release];
- [_frameworkSearchPaths release];
-
- [super dealloc];
}
- (JSGlobalContextRef)context {
@@ -238,54 +233,58 @@ - (void)setValue:(id)value forUndefinedKey:(NSString *)key {
[_exportedObjects setObject:value forKey:key];
}
+- (void)setNilValueForKey:(NSString *)key {
+ [_exportedObjects removeObjectForKey:key];
+}
+
#pragma mark -
#pragma mark Object Conversion
static NSString * const MOMochaRuntimeObjectBoxKey = @"MOMochaRuntimeObjectBoxKey";
+ (JSValueRef)JSValueForObject:(id)object inContext:(JSContextRef)ctx {
- return [[Mocha runtimeWithContext:ctx] JSValueForObject:object];
+ return [[Mocha runtimeWithContext:ctx] JSValueForObject:object];
}
+ (id)objectForJSValue:(JSValueRef)value inContext:(JSContextRef)ctx {
return [self objectForJSValue:value inContext:ctx unboxObjects:YES];
}
+ (id)objectForJSValue:(JSValueRef)value inContext:(JSContextRef)ctx unboxObjects:(BOOL)unboxObjects {
- if (value == NULL || JSValueIsUndefined(ctx, value)) {
- return [MOUndefined undefined];
- }
+ if (value == NULL || JSValueIsUndefined(ctx, value)) {
+ return [MOUndefined undefined];
+ }
if (JSValueIsNull(ctx, value)) {
return nil;
}
-
- if (JSValueIsString(ctx, value)) {
- JSStringRef resultStringJS = JSValueToStringCopy(ctx, value, NULL);
- NSString *resultString = [(NSString *)JSStringCopyCFString(kCFAllocatorDefault, resultStringJS) autorelease];
- JSStringRelease(resultStringJS);
- return resultString;
- }
-
- if (JSValueIsNumber(ctx, value)) {
- double v = JSValueToNumber(ctx, value, NULL);
+
+ if (JSValueIsString(ctx, value)) {
+ JSStringRef resultStringJS = JSValueToStringCopy(ctx, value, NULL);
+ NSString *resultString = (NSString *)CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, resultStringJS));
+ JSStringRelease(resultStringJS);
+ return resultString;
+ }
+
+ if (JSValueIsNumber(ctx, value)) {
+ double v = JSValueToNumber(ctx, value, NULL);
return [NSNumber numberWithDouble:v];
- }
-
- if (JSValueIsBoolean(ctx, value)) {
- bool v = JSValueToBoolean(ctx, value);
+ }
+
+ if (JSValueIsBoolean(ctx, value)) {
+ bool v = JSValueToBoolean(ctx, value);
return [NSNumber numberWithBool:v];
- }
-
- if (!JSValueIsObject(ctx, value)) {
- return nil;
- }
-
- JSObjectRef jsObject = JSValueToObject(ctx, value, NULL);
- id private = JSObjectGetPrivate(jsObject);
-
- if (private != nil) {
+ }
+
+ if (!JSValueIsObject(ctx, value)) {
+ return nil;
+ }
+
+ JSObjectRef jsObject = JSValueToObject(ctx, value, NULL);
+ id private = (__bridge id)JSObjectGetPrivate(jsObject);
+
+ if (private != nil) {
if ([private isKindOfClass:[MOBox class]]) {
if (unboxObjects == YES) {
// Boxed ObjC object
@@ -305,168 +304,168 @@ + (id)objectForJSValue:(JSValueRef)value inContext:(JSContextRef)ctx unboxObject
else {
return private;
}
- }
- else {
+ }
+ else {
BOOL isFunction = JSObjectIsFunction(ctx, jsObject);
if (isFunction) {
// Function
return [MOJavaScriptObject objectWithJSObject:jsObject context:ctx];
}
- // Normal JS object
- JSStringRef scriptJS = JSStringCreateWithUTF8CString("return arguments[0].constructor == Array.prototype.constructor");
- JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL);
- JSValueRef result = JSObjectCallAsFunction(ctx, fn, NULL, 1, (JSValueRef *)&jsObject, NULL);
- JSStringRelease(scriptJS);
-
- BOOL isArray = JSValueToBoolean(ctx, result);
- if (isArray) {
- // Array
- return [self arrayForJSArray:jsObject inContext:ctx];
- }
- else {
- // Object
- return [self dictionaryForJSHash:jsObject inContext:ctx];
- }
- }
-
- return nil;
+ // Normal JS object
+ JSStringRef scriptJS = JSStringCreateWithUTF8CString("return arguments[0].constructor == Array.prototype.constructor");
+ JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL);
+ JSValueRef result = JSObjectCallAsFunction(ctx, fn, NULL, 1, (JSValueRef *)&jsObject, NULL);
+ JSStringRelease(scriptJS);
+
+ BOOL isArray = JSValueToBoolean(ctx, result);
+ if (isArray) {
+ // Array
+ return [self arrayForJSArray:jsObject inContext:ctx];
+ }
+ else {
+ // Object
+ return [self dictionaryForJSHash:jsObject inContext:ctx];
+ }
+ }
+
+ return nil;
}
+ (NSArray *)arrayForJSArray:(JSObjectRef)arrayValue inContext:(JSContextRef)ctx {
- JSValueRef exception = NULL;
- JSStringRef lengthJS = JSStringCreateWithUTF8CString("length");
- NSUInteger length = JSValueToNumber(ctx, JSObjectGetProperty(ctx, arrayValue, lengthJS, NULL), &exception);
- JSStringRelease(lengthJS);
-
- if (exception != NULL) {
- return nil;
- }
-
- NSMutableArray *array = [NSMutableArray arrayWithCapacity:length];
-
- for (NSUInteger i=0; i<length; i++) {
- id obj = nil;
- JSValueRef jsValue = JSObjectGetPropertyAtIndex(ctx, arrayValue, (unsigned int)i, &exception);
- if (exception != NULL) {
- return nil;
- }
-
- obj = [self objectForJSValue:jsValue inContext:ctx unboxObjects:YES];
- if (obj == nil) {
- obj = [NSNull null];
- }
-
- [array addObject:obj];
- }
-
- return [[array copy] autorelease];
+ JSValueRef exception = NULL;
+ JSStringRef lengthJS = JSStringCreateWithUTF8CString("length");
+ NSUInteger length = JSValueToNumber(ctx, JSObjectGetProperty(ctx, arrayValue, lengthJS, NULL), &exception);
+ JSStringRelease(lengthJS);
+
+ if (exception != NULL) {
+ return nil;
+ }
+
+ NSMutableArray *array = [NSMutableArray arrayWithCapacity:length];
+
+ for (NSUInteger i=0; i<length; i++) {
+ id obj = nil;
+ JSValueRef jsValue = JSObjectGetPropertyAtIndex(ctx, arrayValue, (unsigned int)i, &exception);
+ if (exception != NULL) {
+ return nil;
+ }
+
+ obj = [self objectForJSValue:jsValue inContext:ctx unboxObjects:YES];
+ if (obj == nil) {
+ obj = [NSNull null];
+ }
+
+ [array addObject:obj];
+ }
+
+ return [array copy];
}
+ (NSDictionary *)dictionaryForJSHash:(JSObjectRef)hashValue inContext:(JSContextRef)ctx {
- JSPropertyNameArrayRef names = JSObjectCopyPropertyNames(ctx, hashValue);
- NSUInteger length = JSPropertyNameArrayGetCount(names);
-
- NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:length];
- JSValueRef exception = NULL;
-
- for (NSUInteger i=0; i<length; i++) {
- id obj = nil;
- JSStringRef name = JSPropertyNameArrayGetNameAtIndex(names, i);
- JSValueRef jsValue = JSObjectGetProperty(ctx, hashValue, name, &exception);
-
- if (exception != NULL) {
- return NO;
- }
-
- obj = [self objectForJSValue:jsValue inContext:ctx unboxObjects:YES];
- if (obj == nil) {
- obj = [NSNull null];
- }
-
- NSString *key = [(NSString *)JSStringCopyCFString(kCFAllocatorDefault, name) autorelease];
- [dictionary setObject:obj forKey:key];
- }
-
- JSPropertyNameArrayRelease(names);
-
- return [[dictionary copy] autorelease];
+ JSPropertyNameArrayRef names = JSObjectCopyPropertyNames(ctx, hashValue);
+ NSUInteger length = JSPropertyNameArrayGetCount(names);
+
+ NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:length];
+ JSValueRef exception = NULL;
+
+ for (NSUInteger i=0; i<length; i++) {
+ id obj = nil;
+ JSStringRef name = JSPropertyNameArrayGetNameAtIndex(names, i);
+ JSValueRef jsValue = JSObjectGetProperty(ctx, hashValue, name, &exception);
+
+ if (exception != NULL) {
+ return nil;
+ }
+
+ obj = [self objectForJSValue:jsValue inContext:ctx unboxObjects:YES];
+ if (obj == nil) {
+ obj = [NSNull null];
+ }
+
+ NSString *key = (NSString *)CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, name));
+ [dictionary setObject:obj forKey:key];
+ }
+
+ JSPropertyNameArrayRelease(names);
+
+ return [dictionary copy];
}
- (JSValueRef)JSValueForObject:(id)object {
- JSValueRef value = NULL;
-
- if ([object isKindOfClass:[MOBox class]]) {
+ JSValueRef value = NULL;
+
+ if ([object isKindOfClass:[MOBox class]]) {
value = [object JSObject];
}
/*else if ([object isKindOfClass:[NSString class]]) {
- JSStringRef string = JSStringCreateWithCFString((CFStringRef)object);
- value = JSValueMakeString(_ctx, string);
- JSStringRelease(string);
- }
- else if ([object isKindOfClass:[NSNumber class]]) {
- double doubleValue = [object doubleValue];
- value = JSValueMakeNumber(_ctx, doubleValue);
- }*/
+ JSStringRef string = JSStringCreateWithCFString((CFStringRef)object);
+ value = JSValueMakeString(_ctx, string);
+ JSStringRelease(string);
+ }
+ else if ([object isKindOfClass:[NSNumber class]]) {
+ double doubleValue = [object doubleValue];
+ value = JSValueMakeNumber(_ctx, doubleValue);
+ }*/
else if ([object isKindOfClass:NSClassFromString(@"NSBlock")]) {
// Auto-box blocks inside of a closure object
MOClosure *closure = [MOClosure closureWithBlock:object];
value = [self boxedJSObjectForObject:closure];
}
- else if (object == nil/* || [object isKindOfClass:[NSNull class]]*/) {
- value = JSValueMakeNull(_ctx);
- }
+ else if (object == nil/* || [object isKindOfClass:[NSNull class]]*/) {
+ value = JSValueMakeNull(_ctx);
+ }
else if (object == [MOUndefined undefined]) {
value = JSValueMakeUndefined(_ctx);
}
-
- if (value == NULL) {
- value = [self boxedJSObjectForObject:object];
- }
-
- return value;
+
+ if (value == NULL) {
+ value = [self boxedJSObjectForObject:object];
+ }
+
+ return value;
}
- (id)objectForJSValue:(JSValueRef)value {
return [self objectForJSValue:value unboxObjects:YES];
}
- (id)objectForJSValue:(JSValueRef)value unboxObjects:(BOOL)unboxObjects {
- return [Mocha objectForJSValue:value inContext:_ctx unboxObjects:unboxObjects];
+ return [Mocha objectForJSValue:value inContext:_ctx unboxObjects:unboxObjects];
}
- (JSObjectRef)boxedJSObjectForObject:(id)object {
if (object == nil) {
return NULL;
}
- MOBox *box = objc_getAssociatedObject(object, MOMochaRuntimeObjectBoxKey);
+ MOBox *box = objc_getAssociatedObject(object, (__bridge const void *)(MOMochaRuntimeObjectBoxKey));
if (box != nil) {
return [box JSObject];
}
- box = [[[MOBox alloc] init] autorelease];
+ box = [[MOBox alloc] init];
box.representedObject = object;
JSObjectRef jsObject = NULL;
if ([object isKindOfClass:[MOMethod class]]
|| [object isKindOfClass:[MOClosure class]]
|| [object isKindOfClass:[MOBridgeSupportFunction class]]) {
- jsObject = JSObjectMake(_ctx, MOFunctionClass, box);
+ jsObject = JSObjectMake(_ctx, MOFunctionClass, (__bridge void *)(box));
}
else {
- jsObject = JSObjectMake(_ctx, MOBoxedObjectClass, box);;
+ jsObject = JSObjectMake(_ctx, MOBoxedObjectClass, (__bridge void *)(box));
}
box.JSObject = jsObject;
- objc_setAssociatedObject(object, MOMochaRuntimeObjectBoxKey, box, OBJC_ASSOCIATION_RETAIN);
+ objc_setAssociatedObject(object, (__bridge const void *)(MOMochaRuntimeObjectBoxKey), box, OBJC_ASSOCIATION_RETAIN);
return jsObject;
}
- (id)unboxedObjectForJSObject:(JSObjectRef)jsObject {
- id private = JSObjectGetPrivate(jsObject);
+ id private = (__bridge id)(JSObjectGetPrivate(jsObject));
if ([private isKindOfClass:[MOBox class]]) {
return [private representedObject];
}
@@ -498,7 +497,7 @@ - (JSValueRef)setObject:(id)object withName:(NSString *)name {
- (JSValueRef)setObject:(id)object withName:(NSString *)name attributes:(JSPropertyAttributes)attributes {
JSValueRef jsValue = [self JSValueForObject:object];
-
+
// Set
JSValueRef exception = NULL;
JSStringRef jsName = JSStringCreateWithUTF8CString([name UTF8String]);
@@ -547,7 +546,7 @@ - (JSValueRef)evalJSString:(NSString *)string scriptPath:(NSString *)scriptPath
return NULL;
}
- JSStringRef jsString = JSStringCreateWithCFString((CFStringRef)string);
+ JSStringRef jsString = JSStringCreateWithCFString((__bridge CFStringRef)string);
JSStringRef jsScriptPath = (scriptPath != nil ? JSStringCreateWithUTF8CString([scriptPath UTF8String]) : NULL);
JSValueRef exception = NULL;
@@ -626,7 +625,7 @@ - (JSValueRef)callJSFunction:(JSObjectRef)jsFunction withArgumentsInArray:(NSArr
for (NSUInteger i=0; i<argumentsCount; i++) {
id argument = [arguments objectAtIndex:i];
JSValueRef value = [self JSValueForObject:argument];
- jsArguments[i] = value;
+ jsArguments[i] = value;
}
}
@@ -671,7 +670,7 @@ - (BOOL)isSyntaxValidForString:(NSString *)string {
+ (NSException *)exceptionWithJSException:(JSValueRef)exception context:(JSContextRef)ctx {
JSStringRef resultStringJS = JSValueToStringCopy(ctx, exception, NULL);
- NSString *error = [(NSString *)JSStringCopyCFString(kCFAllocatorDefault, resultStringJS) autorelease];
+ NSString *error = (NSString *)CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, resultStringJS));
JSStringRelease(resultStringJS);
if (JSValueGetType(ctx, exception) != kJSTypeObject) {
@@ -688,11 +687,11 @@ + (NSException *)exceptionWithJSException:(JSValueRef)exception context:(JSConte
for (size_t i = 0; i < count; i++) {
JSStringRef jsName = JSPropertyNameArrayGetNameAtIndex(jsNames, i);
- NSString *name = [(NSString *)JSStringCopyCFString(kCFAllocatorDefault, jsName) autorelease];
+ NSString *name = (NSString *)CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, jsName));
JSValueRef jsValueRef = JSObjectGetProperty(ctx, jsObject, jsName, NULL);
JSStringRef valueJS = JSValueToStringCopy(ctx, jsValueRef, NULL);
- NSString *value = [(NSString *)JSStringCopyCFString(kCFAllocatorDefault, valueJS) autorelease];
+ NSString *value = (NSString *)CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, valueJS));
JSStringRelease(valueJS);
[userInfo setObject:value forKey:name];
@@ -758,11 +757,11 @@ - (BOOL)loadFrameworkWithName:(NSString *)frameworkName inDirectory:(NSString *)
// Load the BridgeSupport data
NSString *bridgeSupportPath = [frameworkPath stringByAppendingPathComponent:[NSString stringWithFormat:@"Resources/BridgeSupport/%@.bridgesupport", frameworkName]];
- NSError *error = nil;
+ NSError *error = nil;
if (![[MOBridgeSupportController sharedController] loadBridgeSupportAtURL:[NSURL fileURLWithPath:bridgeSupportPath] error:&error]) {
- //NSLog(@"ERROR: Failed to load BridgeSupport for framework at path: %@. Error: %@", bridgeSupportPath, error);
- //return NO;
- }
+ //NSLog(@"ERROR: Failed to load BridgeSupport for framework at path: %@. Error: %@", bridgeSupportPath, error);
+ //return NO;
+ }
// Load the extras BridgeSupport dylib
NSString *dylibPath = [frameworkPath stringByAppendingPathComponent:[NSString stringWithFormat:@"Resources/BridgeSupport/%@.dylib", frameworkName]];
@@ -878,7 +877,7 @@ - (void)finalizeForMochaScript {
#pragma mark Global Object
JSValueRef Mocha_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyNameJS, JSValueRef *exception) {
- NSString *propertyName = [(NSString *)JSStringCopyCFString(kCFAllocatorDefault, propertyNameJS) autorelease];
+ NSString *propertyName = (NSString *)CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, propertyNameJS));
if ([propertyName isEqualToString:@"__mocha__"]) {
return NULL;
@@ -916,7 +915,7 @@ JSValueRef Mocha_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef p
// Constants
else if ([symbol isKindOfClass:[MOBridgeSupportConstant class]]) {
- NSString *type = nil;
+ NSString *type = nil;
#if __LP64__
type = [(MOBridgeSupportConstant *)symbol type64];
if (type == nil) {
@@ -927,13 +926,13 @@ JSValueRef Mocha_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef p
#endif
// Raise if there is no type
- if (type == nil) {
- NSException *e = [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"No type defined for symbol: %@", symbol] userInfo:nil];
+ if (type == nil) {
+ NSException *e = [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"No type defined for symbol: %@", symbol] userInfo:nil];
if (exception != NULL) {
*exception = [runtime JSValueForObject:e];
}
return NULL;
- }
+ }
// Grab symbol
void *symbol = dlsym(RTLD_DEFAULT, [propertyName UTF8String]);
@@ -946,7 +945,7 @@ JSValueRef Mocha_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef p
}
char typeEncodingChar = [type UTF8String][0];
- MOFunctionArgument *argument = [[[MOFunctionArgument alloc] init] autorelease];
+ MOFunctionArgument *argument = [[MOFunctionArgument alloc] init];
if (typeEncodingChar == _C_STRUCT_B) {
[argument setStructureTypeEncoding:type withCustomStorage:symbol];
@@ -970,18 +969,18 @@ JSValueRef Mocha_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef p
// Enums
else if ([symbol isKindOfClass:[MOBridgeSupportEnum class]]) {
- NSNumber *value = [(MOBridgeSupportEnum *)symbol value];
-
+ NSNumber *value = [(MOBridgeSupportEnum *)symbol value];
+
double doubleValue = 0;
-
+
#if __LP64__
- NSNumber *value64 = [(MOBridgeSupportEnum *)symbol value64];
- if (value != nil) {
- doubleValue = [value doubleValue];
- }
- else if (value64 != nil) {
- doubleValue = [value doubleValue];
- }
+ NSNumber *value64 = [(MOBridgeSupportEnum *)symbol value64];
+ if (value != nil) {
+ doubleValue = [value doubleValue];
+ }
+ else if (value64 != nil) {
+ doubleValue = [value doubleValue];
+ }
else {
NSException *e = [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"No value for enum: %@", symbol] userInfo:nil];
if (exception != NULL) {
@@ -990,9 +989,9 @@ JSValueRef Mocha_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef p
return NULL;
}
#else
- if (value != nil) {
- doubleValue = [value doubleValue];
- }
+ if (value != nil) {
+ doubleValue = [value doubleValue];
+ }
else {
NSException *e = [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"No value for enum: %@", symbol] userInfo:nil];
if (exception != NULL) {
@@ -1022,39 +1021,37 @@ JSValueRef Mocha_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef p
#pragma mark Mocha Objects
static void MOObject_initialize(JSContextRef ctx, JSObjectRef object) {
- MOBox *private = JSObjectGetPrivate(object);
- [private retain];
+
}
static void MOObject_finalize(JSObjectRef object) {
- MOBox *private = JSObjectGetPrivate(object);
+ MOBox *private = (__bridge MOBox *)(JSObjectGetPrivate(object));
id o = [private representedObject];
// Give the object a change to finalize itself
if ([o respondsToSelector:@selector(finalizeForMochaScript)]) {
[o finalizeForMochaScript];
}
- objc_setAssociatedObject(o, MOMochaRuntimeObjectBoxKey, nil, OBJC_ASSOCIATION_RETAIN);
+ // Remove the object association
+ objc_setAssociatedObject(o, (__bridge const void *)(MOMochaRuntimeObjectBoxKey), nil, OBJC_ASSOCIATION_RETAIN);
JSObjectSetPrivate(object, NULL);
-
- [private release];
}
#pragma mark -
#pragma mark Mocha Boxed Objects
static bool MOBoxedObject_hasProperty(JSContextRef ctx, JSObjectRef objectJS, JSStringRef propertyNameJS) {
- NSString *propertyName = [(NSString *)JSStringCopyCFString(NULL, propertyNameJS) autorelease];
-
- //Mocha *runtime = [Mocha runtimeWithContext:ctx];
-
- id private = JSObjectGetPrivate(objectJS);
- id object = [private representedObject];
- Class objectClass = [object class];
-
+ NSString *propertyName = (NSString *)CFBridgingRelease(JSStringCopyCFString(NULL, propertyNameJS));
+
+ //Mocha *runtime = [Mocha runtimeWithContext:ctx];
+
+ id private = (__bridge id)(JSObjectGetPrivate(objectJS));
+ id object = [private representedObject];
+ Class objectClass = [object class];
+
// Property
/*if (runtime.autocallObjCProperties) {
objc_property_t property = class_getProperty(objectClass, [propertyName UTF8String]);
@@ -1065,30 +1062,25 @@ static bool MOBoxedObject_hasProperty(JSContextRef ctx, JSObjectRef objectJS, JS
}
}
}*/
-
- // Association object
- id value = objc_getAssociatedObject(object, propertyName);
- if (value != nil) {
- return YES;
- }
-
- // Method
- SEL selector = MOSelectorFromPropertyName(propertyName);
- NSMethodSignature *methodSignature = [object methodSignatureForSelector:selector];
- if (!methodSignature) {
- selector = MOSelectorFromPropertyName([propertyName stringByAppendingString:@"_"]);
- methodSignature = [object methodSignatureForSelector:selector];
+
+ // Association object
+ id value = objc_getAssociatedObject(object, (__bridge const void *)(propertyName));
+ if (value != nil) {
+ return YES;
}
+ // Method
+ SEL selector = MOSelectorFromPropertyName(propertyName);
+ NSMethodSignature *methodSignature = [object methodSignatureForSelector:selector];
if (methodSignature != nil) {
- if ([objectClass respondsToSelector:@selector(isSelectorExcludedFromMochaScript:)]) {
- if (![objectClass isSelectorExcludedFromMochaScript:selector]) {
- return YES;
- }
- }
- else {
- return YES;
- }