├── .gitignore ├── .gitlab-ci.yml ├── Demo └── NVMAspectsDemo │ ├── NVMAspectsDemo.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── NVMAspectsDemo.xcscheme │ └── NVMAspectsDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── LICENSE ├── NVMAspects.podspec ├── NVMAspects.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── NVMAspects.xcscheme │ └── NVMAspectsTests.xcscheme ├── NVMAspects.xcworkspace └── contents.xcworkspacedata ├── NVMAspects ├── Assets │ └── NVMAspects.bundle │ │ ├── Info.plist │ │ └── Media.xcassets │ │ └── Contents.json ├── Classes │ ├── AspectData.h │ ├── AspectData.m │ ├── Aspects.h │ ├── Aspects.m │ ├── Utils.h │ └── Utils.m ├── Info.plist ├── NVMAspects.h └── libffi │ ├── ffi.h │ ├── ffi_arm.h │ ├── ffi_arm64.h │ ├── ffi_common.h │ ├── ffi_i386.h │ ├── ffi_x86_64.h │ ├── ffitarget.h │ ├── ffitarget_arm.h │ ├── ffitarget_arm64.h │ ├── ffitarget_i386.h │ ├── ffitarget_x86_64.h │ └── libffi.a ├── NVMAspectsTests ├── Info.plist └── NVMStructTests.mm ├── Podfile ├── Podfile.lock ├── Pods ├── Manifest.lock ├── Pods.xcodeproj │ └── project.pbxproj └── Target Support Files │ ├── Pods-NVMAspects │ ├── Info.plist │ ├── Pods-NVMAspects-acknowledgements.markdown │ ├── Pods-NVMAspects-acknowledgements.plist │ ├── Pods-NVMAspects-dummy.m │ ├── Pods-NVMAspects-resources.sh │ ├── Pods-NVMAspects-umbrella.h │ ├── Pods-NVMAspects.debug.xcconfig │ ├── Pods-NVMAspects.modulemap │ └── Pods-NVMAspects.release.xcconfig │ ├── Pods-NVMAspectsDemo │ ├── Info.plist │ ├── Pods-NVMAspectsDemo-acknowledgements.markdown │ ├── Pods-NVMAspectsDemo-acknowledgements.plist │ ├── Pods-NVMAspectsDemo-dummy.m │ ├── Pods-NVMAspectsDemo-frameworks.sh │ ├── Pods-NVMAspectsDemo-resources.sh │ ├── Pods-NVMAspectsDemo-umbrella.h │ ├── Pods-NVMAspectsDemo.debug.xcconfig │ ├── Pods-NVMAspectsDemo.modulemap │ └── Pods-NVMAspectsDemo.release.xcconfig │ └── Pods-NVMAspectsTests │ ├── Info.plist │ ├── Pods-NVMAspectsTests-acknowledgements.markdown │ ├── Pods-NVMAspectsTests-acknowledgements.plist │ ├── Pods-NVMAspectsTests-dummy.m │ ├── Pods-NVMAspectsTests-frameworks.sh │ ├── Pods-NVMAspectsTests-resources.sh │ ├── Pods-NVMAspectsTests-umbrella.h │ ├── Pods-NVMAspectsTests.debug.xcconfig │ ├── Pods-NVMAspectsTests.modulemap │ └── Pods-NVMAspectsTests.release.xcconfig └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/f93202c42e947f3be10b3bd6912b48e30e7e9781/Objective-C.gitignore 2 | 3 | # Xcode 4 | # 5 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 6 | 7 | ## Build generated 8 | build/ 9 | DerivedData/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xcuserstate 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | *.dSYM.zip 30 | *.dSYM 31 | 32 | # CocoaPods 33 | # 34 | # We recommend against adding the Pods directory to your .gitignore. However 35 | # you should judge for yourself, the pros and cons are mentioned at: 36 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 37 | # 38 | # Pods/ 39 | 40 | # Carthage 41 | # 42 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 43 | # Carthage/Checkouts 44 | 45 | Carthage/Build 46 | 47 | # fastlane 48 | # 49 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 50 | # screenshots whenever they are needed. 51 | # For more information about the recommended setup visit: 52 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 53 | 54 | fastlane/report.xml 55 | fastlane/screenshots 56 | 57 | #Code Injection 58 | # 59 | # After new code Injection tools there's a generated folder /iOSInjectionProject 60 | # https://github.com/johnno1962/injectionforxcode 61 | 62 | iOSInjectionProject/ 63 | 64 | 65 | ### https://raw.github.com/github/gitignore/f93202c42e947f3be10b3bd6912b48e30e7e9781/Swift.gitignore 66 | 67 | # Xcode 68 | # 69 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 70 | 71 | ## Build generated 72 | build/ 73 | DerivedData/ 74 | 75 | ## Various settings 76 | *.pbxuser 77 | !default.pbxuser 78 | *.mode1v3 79 | !default.mode1v3 80 | *.mode2v3 81 | !default.mode2v3 82 | *.perspectivev3 83 | !default.perspectivev3 84 | xcuserdata/ 85 | 86 | ## Other 87 | *.moved-aside 88 | *.xcuserstate 89 | 90 | ## Obj-C/Swift specific 91 | *.hmap 92 | *.ipa 93 | *.dSYM.zip 94 | *.dSYM 95 | 96 | ## Playgrounds 97 | timeline.xctimeline 98 | playground.xcworkspace 99 | 100 | # Swift Package Manager 101 | # 102 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 103 | # Packages/ 104 | .build/ 105 | 106 | # CocoaPods 107 | # 108 | # We recommend against adding the Pods directory to your .gitignore. However 109 | # you should judge for yourself, the pros and cons are mentioned at: 110 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 111 | # 112 | # Pods/ 113 | 114 | # Carthage 115 | # 116 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 117 | # Carthage/Checkouts 118 | 119 | Carthage/Build 120 | 121 | # fastlane 122 | # 123 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 124 | # screenshots whenever they are needed. 125 | # For more information about the recommended setup visit: 126 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 127 | 128 | fastlane/report.xml 129 | fastlane/Preview.html 130 | fastlane/screenshots 131 | fastlane/test_output 132 | test_output 133 | 134 | 135 | ### https://raw.github.com/github/gitignore/f93202c42e947f3be10b3bd6912b48e30e7e9781/Global/JetBrains.gitignore 136 | 137 | # We just ignore .idea totally. 138 | .idea 139 | 140 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 141 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 142 | 143 | # User-specific stuff: 144 | .idea/workspace.xml 145 | .idea/tasks.xml 146 | .idea/dictionaries 147 | .idea/vcs.xml 148 | .idea/jsLibraryMappings.xml 149 | 150 | # Sensitive or high-churn files: 151 | .idea/dataSources.ids 152 | .idea/dataSources.xml 153 | .idea/dataSources.local.xml 154 | .idea/sqlDataSources.xml 155 | .idea/dynamic.xml 156 | .idea/uiDesigner.xml 157 | 158 | # Gradle: 159 | .idea/gradle.xml 160 | .idea/libraries 161 | 162 | # Mongo Explorer plugin: 163 | .idea/mongoSettings.xml 164 | 165 | ## File-based project format: 166 | *.iws 167 | 168 | ## Plugin-specific files: 169 | 170 | # IntelliJ 171 | /out/ 172 | 173 | # mpeltonen/sbt-idea plugin 174 | .idea_modules/ 175 | 176 | # JIRA plugin 177 | atlassian-ide-plugin.xml 178 | 179 | # Crashlytics plugin (for Android Studio and IntelliJ) 180 | com_crashlytics_export_strings.xml 181 | crashlytics.properties 182 | crashlytics-build.properties 183 | fabric.properties 184 | 185 | 186 | ### https://raw.github.com/github/gitignore/f93202c42e947f3be10b3bd6912b48e30e7e9781/Global/Xcode.gitignore 187 | 188 | # Xcode 189 | # 190 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 191 | 192 | ## Build generated 193 | build/ 194 | DerivedData/ 195 | 196 | ## Various settings 197 | *.pbxuser 198 | !default.pbxuser 199 | *.mode1v3 200 | !default.mode1v3 201 | *.mode2v3 202 | !default.mode2v3 203 | *.perspectivev3 204 | !default.perspectivev3 205 | xcuserdata/ 206 | 207 | ## Other 208 | *.moved-aside 209 | *.xccheckout 210 | *.xcscmblueprint 211 | 212 | 213 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - build 3 | 4 | analyze_proect: 5 | stage: build 6 | script: 7 | - scan --workspace 'NVMAspects.xcworkspace' --scheme 'NVMAspectsTests' --device 'iPhone 7 Plus' --code_coverage --clean --verbose 8 | - nvmlint 9 | only: 10 | - master 11 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | AD908D061D6C28E700AF2F48 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AD908D051D6C28E700AF2F48 /* main.m */; }; 11 | AD908D091D6C28E700AF2F48 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AD908D081D6C28E700AF2F48 /* AppDelegate.m */; }; 12 | AD908D0C1D6C28E700AF2F48 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AD908D0B1D6C28E700AF2F48 /* ViewController.m */; }; 13 | AD908D0F1D6C28E700AF2F48 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AD908D0D1D6C28E700AF2F48 /* Main.storyboard */; }; 14 | AD908D111D6C28E700AF2F48 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AD908D101D6C28E700AF2F48 /* Assets.xcassets */; }; 15 | AD908D141D6C28E700AF2F48 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AD908D121D6C28E700AF2F48 /* LaunchScreen.storyboard */; }; 16 | CB7B40651FAC94E80036429C /* NVMAspects.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB7B40661FAC94E80036429C /* NVMAspects.framework */; }; 17 | D282691EAA07498AA454A83B /* Pods_NVMAspectsDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C94F8071F36719AC2CE0B6A /* Pods_NVMAspectsDemo.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXCopyFilesBuildPhase section */ 21 | AD5A93731DB8C51000250698 /* Embed Frameworks */ = { 22 | isa = PBXCopyFilesBuildPhase; 23 | buildActionMask = 2147483647; 24 | dstPath = ""; 25 | dstSubfolderSpec = 10; 26 | files = ( 27 | ); 28 | name = "Embed Frameworks"; 29 | runOnlyForDeploymentPostprocessing = 0; 30 | }; 31 | /* End PBXCopyFilesBuildPhase section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 5A25529C9423250CA95423C0 /* Pods-NVMAspectsDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NVMAspectsDemo.release.xcconfig"; path = "../../Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo.release.xcconfig"; sourceTree = ""; }; 35 | 5F22F7DF41862F0BFC6798EC /* Pods-NVMAspectsDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NVMAspectsDemo.debug.xcconfig"; path = "../../Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo.debug.xcconfig"; sourceTree = ""; }; 36 | 9C94F8071F36719AC2CE0B6A /* Pods_NVMAspectsDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NVMAspectsDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | AD908D011D6C28E700AF2F48 /* NVMAspectsDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NVMAspectsDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | AD908D051D6C28E700AF2F48 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 39 | AD908D071D6C28E700AF2F48 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 40 | AD908D081D6C28E700AF2F48 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 41 | AD908D0A1D6C28E700AF2F48 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 42 | AD908D0B1D6C28E700AF2F48 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 43 | AD908D0E1D6C28E700AF2F48 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 44 | AD908D101D6C28E700AF2F48 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 45 | AD908D131D6C28E700AF2F48 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 46 | AD908D151D6C28E700AF2F48 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | CB7B40661FAC94E80036429C /* NVMAspects.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = NVMAspects.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | /* End PBXFileReference section */ 49 | 50 | /* Begin PBXFrameworksBuildPhase section */ 51 | AD908CFE1D6C28E700AF2F48 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | CB7B40651FAC94E80036429C /* NVMAspects.framework in Frameworks */, 56 | D282691EAA07498AA454A83B /* Pods_NVMAspectsDemo.framework in Frameworks */, 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | /* End PBXFrameworksBuildPhase section */ 61 | 62 | /* Begin PBXGroup section */ 63 | AD908CF81D6C28E700AF2F48 = { 64 | isa = PBXGroup; 65 | children = ( 66 | AD908D031D6C28E700AF2F48 /* NVMAspectsDemo */, 67 | ADD9C8511D6C3A6500A441E3 /* Frameworks */, 68 | AD908D021D6C28E700AF2F48 /* Products */, 69 | CA8B0ADAB087A3CE92B2ACD5 /* Pods */, 70 | ); 71 | sourceTree = ""; 72 | }; 73 | AD908D021D6C28E700AF2F48 /* Products */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | AD908D011D6C28E700AF2F48 /* NVMAspectsDemo.app */, 77 | ); 78 | name = Products; 79 | sourceTree = ""; 80 | }; 81 | AD908D031D6C28E700AF2F48 /* NVMAspectsDemo */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | AD908D071D6C28E700AF2F48 /* AppDelegate.h */, 85 | AD908D081D6C28E700AF2F48 /* AppDelegate.m */, 86 | AD908D0A1D6C28E700AF2F48 /* ViewController.h */, 87 | AD908D0B1D6C28E700AF2F48 /* ViewController.m */, 88 | AD908D0D1D6C28E700AF2F48 /* Main.storyboard */, 89 | AD908D101D6C28E700AF2F48 /* Assets.xcassets */, 90 | AD908D121D6C28E700AF2F48 /* LaunchScreen.storyboard */, 91 | AD908D151D6C28E700AF2F48 /* Info.plist */, 92 | AD908D041D6C28E700AF2F48 /* Supporting Files */, 93 | ); 94 | path = NVMAspectsDemo; 95 | sourceTree = ""; 96 | }; 97 | AD908D041D6C28E700AF2F48 /* Supporting Files */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | AD908D051D6C28E700AF2F48 /* main.m */, 101 | ); 102 | name = "Supporting Files"; 103 | sourceTree = ""; 104 | }; 105 | ADD9C8511D6C3A6500A441E3 /* Frameworks */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | CB7B40661FAC94E80036429C /* NVMAspects.framework */, 109 | 9C94F8071F36719AC2CE0B6A /* Pods_NVMAspectsDemo.framework */, 110 | ); 111 | name = Frameworks; 112 | sourceTree = ""; 113 | }; 114 | CA8B0ADAB087A3CE92B2ACD5 /* Pods */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 5F22F7DF41862F0BFC6798EC /* Pods-NVMAspectsDemo.debug.xcconfig */, 118 | 5A25529C9423250CA95423C0 /* Pods-NVMAspectsDemo.release.xcconfig */, 119 | ); 120 | name = Pods; 121 | sourceTree = ""; 122 | }; 123 | /* End PBXGroup section */ 124 | 125 | /* Begin PBXNativeTarget section */ 126 | AD908D001D6C28E700AF2F48 /* NVMAspectsDemo */ = { 127 | isa = PBXNativeTarget; 128 | buildConfigurationList = AD908D181D6C28E700AF2F48 /* Build configuration list for PBXNativeTarget "NVMAspectsDemo" */; 129 | buildPhases = ( 130 | 8AFFA14B5F2818E47662C993 /* [CP] Check Pods Manifest.lock */, 131 | AD908CFD1D6C28E700AF2F48 /* Sources */, 132 | AD908CFE1D6C28E700AF2F48 /* Frameworks */, 133 | AD908CFF1D6C28E700AF2F48 /* Resources */, 134 | AD5A93731DB8C51000250698 /* Embed Frameworks */, 135 | E13E9060C84D7D0BEDA44037 /* [CP] Embed Pods Frameworks */, 136 | B520A6278537623EAA688835 /* [CP] Copy Pods Resources */, 137 | ); 138 | buildRules = ( 139 | ); 140 | dependencies = ( 141 | ); 142 | name = NVMAspectsDemo; 143 | productName = NVMAspectsDemo; 144 | productReference = AD908D011D6C28E700AF2F48 /* NVMAspectsDemo.app */; 145 | productType = "com.apple.product-type.application"; 146 | }; 147 | /* End PBXNativeTarget section */ 148 | 149 | /* Begin PBXProject section */ 150 | AD908CF91D6C28E700AF2F48 /* Project object */ = { 151 | isa = PBXProject; 152 | attributes = { 153 | CLASSPREFIX = NVM; 154 | LastUpgradeCheck = 0900; 155 | ORGANIZATIONNAME = "Rajax Network Technology Co., Ltd."; 156 | TargetAttributes = { 157 | AD908D001D6C28E700AF2F48 = { 158 | CreatedOnToolsVersion = 7.3.1; 159 | DevelopmentTeam = QPVN24KKHM; 160 | }; 161 | }; 162 | }; 163 | buildConfigurationList = AD908CFC1D6C28E700AF2F48 /* Build configuration list for PBXProject "NVMAspectsDemo" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | Base, 170 | ); 171 | mainGroup = AD908CF81D6C28E700AF2F48; 172 | productRefGroup = AD908D021D6C28E700AF2F48 /* Products */; 173 | projectDirPath = ""; 174 | projectRoot = ""; 175 | targets = ( 176 | AD908D001D6C28E700AF2F48 /* NVMAspectsDemo */, 177 | ); 178 | }; 179 | /* End PBXProject section */ 180 | 181 | /* Begin PBXResourcesBuildPhase section */ 182 | AD908CFF1D6C28E700AF2F48 /* Resources */ = { 183 | isa = PBXResourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | AD908D141D6C28E700AF2F48 /* LaunchScreen.storyboard in Resources */, 187 | AD908D111D6C28E700AF2F48 /* Assets.xcassets in Resources */, 188 | AD908D0F1D6C28E700AF2F48 /* Main.storyboard in Resources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXResourcesBuildPhase section */ 193 | 194 | /* Begin PBXShellScriptBuildPhase section */ 195 | 8AFFA14B5F2818E47662C993 /* [CP] Check Pods Manifest.lock */ = { 196 | isa = PBXShellScriptBuildPhase; 197 | buildActionMask = 2147483647; 198 | files = ( 199 | ); 200 | inputPaths = ( 201 | ); 202 | name = "[CP] Check Pods Manifest.lock"; 203 | outputPaths = ( 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | shellPath = /bin/sh; 207 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; 208 | showEnvVarsInLog = 0; 209 | }; 210 | B520A6278537623EAA688835 /* [CP] Copy Pods Resources */ = { 211 | isa = PBXShellScriptBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | ); 215 | inputPaths = ( 216 | ); 217 | name = "[CP] Copy Pods Resources"; 218 | outputPaths = ( 219 | ); 220 | runOnlyForDeploymentPostprocessing = 0; 221 | shellPath = /bin/sh; 222 | shellScript = "\"${SRCROOT}/../../Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo-resources.sh\"\n"; 223 | showEnvVarsInLog = 0; 224 | }; 225 | E13E9060C84D7D0BEDA44037 /* [CP] Embed Pods Frameworks */ = { 226 | isa = PBXShellScriptBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | ); 230 | inputPaths = ( 231 | ); 232 | name = "[CP] Embed Pods Frameworks"; 233 | outputPaths = ( 234 | ); 235 | runOnlyForDeploymentPostprocessing = 0; 236 | shellPath = /bin/sh; 237 | shellScript = "\"${SRCROOT}/../../Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo-frameworks.sh\"\n"; 238 | showEnvVarsInLog = 0; 239 | }; 240 | /* End PBXShellScriptBuildPhase section */ 241 | 242 | /* Begin PBXSourcesBuildPhase section */ 243 | AD908CFD1D6C28E700AF2F48 /* Sources */ = { 244 | isa = PBXSourcesBuildPhase; 245 | buildActionMask = 2147483647; 246 | files = ( 247 | AD908D0C1D6C28E700AF2F48 /* ViewController.m in Sources */, 248 | AD908D091D6C28E700AF2F48 /* AppDelegate.m in Sources */, 249 | AD908D061D6C28E700AF2F48 /* main.m in Sources */, 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | }; 253 | /* End PBXSourcesBuildPhase section */ 254 | 255 | /* Begin PBXVariantGroup section */ 256 | AD908D0D1D6C28E700AF2F48 /* Main.storyboard */ = { 257 | isa = PBXVariantGroup; 258 | children = ( 259 | AD908D0E1D6C28E700AF2F48 /* Base */, 260 | ); 261 | name = Main.storyboard; 262 | sourceTree = ""; 263 | }; 264 | AD908D121D6C28E700AF2F48 /* LaunchScreen.storyboard */ = { 265 | isa = PBXVariantGroup; 266 | children = ( 267 | AD908D131D6C28E700AF2F48 /* Base */, 268 | ); 269 | name = LaunchScreen.storyboard; 270 | sourceTree = ""; 271 | }; 272 | /* End PBXVariantGroup section */ 273 | 274 | /* Begin XCBuildConfiguration section */ 275 | AD908D161D6C28E700AF2F48 /* Debug */ = { 276 | isa = XCBuildConfiguration; 277 | buildSettings = { 278 | ALWAYS_SEARCH_USER_PATHS = NO; 279 | CLANG_ANALYZER_NONNULL = YES; 280 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 281 | CLANG_CXX_LIBRARY = "libc++"; 282 | CLANG_ENABLE_MODULES = YES; 283 | CLANG_ENABLE_OBJC_ARC = YES; 284 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 285 | CLANG_WARN_BOOL_CONVERSION = YES; 286 | CLANG_WARN_COMMA = YES; 287 | CLANG_WARN_CONSTANT_CONVERSION = YES; 288 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 289 | CLANG_WARN_EMPTY_BODY = YES; 290 | CLANG_WARN_ENUM_CONVERSION = YES; 291 | CLANG_WARN_INFINITE_RECURSION = YES; 292 | CLANG_WARN_INT_CONVERSION = YES; 293 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 294 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 295 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 296 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 297 | CLANG_WARN_STRICT_PROTOTYPES = YES; 298 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 299 | CLANG_WARN_UNREACHABLE_CODE = YES; 300 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 301 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 302 | COPY_PHASE_STRIP = NO; 303 | DEBUG_INFORMATION_FORMAT = dwarf; 304 | ENABLE_STRICT_OBJC_MSGSEND = YES; 305 | ENABLE_TESTABILITY = YES; 306 | GCC_C_LANGUAGE_STANDARD = gnu99; 307 | GCC_DYNAMIC_NO_PIC = NO; 308 | GCC_NO_COMMON_BLOCKS = YES; 309 | GCC_OPTIMIZATION_LEVEL = 0; 310 | GCC_PREPROCESSOR_DEFINITIONS = ( 311 | "DEBUG=1", 312 | "$(inherited)", 313 | ); 314 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 315 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 316 | GCC_WARN_UNDECLARED_SELECTOR = YES; 317 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 318 | GCC_WARN_UNUSED_FUNCTION = YES; 319 | GCC_WARN_UNUSED_VARIABLE = YES; 320 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 321 | MTL_ENABLE_DEBUG_INFO = YES; 322 | ONLY_ACTIVE_ARCH = YES; 323 | SDKROOT = iphoneos; 324 | }; 325 | name = Debug; 326 | }; 327 | AD908D171D6C28E700AF2F48 /* Release */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | ALWAYS_SEARCH_USER_PATHS = NO; 331 | CLANG_ANALYZER_NONNULL = YES; 332 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 333 | CLANG_CXX_LIBRARY = "libc++"; 334 | CLANG_ENABLE_MODULES = YES; 335 | CLANG_ENABLE_OBJC_ARC = YES; 336 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 337 | CLANG_WARN_BOOL_CONVERSION = YES; 338 | CLANG_WARN_COMMA = YES; 339 | CLANG_WARN_CONSTANT_CONVERSION = YES; 340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 341 | CLANG_WARN_EMPTY_BODY = YES; 342 | CLANG_WARN_ENUM_CONVERSION = YES; 343 | CLANG_WARN_INFINITE_RECURSION = YES; 344 | CLANG_WARN_INT_CONVERSION = YES; 345 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 346 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 347 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 348 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 349 | CLANG_WARN_STRICT_PROTOTYPES = YES; 350 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 351 | CLANG_WARN_UNREACHABLE_CODE = YES; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 354 | COPY_PHASE_STRIP = NO; 355 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 356 | ENABLE_NS_ASSERTIONS = NO; 357 | ENABLE_STRICT_OBJC_MSGSEND = YES; 358 | GCC_C_LANGUAGE_STANDARD = gnu99; 359 | GCC_NO_COMMON_BLOCKS = YES; 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 367 | MTL_ENABLE_DEBUG_INFO = NO; 368 | SDKROOT = iphoneos; 369 | VALIDATE_PRODUCT = YES; 370 | }; 371 | name = Release; 372 | }; 373 | AD908D191D6C28E700AF2F48 /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | baseConfigurationReference = 5F22F7DF41862F0BFC6798EC /* Pods-NVMAspectsDemo.debug.xcconfig */; 376 | buildSettings = { 377 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 378 | DEVELOPMENT_TEAM = QPVN24KKHM; 379 | FRAMEWORK_SEARCH_PATHS = ( 380 | "$(inherited)", 381 | "$(BUILT_PRODUCTS_DIR)", 382 | ); 383 | INFOPLIST_FILE = NVMAspectsDemo/Info.plist; 384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 385 | PRODUCT_BUNDLE_IDENTIFIER = me.ele.ios.NVMAspectsDemo; 386 | PRODUCT_NAME = "$(TARGET_NAME)"; 387 | }; 388 | name = Debug; 389 | }; 390 | AD908D1A1D6C28E700AF2F48 /* Release */ = { 391 | isa = XCBuildConfiguration; 392 | baseConfigurationReference = 5A25529C9423250CA95423C0 /* Pods-NVMAspectsDemo.release.xcconfig */; 393 | buildSettings = { 394 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 395 | DEVELOPMENT_TEAM = QPVN24KKHM; 396 | FRAMEWORK_SEARCH_PATHS = ( 397 | "$(inherited)", 398 | "$(BUILT_PRODUCTS_DIR)", 399 | ); 400 | INFOPLIST_FILE = NVMAspectsDemo/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 402 | PRODUCT_BUNDLE_IDENTIFIER = me.ele.ios.NVMAspectsDemo; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | }; 405 | name = Release; 406 | }; 407 | /* End XCBuildConfiguration section */ 408 | 409 | /* Begin XCConfigurationList section */ 410 | AD908CFC1D6C28E700AF2F48 /* Build configuration list for PBXProject "NVMAspectsDemo" */ = { 411 | isa = XCConfigurationList; 412 | buildConfigurations = ( 413 | AD908D161D6C28E700AF2F48 /* Debug */, 414 | AD908D171D6C28E700AF2F48 /* Release */, 415 | ); 416 | defaultConfigurationIsVisible = 0; 417 | defaultConfigurationName = Release; 418 | }; 419 | AD908D181D6C28E700AF2F48 /* Build configuration list for PBXNativeTarget "NVMAspectsDemo" */ = { 420 | isa = XCConfigurationList; 421 | buildConfigurations = ( 422 | AD908D191D6C28E700AF2F48 /* Debug */, 423 | AD908D1A1D6C28E700AF2F48 /* Release */, 424 | ); 425 | defaultConfigurationIsVisible = 0; 426 | defaultConfigurationName = Release; 427 | }; 428 | /* End XCConfigurationList section */ 429 | }; 430 | rootObject = AD908CF91D6C28E700AF2F48 /* Project object */; 431 | } 432 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo.xcodeproj/xcshareddata/xcschemes/NVMAspectsDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 46 | 47 | 48 | 49 | 55 | 56 | 57 | 58 | 59 | 60 | 71 | 73 | 79 | 80 | 81 | 82 | 83 | 84 | 90 | 92 | 98 | 99 | 100 | 101 | 103 | 104 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // NVMAspectsDemo 4 | // 5 | // Created by Karl Peng on 03/28/2017. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // NVMAspectsDemo 4 | // 5 | // Created by Karl Peng on 03/28/2017. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import 11 | 12 | typedef void(^NormalBlock)(void); 13 | 14 | @interface AppDelegate (NoIMP) 15 | 16 | - (void)methodWithoutImplement; 17 | 18 | @end 19 | 20 | @implementation AppDelegate 21 | 22 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 23 | typedef char array[3][3]; 24 | NSUInteger size = 0; 25 | NSUInteger align = 0; 26 | NSGetSizeAndAlignment(@encode(array), &size, &align); 27 | 28 | [AppDelegate nvm_hookInstanceMethod:@selector(methodReturnVoid) 29 | usingBlock:^(NVMAspectInfo *info) { 30 | [info.invocation invoke]; 31 | NSLog(@"Hooked methodReturnVoid"); 32 | }]; 33 | 34 | [AppDelegate nvm_hookInstanceMethod:@selector(methodReturnVoid) 35 | usingBlock:^(NVMAspectInfo *info) { 36 | [info.invocation invoke]; 37 | NSLog(@"Hooked methodReturnVoid again"); 38 | }]; 39 | 40 | NSObject *object = [NSObject new]; 41 | [AppDelegate nvm_hookInstanceMethod:@selector(methodReturnHookedObject) 42 | usingBlock:^(NVMAspectInfo *info){ 43 | [info.invocation invoke]; 44 | NSLog(@"Hooked methodReturnObject"); 45 | void *returnObject = (__bridge void *)object; 46 | [info.invocation setReturnValue:&returnObject]; 47 | }]; 48 | [AppDelegate nvm_hookInstanceMethod:@selector(methodReturnORIObject) 49 | usingBlock:^(NVMAspectInfo *info) { 50 | NSLog(@"Hooked methodReturnORIObject"); 51 | [info.invocation invoke]; 52 | }]; 53 | 54 | [AppDelegate nvm_hookInstanceMethod:@selector(methodReturnInt) 55 | usingBlock:^NSInteger (NVMAspectInfo *info) { 56 | [info.invocation invoke]; 57 | NSLog(@"Hooked methodReturnInt"); 58 | return 2; 59 | }]; 60 | 61 | class_addPlaceholderIfNoImplement([AppDelegate class], 62 | @selector(methodWithoutImplement), 63 | [AppDelegate instanceMethodSignatureForSelector:@selector(methodReturnVoid)]); 64 | 65 | [AppDelegate nvm_hookInstanceMethod:@selector(methodWithoutImplement) 66 | usingBlock:^(NVMAspectInfo *info) { 67 | [info.invocation invoke]; 68 | NSLog(@"%@", info.slf); 69 | NSLog(@"Hooked methodWithoutImplement"); 70 | }]; 71 | 72 | [AppDelegate nvm_hookInstanceMethod:@selector(methodReturnArray) 73 | usingBlock:^(NVMAspectInfo *info) { 74 | [info.invocation invoke]; 75 | NSLog(@"Hooked methodReturnArray"); 76 | }]; 77 | 78 | [AppDelegate nvm_hookInstanceMethod:@selector(methodReturnBlock) 79 | usingBlock:^(NVMAspectInfo *info) { 80 | [info.invocation invoke]; 81 | NSLog(@"Hooked methodReturnBlock"); 82 | }]; 83 | [AppDelegate nvm_hookInstanceMethod:@selector(methodWithInt:object:block:) 84 | usingBlock:^(NVMAspectInfo *info, NSInteger argInt, 85 | id argObject, NormalBlock argBlock) { 86 | [info.invocation invoke]; 87 | NSLog(@"Hooked methodWithMultiArgs"); 88 | }]; 89 | 90 | [self methodReturnVoid]; 91 | 92 | NSObject *returnObject = [self methodReturnHookedObject]; 93 | NSAssert(returnObject == object, nil); 94 | 95 | NSAssert([self methodReturnInt] == 1, nil); 96 | 97 | [self methodWithoutImplement]; 98 | 99 | [self methodReturnBlock]; 100 | 101 | [self methodReturnORIObject]; 102 | 103 | [self methodReturnArray]; 104 | 105 | [self methodReturnBlock]; 106 | 107 | [self methodWithInt:1 object:nil block:nil]; 108 | 109 | return YES; 110 | } 111 | 112 | - (NormalBlock)methodReturnBlock { 113 | NSLog(@"methodReturnBlock"); 114 | return nil; 115 | } 116 | 117 | - (NSArray *)methodReturnArray { 118 | NSLog(@"methodReturnArray"); 119 | return nil; 120 | } 121 | 122 | - (void)methodReturnVoid { 123 | NSLog(@"ORI methodReturnVoid"); 124 | } 125 | 126 | - (id)methodReturnHookedObject { 127 | NSLog(@"ORI methodReturnHookedObject"); 128 | return [NSObject new]; 129 | } 130 | 131 | - (id)methodReturnORIObject { 132 | NSLog(@"ORI methodReturnORIObject"); 133 | return [NSObject new]; 134 | } 135 | 136 | - (NSInteger)methodReturnInt { 137 | NSLog(@"ORI methodReturnInt"); 138 | return 1; 139 | } 140 | 141 | - (NormalBlock)methodWithInt:(NSInteger)argInt object:(id)argObject 142 | block:(NormalBlock)argBlock { 143 | NSLog(@"ORI methodWithMultiArgs"); 144 | return nil; 145 | } 146 | 147 | - (void)applicationWillResignActive:(UIApplication *)application { 148 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 149 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 150 | } 151 | 152 | - (void)applicationDidEnterBackground:(UIApplication *)application { 153 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 154 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 155 | } 156 | 157 | - (void)applicationWillEnterForeground:(UIApplication *)application { 158 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 159 | } 160 | 161 | - (void)applicationDidBecomeActive:(UIApplication *)application { 162 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 163 | } 164 | 165 | - (void)applicationWillTerminate:(UIApplication *)application { 166 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 167 | } 168 | 169 | @end 170 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // NVMAspectsDemo 4 | // 5 | // Created by Karl Peng on 03/28/2017. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // NVMAspectsDemo 4 | // 5 | // Created by Karl Peng on 03/28/2017. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Demo/NVMAspectsDemo/NVMAspectsDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // NVMAspectsDemo 4 | // 5 | // Created by Karl Peng on 03/28/2017. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 eleme 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NVMAspects.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint NVMAspects.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'NVMAspects' 11 | s.version = '0.9.2' 12 | s.license = 'mit' 13 | s.summary = 'Yet another AOP library for Objective-C.' 14 | 15 | # This description is used to generate tags and improve search results. 16 | # * Think: What does it do? Why did you write it? What is the focus? 17 | # * Try to keep it short, snappy and to the point. 18 | # * Write the description between the DESC delimiters below. 19 | # * Finally, don't worry about the indent, CocoaPods strips it! 20 | 21 | s.description = <<-DESC 22 | TODO: Add long description of the pod here. 23 | DESC 24 | 25 | s.homepage = "https://github.com/eleme/NVMAspects" 26 | s.author = { 'Karl Peng' => 'codelife2012@gmail.com' } 27 | s.source = { :git => 'https://github.com/eleme/NVMAspects.git', :tag => s.version.to_s } 28 | 29 | s.ios.deployment_target = '8.0' 30 | 31 | s.source_files = ['NVMAspects/Classes/**/*', 'NVMAspects/NVMAspects.h', 'NVMAspects/libffi/*.h'] 32 | s.vendored_library = 'NVMAspects/libffi/libffi.a' 33 | 34 | # s.resource_bundles = { 35 | # 'NVMAspects' => ['NVMAspects/Assets/NVMAspects.bundle/**/*'] 36 | # } 37 | 38 | s.public_header_files = ['NVMAspects/NVMAspects.h', 'NVMAspects/Classes/Aspects.h'] 39 | 40 | s.frameworks = 'Foundation' 41 | end 42 | -------------------------------------------------------------------------------- /NVMAspects.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NVMAspects.xcodeproj/xcshareddata/xcschemes/NVMAspects.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 32 | 33 | 35 | 41 | 42 | 43 | 44 | 45 | 51 | 52 | 53 | 54 | 55 | 56 | 67 | 68 | 74 | 75 | 76 | 77 | 78 | 79 | 85 | 86 | 92 | 93 | 94 | 95 | 97 | 98 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /NVMAspects.xcodeproj/xcshareddata/xcschemes/NVMAspectsTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 32 | 33 | 35 | 41 | 42 | 43 | 44 | 45 | 51 | 52 | 53 | 54 | 55 | 56 | 67 | 69 | 75 | 76 | 77 | 78 | 79 | 80 | 86 | 87 | 89 | 90 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /NVMAspects.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | 15 | 16 | 18 | 19 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /NVMAspects/Assets/NVMAspects.bundle/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | me.ele.ios.NVMAspects.assets 7 | 8 | 9 | -------------------------------------------------------------------------------- /NVMAspects/Assets/NVMAspects.bundle/Media.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /NVMAspects/Classes/AspectData.h: -------------------------------------------------------------------------------- 1 | // 2 | // AspectData.h 3 | // NVMAspects 4 | // 5 | // Created by Karl Peng on 3/28/17. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NVMAspectData : NSObject 12 | 13 | + (instancetype)aspectDataWithClass:(Class)cls 14 | selector:(SEL)selector 15 | impBlock:(id)impBlock 16 | error:(NSError **)error; 17 | 18 | @property (nonatomic, unsafe_unretained, readonly) Class cls; 19 | @property (nonatomic, assign, readonly) SEL selector; 20 | @property (nonatomic, strong, readonly) NSMethodSignature *methodSignature; 21 | 22 | @property (nonatomic, assign) BOOL hasReturnValue; 23 | 24 | @property (nonatomic, assign) IMP oriIMP; 25 | 26 | @property (nonatomic, copy, readonly) id impBlock; 27 | @property (nonatomic, strong, readonly) NSMethodSignature *blockSignature; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /NVMAspects/Classes/AspectData.m: -------------------------------------------------------------------------------- 1 | // 2 | // AspectData.m 3 | // NVMAspects 4 | // 5 | // Created by Karl Peng on 3/28/17. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import "AspectData.h" 10 | #import "Aspects.h" 11 | #import "Utils.h" 12 | 13 | static NSString *const NilSignatureNote = @"" 14 | "Block and Method should all have signature," 15 | "if you try to add a method to a class," 16 | "please call class_addPlaceholderIfNoImplement first."; 17 | 18 | static NSString *const SignatureNote = @"" 19 | "Block's signature should compatible with method." 20 | "This means they have same return type," 21 | "but block take NVMAspectInfo as first argument, then method args"; 22 | 23 | @interface NVMAspectData () 24 | 25 | @property (nonatomic, unsafe_unretained, readwrite) Class cls; 26 | @property (nonatomic, assign, readwrite) SEL selector; 27 | @property (nonatomic, strong, readwrite) NSMethodSignature *methodSignature; 28 | 29 | @property (nonatomic, copy, readwrite) id impBlock; 30 | @property (nonatomic, strong, readwrite) NSMethodSignature *blockSignature; 31 | 32 | @end 33 | 34 | @implementation NVMAspectData 35 | 36 | + (instancetype)aspectDataWithClass:(Class)cls 37 | selector:(SEL)selector 38 | impBlock:(id)impBlock 39 | error:(NSError *__autoreleasing *)error { 40 | NSMethodSignature *blockSignature = BlockSignature(impBlock, error); 41 | NSMethodSignature *methodSignature = [cls instanceMethodSignatureForSelector:selector]; 42 | 43 | BOOL allHave = blockSignature && methodSignature; 44 | NSAssert(allHave, NilSignatureNote); 45 | if (!allHave) { 46 | return nil; 47 | } 48 | 49 | if (!IsCompatibleWithBlockSignature(methodSignature, blockSignature, error)) { 50 | NSAssert(NO, SignatureNote); 51 | return nil; 52 | } 53 | 54 | NVMAspectData *data = [NVMAspectData new]; 55 | data.cls = cls; 56 | data.selector = selector; 57 | data.methodSignature = methodSignature; 58 | data.hasReturnValue = !ObjCTypeIsEqual(methodSignature.methodReturnType, 59 | @encode(void)); 60 | 61 | data.oriIMP = [cls instanceMethodForSelector:selector]; 62 | data.impBlock = impBlock; 63 | data.blockSignature = blockSignature; 64 | 65 | return data; 66 | } 67 | 68 | - (NSString *)description { 69 | return [NSString stringWithFormat:@"Aspect data for selector:%@ in class %@", 70 | NSStringFromSelector(self.selector), 71 | self.cls]; 72 | } 73 | 74 | // Block internals. 75 | typedef NS_OPTIONS(int, _BlockFlags) { 76 | BlockFlagsHasCopyDisposeHelpers = (1 << 25), 77 | BlockFlagsHasSignature = (1 << 30) 78 | }; 79 | 80 | typedef struct _Block { 81 | __unused Class isa; 82 | _BlockFlags flags; 83 | __unused int reserved; 84 | void (__unused *invoke)(struct _Block *block, ...); 85 | struct { 86 | unsigned long int reserved; 87 | unsigned long int size; 88 | // requires AspectBlockFlagsHasCopyDisposeHelpers 89 | void (*copy)(void *dst, const void *src); 90 | void (*dispose)(const void *); 91 | // requires AspectBlockFlagsHasSignature 92 | const char *signature; 93 | const char *layout; 94 | } *descriptor; 95 | // imported variables 96 | } *_BlockRef; 97 | 98 | static NSMethodSignature *BlockSignature(id block, NSError **error) { 99 | _BlockRef layout = (__bridge void *)block; 100 | if (!(layout->flags & BlockFlagsHasSignature)) { 101 | AspectLuckySetError(error, NVMAspectErrorMissingBlockSignature, 102 | [NSString stringWithFormat:@"Block %@ missing a type signature.", block]); 103 | return nil; 104 | } 105 | void *desc = layout->descriptor; 106 | desc += 2 * sizeof(unsigned long int); 107 | if (layout->flags & BlockFlagsHasCopyDisposeHelpers) { 108 | desc += 2 * sizeof(void *); 109 | } 110 | if (!desc) { 111 | AspectLuckySetError(error, NVMAspectErrorMissingBlockSignature, 112 | [NSString stringWithFormat:@"Block %@ missing a type signature.", block]); 113 | return nil; 114 | } 115 | const char *signature = (*(const char **)desc); 116 | return [NSMethodSignature signatureWithObjCTypes:signature]; 117 | } 118 | 119 | static BOOL IsCompatibleWithBlockSignature(NSMethodSignature *methodSignature, 120 | NSMethodSignature *blockSignature, 121 | NSError **error) { 122 | NSCParameterAssert(blockSignature); 123 | NSCParameterAssert(methodSignature); 124 | 125 | BOOL signaturesMatch = (blockSignature.numberOfArguments == methodSignature.numberOfArguments && 126 | blockSignature.numberOfArguments >= 2); 127 | NSCAssert(signaturesMatch, nil); 128 | 129 | if (signaturesMatch) { 130 | signaturesMatch = ObjCTypeIsEqual([blockSignature getArgumentTypeAtIndex:1], 131 | @encode(NVMAspectInfo *)); 132 | 133 | NSCAssert(signaturesMatch, nil); 134 | } 135 | 136 | if (signaturesMatch) { 137 | for (NSUInteger idx = 2; idx < blockSignature.numberOfArguments; idx++) { 138 | // Only compare parameter, not the optional type data. 139 | signaturesMatch = ObjCTypeIsEqual([methodSignature getArgumentTypeAtIndex:idx], 140 | [blockSignature getArgumentTypeAtIndex:idx]); 141 | if (!signaturesMatch) { 142 | NSCAssert(signaturesMatch, nil); 143 | break; 144 | } 145 | } 146 | } 147 | 148 | if (!signaturesMatch) { 149 | NSString *description = [NSString stringWithFormat:@"Block signature %@ doesn't match %@.", blockSignature, methodSignature]; 150 | AspectLuckySetError(error, NVMAspectErrorIncompatibleBlockSignature, description); 151 | } 152 | 153 | return signaturesMatch; 154 | } 155 | 156 | @end 157 | -------------------------------------------------------------------------------- /NVMAspects/Classes/Aspects.h: -------------------------------------------------------------------------------- 1 | // 2 | // Aspects.h 3 | // NVMAspects 4 | // 5 | // Created by Karl Peng on 3/28/17. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, NVMAspectErrorCode) { 12 | NVMAspectErrorMissingBlockSignature, 13 | NVMAspectErrorIncompatibleBlockSignature, 14 | NVMAspectErrorFailToAllocTrampoline, 15 | NVMAspectErrorUnsupportArgumentType, 16 | }; 17 | 18 | @interface NVMAspectInfo : NSObject 19 | 20 | @property (nonatomic, unsafe_unretained) id slf; 21 | @property (nonatomic, assign) SEL selector; 22 | 23 | @property (nonatomic, strong) NSInvocation *invocation; 24 | 25 | @end 26 | 27 | extern NSString *const NVMAspectErrorDomain; 28 | 29 | /* Add a placeholder first if you don't sure cls has a implement, 30 | * this method provide a method signature to the runtime. 31 | */ 32 | extern BOOL class_addPlaceholderIfNoImplement(Class cls, SEL sel, 33 | NSMethodSignature* sig); 34 | 35 | @interface NSObject (NVMAspects) 36 | 37 | /* In practice, all error should be solved when release. 38 | */ 39 | + (BOOL)nvm_hookInstanceMethod:(SEL)selector 40 | usingBlock:(id)block; 41 | 42 | + (BOOL)nvm_hookClassMethod:(SEL)selector 43 | usingBlock:(id)block; 44 | 45 | /* When dynamic hook some class at runtime, you may want to get error info 46 | */ 47 | + (BOOL)nvm_hookInstanceMethod:(SEL)selector 48 | usingBlock:(id)block 49 | error:(NSError **)error; 50 | 51 | + (BOOL)nvm_hookClassMethod:(SEL)selector 52 | usingBlock:(id)block 53 | error:(NSError **)error; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /NVMAspects/Classes/Aspects.m: -------------------------------------------------------------------------------- 1 | // 2 | // Aspects.m 3 | // NVMAspects 4 | // 5 | // Created by Karl Peng on 3/28/17. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import "Aspects.h" 10 | #import 11 | #import "ffi.h" 12 | #import 13 | #import "AspectData.h" 14 | #import "Utils.h" 15 | 16 | @interface NVMAspectInvocation : NSInvocation 17 | 18 | @property (nonatomic, assign) IMP imp; 19 | 20 | @end 21 | 22 | @interface NVMAspectInvocation (PrivateHack) 23 | 24 | - (void)invokeUsingIMP:(IMP)imp; 25 | 26 | @end 27 | 28 | @implementation NVMAspectInvocation 29 | 30 | - (void)invokeWithTarget:(id)target { 31 | NSAssert(NO, @"Can't change target for this invocation"); 32 | } 33 | 34 | - (void)invoke { 35 | if (self.imp) { 36 | [self invokeUsingIMP:self.imp]; 37 | } 38 | } 39 | 40 | @end 41 | 42 | @implementation NVMAspectInfo 43 | 44 | - (NSString *)description { 45 | return [NSString stringWithFormat:@"Aspect info invocate with %@", 46 | self.invocation]; 47 | } 48 | 49 | @end 50 | 51 | NSString *const NVMAspectErrorDomain = @"AspectErrorDomain"; 52 | 53 | static void MessageInterpreter(ffi_cif *cif, void *ret, 54 | void **args, void *userdata) { 55 | NVMAspectData *data = (__bridge NVMAspectData *)userdata; 56 | NSUInteger numberOfArguments = data.blockSignature.numberOfArguments; 57 | 58 | NVMAspectInvocation *methodInvocation = nil; 59 | if (data.oriIMP) { 60 | methodInvocation = (id)[NVMAspectInvocation invocationWithMethodSignature:data.methodSignature]; 61 | methodInvocation.imp = data.oriIMP; 62 | for (NSUInteger idx = 0; idx < numberOfArguments; idx++) { 63 | [methodInvocation setArgument:args[idx] atIndex:idx]; 64 | } 65 | } 66 | 67 | NVMAspectInfo *info = [NVMAspectInfo new]; 68 | void **slf = args[0]; 69 | info.slf = (__bridge id)(*slf); 70 | info.selector = data.selector; 71 | info.invocation = methodInvocation; 72 | 73 | NSInvocation *blockInvocation = [NSInvocation invocationWithMethodSignature:data.blockSignature]; 74 | if (numberOfArguments > 1) { 75 | [blockInvocation setArgument:&info atIndex:1]; 76 | } 77 | for (NSUInteger idx = 2; idx < numberOfArguments; idx++) { 78 | [blockInvocation setArgument:args[idx] atIndex:idx]; 79 | } 80 | 81 | [blockInvocation invokeWithTarget:data.impBlock]; 82 | if (data.hasReturnValue) { 83 | [methodInvocation getReturnValue:ret]; 84 | } 85 | 86 | data = nil; 87 | } 88 | 89 | typedef void(^WorkBlock)(void); 90 | static inline void PerformBlockInGlobalLock(WorkBlock block) { 91 | static pthread_mutex_t lock; 92 | static dispatch_once_t onceToken; 93 | dispatch_once(&onceToken, ^{ 94 | pthread_mutex_init(&lock, NULL); 95 | }); 96 | 97 | pthread_mutex_lock(&lock); 98 | if (block) { 99 | block(); 100 | } 101 | pthread_mutex_unlock(&lock); 102 | } 103 | 104 | static NSString *CifNote = @"Fail to alloc ffi_cif for trampoline, this should really rare."; 105 | static NSString *ClosureNote = @"Fail to alloc ffi_closure for trampoline, this should be really rare."; 106 | static NSString *UnsupportNote = @"Encounter a unsupport type, contact the author"; 107 | 108 | static inline BOOL HookClass(Class class, SEL selector, 109 | id block, NSError **error) { 110 | NVMAspectData *data = [NVMAspectData aspectDataWithClass:class 111 | selector:selector 112 | impBlock:block 113 | error:error]; 114 | if (!data) { 115 | return NO; 116 | } 117 | 118 | NSMethodSignature *methodSignature = data.methodSignature; 119 | NSUInteger argCount = methodSignature.numberOfArguments; 120 | 121 | ffi_type *returnType = ffiTypeFromEncodingChar(methodSignature.methodReturnType); 122 | if (!returnType) { 123 | NSCAssert(NO, UnsupportNote); 124 | AspectLuckySetError(error, NVMAspectErrorUnsupportArgumentType, UnsupportNote); 125 | return NO; 126 | } 127 | 128 | ffi_type **argTypes = malloc(sizeof(ffi_type *) *argCount); 129 | // After this, return No will leak some memory, but this should not happen when you ship a stable relase. 130 | for (int i = 0; i < argCount; i++) { 131 | argTypes[i] = ffiTypeFromEncodingChar([methodSignature getArgumentTypeAtIndex:i]); 132 | 133 | if (!argTypes[i]) { 134 | NSCAssert(NO, UnsupportNote); 135 | AspectLuckySetError(error, NVMAspectErrorUnsupportArgumentType, UnsupportNote); 136 | return NO; 137 | } 138 | } 139 | 140 | ffi_cif *cif = malloc(sizeof(ffi_cif)); 141 | ffi_status status = ffi_prep_cif(cif, FFI_DEFAULT_ABI, 142 | (unsigned int)argCount, returnType, argTypes); 143 | 144 | if (status != FFI_OK) { 145 | AspectLuckySetError(error, NVMAspectErrorFailToAllocTrampoline, 146 | CifNote); 147 | NSCAssert(NO, CifNote); 148 | return NO; 149 | } 150 | 151 | IMP newIMP = NULL; 152 | void *userData = (void *)(__bridge_retained CFTypeRef)data; 153 | ffi_closure *closure = ffi_closure_alloc(sizeof(ffi_closure), (void **)&newIMP); 154 | status = ffi_prep_closure_loc(closure, cif, &MessageInterpreter, userData, newIMP); 155 | 156 | if (status != FFI_OK) { 157 | AspectLuckySetError(error, NVMAspectErrorFailToAllocTrampoline, 158 | ClosureNote); 159 | NSCAssert(NO, ClosureNote); 160 | return NO; 161 | } 162 | 163 | PerformBlockInGlobalLock(^{ 164 | Method method = class_getInstanceMethod(class, selector); 165 | NSCAssert(method, @"$@ should contain a implementation for %@", 166 | class, NSStringFromSelector(selector)); 167 | data.oriIMP = method_getImplementation(method); 168 | method_setImplementation(method, newIMP); 169 | }); 170 | 171 | return YES; 172 | } 173 | 174 | BOOL class_addPlaceholderIfNoImplement(Class cls, SEL sel, 175 | NSMethodSignature* sig) { 176 | NSCParameterAssert(cls); 177 | NSCParameterAssert(sig); 178 | 179 | Method method = class_getInstanceMethod(cls, sel); 180 | if (!method) { 181 | void *imp = NULL; 182 | class_addMethod(cls, sel, imp, ObjCTypesInSignature(sig).UTF8String); 183 | return YES; 184 | } 185 | return NO; 186 | } 187 | 188 | @implementation NSObject (NVMAspects) 189 | 190 | + (BOOL)nvm_hookClassMethod:(SEL)selector 191 | usingBlock:(id)block { 192 | return HookClass(object_getClass(self), selector, block, NULL); 193 | } 194 | 195 | + (BOOL)nvm_hookInstanceMethod:(SEL)selector usingBlock:(id)block { 196 | return HookClass(self, selector, block, NULL); 197 | } 198 | 199 | + (BOOL)nvm_hookClassMethod:(SEL)selector 200 | usingBlock:(id)block 201 | error:(NSError *__autoreleasing *)error { 202 | return HookClass(object_getClass(self), selector, block, error); 203 | } 204 | 205 | + (BOOL)nvm_hookInstanceMethod:(SEL)selector 206 | usingBlock:(id)block 207 | error:(NSError *__autoreleasing *)error { 208 | return HookClass(self, selector, block, error); 209 | } 210 | 211 | @end 212 | -------------------------------------------------------------------------------- /NVMAspects/Classes/Utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Utils.h 3 | // NVMAspects 4 | // 5 | // Created by Karl Peng on 3/28/17. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ffi.h" 11 | 12 | extern ffi_type *ffiTypeFromEncodingChar(const char *c); 13 | 14 | extern void AspectLuckySetError(NSError **error, NSInteger code, NSString *description); 15 | 16 | extern BOOL ObjCTypeIsEqual(const char *type, const char *otherType); 17 | 18 | extern NSString *ObjCTypesInSignature(NSMethodSignature *signature); 19 | -------------------------------------------------------------------------------- /NVMAspects/Classes/Utils.m: -------------------------------------------------------------------------------- 1 | // 2 | // Utils.m 3 | // NVMAspects 4 | // 5 | // Created by Karl Peng on 3/28/17. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import "Utils.h" 10 | #import 11 | #import "Aspects.h" 12 | 13 | static inline ffi_type ** elementsInStructsForEncodingChar(const char *encoding); 14 | static inline ffi_type *ffiTypeForStructEncodingChar(const char *c); 15 | 16 | // Struct encoding is a magic. 17 | static inline ffi_type *ffiTypeForStructEncodingChar(const char *c) { 18 | NSUInteger size = 0; 19 | NSUInteger align = 0; 20 | NSGetSizeAndAlignment(c, &size, &align); 21 | ffi_type **elements = elementsInStructsForEncodingChar(c); 22 | if (size && elements == NULL) { 23 | NSCAssert(NO, @"should have elements"); 24 | return NULL; 25 | } 26 | 27 | ffi_type *structType = malloc(sizeof(ffi_type)); 28 | structType->alignment = align; 29 | structType->size = size; 30 | structType->type = FFI_TYPE_STRUCT; 31 | structType->elements = elementsInStructsForEncodingChar(c); 32 | 33 | return structType; 34 | } 35 | 36 | static inline ffi_type * ffiTypeForPrimitiveEncodingChar(const char *c) { 37 | if (!c || !strlen(c)) { 38 | return NULL; 39 | } 40 | 41 | switch (c[0]) { 42 | case _C_ID: 43 | return &ffi_type_pointer; 44 | case _C_CLASS: 45 | return &ffi_type_pointer; 46 | case _C_SEL: 47 | return &ffi_type_pointer; 48 | case _C_CHR: 49 | return &ffi_type_schar; 50 | case _C_UCHR: 51 | return &ffi_type_uchar; 52 | case _C_SHT: 53 | return &ffi_type_sshort; 54 | case _C_USHT: 55 | return &ffi_type_ushort; 56 | case _C_INT: 57 | return &ffi_type_sint; 58 | case _C_UINT: 59 | return &ffi_type_uint; 60 | case _C_LNG: 61 | return &ffi_type_slong; 62 | case _C_ULNG: 63 | return &ffi_type_ulong; 64 | case _C_LNG_LNG: 65 | return &ffi_type_sint64; 66 | case _C_ULNG_LNG: 67 | return &ffi_type_uint64; 68 | case _C_FLT: 69 | return &ffi_type_float; 70 | case _C_DBL: 71 | return &ffi_type_double; 72 | case _C_BOOL: 73 | return &ffi_type_uint8; 74 | case _C_VOID: 75 | return &ffi_type_void; 76 | case _C_PTR: 77 | return &ffi_type_pointer; 78 | } 79 | 80 | return NULL; 81 | } 82 | 83 | static inline ffi_type *primitiveTypeInCArrayFromCharEncoding(char const *encoding) { 84 | long len = strlen(encoding); 85 | const char *primitiveTypeEncoding = NULL; 86 | for (long position = len - 1; position >= 0; position--) { 87 | if (encoding[position] >= '0' && encoding[position] <= '9') { 88 | primitiveTypeEncoding = &encoding[position + 1]; 89 | break; 90 | } 91 | } 92 | 93 | return ffiTypeForPrimitiveEncodingChar(primitiveTypeEncoding); 94 | } 95 | 96 | ffi_type *ffiTypeForCArrayEncoding(char const *encoding) { 97 | // this implement may crash in some situations, invesgate it later. 98 | 99 | ffi_type *primitiveType = &ffi_type_uchar; 100 | NSCAssert(primitiveType, nil); 101 | 102 | NSUInteger size = 0; 103 | NSUInteger align = 0; 104 | NSGetSizeAndAlignment(encoding, &size, &align); 105 | ffi_type *cAarrayType = malloc(sizeof(ffi_type)); 106 | cAarrayType->size = size; 107 | cAarrayType->alignment = align; 108 | // use a struct to simulate a c array 109 | cAarrayType->type = FFI_TYPE_STRUCT; 110 | 111 | NSInteger elementCount = size; 112 | ffi_type **elements = malloc(sizeof(void *) *(elementCount + 1)); 113 | for (NSInteger index = 0; index < elementCount; index++) { 114 | elements[index] = primitiveType; 115 | } 116 | elements[elementCount] = NULL; 117 | cAarrayType->elements = elements; 118 | 119 | return cAarrayType; 120 | } 121 | 122 | static inline char const *startPositionForStructElement(char const *encoding) { 123 | // struct encoding is like this:"{CGRect={CGPoint=dd}{CGSize=dd}}" 124 | // so first element is after '=' 125 | while (encoding[0] != '=') { 126 | encoding++; // trim to = 127 | } 128 | encoding++; //trim = 129 | 130 | return encoding; 131 | } 132 | 133 | static inline ffi_type ** elementsInStructsForEncodingChar(const char *encoding) { 134 | encoding = startPositionForStructElement(encoding); 135 | 136 | NSPointerArray *array = [NSPointerArray pointerArrayWithOptions:NSPointerFunctionsOpaqueMemory]; 137 | while (encoding[0] != _C_STRUCT_E) { 138 | const char *end = NSGetSizeAndAlignment(encoding, NULL, NULL); 139 | ffi_type *type = NULL; 140 | if (encoding[0] == _C_STRUCT_B) { 141 | type = ffiTypeForStructEncodingChar(encoding); 142 | } else if (encoding[0] == _C_ARY_B) { 143 | NSCAssert(NO, @"Struct contain c aaray is not support"); 144 | } else { 145 | type = ffiTypeForPrimitiveEncodingChar(encoding); 146 | } 147 | 148 | NSCAssert(type, @"should have a type"); 149 | if (!type) { 150 | return NULL; 151 | } 152 | 153 | [array addPointer:type]; 154 | encoding = end; 155 | } 156 | 157 | NSInteger typeCount = array.count; 158 | ffi_type **types = calloc(typeCount + 1, sizeof(void *)); 159 | for (NSUInteger step = 0; step < typeCount; step++) { 160 | types[step] = [array pointerAtIndex:step]; 161 | } 162 | 163 | return types; 164 | } 165 | 166 | static inline const char *trimedEncodingChar(const char *c) { 167 | NSCharacterSet *trimedEncodings = [NSCharacterSet characterSetWithCharactersInString:@"rnNoORV"]; 168 | while ([trimedEncodings hasMemberInPlane:c[0]]) { 169 | // trim const and other in out identifier 170 | c = &c[1]; 171 | } 172 | return c; 173 | } 174 | 175 | ffi_type * ffiTypeFromEncodingChar(const char *c) { 176 | if (!c || !strlen(c)) { 177 | return NULL; 178 | } 179 | c = trimedEncodingChar(c); 180 | if (c[0] == _C_STRUCT_B) { 181 | return ffiTypeForStructEncodingChar(c); 182 | } 183 | return ffiTypeForPrimitiveEncodingChar(c); 184 | } 185 | 186 | void AspectLuckySetError(NSError **error, NSInteger code, NSString *description) { 187 | if (error) { 188 | *error = [NSError errorWithDomain:NVMAspectErrorDomain 189 | code:code 190 | userInfo:@{ NSLocalizedDescriptionKey: description}]; 191 | } 192 | } 193 | 194 | static inline bool isExtraEncoding(char encoding) { 195 | return encoding == '"' || encoding == '<'; 196 | } 197 | 198 | BOOL ObjCTypeIsEqual(const char *type, const char *otherType) { 199 | unsigned long typeLen = strlen(type); 200 | unsigned long otherTypeLen = strlen(otherType); 201 | unsigned long minLen = MIN(typeLen, otherTypeLen); 202 | 203 | if (minLen == 0) { 204 | return NO; 205 | } 206 | 207 | bool equal = strncmp(type, otherType, minLen) == 0; 208 | if (typeLen > minLen) { 209 | equal = isExtraEncoding(type[minLen]); 210 | } 211 | if (otherTypeLen > minLen) { 212 | equal = isExtraEncoding(otherType[minLen]); 213 | } 214 | 215 | return equal; 216 | } 217 | 218 | NSString *ObjCTypesInSignature(NSMethodSignature *signature) { 219 | NSMutableString *string = [NSMutableString stringWithFormat:@"%s", signature.methodReturnType]; 220 | for (NSInteger i = 0; i < signature.numberOfArguments; i++) { 221 | [string appendString:[NSString stringWithUTF8String:[signature getArgumentTypeAtIndex:i]]]; 222 | } 223 | return string; 224 | } 225 | -------------------------------------------------------------------------------- /NVMAspects/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /NVMAspects/NVMAspects.h: -------------------------------------------------------------------------------- 1 | // 2 | // NVMAspects.h 3 | // NVMAspects 4 | // 5 | // Created by Karl Peng on 03/28/2017. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import "Aspects.h" 10 | 11 | //! Project version number for NVMAspects. 12 | FOUNDATION_EXPORT double NVMAspectsVersionNumber; 13 | 14 | //! Project version string for NVMAspects. 15 | FOUNDATION_EXPORT const unsigned char NVMAspectsVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /NVMAspects/libffi/ffi.h: -------------------------------------------------------------------------------- 1 | /* -----------------------------------------------------------------*-C-*- 2 | libffi 3.2.1 - Copyright (c) 2011, 2014 Anthony Green 3 | - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the ``Software''), to deal in the Software without 8 | restriction, including without limitation the rights to use, copy, 9 | modify, merge, publish, distribute, sublicense, and/or sell copies 10 | of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | 25 | ----------------------------------------------------------------------- */ 26 | 27 | /* ------------------------------------------------------------------- 28 | libffi-iOS is built based on libffi-3.2.1, provides universal library 29 | (i386, x86_64, armv7, arm64), both ffi_call and ffi_closure are fully 30 | tested. 31 | https://github.com/sunnyxx/libffi-iOS 32 | by sunnyxx 33 | -------------------------------------------------------------------- */ 34 | 35 | #ifdef __arm64__ 36 | #include 37 | #endif 38 | 39 | #ifdef __i386__ 40 | #include 41 | #endif 42 | 43 | #ifdef __arm__ 44 | #include 45 | #endif 46 | 47 | #ifdef __x86_64__ 48 | #include 49 | #endif 50 | -------------------------------------------------------------------------------- /NVMAspects/libffi/ffi_arm.h: -------------------------------------------------------------------------------- 1 | /* -----------------------------------------------------------------*-C-*- 2 | libffi 3.99999 - Copyright (c) 2011, 2014 Anthony Green 3 | - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the ``Software''), to deal in the Software without 8 | restriction, including without limitation the rights to use, copy, 9 | modify, merge, publish, distribute, sublicense, and/or sell copies 10 | of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | 25 | ----------------------------------------------------------------------- */ 26 | 27 | /* ------------------------------------------------------------------- 28 | Most of the API is documented in doc/libffi.texi. 29 | 30 | The raw API is designed to bypass some of the argument packing and 31 | unpacking on architectures for which it can be avoided. Routines 32 | are provided to emulate the raw API if the underlying platform 33 | doesn't allow faster implementation. 34 | 35 | More details on the raw API can be found in: 36 | 37 | http://gcc.gnu.org/ml/java/1999-q3/msg00138.html 38 | 39 | and 40 | 41 | http://gcc.gnu.org/ml/java/1999-q3/msg00174.html 42 | -------------------------------------------------------------------- */ 43 | 44 | #ifndef LIBFFI_H 45 | #define LIBFFI_H 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /* Specify which architecture libffi is configured for. */ 52 | #ifndef ARM 53 | #define ARM 54 | #endif 55 | 56 | /* ---- System configuration information --------------------------------- */ 57 | 58 | #include 59 | 60 | #ifndef LIBFFI_ASM 61 | 62 | #if defined(_MSC_VER) && !defined(__clang__) 63 | #define __attribute__(X) 64 | #endif 65 | 66 | #include 67 | #include 68 | 69 | /* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). 70 | But we can find it either under the correct ANSI name, or under GNU 71 | C's internal name. */ 72 | 73 | #define FFI_64_BIT_MAX 9223372036854775807 74 | 75 | #ifdef LONG_LONG_MAX 76 | # define FFI_LONG_LONG_MAX LONG_LONG_MAX 77 | #else 78 | # ifdef LLONG_MAX 79 | # define FFI_LONG_LONG_MAX LLONG_MAX 80 | # ifdef _AIX52 /* or newer has C99 LLONG_MAX */ 81 | # undef FFI_64_BIT_MAX 82 | # define FFI_64_BIT_MAX 9223372036854775807LL 83 | # endif /* _AIX52 or newer */ 84 | # else 85 | # ifdef __GNUC__ 86 | # define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ 87 | # endif 88 | # ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ 89 | # ifndef __PPC64__ 90 | # if defined (__IBMC__) || defined (__IBMCPP__) 91 | # define FFI_LONG_LONG_MAX LONGLONG_MAX 92 | # endif 93 | # endif /* __PPC64__ */ 94 | # undef FFI_64_BIT_MAX 95 | # define FFI_64_BIT_MAX 9223372036854775807LL 96 | # endif 97 | # endif 98 | #endif 99 | 100 | /* The closure code assumes that this works on pointers, i.e. a size_t 101 | can hold a pointer. */ 102 | 103 | typedef struct _ffi_type 104 | { 105 | size_t size; 106 | unsigned short alignment; 107 | unsigned short type; 108 | struct _ffi_type **elements; 109 | } ffi_type; 110 | 111 | #ifndef LIBFFI_HIDE_BASIC_TYPES 112 | #if SCHAR_MAX == 127 113 | # define ffi_type_uchar ffi_type_uint8 114 | # define ffi_type_schar ffi_type_sint8 115 | #else 116 | #error "char size not supported" 117 | #endif 118 | 119 | #if SHRT_MAX == 32767 120 | # define ffi_type_ushort ffi_type_uint16 121 | # define ffi_type_sshort ffi_type_sint16 122 | #elif SHRT_MAX == 2147483647 123 | # define ffi_type_ushort ffi_type_uint32 124 | # define ffi_type_sshort ffi_type_sint32 125 | #else 126 | #error "short size not supported" 127 | #endif 128 | 129 | #if INT_MAX == 32767 130 | # define ffi_type_uint ffi_type_uint16 131 | # define ffi_type_sint ffi_type_sint16 132 | #elif INT_MAX == 2147483647 133 | # define ffi_type_uint ffi_type_uint32 134 | # define ffi_type_sint ffi_type_sint32 135 | #elif INT_MAX == 9223372036854775807 136 | # define ffi_type_uint ffi_type_uint64 137 | # define ffi_type_sint ffi_type_sint64 138 | #else 139 | #error "int size not supported" 140 | #endif 141 | 142 | #if LONG_MAX == 2147483647 143 | # if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX 144 | #error "no 64-bit data type supported" 145 | # endif 146 | #elif LONG_MAX != FFI_64_BIT_MAX 147 | #error "long size not supported" 148 | #endif 149 | 150 | #if LONG_MAX == 2147483647 151 | # define ffi_type_ulong ffi_type_uint32 152 | # define ffi_type_slong ffi_type_sint32 153 | #elif LONG_MAX == FFI_64_BIT_MAX 154 | # define ffi_type_ulong ffi_type_uint64 155 | # define ffi_type_slong ffi_type_sint64 156 | #else 157 | #error "long size not supported" 158 | #endif 159 | 160 | /* Need minimal decorations for DLLs to works on Windows. GCC has 161 | autoimport and autoexport. Rely on Libtool to help MSVC export 162 | from a DLL, but always declare data to be imported for MSVC 163 | clients. This costs an extra indirection for MSVC clients using 164 | the static version of the library, but don't worry about that. 165 | Besides, as a workaround, they can define FFI_BUILDING if they 166 | *know* they are going to link with the static library. */ 167 | #if defined _MSC_VER && !defined FFI_BUILDING 168 | #define FFI_EXTERN extern __declspec(dllimport) 169 | #else 170 | #define FFI_EXTERN extern 171 | #endif 172 | 173 | /* These are defined in types.c. */ 174 | FFI_EXTERN ffi_type ffi_type_void; 175 | FFI_EXTERN ffi_type ffi_type_uint8; 176 | FFI_EXTERN ffi_type ffi_type_sint8; 177 | FFI_EXTERN ffi_type ffi_type_uint16; 178 | FFI_EXTERN ffi_type ffi_type_sint16; 179 | FFI_EXTERN ffi_type ffi_type_uint32; 180 | FFI_EXTERN ffi_type ffi_type_sint32; 181 | FFI_EXTERN ffi_type ffi_type_uint64; 182 | FFI_EXTERN ffi_type ffi_type_sint64; 183 | FFI_EXTERN ffi_type ffi_type_float; 184 | FFI_EXTERN ffi_type ffi_type_double; 185 | FFI_EXTERN ffi_type ffi_type_pointer; 186 | 187 | #if 0 188 | FFI_EXTERN ffi_type ffi_type_longdouble; 189 | #else 190 | #define ffi_type_longdouble ffi_type_double 191 | #endif 192 | 193 | #ifdef FFI_TARGET_HAS_COMPLEX_TYPE 194 | FFI_EXTERN ffi_type ffi_type_complex_float; 195 | FFI_EXTERN ffi_type ffi_type_complex_double; 196 | #if 0 197 | FFI_EXTERN ffi_type ffi_type_complex_longdouble; 198 | #else 199 | #define ffi_type_complex_longdouble ffi_type_complex_double 200 | #endif 201 | #endif 202 | #endif /* LIBFFI_HIDE_BASIC_TYPES */ 203 | 204 | typedef enum { 205 | FFI_OK = 0, 206 | FFI_BAD_TYPEDEF, 207 | FFI_BAD_ABI 208 | } ffi_status; 209 | 210 | typedef struct { 211 | ffi_abi abi; 212 | unsigned nargs; 213 | ffi_type **arg_types; 214 | ffi_type *rtype; 215 | unsigned bytes; 216 | unsigned flags; 217 | #ifdef FFI_EXTRA_CIF_FIELDS 218 | FFI_EXTRA_CIF_FIELDS; 219 | #endif 220 | } ffi_cif; 221 | 222 | /* ---- Definitions for the raw API -------------------------------------- */ 223 | 224 | #ifndef FFI_SIZEOF_ARG 225 | # if LONG_MAX == 2147483647 226 | # define FFI_SIZEOF_ARG 4 227 | # elif LONG_MAX == FFI_64_BIT_MAX 228 | # define FFI_SIZEOF_ARG 8 229 | # endif 230 | #endif 231 | 232 | #ifndef FFI_SIZEOF_JAVA_RAW 233 | # define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG 234 | #endif 235 | 236 | typedef union { 237 | ffi_sarg sint; 238 | ffi_arg uint; 239 | float flt; 240 | char data[FFI_SIZEOF_ARG]; 241 | void* ptr; 242 | } ffi_raw; 243 | 244 | #if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 245 | /* This is a special case for mips64/n32 ABI (and perhaps others) where 246 | sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ 247 | typedef union { 248 | signed int sint; 249 | unsigned int uint; 250 | float flt; 251 | char data[FFI_SIZEOF_JAVA_RAW]; 252 | void* ptr; 253 | } ffi_java_raw; 254 | #else 255 | typedef ffi_raw ffi_java_raw; 256 | #endif 257 | 258 | 259 | void ffi_raw_call (ffi_cif *cif, 260 | void (*fn)(void), 261 | void *rvalue, 262 | ffi_raw *avalue); 263 | 264 | void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); 265 | void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); 266 | size_t ffi_raw_size (ffi_cif *cif); 267 | 268 | /* This is analogous to the raw API, except it uses Java parameter 269 | packing, even on 64-bit machines. I.e. on 64-bit machines longs 270 | and doubles are followed by an empty 64-bit word. */ 271 | 272 | void ffi_java_raw_call (ffi_cif *cif, 273 | void (*fn)(void), 274 | void *rvalue, 275 | ffi_java_raw *avalue); 276 | 277 | void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); 278 | void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); 279 | size_t ffi_java_raw_size (ffi_cif *cif); 280 | 281 | /* ---- Definitions for closures ----------------------------------------- */ 282 | 283 | #if FFI_CLOSURES 284 | 285 | #ifdef _MSC_VER 286 | __declspec(align(8)) 287 | #endif 288 | typedef struct { 289 | #if 1 290 | void *trampoline_table; 291 | void *trampoline_table_entry; 292 | #else 293 | char tramp[FFI_TRAMPOLINE_SIZE]; 294 | #endif 295 | ffi_cif *cif; 296 | void (*fun)(ffi_cif*,void*,void**,void*); 297 | void *user_data; 298 | } ffi_closure 299 | #ifdef __GNUC__ 300 | __attribute__((aligned (8))) 301 | #endif 302 | ; 303 | 304 | #ifndef __GNUC__ 305 | # ifdef __sgi 306 | # pragma pack 0 307 | # endif 308 | #endif 309 | 310 | void *ffi_closure_alloc (size_t size, void **code); 311 | void ffi_closure_free (void *); 312 | 313 | ffi_status 314 | ffi_prep_closure (ffi_closure*, 315 | ffi_cif *, 316 | void (*fun)(ffi_cif*,void*,void**,void*), 317 | void *user_data) 318 | __attribute__((deprecated ("use ffi_prep_closure_loc instead"))); 319 | 320 | ffi_status 321 | ffi_prep_closure_loc (ffi_closure*, 322 | ffi_cif *, 323 | void (*fun)(ffi_cif*,void*,void**,void*), 324 | void *user_data, 325 | void*codeloc); 326 | 327 | #ifdef __sgi 328 | # pragma pack 8 329 | #endif 330 | typedef struct { 331 | #if 1 332 | void *trampoline_table; 333 | void *trampoline_table_entry; 334 | #else 335 | char tramp[FFI_TRAMPOLINE_SIZE]; 336 | #endif 337 | ffi_cif *cif; 338 | 339 | #if !FFI_NATIVE_RAW_API 340 | 341 | /* If this is enabled, then a raw closure has the same layout 342 | as a regular closure. We use this to install an intermediate 343 | handler to do the transaltion, void** -> ffi_raw*. */ 344 | 345 | void (*translate_args)(ffi_cif*,void*,void**,void*); 346 | void *this_closure; 347 | 348 | #endif 349 | 350 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*); 351 | void *user_data; 352 | 353 | } ffi_raw_closure; 354 | 355 | typedef struct { 356 | #if 1 357 | void *trampoline_table; 358 | void *trampoline_table_entry; 359 | #else 360 | char tramp[FFI_TRAMPOLINE_SIZE]; 361 | #endif 362 | 363 | ffi_cif *cif; 364 | 365 | #if !FFI_NATIVE_RAW_API 366 | 367 | /* If this is enabled, then a raw closure has the same layout 368 | as a regular closure. We use this to install an intermediate 369 | handler to do the translation, void** -> ffi_raw*. */ 370 | 371 | void (*translate_args)(ffi_cif*,void*,void**,void*); 372 | void *this_closure; 373 | 374 | #endif 375 | 376 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); 377 | void *user_data; 378 | 379 | } ffi_java_raw_closure; 380 | 381 | ffi_status 382 | ffi_prep_raw_closure (ffi_raw_closure*, 383 | ffi_cif *cif, 384 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*), 385 | void *user_data); 386 | 387 | ffi_status 388 | ffi_prep_raw_closure_loc (ffi_raw_closure*, 389 | ffi_cif *cif, 390 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*), 391 | void *user_data, 392 | void *codeloc); 393 | 394 | ffi_status 395 | ffi_prep_java_raw_closure (ffi_java_raw_closure*, 396 | ffi_cif *cif, 397 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), 398 | void *user_data); 399 | 400 | ffi_status 401 | ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, 402 | ffi_cif *cif, 403 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), 404 | void *user_data, 405 | void *codeloc); 406 | 407 | #endif /* FFI_CLOSURES */ 408 | 409 | #if FFI_GO_CLOSURES 410 | 411 | typedef struct { 412 | void *tramp; 413 | ffi_cif *cif; 414 | void (*fun)(ffi_cif*,void*,void**,void*); 415 | } ffi_go_closure; 416 | 417 | ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *, 418 | void (*fun)(ffi_cif*,void*,void**,void*)); 419 | 420 | void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, 421 | void **avalue, void *closure); 422 | 423 | #endif /* FFI_GO_CLOSURES */ 424 | 425 | /* ---- Public interface definition -------------------------------------- */ 426 | 427 | ffi_status ffi_prep_cif(ffi_cif *cif, 428 | ffi_abi abi, 429 | unsigned int nargs, 430 | ffi_type *rtype, 431 | ffi_type **atypes); 432 | 433 | ffi_status ffi_prep_cif_var(ffi_cif *cif, 434 | ffi_abi abi, 435 | unsigned int nfixedargs, 436 | unsigned int ntotalargs, 437 | ffi_type *rtype, 438 | ffi_type **atypes); 439 | 440 | void ffi_call(ffi_cif *cif, 441 | void (*fn)(void), 442 | void *rvalue, 443 | void **avalue); 444 | 445 | ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type, 446 | size_t *offsets); 447 | 448 | /* Useful for eliminating compiler warnings. */ 449 | #define FFI_FN(f) ((void (*)(void))f) 450 | 451 | /* ---- Definitions shared with assembly code ---------------------------- */ 452 | 453 | #endif 454 | 455 | /* If these change, update src/mips/ffitarget.h. */ 456 | #define FFI_TYPE_VOID 0 457 | #define FFI_TYPE_INT 1 458 | #define FFI_TYPE_FLOAT 2 459 | #define FFI_TYPE_DOUBLE 3 460 | #if 0 461 | #define FFI_TYPE_LONGDOUBLE 4 462 | #else 463 | #define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE 464 | #endif 465 | #define FFI_TYPE_UINT8 5 466 | #define FFI_TYPE_SINT8 6 467 | #define FFI_TYPE_UINT16 7 468 | #define FFI_TYPE_SINT16 8 469 | #define FFI_TYPE_UINT32 9 470 | #define FFI_TYPE_SINT32 10 471 | #define FFI_TYPE_UINT64 11 472 | #define FFI_TYPE_SINT64 12 473 | #define FFI_TYPE_STRUCT 13 474 | #define FFI_TYPE_POINTER 14 475 | #define FFI_TYPE_COMPLEX 15 476 | 477 | /* This should always refer to the last type code (for sanity checks). */ 478 | #define FFI_TYPE_LAST FFI_TYPE_COMPLEX 479 | 480 | #ifdef __cplusplus 481 | } 482 | #endif 483 | 484 | #endif 485 | -------------------------------------------------------------------------------- /NVMAspects/libffi/ffi_arm64.h: -------------------------------------------------------------------------------- 1 | /* -----------------------------------------------------------------*-C-*- 2 | libffi 3.99999 - Copyright (c) 2011, 2014 Anthony Green 3 | - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the ``Software''), to deal in the Software without 8 | restriction, including without limitation the rights to use, copy, 9 | modify, merge, publish, distribute, sublicense, and/or sell copies 10 | of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | 25 | ----------------------------------------------------------------------- */ 26 | 27 | /* ------------------------------------------------------------------- 28 | Most of the API is documented in doc/libffi.texi. 29 | 30 | The raw API is designed to bypass some of the argument packing and 31 | unpacking on architectures for which it can be avoided. Routines 32 | are provided to emulate the raw API if the underlying platform 33 | doesn't allow faster implementation. 34 | 35 | More details on the raw API can be found in: 36 | 37 | http://gcc.gnu.org/ml/java/1999-q3/msg00138.html 38 | 39 | and 40 | 41 | http://gcc.gnu.org/ml/java/1999-q3/msg00174.html 42 | -------------------------------------------------------------------- */ 43 | 44 | #ifndef LIBFFI_H 45 | #define LIBFFI_H 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /* Specify which architecture libffi is configured for. */ 52 | #ifndef AARCH64 53 | #define AARCH64 54 | #endif 55 | 56 | /* ---- System configuration information --------------------------------- */ 57 | 58 | #include "ffitarget.h" 59 | 60 | #ifndef LIBFFI_ASM 61 | 62 | #if defined(_MSC_VER) && !defined(__clang__) 63 | #define __attribute__(X) 64 | #endif 65 | 66 | #include 67 | #include 68 | 69 | /* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). 70 | But we can find it either under the correct ANSI name, or under GNU 71 | C's internal name. */ 72 | 73 | #define FFI_64_BIT_MAX 9223372036854775807 74 | 75 | #ifdef LONG_LONG_MAX 76 | # define FFI_LONG_LONG_MAX LONG_LONG_MAX 77 | #else 78 | # ifdef LLONG_MAX 79 | # define FFI_LONG_LONG_MAX LLONG_MAX 80 | # ifdef _AIX52 /* or newer has C99 LLONG_MAX */ 81 | # undef FFI_64_BIT_MAX 82 | # define FFI_64_BIT_MAX 9223372036854775807LL 83 | # endif /* _AIX52 or newer */ 84 | # else 85 | # ifdef __GNUC__ 86 | # define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ 87 | # endif 88 | # ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ 89 | # ifndef __PPC64__ 90 | # if defined (__IBMC__) || defined (__IBMCPP__) 91 | # define FFI_LONG_LONG_MAX LONGLONG_MAX 92 | # endif 93 | # endif /* __PPC64__ */ 94 | # undef FFI_64_BIT_MAX 95 | # define FFI_64_BIT_MAX 9223372036854775807LL 96 | # endif 97 | # endif 98 | #endif 99 | 100 | /* The closure code assumes that this works on pointers, i.e. a size_t 101 | can hold a pointer. */ 102 | 103 | typedef struct _ffi_type 104 | { 105 | size_t size; 106 | unsigned short alignment; 107 | unsigned short type; 108 | struct _ffi_type **elements; 109 | } ffi_type; 110 | 111 | #ifndef LIBFFI_HIDE_BASIC_TYPES 112 | #if SCHAR_MAX == 127 113 | # define ffi_type_uchar ffi_type_uint8 114 | # define ffi_type_schar ffi_type_sint8 115 | #else 116 | #error "char size not supported" 117 | #endif 118 | 119 | #if SHRT_MAX == 32767 120 | # define ffi_type_ushort ffi_type_uint16 121 | # define ffi_type_sshort ffi_type_sint16 122 | #elif SHRT_MAX == 2147483647 123 | # define ffi_type_ushort ffi_type_uint32 124 | # define ffi_type_sshort ffi_type_sint32 125 | #else 126 | #error "short size not supported" 127 | #endif 128 | 129 | #if INT_MAX == 32767 130 | # define ffi_type_uint ffi_type_uint16 131 | # define ffi_type_sint ffi_type_sint16 132 | #elif INT_MAX == 2147483647 133 | # define ffi_type_uint ffi_type_uint32 134 | # define ffi_type_sint ffi_type_sint32 135 | #elif INT_MAX == 9223372036854775807 136 | # define ffi_type_uint ffi_type_uint64 137 | # define ffi_type_sint ffi_type_sint64 138 | #else 139 | #error "int size not supported" 140 | #endif 141 | 142 | #if LONG_MAX == 2147483647 143 | # if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX 144 | #error "no 64-bit data type supported" 145 | # endif 146 | #elif LONG_MAX != FFI_64_BIT_MAX 147 | #error "long size not supported" 148 | #endif 149 | 150 | #if LONG_MAX == 2147483647 151 | # define ffi_type_ulong ffi_type_uint32 152 | # define ffi_type_slong ffi_type_sint32 153 | #elif LONG_MAX == FFI_64_BIT_MAX 154 | # define ffi_type_ulong ffi_type_uint64 155 | # define ffi_type_slong ffi_type_sint64 156 | #else 157 | #error "long size not supported" 158 | #endif 159 | 160 | /* Need minimal decorations for DLLs to works on Windows. GCC has 161 | autoimport and autoexport. Rely on Libtool to help MSVC export 162 | from a DLL, but always declare data to be imported for MSVC 163 | clients. This costs an extra indirection for MSVC clients using 164 | the static version of the library, but don't worry about that. 165 | Besides, as a workaround, they can define FFI_BUILDING if they 166 | *know* they are going to link with the static library. */ 167 | #if defined _MSC_VER && !defined FFI_BUILDING 168 | #define FFI_EXTERN extern __declspec(dllimport) 169 | #else 170 | #define FFI_EXTERN extern 171 | #endif 172 | 173 | /* These are defined in types.c. */ 174 | FFI_EXTERN ffi_type ffi_type_void; 175 | FFI_EXTERN ffi_type ffi_type_uint8; 176 | FFI_EXTERN ffi_type ffi_type_sint8; 177 | FFI_EXTERN ffi_type ffi_type_uint16; 178 | FFI_EXTERN ffi_type ffi_type_sint16; 179 | FFI_EXTERN ffi_type ffi_type_uint32; 180 | FFI_EXTERN ffi_type ffi_type_sint32; 181 | FFI_EXTERN ffi_type ffi_type_uint64; 182 | FFI_EXTERN ffi_type ffi_type_sint64; 183 | FFI_EXTERN ffi_type ffi_type_float; 184 | FFI_EXTERN ffi_type ffi_type_double; 185 | FFI_EXTERN ffi_type ffi_type_pointer; 186 | 187 | #if 0 188 | FFI_EXTERN ffi_type ffi_type_longdouble; 189 | #else 190 | #define ffi_type_longdouble ffi_type_double 191 | #endif 192 | 193 | #ifdef FFI_TARGET_HAS_COMPLEX_TYPE 194 | FFI_EXTERN ffi_type ffi_type_complex_float; 195 | FFI_EXTERN ffi_type ffi_type_complex_double; 196 | #if 0 197 | FFI_EXTERN ffi_type ffi_type_complex_longdouble; 198 | #else 199 | #define ffi_type_complex_longdouble ffi_type_complex_double 200 | #endif 201 | #endif 202 | #endif /* LIBFFI_HIDE_BASIC_TYPES */ 203 | 204 | typedef enum { 205 | FFI_OK = 0, 206 | FFI_BAD_TYPEDEF, 207 | FFI_BAD_ABI 208 | } ffi_status; 209 | 210 | typedef struct { 211 | ffi_abi abi; 212 | unsigned nargs; 213 | ffi_type **arg_types; 214 | ffi_type *rtype; 215 | unsigned bytes; 216 | unsigned flags; 217 | #ifdef FFI_EXTRA_CIF_FIELDS 218 | FFI_EXTRA_CIF_FIELDS; 219 | #endif 220 | } ffi_cif; 221 | 222 | /* ---- Definitions for the raw API -------------------------------------- */ 223 | 224 | #ifndef FFI_SIZEOF_ARG 225 | # if LONG_MAX == 2147483647 226 | # define FFI_SIZEOF_ARG 4 227 | # elif LONG_MAX == FFI_64_BIT_MAX 228 | # define FFI_SIZEOF_ARG 8 229 | # endif 230 | #endif 231 | 232 | #ifndef FFI_SIZEOF_JAVA_RAW 233 | # define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG 234 | #endif 235 | 236 | typedef union { 237 | ffi_sarg sint; 238 | ffi_arg uint; 239 | float flt; 240 | char data[FFI_SIZEOF_ARG]; 241 | void* ptr; 242 | } ffi_raw; 243 | 244 | #if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 245 | /* This is a special case for mips64/n32 ABI (and perhaps others) where 246 | sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ 247 | typedef union { 248 | signed int sint; 249 | unsigned int uint; 250 | float flt; 251 | char data[FFI_SIZEOF_JAVA_RAW]; 252 | void* ptr; 253 | } ffi_java_raw; 254 | #else 255 | typedef ffi_raw ffi_java_raw; 256 | #endif 257 | 258 | 259 | void ffi_raw_call (ffi_cif *cif, 260 | void (*fn)(void), 261 | void *rvalue, 262 | ffi_raw *avalue); 263 | 264 | void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); 265 | void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); 266 | size_t ffi_raw_size (ffi_cif *cif); 267 | 268 | /* This is analogous to the raw API, except it uses Java parameter 269 | packing, even on 64-bit machines. I.e. on 64-bit machines longs 270 | and doubles are followed by an empty 64-bit word. */ 271 | 272 | void ffi_java_raw_call (ffi_cif *cif, 273 | void (*fn)(void), 274 | void *rvalue, 275 | ffi_java_raw *avalue); 276 | 277 | void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); 278 | void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); 279 | size_t ffi_java_raw_size (ffi_cif *cif); 280 | 281 | /* ---- Definitions for closures ----------------------------------------- */ 282 | 283 | #if FFI_CLOSURES 284 | 285 | #ifdef _MSC_VER 286 | __declspec(align(8)) 287 | #endif 288 | typedef struct { 289 | #if 1 290 | void *trampoline_table; 291 | void *trampoline_table_entry; 292 | #else 293 | char tramp[FFI_TRAMPOLINE_SIZE]; 294 | #endif 295 | ffi_cif *cif; 296 | void (*fun)(ffi_cif*,void*,void**,void*); 297 | void *user_data; 298 | } ffi_closure 299 | #ifdef __GNUC__ 300 | __attribute__((aligned (8))) 301 | #endif 302 | ; 303 | 304 | #ifndef __GNUC__ 305 | # ifdef __sgi 306 | # pragma pack 0 307 | # endif 308 | #endif 309 | 310 | void *ffi_closure_alloc (size_t size, void **code); 311 | void ffi_closure_free (void *); 312 | 313 | ffi_status 314 | ffi_prep_closure (ffi_closure*, 315 | ffi_cif *, 316 | void (*fun)(ffi_cif*,void*,void**,void*), 317 | void *user_data) 318 | __attribute__((deprecated ("use ffi_prep_closure_loc instead"))); 319 | 320 | ffi_status 321 | ffi_prep_closure_loc (ffi_closure*, 322 | ffi_cif *, 323 | void (*fun)(ffi_cif*,void*,void**,void*), 324 | void *user_data, 325 | void*codeloc); 326 | 327 | #ifdef __sgi 328 | # pragma pack 8 329 | #endif 330 | typedef struct { 331 | #if 1 332 | void *trampoline_table; 333 | void *trampoline_table_entry; 334 | #else 335 | char tramp[FFI_TRAMPOLINE_SIZE]; 336 | #endif 337 | ffi_cif *cif; 338 | 339 | #if !FFI_NATIVE_RAW_API 340 | 341 | /* If this is enabled, then a raw closure has the same layout 342 | as a regular closure. We use this to install an intermediate 343 | handler to do the transaltion, void** -> ffi_raw*. */ 344 | 345 | void (*translate_args)(ffi_cif*,void*,void**,void*); 346 | void *this_closure; 347 | 348 | #endif 349 | 350 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*); 351 | void *user_data; 352 | 353 | } ffi_raw_closure; 354 | 355 | typedef struct { 356 | #if 1 357 | void *trampoline_table; 358 | void *trampoline_table_entry; 359 | #else 360 | char tramp[FFI_TRAMPOLINE_SIZE]; 361 | #endif 362 | 363 | ffi_cif *cif; 364 | 365 | #if !FFI_NATIVE_RAW_API 366 | 367 | /* If this is enabled, then a raw closure has the same layout 368 | as a regular closure. We use this to install an intermediate 369 | handler to do the translation, void** -> ffi_raw*. */ 370 | 371 | void (*translate_args)(ffi_cif*,void*,void**,void*); 372 | void *this_closure; 373 | 374 | #endif 375 | 376 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); 377 | void *user_data; 378 | 379 | } ffi_java_raw_closure; 380 | 381 | ffi_status 382 | ffi_prep_raw_closure (ffi_raw_closure*, 383 | ffi_cif *cif, 384 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*), 385 | void *user_data); 386 | 387 | ffi_status 388 | ffi_prep_raw_closure_loc (ffi_raw_closure*, 389 | ffi_cif *cif, 390 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*), 391 | void *user_data, 392 | void *codeloc); 393 | 394 | ffi_status 395 | ffi_prep_java_raw_closure (ffi_java_raw_closure*, 396 | ffi_cif *cif, 397 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), 398 | void *user_data); 399 | 400 | ffi_status 401 | ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, 402 | ffi_cif *cif, 403 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), 404 | void *user_data, 405 | void *codeloc); 406 | 407 | #endif /* FFI_CLOSURES */ 408 | 409 | #if FFI_GO_CLOSURES 410 | 411 | typedef struct { 412 | void *tramp; 413 | ffi_cif *cif; 414 | void (*fun)(ffi_cif*,void*,void**,void*); 415 | } ffi_go_closure; 416 | 417 | ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *, 418 | void (*fun)(ffi_cif*,void*,void**,void*)); 419 | 420 | void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, 421 | void **avalue, void *closure); 422 | 423 | #endif /* FFI_GO_CLOSURES */ 424 | 425 | /* ---- Public interface definition -------------------------------------- */ 426 | 427 | ffi_status ffi_prep_cif(ffi_cif *cif, 428 | ffi_abi abi, 429 | unsigned int nargs, 430 | ffi_type *rtype, 431 | ffi_type **atypes); 432 | 433 | ffi_status ffi_prep_cif_var(ffi_cif *cif, 434 | ffi_abi abi, 435 | unsigned int nfixedargs, 436 | unsigned int ntotalargs, 437 | ffi_type *rtype, 438 | ffi_type **atypes); 439 | 440 | void ffi_call(ffi_cif *cif, 441 | void (*fn)(void), 442 | void *rvalue, 443 | void **avalue); 444 | 445 | ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type, 446 | size_t *offsets); 447 | 448 | /* Useful for eliminating compiler warnings. */ 449 | #define FFI_FN(f) ((void (*)(void))f) 450 | 451 | /* ---- Definitions shared with assembly code ---------------------------- */ 452 | 453 | #endif 454 | 455 | /* If these change, update src/mips/ffitarget.h. */ 456 | #define FFI_TYPE_VOID 0 457 | #define FFI_TYPE_INT 1 458 | #define FFI_TYPE_FLOAT 2 459 | #define FFI_TYPE_DOUBLE 3 460 | #if 0 461 | #define FFI_TYPE_LONGDOUBLE 4 462 | #else 463 | #define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE 464 | #endif 465 | #define FFI_TYPE_UINT8 5 466 | #define FFI_TYPE_SINT8 6 467 | #define FFI_TYPE_UINT16 7 468 | #define FFI_TYPE_SINT16 8 469 | #define FFI_TYPE_UINT32 9 470 | #define FFI_TYPE_SINT32 10 471 | #define FFI_TYPE_UINT64 11 472 | #define FFI_TYPE_SINT64 12 473 | #define FFI_TYPE_STRUCT 13 474 | #define FFI_TYPE_POINTER 14 475 | #define FFI_TYPE_COMPLEX 15 476 | 477 | /* This should always refer to the last type code (for sanity checks). */ 478 | #define FFI_TYPE_LAST FFI_TYPE_COMPLEX 479 | 480 | #ifdef __cplusplus 481 | } 482 | #endif 483 | 484 | #endif 485 | -------------------------------------------------------------------------------- /NVMAspects/libffi/ffi_common.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- 2 | ffi_common.h - Copyright (C) 2011, 2012, 2013 Anthony Green 3 | Copyright (C) 2007 Free Software Foundation, Inc 4 | Copyright (c) 1996 Red Hat, Inc. 5 | 6 | Common internal definitions and macros. Only necessary for building 7 | libffi. 8 | ----------------------------------------------------------------------- */ 9 | 10 | #ifndef FFI_COMMON_H 11 | #define FFI_COMMON_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include 18 | 19 | /* Do not move this. Some versions of AIX are very picky about where 20 | this is positioned. */ 21 | #ifdef __GNUC__ 22 | # if HAVE_ALLOCA_H 23 | # include 24 | # else 25 | /* mingw64 defines this already in malloc.h. */ 26 | # ifndef alloca 27 | # define alloca __builtin_alloca 28 | # endif 29 | # endif 30 | # define MAYBE_UNUSED __attribute__((__unused__)) 31 | #else 32 | # define MAYBE_UNUSED 33 | # if HAVE_ALLOCA_H 34 | # include 35 | # else 36 | # ifdef _AIX 37 | # pragma alloca 38 | # else 39 | # ifndef alloca /* predefined by HP cc +Olibcalls */ 40 | # ifdef _MSC_VER 41 | # define alloca _alloca 42 | # else 43 | char *alloca (); 44 | # endif 45 | # endif 46 | # endif 47 | # endif 48 | #endif 49 | 50 | /* Check for the existence of memcpy. */ 51 | #if STDC_HEADERS 52 | # include 53 | #else 54 | # ifndef HAVE_MEMCPY 55 | # define memcpy(d, s, n) bcopy ((s), (d), (n)) 56 | # endif 57 | #endif 58 | 59 | #if defined(FFI_DEBUG) 60 | #include 61 | #endif 62 | 63 | #ifdef FFI_DEBUG 64 | void ffi_assert(char *expr, char *file, int line); 65 | void ffi_stop_here(void); 66 | void ffi_type_test(ffi_type *a, char *file, int line); 67 | 68 | #define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__)) 69 | #define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l))) 70 | #define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__) 71 | #else 72 | #define FFI_ASSERT(x) 73 | #define FFI_ASSERT_AT(x, f, l) 74 | #define FFI_ASSERT_VALID_TYPE(x) 75 | #endif 76 | 77 | #define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1) 78 | #define ALIGN_DOWN(v, a) (((size_t) (v)) & -a) 79 | 80 | /* Perform machine dependent cif processing */ 81 | ffi_status ffi_prep_cif_machdep(ffi_cif *cif); 82 | ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, 83 | unsigned int nfixedargs, unsigned int ntotalargs); 84 | 85 | 86 | #if HAVE_LONG_DOUBLE_VARIANT 87 | /* Used to adjust size/alignment of ffi types. */ 88 | void ffi_prep_types (ffi_abi abi); 89 | #endif 90 | 91 | /* Used internally, but overridden by some architectures */ 92 | ffi_status ffi_prep_cif_core(ffi_cif *cif, 93 | ffi_abi abi, 94 | unsigned int isvariadic, 95 | unsigned int nfixedargs, 96 | unsigned int ntotalargs, 97 | ffi_type *rtype, 98 | ffi_type **atypes); 99 | 100 | /* Extended cif, used in callback from assembly routine */ 101 | typedef struct 102 | { 103 | ffi_cif *cif; 104 | void *rvalue; 105 | void **avalue; 106 | } extended_cif; 107 | 108 | /* Terse sized type definitions. */ 109 | #if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C) 110 | typedef unsigned char UINT8; 111 | typedef signed char SINT8; 112 | typedef unsigned short UINT16; 113 | typedef signed short SINT16; 114 | typedef unsigned int UINT32; 115 | typedef signed int SINT32; 116 | # ifdef _MSC_VER 117 | typedef unsigned __int64 UINT64; 118 | typedef signed __int64 SINT64; 119 | # else 120 | # include 121 | typedef uint64_t UINT64; 122 | typedef int64_t SINT64; 123 | # endif 124 | #else 125 | typedef unsigned int UINT8 __attribute__((__mode__(__QI__))); 126 | typedef signed int SINT8 __attribute__((__mode__(__QI__))); 127 | typedef unsigned int UINT16 __attribute__((__mode__(__HI__))); 128 | typedef signed int SINT16 __attribute__((__mode__(__HI__))); 129 | typedef unsigned int UINT32 __attribute__((__mode__(__SI__))); 130 | typedef signed int SINT32 __attribute__((__mode__(__SI__))); 131 | typedef unsigned int UINT64 __attribute__((__mode__(__DI__))); 132 | typedef signed int SINT64 __attribute__((__mode__(__DI__))); 133 | #endif 134 | 135 | typedef float FLOAT32; 136 | 137 | #ifndef __GNUC__ 138 | #define __builtin_expect(x, expected_value) (x) 139 | #endif 140 | #define LIKELY(x) __builtin_expect(!!(x),1) 141 | #define UNLIKELY(x) __builtin_expect((x)!=0,0) 142 | 143 | #ifdef __cplusplus 144 | } 145 | #endif 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /NVMAspects/libffi/ffi_i386.h: -------------------------------------------------------------------------------- 1 | #ifdef __i386__ 2 | 3 | /* -----------------------------------------------------------------*-C-*- 4 | libffi 3.2.1 - Copyright (c) 2011, 2014 Anthony Green 5 | - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. 6 | 7 | Permission is hereby granted, free of charge, to any person 8 | obtaining a copy of this software and associated documentation 9 | files (the ``Software''), to deal in the Software without 10 | restriction, including without limitation the rights to use, copy, 11 | modify, merge, publish, distribute, sublicense, and/or sell copies 12 | of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | 27 | ----------------------------------------------------------------------- */ 28 | 29 | /* ------------------------------------------------------------------- 30 | The basic API is described in the README file. 31 | 32 | The raw API is designed to bypass some of the argument packing 33 | and unpacking on architectures for which it can be avoided. 34 | 35 | The closure API allows interpreted functions to be packaged up 36 | inside a C function pointer, so that they can be called as C functions, 37 | with no understanding on the client side that they are interpreted. 38 | It can also be used in other cases in which it is necessary to package 39 | up a user specified parameter and a function pointer as a single 40 | function pointer. 41 | 42 | The closure API must be implemented in order to get its functionality, 43 | e.g. for use by gij. Routines are provided to emulate the raw API 44 | if the underlying platform doesn't allow faster implementation. 45 | 46 | More details on the raw and cloure API can be found in: 47 | 48 | http://gcc.gnu.org/ml/java/1999-q3/msg00138.html 49 | 50 | and 51 | 52 | http://gcc.gnu.org/ml/java/1999-q3/msg00174.html 53 | -------------------------------------------------------------------- */ 54 | 55 | #ifndef LIBFFI_H 56 | #define LIBFFI_H 57 | 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | 62 | /* Specify which architecture libffi is configured for. */ 63 | #ifndef X86_DARWIN 64 | #define X86_DARWIN 65 | #endif 66 | 67 | /* ---- System configuration information --------------------------------- */ 68 | 69 | #include 70 | 71 | #ifndef LIBFFI_ASM 72 | 73 | #if defined(_MSC_VER) && !defined(__clang__) 74 | #define __attribute__(X) 75 | #endif 76 | 77 | #include 78 | #include 79 | 80 | /* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). 81 | But we can find it either under the correct ANSI name, or under GNU 82 | C's internal name. */ 83 | 84 | #define FFI_64_BIT_MAX 9223372036854775807 85 | 86 | #ifdef LONG_LONG_MAX 87 | # define FFI_LONG_LONG_MAX LONG_LONG_MAX 88 | #else 89 | # ifdef LLONG_MAX 90 | # define FFI_LONG_LONG_MAX LLONG_MAX 91 | # ifdef _AIX52 /* or newer has C99 LLONG_MAX */ 92 | # undef FFI_64_BIT_MAX 93 | # define FFI_64_BIT_MAX 9223372036854775807LL 94 | # endif /* _AIX52 or newer */ 95 | # else 96 | # ifdef __GNUC__ 97 | # define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ 98 | # endif 99 | # ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ 100 | # ifndef __PPC64__ 101 | # if defined (__IBMC__) || defined (__IBMCPP__) 102 | # define FFI_LONG_LONG_MAX LONGLONG_MAX 103 | # endif 104 | # endif /* __PPC64__ */ 105 | # undef FFI_64_BIT_MAX 106 | # define FFI_64_BIT_MAX 9223372036854775807LL 107 | # endif 108 | # endif 109 | #endif 110 | 111 | /* The closure code assumes that this works on pointers, i.e. a size_t */ 112 | /* can hold a pointer. */ 113 | 114 | typedef struct _ffi_type 115 | { 116 | size_t size; 117 | unsigned short alignment; 118 | unsigned short type; 119 | struct _ffi_type **elements; 120 | } ffi_type; 121 | 122 | #ifndef LIBFFI_HIDE_BASIC_TYPES 123 | #if SCHAR_MAX == 127 124 | # define ffi_type_uchar ffi_type_uint8 125 | # define ffi_type_schar ffi_type_sint8 126 | #else 127 | #error "char size not supported" 128 | #endif 129 | 130 | #if SHRT_MAX == 32767 131 | # define ffi_type_ushort ffi_type_uint16 132 | # define ffi_type_sshort ffi_type_sint16 133 | #elif SHRT_MAX == 2147483647 134 | # define ffi_type_ushort ffi_type_uint32 135 | # define ffi_type_sshort ffi_type_sint32 136 | #else 137 | #error "short size not supported" 138 | #endif 139 | 140 | #if INT_MAX == 32767 141 | # define ffi_type_uint ffi_type_uint16 142 | # define ffi_type_sint ffi_type_sint16 143 | #elif INT_MAX == 2147483647 144 | # define ffi_type_uint ffi_type_uint32 145 | # define ffi_type_sint ffi_type_sint32 146 | #elif INT_MAX == 9223372036854775807 147 | # define ffi_type_uint ffi_type_uint64 148 | # define ffi_type_sint ffi_type_sint64 149 | #else 150 | #error "int size not supported" 151 | #endif 152 | 153 | #if LONG_MAX == 2147483647 154 | # if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX 155 | #error "no 64-bit data type supported" 156 | # endif 157 | #elif LONG_MAX != FFI_64_BIT_MAX 158 | #error "long size not supported" 159 | #endif 160 | 161 | #if LONG_MAX == 2147483647 162 | # define ffi_type_ulong ffi_type_uint32 163 | # define ffi_type_slong ffi_type_sint32 164 | #elif LONG_MAX == FFI_64_BIT_MAX 165 | # define ffi_type_ulong ffi_type_uint64 166 | # define ffi_type_slong ffi_type_sint64 167 | #else 168 | #error "long size not supported" 169 | #endif 170 | 171 | /* Need minimal decorations for DLLs to works on Windows. */ 172 | /* GCC has autoimport and autoexport. Rely on Libtool to */ 173 | /* help MSVC export from a DLL, but always declare data */ 174 | /* to be imported for MSVC clients. This costs an extra */ 175 | /* indirection for MSVC clients using the static version */ 176 | /* of the library, but don't worry about that. Besides, */ 177 | /* as a workaround, they can define FFI_BUILDING if they */ 178 | /* *know* they are going to link with the static library. */ 179 | #if defined _MSC_VER && !defined FFI_BUILDING 180 | #define FFI_EXTERN extern __declspec(dllimport) 181 | #else 182 | #define FFI_EXTERN extern 183 | #endif 184 | 185 | /* These are defined in types.c */ 186 | FFI_EXTERN ffi_type ffi_type_void; 187 | FFI_EXTERN ffi_type ffi_type_uint8; 188 | FFI_EXTERN ffi_type ffi_type_sint8; 189 | FFI_EXTERN ffi_type ffi_type_uint16; 190 | FFI_EXTERN ffi_type ffi_type_sint16; 191 | FFI_EXTERN ffi_type ffi_type_uint32; 192 | FFI_EXTERN ffi_type ffi_type_sint32; 193 | FFI_EXTERN ffi_type ffi_type_uint64; 194 | FFI_EXTERN ffi_type ffi_type_sint64; 195 | FFI_EXTERN ffi_type ffi_type_float; 196 | FFI_EXTERN ffi_type ffi_type_double; 197 | FFI_EXTERN ffi_type ffi_type_pointer; 198 | 199 | #if 1 200 | FFI_EXTERN ffi_type ffi_type_longdouble; 201 | #else 202 | #define ffi_type_longdouble ffi_type_double 203 | #endif 204 | 205 | #ifdef FFI_TARGET_HAS_COMPLEX_TYPE 206 | FFI_EXTERN ffi_type ffi_type_complex_float; 207 | FFI_EXTERN ffi_type ffi_type_complex_double; 208 | #if 1 209 | FFI_EXTERN ffi_type ffi_type_complex_longdouble; 210 | #else 211 | #define ffi_type_complex_longdouble ffi_type_complex_double 212 | #endif 213 | #endif 214 | #endif /* LIBFFI_HIDE_BASIC_TYPES */ 215 | 216 | typedef enum { 217 | FFI_OK = 0, 218 | FFI_BAD_TYPEDEF, 219 | FFI_BAD_ABI 220 | } ffi_status; 221 | 222 | typedef unsigned FFI_TYPE; 223 | 224 | typedef struct { 225 | ffi_abi abi; 226 | unsigned nargs; 227 | ffi_type **arg_types; 228 | ffi_type *rtype; 229 | unsigned bytes; 230 | unsigned flags; 231 | #ifdef FFI_EXTRA_CIF_FIELDS 232 | FFI_EXTRA_CIF_FIELDS; 233 | #endif 234 | } ffi_cif; 235 | 236 | #if 0 237 | /* Used to adjust size/alignment of ffi types. */ 238 | void ffi_prep_types (ffi_abi abi); 239 | #endif 240 | 241 | /* Used internally, but overridden by some architectures */ 242 | ffi_status ffi_prep_cif_core(ffi_cif *cif, 243 | ffi_abi abi, 244 | unsigned int isvariadic, 245 | unsigned int nfixedargs, 246 | unsigned int ntotalargs, 247 | ffi_type *rtype, 248 | ffi_type **atypes); 249 | 250 | /* ---- Definitions for the raw API -------------------------------------- */ 251 | 252 | #ifndef FFI_SIZEOF_ARG 253 | # if LONG_MAX == 2147483647 254 | # define FFI_SIZEOF_ARG 4 255 | # elif LONG_MAX == FFI_64_BIT_MAX 256 | # define FFI_SIZEOF_ARG 8 257 | # endif 258 | #endif 259 | 260 | #ifndef FFI_SIZEOF_JAVA_RAW 261 | # define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG 262 | #endif 263 | 264 | typedef union { 265 | ffi_sarg sint; 266 | ffi_arg uint; 267 | float flt; 268 | char data[FFI_SIZEOF_ARG]; 269 | void* ptr; 270 | } ffi_raw; 271 | 272 | #if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 273 | /* This is a special case for mips64/n32 ABI (and perhaps others) where 274 | sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ 275 | typedef union { 276 | signed int sint; 277 | unsigned int uint; 278 | float flt; 279 | char data[FFI_SIZEOF_JAVA_RAW]; 280 | void* ptr; 281 | } ffi_java_raw; 282 | #else 283 | typedef ffi_raw ffi_java_raw; 284 | #endif 285 | 286 | 287 | void ffi_raw_call (ffi_cif *cif, 288 | void (*fn)(void), 289 | void *rvalue, 290 | ffi_raw *avalue); 291 | 292 | void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); 293 | void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); 294 | size_t ffi_raw_size (ffi_cif *cif); 295 | 296 | /* This is analogous to the raw API, except it uses Java parameter */ 297 | /* packing, even on 64-bit machines. I.e. on 64-bit machines */ 298 | /* longs and doubles are followed by an empty 64-bit word. */ 299 | 300 | void ffi_java_raw_call (ffi_cif *cif, 301 | void (*fn)(void), 302 | void *rvalue, 303 | ffi_java_raw *avalue); 304 | 305 | void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); 306 | void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); 307 | size_t ffi_java_raw_size (ffi_cif *cif); 308 | 309 | /* ---- Definitions for closures ----------------------------------------- */ 310 | 311 | #if FFI_CLOSURES 312 | 313 | #ifdef _MSC_VER 314 | __declspec(align(8)) 315 | #endif 316 | typedef struct { 317 | #if 0 318 | void *trampoline_table; 319 | void *trampoline_table_entry; 320 | #else 321 | char tramp[FFI_TRAMPOLINE_SIZE]; 322 | #endif 323 | ffi_cif *cif; 324 | void (*fun)(ffi_cif*,void*,void**,void*); 325 | void *user_data; 326 | #ifdef __GNUC__ 327 | } ffi_closure __attribute__((aligned (8))); 328 | #else 329 | } ffi_closure; 330 | # ifdef __sgi 331 | # pragma pack 0 332 | # endif 333 | #endif 334 | 335 | void *ffi_closure_alloc (size_t size, void **code); 336 | void ffi_closure_free (void *); 337 | 338 | ffi_status 339 | ffi_prep_closure (ffi_closure*, 340 | ffi_cif *, 341 | void (*fun)(ffi_cif*,void*,void**,void*), 342 | void *user_data); 343 | 344 | ffi_status 345 | ffi_prep_closure_loc (ffi_closure*, 346 | ffi_cif *, 347 | void (*fun)(ffi_cif*,void*,void**,void*), 348 | void *user_data, 349 | void*codeloc); 350 | 351 | #ifdef __sgi 352 | # pragma pack 8 353 | #endif 354 | typedef struct { 355 | #if 0 356 | void *trampoline_table; 357 | void *trampoline_table_entry; 358 | #else 359 | char tramp[FFI_TRAMPOLINE_SIZE]; 360 | #endif 361 | ffi_cif *cif; 362 | 363 | #if !FFI_NATIVE_RAW_API 364 | 365 | /* if this is enabled, then a raw closure has the same layout 366 | as a regular closure. We use this to install an intermediate 367 | handler to do the transaltion, void** -> ffi_raw*. */ 368 | 369 | void (*translate_args)(ffi_cif*,void*,void**,void*); 370 | void *this_closure; 371 | 372 | #endif 373 | 374 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*); 375 | void *user_data; 376 | 377 | } ffi_raw_closure; 378 | 379 | typedef struct { 380 | #if 0 381 | void *trampoline_table; 382 | void *trampoline_table_entry; 383 | #else 384 | char tramp[FFI_TRAMPOLINE_SIZE]; 385 | #endif 386 | 387 | ffi_cif *cif; 388 | 389 | #if !FFI_NATIVE_RAW_API 390 | 391 | /* if this is enabled, then a raw closure has the same layout 392 | as a regular closure. We use this to install an intermediate 393 | handler to do the transaltion, void** -> ffi_raw*. */ 394 | 395 | void (*translate_args)(ffi_cif*,void*,void**,void*); 396 | void *this_closure; 397 | 398 | #endif 399 | 400 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); 401 | void *user_data; 402 | 403 | } ffi_java_raw_closure; 404 | 405 | ffi_status 406 | ffi_prep_raw_closure (ffi_raw_closure*, 407 | ffi_cif *cif, 408 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*), 409 | void *user_data); 410 | 411 | ffi_status 412 | ffi_prep_raw_closure_loc (ffi_raw_closure*, 413 | ffi_cif *cif, 414 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*), 415 | void *user_data, 416 | void *codeloc); 417 | 418 | ffi_status 419 | ffi_prep_java_raw_closure (ffi_java_raw_closure*, 420 | ffi_cif *cif, 421 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), 422 | void *user_data); 423 | 424 | ffi_status 425 | ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, 426 | ffi_cif *cif, 427 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), 428 | void *user_data, 429 | void *codeloc); 430 | 431 | #endif /* FFI_CLOSURES */ 432 | 433 | /* ---- Public interface definition -------------------------------------- */ 434 | 435 | ffi_status ffi_prep_cif(ffi_cif *cif, 436 | ffi_abi abi, 437 | unsigned int nargs, 438 | ffi_type *rtype, 439 | ffi_type **atypes); 440 | 441 | ffi_status ffi_prep_cif_var(ffi_cif *cif, 442 | ffi_abi abi, 443 | unsigned int nfixedargs, 444 | unsigned int ntotalargs, 445 | ffi_type *rtype, 446 | ffi_type **atypes); 447 | 448 | void ffi_call(ffi_cif *cif, 449 | void (*fn)(void), 450 | void *rvalue, 451 | void **avalue); 452 | 453 | /* Useful for eliminating compiler warnings */ 454 | #define FFI_FN(f) ((void (*)(void))f) 455 | 456 | /* ---- Definitions shared with assembly code ---------------------------- */ 457 | 458 | #endif 459 | 460 | /* If these change, update src/mips/ffitarget.h. */ 461 | #define FFI_TYPE_VOID 0 462 | #define FFI_TYPE_INT 1 463 | #define FFI_TYPE_FLOAT 2 464 | #define FFI_TYPE_DOUBLE 3 465 | #if 1 466 | #define FFI_TYPE_LONGDOUBLE 4 467 | #else 468 | #define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE 469 | #endif 470 | #define FFI_TYPE_UINT8 5 471 | #define FFI_TYPE_SINT8 6 472 | #define FFI_TYPE_UINT16 7 473 | #define FFI_TYPE_SINT16 8 474 | #define FFI_TYPE_UINT32 9 475 | #define FFI_TYPE_SINT32 10 476 | #define FFI_TYPE_UINT64 11 477 | #define FFI_TYPE_SINT64 12 478 | #define FFI_TYPE_STRUCT 13 479 | #define FFI_TYPE_POINTER 14 480 | #define FFI_TYPE_COMPLEX 15 481 | 482 | /* This should always refer to the last type code (for sanity checks) */ 483 | #define FFI_TYPE_LAST FFI_TYPE_COMPLEX 484 | 485 | #ifdef __cplusplus 486 | } 487 | #endif 488 | 489 | #endif 490 | 491 | 492 | #endif -------------------------------------------------------------------------------- /NVMAspects/libffi/ffi_x86_64.h: -------------------------------------------------------------------------------- 1 | /* -----------------------------------------------------------------*-C-*- 2 | libffi 3.99999 - Copyright (c) 2011, 2014 Anthony Green 3 | - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the ``Software''), to deal in the Software without 8 | restriction, including without limitation the rights to use, copy, 9 | modify, merge, publish, distribute, sublicense, and/or sell copies 10 | of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | 25 | ----------------------------------------------------------------------- */ 26 | 27 | /* ------------------------------------------------------------------- 28 | Most of the API is documented in doc/libffi.texi. 29 | 30 | The raw API is designed to bypass some of the argument packing and 31 | unpacking on architectures for which it can be avoided. Routines 32 | are provided to emulate the raw API if the underlying platform 33 | doesn't allow faster implementation. 34 | 35 | More details on the raw API can be found in: 36 | 37 | http://gcc.gnu.org/ml/java/1999-q3/msg00138.html 38 | 39 | and 40 | 41 | http://gcc.gnu.org/ml/java/1999-q3/msg00174.html 42 | -------------------------------------------------------------------- */ 43 | 44 | #ifndef LIBFFI_H 45 | #define LIBFFI_H 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /* Specify which architecture libffi is configured for. */ 52 | #ifndef X86_64 53 | #define X86_64 54 | #endif 55 | 56 | /* ---- System configuration information --------------------------------- */ 57 | 58 | #include 59 | 60 | #ifndef LIBFFI_ASM 61 | 62 | #if defined(_MSC_VER) && !defined(__clang__) 63 | #define __attribute__(X) 64 | #endif 65 | 66 | #include 67 | #include 68 | 69 | /* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). 70 | But we can find it either under the correct ANSI name, or under GNU 71 | C's internal name. */ 72 | 73 | #define FFI_64_BIT_MAX 9223372036854775807 74 | 75 | #ifdef LONG_LONG_MAX 76 | # define FFI_LONG_LONG_MAX LONG_LONG_MAX 77 | #else 78 | # ifdef LLONG_MAX 79 | # define FFI_LONG_LONG_MAX LLONG_MAX 80 | # ifdef _AIX52 /* or newer has C99 LLONG_MAX */ 81 | # undef FFI_64_BIT_MAX 82 | # define FFI_64_BIT_MAX 9223372036854775807LL 83 | # endif /* _AIX52 or newer */ 84 | # else 85 | # ifdef __GNUC__ 86 | # define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ 87 | # endif 88 | # ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ 89 | # ifndef __PPC64__ 90 | # if defined (__IBMC__) || defined (__IBMCPP__) 91 | # define FFI_LONG_LONG_MAX LONGLONG_MAX 92 | # endif 93 | # endif /* __PPC64__ */ 94 | # undef FFI_64_BIT_MAX 95 | # define FFI_64_BIT_MAX 9223372036854775807LL 96 | # endif 97 | # endif 98 | #endif 99 | 100 | /* The closure code assumes that this works on pointers, i.e. a size_t 101 | can hold a pointer. */ 102 | 103 | typedef struct _ffi_type 104 | { 105 | size_t size; 106 | unsigned short alignment; 107 | unsigned short type; 108 | struct _ffi_type **elements; 109 | } ffi_type; 110 | 111 | #ifndef LIBFFI_HIDE_BASIC_TYPES 112 | #if SCHAR_MAX == 127 113 | # define ffi_type_uchar ffi_type_uint8 114 | # define ffi_type_schar ffi_type_sint8 115 | #else 116 | #error "char size not supported" 117 | #endif 118 | 119 | #if SHRT_MAX == 32767 120 | # define ffi_type_ushort ffi_type_uint16 121 | # define ffi_type_sshort ffi_type_sint16 122 | #elif SHRT_MAX == 2147483647 123 | # define ffi_type_ushort ffi_type_uint32 124 | # define ffi_type_sshort ffi_type_sint32 125 | #else 126 | #error "short size not supported" 127 | #endif 128 | 129 | #if INT_MAX == 32767 130 | # define ffi_type_uint ffi_type_uint16 131 | # define ffi_type_sint ffi_type_sint16 132 | #elif INT_MAX == 2147483647 133 | # define ffi_type_uint ffi_type_uint32 134 | # define ffi_type_sint ffi_type_sint32 135 | #elif INT_MAX == 9223372036854775807 136 | # define ffi_type_uint ffi_type_uint64 137 | # define ffi_type_sint ffi_type_sint64 138 | #else 139 | #error "int size not supported" 140 | #endif 141 | 142 | #if LONG_MAX == 2147483647 143 | # if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX 144 | #error "no 64-bit data type supported" 145 | # endif 146 | #elif LONG_MAX != FFI_64_BIT_MAX 147 | #error "long size not supported" 148 | #endif 149 | 150 | #if LONG_MAX == 2147483647 151 | # define ffi_type_ulong ffi_type_uint32 152 | # define ffi_type_slong ffi_type_sint32 153 | #elif LONG_MAX == FFI_64_BIT_MAX 154 | # define ffi_type_ulong ffi_type_uint64 155 | # define ffi_type_slong ffi_type_sint64 156 | #else 157 | #error "long size not supported" 158 | #endif 159 | 160 | /* Need minimal decorations for DLLs to works on Windows. GCC has 161 | autoimport and autoexport. Rely on Libtool to help MSVC export 162 | from a DLL, but always declare data to be imported for MSVC 163 | clients. This costs an extra indirection for MSVC clients using 164 | the static version of the library, but don't worry about that. 165 | Besides, as a workaround, they can define FFI_BUILDING if they 166 | *know* they are going to link with the static library. */ 167 | #if defined _MSC_VER && !defined FFI_BUILDING 168 | #define FFI_EXTERN extern __declspec(dllimport) 169 | #else 170 | #define FFI_EXTERN extern 171 | #endif 172 | 173 | /* These are defined in types.c. */ 174 | FFI_EXTERN ffi_type ffi_type_void; 175 | FFI_EXTERN ffi_type ffi_type_uint8; 176 | FFI_EXTERN ffi_type ffi_type_sint8; 177 | FFI_EXTERN ffi_type ffi_type_uint16; 178 | FFI_EXTERN ffi_type ffi_type_sint16; 179 | FFI_EXTERN ffi_type ffi_type_uint32; 180 | FFI_EXTERN ffi_type ffi_type_sint32; 181 | FFI_EXTERN ffi_type ffi_type_uint64; 182 | FFI_EXTERN ffi_type ffi_type_sint64; 183 | FFI_EXTERN ffi_type ffi_type_float; 184 | FFI_EXTERN ffi_type ffi_type_double; 185 | FFI_EXTERN ffi_type ffi_type_pointer; 186 | 187 | #if 1 188 | FFI_EXTERN ffi_type ffi_type_longdouble; 189 | #else 190 | #define ffi_type_longdouble ffi_type_double 191 | #endif 192 | 193 | #ifdef FFI_TARGET_HAS_COMPLEX_TYPE 194 | FFI_EXTERN ffi_type ffi_type_complex_float; 195 | FFI_EXTERN ffi_type ffi_type_complex_double; 196 | #if 1 197 | FFI_EXTERN ffi_type ffi_type_complex_longdouble; 198 | #else 199 | #define ffi_type_complex_longdouble ffi_type_complex_double 200 | #endif 201 | #endif 202 | #endif /* LIBFFI_HIDE_BASIC_TYPES */ 203 | 204 | typedef enum { 205 | FFI_OK = 0, 206 | FFI_BAD_TYPEDEF, 207 | FFI_BAD_ABI 208 | } ffi_status; 209 | 210 | typedef struct { 211 | ffi_abi abi; 212 | unsigned nargs; 213 | ffi_type **arg_types; 214 | ffi_type *rtype; 215 | unsigned bytes; 216 | unsigned flags; 217 | #ifdef FFI_EXTRA_CIF_FIELDS 218 | FFI_EXTRA_CIF_FIELDS; 219 | #endif 220 | } ffi_cif; 221 | 222 | /* ---- Definitions for the raw API -------------------------------------- */ 223 | 224 | #ifndef FFI_SIZEOF_ARG 225 | # if LONG_MAX == 2147483647 226 | # define FFI_SIZEOF_ARG 4 227 | # elif LONG_MAX == FFI_64_BIT_MAX 228 | # define FFI_SIZEOF_ARG 8 229 | # endif 230 | #endif 231 | 232 | #ifndef FFI_SIZEOF_JAVA_RAW 233 | # define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG 234 | #endif 235 | 236 | typedef union { 237 | ffi_sarg sint; 238 | ffi_arg uint; 239 | float flt; 240 | char data[FFI_SIZEOF_ARG]; 241 | void* ptr; 242 | } ffi_raw; 243 | 244 | #if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 245 | /* This is a special case for mips64/n32 ABI (and perhaps others) where 246 | sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ 247 | typedef union { 248 | signed int sint; 249 | unsigned int uint; 250 | float flt; 251 | char data[FFI_SIZEOF_JAVA_RAW]; 252 | void* ptr; 253 | } ffi_java_raw; 254 | #else 255 | typedef ffi_raw ffi_java_raw; 256 | #endif 257 | 258 | 259 | void ffi_raw_call (ffi_cif *cif, 260 | void (*fn)(void), 261 | void *rvalue, 262 | ffi_raw *avalue); 263 | 264 | void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); 265 | void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); 266 | size_t ffi_raw_size (ffi_cif *cif); 267 | 268 | /* This is analogous to the raw API, except it uses Java parameter 269 | packing, even on 64-bit machines. I.e. on 64-bit machines longs 270 | and doubles are followed by an empty 64-bit word. */ 271 | 272 | void ffi_java_raw_call (ffi_cif *cif, 273 | void (*fn)(void), 274 | void *rvalue, 275 | ffi_java_raw *avalue); 276 | 277 | void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); 278 | void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); 279 | size_t ffi_java_raw_size (ffi_cif *cif); 280 | 281 | /* ---- Definitions for closures ----------------------------------------- */ 282 | 283 | #if FFI_CLOSURES 284 | 285 | #ifdef _MSC_VER 286 | __declspec(align(8)) 287 | #endif 288 | typedef struct { 289 | #if 0 290 | void *trampoline_table; 291 | void *trampoline_table_entry; 292 | #else 293 | char tramp[FFI_TRAMPOLINE_SIZE]; 294 | #endif 295 | ffi_cif *cif; 296 | void (*fun)(ffi_cif*,void*,void**,void*); 297 | void *user_data; 298 | } ffi_closure 299 | #ifdef __GNUC__ 300 | __attribute__((aligned (8))) 301 | #endif 302 | ; 303 | 304 | #ifndef __GNUC__ 305 | # ifdef __sgi 306 | # pragma pack 0 307 | # endif 308 | #endif 309 | 310 | void *ffi_closure_alloc (size_t size, void **code); 311 | void ffi_closure_free (void *); 312 | 313 | ffi_status 314 | ffi_prep_closure (ffi_closure*, 315 | ffi_cif *, 316 | void (*fun)(ffi_cif*,void*,void**,void*), 317 | void *user_data) 318 | __attribute__((deprecated ("use ffi_prep_closure_loc instead"))); 319 | 320 | ffi_status 321 | ffi_prep_closure_loc (ffi_closure*, 322 | ffi_cif *, 323 | void (*fun)(ffi_cif*,void*,void**,void*), 324 | void *user_data, 325 | void*codeloc); 326 | 327 | #ifdef __sgi 328 | # pragma pack 8 329 | #endif 330 | typedef struct { 331 | #if 0 332 | void *trampoline_table; 333 | void *trampoline_table_entry; 334 | #else 335 | char tramp[FFI_TRAMPOLINE_SIZE]; 336 | #endif 337 | ffi_cif *cif; 338 | 339 | #if !FFI_NATIVE_RAW_API 340 | 341 | /* If this is enabled, then a raw closure has the same layout 342 | as a regular closure. We use this to install an intermediate 343 | handler to do the transaltion, void** -> ffi_raw*. */ 344 | 345 | void (*translate_args)(ffi_cif*,void*,void**,void*); 346 | void *this_closure; 347 | 348 | #endif 349 | 350 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*); 351 | void *user_data; 352 | 353 | } ffi_raw_closure; 354 | 355 | typedef struct { 356 | #if 0 357 | void *trampoline_table; 358 | void *trampoline_table_entry; 359 | #else 360 | char tramp[FFI_TRAMPOLINE_SIZE]; 361 | #endif 362 | 363 | ffi_cif *cif; 364 | 365 | #if !FFI_NATIVE_RAW_API 366 | 367 | /* If this is enabled, then a raw closure has the same layout 368 | as a regular closure. We use this to install an intermediate 369 | handler to do the translation, void** -> ffi_raw*. */ 370 | 371 | void (*translate_args)(ffi_cif*,void*,void**,void*); 372 | void *this_closure; 373 | 374 | #endif 375 | 376 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); 377 | void *user_data; 378 | 379 | } ffi_java_raw_closure; 380 | 381 | ffi_status 382 | ffi_prep_raw_closure (ffi_raw_closure*, 383 | ffi_cif *cif, 384 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*), 385 | void *user_data); 386 | 387 | ffi_status 388 | ffi_prep_raw_closure_loc (ffi_raw_closure*, 389 | ffi_cif *cif, 390 | void (*fun)(ffi_cif*,void*,ffi_raw*,void*), 391 | void *user_data, 392 | void *codeloc); 393 | 394 | ffi_status 395 | ffi_prep_java_raw_closure (ffi_java_raw_closure*, 396 | ffi_cif *cif, 397 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), 398 | void *user_data); 399 | 400 | ffi_status 401 | ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, 402 | ffi_cif *cif, 403 | void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), 404 | void *user_data, 405 | void *codeloc); 406 | 407 | #endif /* FFI_CLOSURES */ 408 | 409 | #if FFI_GO_CLOSURES 410 | 411 | typedef struct { 412 | void *tramp; 413 | ffi_cif *cif; 414 | void (*fun)(ffi_cif*,void*,void**,void*); 415 | } ffi_go_closure; 416 | 417 | ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *, 418 | void (*fun)(ffi_cif*,void*,void**,void*)); 419 | 420 | void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, 421 | void **avalue, void *closure); 422 | 423 | #endif /* FFI_GO_CLOSURES */ 424 | 425 | /* ---- Public interface definition -------------------------------------- */ 426 | 427 | ffi_status ffi_prep_cif(ffi_cif *cif, 428 | ffi_abi abi, 429 | unsigned int nargs, 430 | ffi_type *rtype, 431 | ffi_type **atypes); 432 | 433 | ffi_status ffi_prep_cif_var(ffi_cif *cif, 434 | ffi_abi abi, 435 | unsigned int nfixedargs, 436 | unsigned int ntotalargs, 437 | ffi_type *rtype, 438 | ffi_type **atypes); 439 | 440 | void ffi_call(ffi_cif *cif, 441 | void (*fn)(void), 442 | void *rvalue, 443 | void **avalue); 444 | 445 | ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type, 446 | size_t *offsets); 447 | 448 | /* Useful for eliminating compiler warnings. */ 449 | #define FFI_FN(f) ((void (*)(void))f) 450 | 451 | /* ---- Definitions shared with assembly code ---------------------------- */ 452 | 453 | #endif 454 | 455 | /* If these change, update src/mips/ffitarget.h. */ 456 | #define FFI_TYPE_VOID 0 457 | #define FFI_TYPE_INT 1 458 | #define FFI_TYPE_FLOAT 2 459 | #define FFI_TYPE_DOUBLE 3 460 | #if 1 461 | #define FFI_TYPE_LONGDOUBLE 4 462 | #else 463 | #define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE 464 | #endif 465 | #define FFI_TYPE_UINT8 5 466 | #define FFI_TYPE_SINT8 6 467 | #define FFI_TYPE_UINT16 7 468 | #define FFI_TYPE_SINT16 8 469 | #define FFI_TYPE_UINT32 9 470 | #define FFI_TYPE_SINT32 10 471 | #define FFI_TYPE_UINT64 11 472 | #define FFI_TYPE_SINT64 12 473 | #define FFI_TYPE_STRUCT 13 474 | #define FFI_TYPE_POINTER 14 475 | #define FFI_TYPE_COMPLEX 15 476 | 477 | /* This should always refer to the last type code (for sanity checks). */ 478 | #define FFI_TYPE_LAST FFI_TYPE_COMPLEX 479 | 480 | #ifdef __cplusplus 481 | } 482 | #endif 483 | 484 | #endif 485 | -------------------------------------------------------------------------------- /NVMAspects/libffi/ffitarget.h: -------------------------------------------------------------------------------- 1 | #ifdef __arm64__ 2 | 3 | #include "ffitarget_arm64.h" 4 | 5 | 6 | #endif 7 | #ifdef __i386__ 8 | 9 | #include 10 | 11 | 12 | #endif 13 | #ifdef __arm__ 14 | 15 | #include 16 | 17 | 18 | #endif 19 | #ifdef __x86_64__ 20 | 21 | #include 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /NVMAspects/libffi/ffitarget_arm.h: -------------------------------------------------------------------------------- 1 | /* -----------------------------------------------------------------*-C-*- 2 | ffitarget.h - Copyright (c) 2012 Anthony Green 3 | Copyright (c) 2010 CodeSourcery 4 | Copyright (c) 1996-2003 Red Hat, Inc. 5 | 6 | Target configuration macros for ARM. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining 9 | a copy of this software and associated documentation files (the 10 | ``Software''), to deal in the Software without restriction, including 11 | without limitation the rights to use, copy, modify, merge, publish, 12 | distribute, sublicense, and/or sell copies of the Software, and to 13 | permit persons to whom the Software is furnished to do so, subject to 14 | the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included 17 | in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 23 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 | DEALINGS IN THE SOFTWARE. 27 | 28 | ----------------------------------------------------------------------- */ 29 | 30 | #ifndef LIBFFI_TARGET_H 31 | #define LIBFFI_TARGET_H 32 | 33 | #ifndef LIBFFI_H 34 | #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." 35 | #endif 36 | 37 | #ifndef LIBFFI_ASM 38 | typedef unsigned long ffi_arg; 39 | typedef signed long ffi_sarg; 40 | 41 | typedef enum ffi_abi { 42 | FFI_FIRST_ABI = 0, 43 | FFI_SYSV, 44 | FFI_VFP, 45 | FFI_LAST_ABI, 46 | #ifdef __ARM_PCS_VFP 47 | FFI_DEFAULT_ABI = FFI_VFP, 48 | #else 49 | FFI_DEFAULT_ABI = FFI_SYSV, 50 | #endif 51 | } ffi_abi; 52 | #endif 53 | 54 | #define FFI_EXTRA_CIF_FIELDS \ 55 | int vfp_used; \ 56 | unsigned short vfp_reg_free, vfp_nargs; \ 57 | signed char vfp_args[16] \ 58 | 59 | #define FFI_TARGET_SPECIFIC_VARIADIC 60 | #define FFI_TARGET_HAS_COMPLEX_TYPE 61 | 62 | /* ---- Definitions for closures ----------------------------------------- */ 63 | 64 | #define FFI_CLOSURES 1 65 | #define FFI_GO_CLOSURES 1 66 | #define FFI_NATIVE_RAW_API 0 67 | 68 | #if defined (FFI_EXEC_TRAMPOLINE_TABLE) && FFI_EXEC_TRAMPOLINE_TABLE 69 | 70 | #ifdef __MACH__ 71 | #define FFI_TRAMPOLINE_SIZE 12 72 | #define FFI_TRAMPOLINE_CLOSURE_OFFSET 8 73 | #else 74 | #error "No trampoline table implementation" 75 | #endif 76 | 77 | #else 78 | #define FFI_TRAMPOLINE_SIZE 12 79 | #define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE 80 | #endif 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /NVMAspects/libffi/ffitarget_arm64.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | ``Software''), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 21 | 22 | #ifndef LIBFFI_TARGET_H 23 | #define LIBFFI_TARGET_H 24 | 25 | #ifndef LIBFFI_H 26 | #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." 27 | #endif 28 | 29 | #ifndef LIBFFI_ASM 30 | #ifdef __ILP32__ 31 | #define FFI_SIZEOF_ARG 8 32 | #define FFI_SIZEOF_JAVA_RAW 4 33 | typedef unsigned long long ffi_arg; 34 | typedef signed long long ffi_sarg; 35 | #else 36 | typedef unsigned long ffi_arg; 37 | typedef signed long ffi_sarg; 38 | #endif 39 | 40 | typedef enum ffi_abi 41 | { 42 | FFI_FIRST_ABI = 0, 43 | FFI_SYSV, 44 | FFI_LAST_ABI, 45 | FFI_DEFAULT_ABI = FFI_SYSV 46 | } ffi_abi; 47 | #endif 48 | 49 | /* ---- Definitions for closures ----------------------------------------- */ 50 | 51 | #define FFI_CLOSURES 1 52 | #define FFI_NATIVE_RAW_API 0 53 | 54 | #if defined (FFI_EXEC_TRAMPOLINE_TABLE) && FFI_EXEC_TRAMPOLINE_TABLE 55 | 56 | #ifdef __MACH__ 57 | #define FFI_TRAMPOLINE_SIZE 16 58 | #define FFI_TRAMPOLINE_CLOSURE_OFFSET 16 59 | #else 60 | #error "No trampoline table implementation" 61 | #endif 62 | 63 | #else 64 | #define FFI_TRAMPOLINE_SIZE 24 65 | #define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE 66 | #endif 67 | 68 | /* ---- Internal ---- */ 69 | 70 | #if defined (__APPLE__) 71 | #define FFI_TARGET_SPECIFIC_VARIADIC 72 | #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs 73 | #else 74 | /* iOS reserves x18 for the system. Disable Go closures until 75 | a new static chain is chosen. */ 76 | #define FFI_GO_CLOSURES 1 77 | #endif 78 | 79 | #define FFI_TARGET_HAS_COMPLEX_TYPE 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /NVMAspects/libffi/ffitarget_i386.h: -------------------------------------------------------------------------------- 1 | #ifdef __i386__ 2 | 3 | /* -----------------------------------------------------------------*-C-*- 4 | ffitarget.h - Copyright (c) 2012, 2014 Anthony Green 5 | Copyright (c) 1996-2003, 2010 Red Hat, Inc. 6 | Copyright (C) 2008 Free Software Foundation, Inc. 7 | 8 | Target configuration macros for x86 and x86-64. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining 11 | a copy of this software and associated documentation files (the 12 | ``Software''), to deal in the Software without restriction, including 13 | without limitation the rights to use, copy, modify, merge, publish, 14 | distribute, sublicense, and/or sell copies of the Software, and to 15 | permit persons to whom the Software is furnished to do so, subject to 16 | the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included 19 | in all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, 22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 28 | DEALINGS IN THE SOFTWARE. 29 | 30 | ----------------------------------------------------------------------- */ 31 | 32 | #ifndef LIBFFI_TARGET_H 33 | #define LIBFFI_TARGET_H 34 | 35 | #ifndef LIBFFI_H 36 | #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." 37 | #endif 38 | 39 | /* ---- System specific configurations ----------------------------------- */ 40 | 41 | /* For code common to all platforms on x86 and x86_64. */ 42 | #define X86_ANY 43 | 44 | #if defined (X86_64) && defined (__i386__) 45 | #undef X86_64 46 | #define X86 47 | #endif 48 | 49 | #ifdef X86_WIN64 50 | #define FFI_SIZEOF_ARG 8 51 | #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ 52 | #endif 53 | 54 | #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION 55 | #define FFI_TARGET_HAS_COMPLEX_TYPE 56 | 57 | /* ---- Generic type definitions ----------------------------------------- */ 58 | 59 | #ifndef LIBFFI_ASM 60 | #ifdef X86_WIN64 61 | #ifdef _MSC_VER 62 | typedef unsigned __int64 ffi_arg; 63 | typedef __int64 ffi_sarg; 64 | #else 65 | typedef unsigned long long ffi_arg; 66 | typedef long long ffi_sarg; 67 | #endif 68 | #else 69 | #if defined __x86_64__ && defined __ILP32__ 70 | #define FFI_SIZEOF_ARG 8 71 | #define FFI_SIZEOF_JAVA_RAW 4 72 | typedef unsigned long long ffi_arg; 73 | typedef long long ffi_sarg; 74 | #else 75 | typedef unsigned long ffi_arg; 76 | typedef signed long ffi_sarg; 77 | #endif 78 | #endif 79 | 80 | typedef enum ffi_abi { 81 | FFI_FIRST_ABI = 0, 82 | 83 | /* ---- Intel x86 Win32 ---------- */ 84 | #ifdef X86_WIN32 85 | FFI_SYSV, 86 | FFI_STDCALL, 87 | FFI_THISCALL, 88 | FFI_FASTCALL, 89 | FFI_MS_CDECL, 90 | FFI_PASCAL, 91 | FFI_REGISTER, 92 | FFI_LAST_ABI, 93 | #ifdef _MSC_VER 94 | FFI_DEFAULT_ABI = FFI_MS_CDECL 95 | #else 96 | FFI_DEFAULT_ABI = FFI_SYSV 97 | #endif 98 | 99 | #elif defined(X86_WIN64) 100 | FFI_WIN64, 101 | FFI_LAST_ABI, 102 | FFI_DEFAULT_ABI = FFI_WIN64 103 | 104 | #else 105 | /* ---- Intel x86 and AMD x86-64 - */ 106 | FFI_SYSV, 107 | FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */ 108 | FFI_THISCALL, 109 | FFI_FASTCALL, 110 | FFI_STDCALL, 111 | FFI_PASCAL, 112 | FFI_REGISTER, 113 | FFI_LAST_ABI, 114 | #if defined(__i386__) || defined(__i386) 115 | FFI_DEFAULT_ABI = FFI_SYSV 116 | #else 117 | FFI_DEFAULT_ABI = FFI_UNIX64 118 | #endif 119 | #endif 120 | } ffi_abi; 121 | #endif 122 | 123 | /* ---- Definitions for closures ----------------------------------------- */ 124 | 125 | #define FFI_CLOSURES 1 126 | #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) 127 | #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) 128 | #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) 129 | #define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4) 130 | 131 | #if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) 132 | #define FFI_TRAMPOLINE_SIZE 24 133 | #define FFI_NATIVE_RAW_API 0 134 | #else 135 | #ifdef X86_WIN32 136 | #define FFI_TRAMPOLINE_SIZE 52 137 | #else 138 | #ifdef X86_WIN64 139 | #define FFI_TRAMPOLINE_SIZE 29 140 | #define FFI_NATIVE_RAW_API 0 141 | #define FFI_NO_RAW_API 1 142 | #else 143 | #define FFI_TRAMPOLINE_SIZE 10 144 | #endif 145 | #endif 146 | #ifndef X86_WIN64 147 | #define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ 148 | #endif 149 | #endif 150 | 151 | #endif 152 | 153 | 154 | 155 | #endif -------------------------------------------------------------------------------- /NVMAspects/libffi/ffitarget_x86_64.h: -------------------------------------------------------------------------------- 1 | /* -----------------------------------------------------------------*-C-*- 2 | ffitarget.h - Copyright (c) 2012, 2014 Anthony Green 3 | Copyright (c) 1996-2003, 2010 Red Hat, Inc. 4 | Copyright (C) 2008 Free Software Foundation, Inc. 5 | 6 | Target configuration macros for x86 and x86-64. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining 9 | a copy of this software and associated documentation files (the 10 | ``Software''), to deal in the Software without restriction, including 11 | without limitation the rights to use, copy, modify, merge, publish, 12 | distribute, sublicense, and/or sell copies of the Software, and to 13 | permit persons to whom the Software is furnished to do so, subject to 14 | the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included 17 | in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 23 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 | DEALINGS IN THE SOFTWARE. 27 | 28 | ----------------------------------------------------------------------- */ 29 | 30 | #ifndef LIBFFI_TARGET_H 31 | #define LIBFFI_TARGET_H 32 | 33 | #ifndef LIBFFI_H 34 | #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." 35 | #endif 36 | 37 | /* ---- System specific configurations ----------------------------------- */ 38 | 39 | /* For code common to all platforms on x86 and x86_64. */ 40 | #define X86_ANY 41 | 42 | #if defined (X86_64) && defined (__i386__) 43 | #undef X86_64 44 | #define X86 45 | #endif 46 | 47 | #ifdef X86_WIN64 48 | #define FFI_SIZEOF_ARG 8 49 | #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ 50 | #endif 51 | 52 | #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION 53 | #ifndef _MSC_VER 54 | #define FFI_TARGET_HAS_COMPLEX_TYPE 55 | #endif 56 | 57 | /* ---- Generic type definitions ----------------------------------------- */ 58 | 59 | #ifndef LIBFFI_ASM 60 | #ifdef X86_WIN64 61 | #ifdef _MSC_VER 62 | typedef unsigned __int64 ffi_arg; 63 | typedef __int64 ffi_sarg; 64 | #else 65 | typedef unsigned long long ffi_arg; 66 | typedef long long ffi_sarg; 67 | #endif 68 | #else 69 | #if defined __x86_64__ && defined __ILP32__ 70 | #define FFI_SIZEOF_ARG 8 71 | #define FFI_SIZEOF_JAVA_RAW 4 72 | typedef unsigned long long ffi_arg; 73 | typedef long long ffi_sarg; 74 | #else 75 | typedef unsigned long ffi_arg; 76 | typedef signed long ffi_sarg; 77 | #endif 78 | #endif 79 | 80 | typedef enum ffi_abi { 81 | #if defined(X86_WIN64) 82 | FFI_FIRST_ABI = 0, 83 | FFI_WIN64, 84 | FFI_LAST_ABI, 85 | FFI_DEFAULT_ABI = FFI_WIN64 86 | 87 | #elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) 88 | FFI_FIRST_ABI = 1, 89 | FFI_UNIX64, 90 | FFI_WIN64, 91 | FFI_EFI64 = FFI_WIN64, 92 | FFI_LAST_ABI, 93 | FFI_DEFAULT_ABI = FFI_UNIX64 94 | 95 | #elif defined(X86_WIN32) 96 | FFI_FIRST_ABI = 0, 97 | FFI_SYSV = 1, 98 | FFI_STDCALL = 2, 99 | FFI_THISCALL = 3, 100 | FFI_FASTCALL = 4, 101 | FFI_MS_CDECL = 5, 102 | FFI_PASCAL = 6, 103 | FFI_REGISTER = 7, 104 | FFI_LAST_ABI, 105 | FFI_DEFAULT_ABI = FFI_MS_CDECL 106 | #else 107 | FFI_FIRST_ABI = 0, 108 | FFI_SYSV = 1, 109 | FFI_THISCALL = 3, 110 | FFI_FASTCALL = 4, 111 | FFI_STDCALL = 5, 112 | FFI_PASCAL = 6, 113 | FFI_REGISTER = 7, 114 | FFI_MS_CDECL = 8, 115 | FFI_LAST_ABI, 116 | FFI_DEFAULT_ABI = FFI_SYSV 117 | #endif 118 | } ffi_abi; 119 | #endif 120 | 121 | /* ---- Definitions for closures ----------------------------------------- */ 122 | 123 | #define FFI_CLOSURES 1 124 | #define FFI_GO_CLOSURES 1 125 | 126 | #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) 127 | #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) 128 | #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) 129 | #define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4) 130 | 131 | #if defined (X86_64) || defined(X86_WIN64) \ 132 | || (defined (__x86_64__) && defined (X86_DARWIN)) 133 | # define FFI_TRAMPOLINE_SIZE 24 134 | # define FFI_NATIVE_RAW_API 0 135 | #else 136 | # define FFI_TRAMPOLINE_SIZE 12 137 | # define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ 138 | #endif 139 | 140 | #endif 141 | 142 | -------------------------------------------------------------------------------- /NVMAspects/libffi/libffi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleme/NVMAspects/364e5917b3498abe89056b0f46ad1677fdf51d44/NVMAspects/libffi/libffi.a -------------------------------------------------------------------------------- /NVMAspectsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /NVMAspectsTests/NVMStructTests.mm: -------------------------------------------------------------------------------- 1 | // 2 | // NVMStructTests.m 3 | // NVMAspects 4 | // 5 | // Created by Karl on 16/04/2017. 6 | // Copyright © 2017 Rajax Network Technology Co., Ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NVMAspects.h" 11 | 12 | #pragma mark - struct define 13 | 14 | typedef struct _SimpleStruct { 15 | char a; 16 | char b; 17 | char c; 18 | char d; 19 | } SimpleStruct, *SimpleStructRef; 20 | 21 | BOOL SimpleStructEqualToSimpleStruct(SimpleStruct one, 22 | SimpleStruct theOther) { 23 | return one.a == theOther.a && one.b == theOther.b; 24 | } 25 | 26 | typedef struct _ComplexStruct { 27 | int a; 28 | double b; 29 | CGRect c; 30 | CFTypeRef d; 31 | } ComplexStruct; 32 | 33 | BOOL ComplexStructEqualToComplexStruct(ComplexStruct one, 34 | ComplexStruct theOther) { 35 | return (one.a == theOther.a && 36 | !(one.b != theOther.b) && 37 | CGRectEqualToRect(one.c, theOther.c) && 38 | one.d == theOther.d); 39 | } 40 | 41 | typedef struct _StructWithCArray { 42 | char a[3]; 43 | char b; 44 | } StructWithCArray; 45 | 46 | BOOL StructWithCArrayEqualToStructWithCArray(StructWithCArray one, 47 | StructWithCArray theOther) { 48 | for (NSInteger i = 0; i < 2; i++) { 49 | if (one.a[i] != theOther.a[i]) { 50 | return NO; 51 | } 52 | } 53 | if (one.b != theOther.b) { 54 | return NO; 55 | } 56 | 57 | return YES; 58 | } 59 | 60 | #pragma mark - InOut 61 | 62 | static CGRect InRect = CGRectMake(1, 2, 3, 4); 63 | static CGRect OutRect = CGRectMake(3, 1, 2, 2); 64 | 65 | static CGPoint InPoint = CGPointMake(1.2, 1.3); 66 | static CGPoint OutPoint = CGPointMake(1.3, 1.4); 67 | 68 | static SimpleStruct InSimpleStruct = {.a = 1, .b = 2}; 69 | static SimpleStruct OutSimpleStruct = {.a = 3, .b = 4}; 70 | 71 | static ComplexStruct InComplexStruct = {.a = 1, .b = 1.1, .c = InRect, NULL}; 72 | static ComplexStruct OutComplexStruct = {.a = 2, .b = 2.2, .c = OutRect, NULL}; 73 | 74 | static SimpleStructRef InSimpleStructRef = &InSimpleStruct; 75 | static SimpleStructRef OutSimpleStructRef = &OutSimpleStruct; 76 | 77 | static StructWithCArray InStructWithCArray = {.a = {1, 2}, .b = 2}; 78 | static StructWithCArray OutStructWithCArray = {.a = {2, 3}, .b = 3}; 79 | 80 | @interface NVMObjectHandleStruct : NSObject 81 | 82 | @end 83 | 84 | @implementation NVMObjectHandleStruct 85 | 86 | - (CGRect)rectForObject:(id)object withRect:(CGRect)inRect { 87 | return OutRect; 88 | } 89 | 90 | - (CGPoint)pointForObject:(id)object withPoint:(CGPoint)inPoint { 91 | return OutPoint; 92 | } 93 | 94 | - (SimpleStruct)simpleStructForObject:(id)object 95 | withSimpleStruct:(SimpleStruct)inSimpleStruct { 96 | return OutSimpleStruct; 97 | } 98 | 99 | - (ComplexStruct)complexStructForObject:(id)object 100 | withComplexStruct:(ComplexStruct)inComplexStruct { 101 | return OutComplexStruct; 102 | } 103 | 104 | - (SimpleStructRef)methodHandleStructRef:(SimpleStructRef)inStructRef { 105 | return OutSimpleStructRef; 106 | } 107 | 108 | - (StructWithCArray)methodHandleStructWithCArray:(StructWithCArray)inStructWithCArray { 109 | return OutStructWithCArray; 110 | } 111 | 112 | @end 113 | 114 | @interface NVMStructTests : XCTestCase 115 | 116 | @property (nonatomic) NVMObjectHandleStruct *targetObject; 117 | 118 | @end 119 | 120 | @implementation NVMStructTests 121 | 122 | - (void)setUp { 123 | [super setUp]; 124 | self.targetObject = [NVMObjectHandleStruct new]; 125 | } 126 | 127 | - (void)testRect { 128 | [self.targetObject nvm_hookInstanceMethod:@selector(rectForObject:withRect:) 129 | usingBlock:^CGRect (NVMAspectInfo *info, id object, CGRect inRect) { 130 | XCTAssert(CGRectEqualToRect(inRect, InRect)); 131 | 132 | CGRect temp; 133 | 134 | [info.oriInvocation getArgument:&temp atIndex:3]; 135 | XCTAssert(CGRectEqualToRect(inRect, temp)); 136 | 137 | [info.oriInvocation invoke]; 138 | [info.oriInvocation getReturnValue:&temp]; 139 | XCTAssert(CGRectEqualToRect(OutRect, temp)); 140 | 141 | return OutRect; 142 | } error:NULL]; 143 | CGRect result = [self.targetObject rectForObject:nil withRect:InRect]; 144 | XCTAssert(CGRectEqualToRect(OutRect, result)); 145 | } 146 | 147 | - (void)testPoint { 148 | [self.targetObject nvm_hookInstanceMethod:@selector(pointForObject:withPoint:) 149 | usingBlock:^CGPoint (NVMAspectInfo *info, id object, CGPoint inPoint) { 150 | XCTAssert(CGPointEqualToPoint(inPoint, InPoint)); 151 | 152 | CGPoint temp; 153 | 154 | [info.oriInvocation getArgument:&temp atIndex:3]; 155 | XCTAssert(CGPointEqualToPoint(InPoint, temp)); 156 | 157 | [info.oriInvocation invoke]; 158 | [info.oriInvocation getReturnValue:&temp]; 159 | XCTAssert(CGPointEqualToPoint(OutPoint, temp)); 160 | 161 | return OutPoint; 162 | } error:NULL]; 163 | CGPoint result = [self.targetObject pointForObject:nil withPoint:InPoint]; 164 | XCTAssert(CGPointEqualToPoint(OutPoint, result)); 165 | } 166 | 167 | - (void)testSimpleStruct { 168 | [self.targetObject nvm_hookInstanceMethod:@selector(simpleStructForObject:withSimpleStruct:) 169 | usingBlock:^SimpleStruct (NVMAspectInfo *info, id object, SimpleStruct inSimpleStruct) { 170 | XCTAssert(SimpleStructEqualToSimpleStruct(inSimpleStruct, InSimpleStruct)); 171 | 172 | SimpleStruct temp; 173 | 174 | [info.oriInvocation getArgument:&temp atIndex:3]; 175 | XCTAssert(SimpleStructEqualToSimpleStruct(InSimpleStruct, temp)); 176 | 177 | [info.oriInvocation invoke]; 178 | [info.oriInvocation getReturnValue:&temp]; 179 | XCTAssert(SimpleStructEqualToSimpleStruct(OutSimpleStruct, temp)); 180 | 181 | return OutSimpleStruct; 182 | } error:NULL]; 183 | SimpleStruct result = [self.targetObject simpleStructForObject:nil 184 | withSimpleStruct:InSimpleStruct]; 185 | XCTAssert(SimpleStructEqualToSimpleStruct(OutSimpleStruct, result)); 186 | } 187 | 188 | - (void)testComplexStruct { 189 | [self.targetObject nvm_hookInstanceMethod:@selector(complexStructForObject:withComplexStruct:) 190 | usingBlock:^ComplexStruct (NVMAspectInfo *info, id object, ComplexStruct inComplexStruct) { 191 | XCTAssert(ComplexStructEqualToComplexStruct(inComplexStruct, InComplexStruct)); 192 | 193 | ComplexStruct temp; 194 | 195 | [info.oriInvocation getArgument:&temp atIndex:3]; 196 | XCTAssert(ComplexStructEqualToComplexStruct(InComplexStruct, temp)); 197 | 198 | [info.oriInvocation invoke]; 199 | [info.oriInvocation getReturnValue:&temp]; 200 | XCTAssert(ComplexStructEqualToComplexStruct(OutComplexStruct, temp)); 201 | 202 | return OutComplexStruct; 203 | } error:NULL]; 204 | ComplexStruct result = [self.targetObject complexStructForObject:nil 205 | withComplexStruct:InComplexStruct]; 206 | XCTAssert(ComplexStructEqualToComplexStruct(OutComplexStruct, result)); 207 | } 208 | 209 | - (void)testStructRef { 210 | [self.targetObject nvm_hookInstanceMethod:@selector(methodHandleStructRef:) 211 | usingBlock:^SimpleStructRef (NVMAspectInfo *info, SimpleStructRef inSimpleStructRef) { 212 | XCTAssert(inSimpleStructRef == InSimpleStructRef); 213 | 214 | SimpleStructRef temp; 215 | 216 | [info.oriInvocation getArgument:&temp atIndex:2]; 217 | XCTAssert(InSimpleStructRef == temp); 218 | 219 | [info.oriInvocation invoke]; 220 | [info.oriInvocation getReturnValue:&temp]; 221 | XCTAssert(OutSimpleStructRef == temp); 222 | 223 | return OutSimpleStructRef; 224 | } error:NULL]; 225 | SimpleStructRef result = [self.targetObject methodHandleStructRef:InSimpleStructRef]; 226 | XCTAssert(result == OutSimpleStructRef); 227 | } 228 | 229 | - (void)notestStructWithCArray { 230 | // struct with c array is not fully support comment out the test 231 | [self.targetObject nvm_hookInstanceMethod:@selector(methodHandleStructWithCArray:) 232 | usingBlock:^StructWithCArray (NVMAspectInfo *info, StructWithCArray inStructWithCArray) { 233 | XCTAssert(StructWithCArrayEqualToStructWithCArray(inStructWithCArray, InStructWithCArray)); 234 | 235 | StructWithCArray temp; 236 | 237 | [info.oriInvocation getArgument:&temp atIndex:2]; 238 | XCTAssert(StructWithCArrayEqualToStructWithCArray(temp, inStructWithCArray)); 239 | 240 | [info.oriInvocation invoke]; 241 | [info.oriInvocation getReturnValue:&temp]; 242 | XCTAssert(StructWithCArrayEqualToStructWithCArray(temp, OutStructWithCArray)); 243 | 244 | return OutStructWithCArray; 245 | } error:NULL]; 246 | StructWithCArray result = [self.targetObject methodHandleStructWithCArray:InStructWithCArray]; 247 | XCTAssert(StructWithCArrayEqualToStructWithCArray(result, OutStructWithCArray)); 248 | } 249 | 250 | @end 251 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | 2 | use_frameworks! 3 | 4 | workspace 'NVMAspects' 5 | 6 | def declare_pods_from_podspec 7 | IO.readlines(Dir.glob('*.podspec').first) 8 | .find_all { |x| x =~ /^\s*?\w+\.dependency\s*/ } 9 | .map { |x| x.strip.gsub(/^\s*?\w*?\.dependency\s*/, '') } 10 | .map { |x| x.gsub(/'|"/, "").split(/,\s*/) } 11 | .each { |x| pod *x } 12 | end 13 | 14 | def declare_pods 15 | 16 | end 17 | 18 | target 'NVMAspects' do 19 | project 'NVMAspects' 20 | declare_pods 21 | 22 | target 'NVMAspectsTests' do 23 | inherit! :search_paths 24 | end 25 | end 26 | 27 | target 'NVMAspectsDemo' do 28 | project 'Demo/NVMAspectsDemo/NVMAspectsDemo' 29 | declare_pods 30 | end 31 | 32 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODFILE CHECKSUM: 65f3a5c293dc8375d5b888bb2967277b80268b52 2 | 3 | COCOAPODS: 1.2.0 4 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODFILE CHECKSUM: 65f3a5c293dc8375d5b888bb2967277b80268b52 2 | 3 | COCOAPODS: 1.2.0 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspects/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspects/Pods-NVMAspects-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspects/Pods-NVMAspects-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspects/Pods-NVMAspects-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_NVMAspects : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_NVMAspects 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspects/Pods-NVMAspects-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | 3) 22 | TARGET_DEVICE_ARGS="--target-device tv" 23 | ;; 24 | *) 25 | TARGET_DEVICE_ARGS="--target-device mac" 26 | ;; 27 | esac 28 | 29 | install_resource() 30 | { 31 | if [[ "$1" = /* ]] ; then 32 | RESOURCE_PATH="$1" 33 | else 34 | RESOURCE_PATH="${PODS_ROOT}/$1" 35 | fi 36 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 37 | cat << EOM 38 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 39 | EOM 40 | exit 1 41 | fi 42 | case $RESOURCE_PATH in 43 | *.storyboard) 44 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 45 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 46 | ;; 47 | *.xib) 48 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 49 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 50 | ;; 51 | *.framework) 52 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 53 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 54 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 55 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | ;; 57 | *.xcdatamodel) 58 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 59 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 60 | ;; 61 | *.xcdatamodeld) 62 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 63 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 64 | ;; 65 | *.xcmappingmodel) 66 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 67 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 68 | ;; 69 | *.xcassets) 70 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 71 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 72 | ;; 73 | *) 74 | echo "$RESOURCE_PATH" 75 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 76 | ;; 77 | esac 78 | } 79 | 80 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 82 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 83 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | fi 86 | rm -f "$RESOURCES_TO_COPY" 87 | 88 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 89 | then 90 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 91 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 92 | while read line; do 93 | if [[ $line != "${PODS_ROOT}*" ]]; then 94 | XCASSET_FILES+=("$line") 95 | fi 96 | done <<<"$OTHER_XCASSETS" 97 | 98 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 99 | fi 100 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspects/Pods-NVMAspects-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_NVMAspectsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_NVMAspectsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspects/Pods-NVMAspects.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' '@executable_path/../../Frameworks' 3 | PODS_BUILD_DIR = $BUILD_DIR 4 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 5 | PODS_ROOT = ${SRCROOT}/Pods 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspects/Pods-NVMAspects.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_NVMAspects { 2 | umbrella header "Pods-NVMAspects-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspects/Pods-NVMAspects.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' '@executable_path/../../Frameworks' 3 | PODS_BUILD_DIR = $BUILD_DIR 4 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 5 | PODS_ROOT = ${SRCROOT}/Pods 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_NVMAspectsDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_NVMAspectsDemo 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 63 | 64 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 65 | code_sign_cmd="$code_sign_cmd &" 66 | fi 67 | echo "$code_sign_cmd" 68 | eval "$code_sign_cmd" 69 | fi 70 | } 71 | 72 | # Strip invalid architectures 73 | strip_invalid_archs() { 74 | binary="$1" 75 | # Get architectures for current file 76 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 77 | stripped="" 78 | for arch in $archs; do 79 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 80 | # Strip non-valid architectures in-place 81 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 82 | stripped="$stripped $arch" 83 | fi 84 | done 85 | if [[ "$stripped" ]]; then 86 | echo "Stripped $binary of architectures:$stripped" 87 | fi 88 | } 89 | 90 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 91 | wait 92 | fi 93 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | 3) 22 | TARGET_DEVICE_ARGS="--target-device tv" 23 | ;; 24 | *) 25 | TARGET_DEVICE_ARGS="--target-device mac" 26 | ;; 27 | esac 28 | 29 | install_resource() 30 | { 31 | if [[ "$1" = /* ]] ; then 32 | RESOURCE_PATH="$1" 33 | else 34 | RESOURCE_PATH="${PODS_ROOT}/$1" 35 | fi 36 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 37 | cat << EOM 38 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 39 | EOM 40 | exit 1 41 | fi 42 | case $RESOURCE_PATH in 43 | *.storyboard) 44 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 45 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 46 | ;; 47 | *.xib) 48 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 49 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 50 | ;; 51 | *.framework) 52 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 53 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 54 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 55 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | ;; 57 | *.xcdatamodel) 58 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 59 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 60 | ;; 61 | *.xcdatamodeld) 62 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 63 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 64 | ;; 65 | *.xcmappingmodel) 66 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 67 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 68 | ;; 69 | *.xcassets) 70 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 71 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 72 | ;; 73 | *) 74 | echo "$RESOURCE_PATH" 75 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 76 | ;; 77 | esac 78 | } 79 | 80 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 82 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 83 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | fi 86 | rm -f "$RESOURCES_TO_COPY" 87 | 88 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 89 | then 90 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 91 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 92 | while read line; do 93 | if [[ $line != "${PODS_ROOT}*" ]]; then 94 | XCASSET_FILES+=("$line") 95 | fi 96 | done <<<"$OTHER_XCASSETS" 97 | 98 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 99 | fi 100 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_NVMAspectsDemoVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_NVMAspectsDemoVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | PODS_BUILD_DIR = $BUILD_DIR 4 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 5 | PODS_ROOT = ${SRCROOT}/../../Pods 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_NVMAspectsDemo { 2 | umbrella header "Pods-NVMAspectsDemo-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsDemo/Pods-NVMAspectsDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | PODS_BUILD_DIR = $BUILD_DIR 4 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 5 | PODS_ROOT = ${SRCROOT}/../../Pods 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Pods-NVMAspectsTests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Pods-NVMAspectsTests-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Pods-NVMAspectsTests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_NVMAspectsTests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_NVMAspectsTests 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Pods-NVMAspectsTests-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 63 | 64 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 65 | code_sign_cmd="$code_sign_cmd &" 66 | fi 67 | echo "$code_sign_cmd" 68 | eval "$code_sign_cmd" 69 | fi 70 | } 71 | 72 | # Strip invalid architectures 73 | strip_invalid_archs() { 74 | binary="$1" 75 | # Get architectures for current file 76 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 77 | stripped="" 78 | for arch in $archs; do 79 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 80 | # Strip non-valid architectures in-place 81 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 82 | stripped="$stripped $arch" 83 | fi 84 | done 85 | if [[ "$stripped" ]]; then 86 | echo "Stripped $binary of architectures:$stripped" 87 | fi 88 | } 89 | 90 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 91 | wait 92 | fi 93 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Pods-NVMAspectsTests-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | 3) 22 | TARGET_DEVICE_ARGS="--target-device tv" 23 | ;; 24 | *) 25 | TARGET_DEVICE_ARGS="--target-device mac" 26 | ;; 27 | esac 28 | 29 | install_resource() 30 | { 31 | if [[ "$1" = /* ]] ; then 32 | RESOURCE_PATH="$1" 33 | else 34 | RESOURCE_PATH="${PODS_ROOT}/$1" 35 | fi 36 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 37 | cat << EOM 38 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 39 | EOM 40 | exit 1 41 | fi 42 | case $RESOURCE_PATH in 43 | *.storyboard) 44 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 45 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 46 | ;; 47 | *.xib) 48 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 49 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 50 | ;; 51 | *.framework) 52 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 53 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 54 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 55 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | ;; 57 | *.xcdatamodel) 58 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 59 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 60 | ;; 61 | *.xcdatamodeld) 62 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 63 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 64 | ;; 65 | *.xcmappingmodel) 66 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 67 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 68 | ;; 69 | *.xcassets) 70 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 71 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 72 | ;; 73 | *) 74 | echo "$RESOURCE_PATH" 75 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 76 | ;; 77 | esac 78 | } 79 | 80 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 82 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 83 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | fi 86 | rm -f "$RESOURCES_TO_COPY" 87 | 88 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 89 | then 90 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 91 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 92 | while read line; do 93 | if [[ $line != "${PODS_ROOT}*" ]]; then 94 | XCASSET_FILES+=("$line") 95 | fi 96 | done <<<"$OTHER_XCASSETS" 97 | 98 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 99 | fi 100 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Pods-NVMAspectsTests-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_NVMAspectsTestsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_NVMAspectsTestsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Pods-NVMAspectsTests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | PODS_BUILD_DIR = $BUILD_DIR 4 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 5 | PODS_ROOT = ${SRCROOT}/Pods 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Pods-NVMAspectsTests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_NVMAspectsTests { 2 | umbrella header "Pods-NVMAspectsTests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-NVMAspectsTests/Pods-NVMAspectsTests.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | PODS_BUILD_DIR = $BUILD_DIR 4 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 5 | PODS_ROOT = ${SRCROOT}/Pods 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NVMAspects 2 | 3 | ## About 4 | Yet another AOP library for Objective-C, but implement by using [libffi](https://github.com/libffi/libffi/). The main goal for this lib is to avoid heavily use of `forwardInvocation`, powerful, easy to use and also easy to read. 5 | 6 | This lib is inspired by [Aspects](https://github.com/steipete/Aspects), [JSPatch](https://github.com/bang590/JSPatch), [NSBlog](https://www.mikeash.com/pyblog/) and [sunnyxx's blog](http://blog.sunnyxx.com/archives/), thanks all these people. 7 | 8 | ## Example 9 | 10 | A simple example is look like this, provide a block to replace the original implementation, look very similar to [Aspects](https://github.com/steipete/Aspects) but have a bit difference. You can alter the arguments or return value by modify `info.invocation`. If you aren't sure the existing of original implementation, you should call `class_addPlaceholderIfNoImplement` fisrt. 11 | 12 | ```objective-c 13 | [[UIImage nvm_hookInstanceMethod:@selector(imageNamed:) 14 | usingBlock:^void(NVMAspectInfo *info, NSString *name) { 15 | NSLog(@"Load image named %@", name); 16 | [info.invocation invoke]; 17 | }]; 18 | ``` 19 | 20 | ## Notes 21 | 22 | - Actually there are some bugs on this lib, [Bit Field](https://github.com/eleme/NVMAspects/issues/3), [Union](https://github.com/eleme/NVMAspects/issues/2), [Struct contain array](https://github.com/eleme/NVMAspects/issues/1). But `bit field` and `union` are also not well supportted by apple's `NSInvocation`, struct contain small array is a bug in `libffi`. All these features used very rare in Objective-C, so it's not a big problem. 23 | 24 | - NVMAspects doesn't forbidden you to hook any method, but if you make some changes to method like `alloc`, you should follow the memory management policy, especially in `ARC`. 25 | 26 | - Currently if a class has defined a method, hook this method will change it's `imp`, even if that method is implemented by it's super class. But this is not a big problem, you can distinguish the class by test `[self class]` in you block. If the class has not defined a method, you should call `class_addPlaceholderIfNoImplement` first. 27 | 28 | - For problem caused by `forwardInvocation`, you can use this keyword to search issues in `Aspects` or `JSPatch`. 29 | 30 | ## Installation 31 | 32 | add the following line to your Podfile: 33 | 34 | ```ruby 35 | pod "NVMAspects" 36 | ``` 37 | 38 | ## License 39 | 40 | NVMAspects is released under the MIT license. 41 | --------------------------------------------------------------------------------