From b72572e9222b345dcf5fb85e78852b02f6680977 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 4 Jun 2018 13:39:21 -0400 Subject: [PATCH 01/44] It builds --- iOS/Sample/Podfile | 2 +- iOS/Sample/Podfile.lock | 48 ++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/iOS/Sample/Podfile b/iOS/Sample/Podfile index 86f9d3e33..f4e5846aa 100644 --- a/iOS/Sample/Podfile +++ b/iOS/Sample/Podfile @@ -11,7 +11,7 @@ target 'Sample' do pod 'DoubleConversion', :podspec => '../third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../third-party-podspecs/Folly.podspec' - # pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' + pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' pod 'ComponentKit', :podspec => '../third-party-podspecs/ComponentKit.podspec' pod 'Yoga','~>1.8.1', :modular_headers => true pod 'Sonar', :podspec => '../../xplat/Sonar/SonarKitCPP.podspec' diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 39f99c6ed..a420d6b7e 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -15,28 +15,28 @@ PODS: - PeerTalk (0.0.2) - RSocket (0.10.0): - Folly - - Sonar (1.0.0): + - Sonar (0.0.1): - Folly - RSocket - - SonarKit (1.0.0): + - SonarKit (0.0.1): - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - PeerTalk - Sonar - - SonarKit/SKIOSNetworkPlugin (= 1.0.0) - - SonarKit/SonarKitLayoutComponentKitSupport (= 1.0.0) - - SonarKit/SonarKitLayoutPlugin (= 1.0.0) - - SonarKit/SonarKitNetworkPlugin (= 1.0.0) - - SonarKit/SonarKitNetworkPlugin (= 1.0.0) - - SonarKit/SKIOSNetworkPlugin (1.0.0): + - SonarKit/SKIOSNetworkPlugin (= 0.0.1) + - SonarKit/SonarKitLayoutComponentKitSupport (= 0.0.1) + - SonarKit/SonarKitLayoutPlugin (= 0.0.1) + - SonarKit/SonarKitNetworkPlugin (= 0.0.1) + - SonarKit/SonarKitNetworkPlugin (= 0.0.1) + - SonarKit/SKIOSNetworkPlugin (0.0.1): - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - PeerTalk - Sonar - SonarKit/SonarKitNetworkPlugin - - SonarKit/SonarKitLayoutComponentKitSupport (1.0.0): + - SonarKit/SonarKitLayoutComponentKitSupport (0.0.1): - CocoaAsyncSocket (~> 7.6) - ComponentKit - Folly @@ -44,16 +44,16 @@ PODS: - PeerTalk - Sonar - SonarKit/SonarKitLayoutPlugin - - Yoga (= 1.8.1) - - SonarKit/SonarKitLayoutPlugin (1.0.0): + - Yoga (~> 1.8) + - SonarKit/SonarKitLayoutPlugin (0.0.1): - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - PeerTalk - Sonar - - Yoga (= 1.8.1) + - Yoga (~> 1.8) - YogaKit (= 1.8.1) - - SonarKit/SonarKitNetworkPlugin (1.0.0): + - SonarKit/SonarKitNetworkPlugin (0.0.1): - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) @@ -110,7 +110,7 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ComponentKit: - :commit: 663f97614c4b398b029bbc0f6b31330e426c6aa7 + :commit: cdb1615aa730370a65baa0cf290b571bbef74cb4 :git: https://github.com/facebook/ComponentKit.git EasyWSClient: :commit: 9b87dc488048900a8cd684f51ddc98143682dbc3 @@ -119,13 +119,13 @@ CHECKOUT OPTIONS: :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e :git: https://github.com/rsms/peertalk RSocket: - :commit: 804eabc02afdec8756a16517e4513ec9301a3315 + :commit: f3531f877f26d13c81cfa9c73a07919d76a9dddd :git: https://github.com/rsocket/rsocket-cpp.git Sonar: - :commit: 9a6f612923b435846c62a96b9ef33f9128b7e9ae + :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 :git: https://github.com/facebook/Sonar.git SonarKit: - :commit: 9a6f612923b435846c62a96b9ef33f9128b7e9ae + :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 :git: https://github.com/facebook/Sonar.git SPEC CHECKSUMS: @@ -133,15 +133,15 @@ SPEC CHECKSUMS: CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f ComponentKit: 7bd0ad508946aeb68dd52ed8739ced9846ff3671 - DoubleConversion: 310ccd7cdf00175c32883664f84fe026025604df - EasyWSClient: 7ec8effe7d86f6061a47d19a55355769c9edfd2f - Folly: 6a1cc25ddcc61d794309b9eb69e1e7c5343f4a98 - glog: f175af2df1f453be65bd355b287a07c842927a99 + DoubleConversion: 9bd61b1134a393694e95e0950c5bf3f99534817f + EasyWSClient: 1527dd5e0c0eb849ece3ee489ac16a0d9316f752 + Folly: 68567e4f7b526af34b4dd801c3ff76fc13e5294c + glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 PeerTalk: f5389c286e4d477e59b73dfbf25c5c70a2464761 - RSocket: 0b49004a22945bbf00a5760d9fd9e7e57be5478d - Sonar: 059d1cf14e9cfa67a7103c666f875e62e8c285d7 - SonarKit: eb72de3f8ec9fa7a2610b6ef1f6a480b99317fdc + RSocket: 706d7fb6d83c1befe57a55edffe525891b0d0674 + Sonar: bcfc8dd5ef1046f4a9bd5f10d66594b4df66a6c2 + SonarKit: a63bfd64d40c8196b30d7f51ba2794e3c17c725d Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 From 308c101fec2f68a07925411ba5b0daa07a5c7363 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 4 Jun 2018 13:40:13 -0400 Subject: [PATCH 02/44] It builds --- iOS/Podfile | 1 - iOS/SonarKit.podspec | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/iOS/Podfile b/iOS/Podfile index 07c87f716..8d31d5990 100644 --- a/iOS/Podfile +++ b/iOS/Podfile @@ -18,5 +18,4 @@ target 'SonarKit' do pod 'Folly', :podspec => 'third-party-podspecs/Folly.podspec' pod 'Sonar', :podspec => '../xplat/Sonar/SonarKitCPP.podspec' pod 'CocoaAsyncSocket' - pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' end diff --git a/iOS/SonarKit.podspec b/iOS/SonarKit.podspec index d4f9c9858..83319d593 100644 --- a/iOS/SonarKit.podspec +++ b/iOS/SonarKit.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |spec| spec.dependency 'Folly' spec.dependency 'Sonar' spec.dependency 'CocoaAsyncSocket', '~> 7.6' - # spec.dependency 'PeerTalk', '~> 0.0' + spec.dependency 'PeerTalk' spec.dependency 'OpenSSL-Universal', '~> 1.0' spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}', 'iOS/SonarKit/FBCxxUtils/*.{h, mm}', spec.public_header_files = 'iOS/SonarKit/CppBridge/*.{h}', From ff2dd0b828d019c520006d41edfefce9f968051f Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 4 Jun 2018 14:07:55 -0400 Subject: [PATCH 03/44] Removed references to local oss and libevent --- iOS/Sample/Podfile | 2 -- iOS/Sample/Podfile.lock | 14 +++++++------- iOS/Sample/Sample.xcodeproj/project.pbxproj | 2 -- iOS/SonarKit.podspec | 2 +- iOS/third-party-podspecs/Folly.podspec | 4 +++- iOS/third-party-podspecs/RSocket.podspec | 2 +- xplat/Sonar/SonarKitCPP.podspec | 3 ++- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/iOS/Sample/Podfile b/iOS/Sample/Podfile index f4e5846aa..862f096d1 100644 --- a/iOS/Sample/Podfile +++ b/iOS/Sample/Podfile @@ -18,8 +18,6 @@ target 'Sample' do pod 'SonarKit', :podspec => '../SonarKit.podspec' pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => '../SonarKit.podspec' pod 'SonarKit/SKIOSNetworkPlugin', :podspec => '../SonarKit.podspec' - pod 'OpenSSL-Universal', '~> 1.0' - pod 'CocoaLibEvent', '~> 1.0' post_install do |installer| installer.pods_project.targets.each do |target| if ['YogaKit'].include? target.name diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index a420d6b7e..5235d5f34 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -8,8 +8,10 @@ PODS: - EasyWSClient (1.0.0) - Folly (2018.05.28.00): - boost-for-react-native + - CocoaLibEvent (~> 1.0) - DoubleConversion - glog + - OpenSSL-Universal (~> 1.0) - glog (0.3.5) - OpenSSL-Universal (1.0.2.13) - PeerTalk (0.0.2) @@ -64,13 +66,11 @@ PODS: - Yoga (~> 1.8.1) DEPENDENCIES: - - CocoaLibEvent (~> 1.0) - ComponentKit (from `../third-party-podspecs/ComponentKit.podspec`) - DoubleConversion (from `../third-party-podspecs/DoubleConversion.podspec`) - EasyWSClient (from `../third-party-podspecs/EasyWSClient.podspec`) - Folly (from `../third-party-podspecs/Folly.podspec`) - glog (from `../third-party-podspecs/glog.podspec`) - - OpenSSL-Universal (~> 1.0) - PeerTalk (from `https://github.com/rsms/peertalk`) - RSocket (from `../third-party-podspecs/RSocket.podspec`) - Sonar (from `../../xplat/Sonar/SonarKitCPP.podspec`) @@ -135,16 +135,16 @@ SPEC CHECKSUMS: ComponentKit: 7bd0ad508946aeb68dd52ed8739ced9846ff3671 DoubleConversion: 9bd61b1134a393694e95e0950c5bf3f99534817f EasyWSClient: 1527dd5e0c0eb849ece3ee489ac16a0d9316f752 - Folly: 68567e4f7b526af34b4dd801c3ff76fc13e5294c + Folly: ce1c216bcb099ca6cda58fefbba02bf2e9fe0381 glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 PeerTalk: f5389c286e4d477e59b73dfbf25c5c70a2464761 - RSocket: 706d7fb6d83c1befe57a55edffe525891b0d0674 - Sonar: bcfc8dd5ef1046f4a9bd5f10d66594b4df66a6c2 - SonarKit: a63bfd64d40c8196b30d7f51ba2794e3c17c725d + RSocket: 38b24504db9efbfb018a3b2b23a2d9500140a2a7 + Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 + SonarKit: 85eb1b3ef1875279d44f73ec276e6bbef1b4fc80 Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 -PODFILE CHECKSUM: 1904a24f0191377e3743dc726e5d7e52455b7ff4 +PODFILE CHECKSUM: 036ec88989af4c8db5dcfdcc2e58fa70ba4d0f22 COCOAPODS: 1.5.2 diff --git a/iOS/Sample/Sample.xcodeproj/project.pbxproj b/iOS/Sample/Sample.xcodeproj/project.pbxproj index 20abb82a8..bbe9e8cf1 100644 --- a/iOS/Sample/Sample.xcodeproj/project.pbxproj +++ b/iOS/Sample/Sample.xcodeproj/project.pbxproj @@ -342,7 +342,6 @@ "\"${PODS_ROOT}/Headers/Public/boost-for-react-native\"", "\"${PODS_ROOT}/Headers/Public/glog\"/**", "\"${PODS_ROOT}/SonarKit\"/**", - "/usr/local/include\\ /usr/local/Cellar/openssl/1.0.2o_1/include", ); INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.3; @@ -410,7 +409,6 @@ "\"${PODS_ROOT}/Headers/Public/boost-for-react-native\"", "\"${PODS_ROOT}/Headers/Public/glog\"/**", "\"${PODS_ROOT}/SonarKit\"/**", - "/usr/local/include\\ /usr/local/Cellar/openssl/1.0.2o_1/include", ); INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.3; diff --git a/iOS/SonarKit.podspec b/iOS/SonarKit.podspec index 83319d593..2e842112e 100644 --- a/iOS/SonarKit.podspec +++ b/iOS/SonarKit.podspec @@ -31,7 +31,7 @@ Pod::Spec.new do |spec| spec.compiler_flags = '-DFB_SONARKIT_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"/usr/local/include\" \"/usr/local/Cellar/openssl/1.0.2o_1/include\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/ComponentKit\"/**" } + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/ComponentKit\"/**" } spec.platforms = { :ios => "8.0" } spec.subspec "SonarKitLayoutPlugin" do |ss| diff --git a/iOS/third-party-podspecs/Folly.podspec b/iOS/third-party-podspecs/Folly.podspec index caa8578ea..1673d6f1d 100755 --- a/iOS/third-party-podspecs/Folly.podspec +++ b/iOS/third-party-podspecs/Folly.podspec @@ -11,6 +11,8 @@ Pod::Spec.new do |spec| spec.dependency 'boost-for-react-native' spec.dependency 'DoubleConversion' spec.dependency 'glog' + spec.dependency 'OpenSSL-Universal', '~> 1.0' + spec.dependency 'CocoaLibEvent', '~> 1.0' spec.compiler_flags = '-DFOLLY_HAVE_PTHREAD=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti -fexceptions -std=c++14 @@ -109,7 +111,7 @@ Pod::Spec.new do |spec| spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++11", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"/usr/local/include\" \"/usr/local/Cellar/openssl/1.0.2o_1/include\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\"" } + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\"" } # Pinning to the same version as React.podspec. spec.platforms = { :ios => "8.0"} diff --git a/iOS/third-party-podspecs/RSocket.podspec b/iOS/third-party-podspecs/RSocket.podspec index 8cb8502fa..ee4265d2f 100644 --- a/iOS/third-party-podspecs/RSocket.podspec +++ b/iOS/third-party-podspecs/RSocket.podspec @@ -47,7 +47,7 @@ Pod::Spec.new do |spec| spec.header_dir = './*' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"/usr/local/include\" \"/usr/local/Cellar/openssl/1.0.2o_1/include\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/DoubleConversion\"/**" } + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/DoubleConversion\"/**" } spec.platforms = { :ios => "8.0" } end diff --git a/xplat/Sonar/SonarKitCPP.podspec b/xplat/Sonar/SonarKitCPP.podspec index 9c9fc67d3..ad45fba03 100644 --- a/xplat/Sonar/SonarKitCPP.podspec +++ b/xplat/Sonar/SonarKitCPP.podspec @@ -20,5 +20,6 @@ Pod::Spec.new do |spec| spec.platforms = { :ios => "8.0" } spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"/usr/local/include\" \"/usr/local/Cellar/openssl/1.0.2o_1/include\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/RSocket\" \"$(PODS_ROOT)/DoubleConversion\"" } + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/RSocket\" \"$(PODS_ROOT)/DoubleConversion\"" } end +# \"/usr/local/include\" \"/usr/local/Cellar/openssl/1.0.2o_1/include\" From f34c79116772943b341107854a4f5965f3e97d93 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 4 Jun 2018 14:23:30 -0400 Subject: [PATCH 04/44] Remove reference to easywsclient --- iOS/Sample/Podfile | 1 - iOS/Sample/Podfile.lock | 150 -------------------- iOS/Sample/Sample.xcodeproj/project.pbxproj | 4 - 3 files changed, 155 deletions(-) delete mode 100644 iOS/Sample/Podfile.lock diff --git a/iOS/Sample/Podfile b/iOS/Sample/Podfile index 862f096d1..09d4fcd55 100644 --- a/iOS/Sample/Podfile +++ b/iOS/Sample/Podfile @@ -7,7 +7,6 @@ swift_version = "4.1" target 'Sample' do pod 'RSocket', :podspec => '../third-party-podspecs/RSocket.podspec' - pod 'EasyWSClient', :podspec => '../third-party-podspecs/EasyWSClient.podspec' pod 'DoubleConversion', :podspec => '../third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../third-party-podspecs/Folly.podspec' diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock deleted file mode 100644 index 5235d5f34..000000000 --- a/iOS/Sample/Podfile.lock +++ /dev/null @@ -1,150 +0,0 @@ -PODS: - - boost-for-react-native (1.63.0) - - CocoaAsyncSocket (7.6.3) - - CocoaLibEvent (1.0.0) - - ComponentKit (0.21): - - Yoga - - DoubleConversion (3.0.0) - - EasyWSClient (1.0.0) - - Folly (2018.05.28.00): - - boost-for-react-native - - CocoaLibEvent (~> 1.0) - - DoubleConversion - - glog - - OpenSSL-Universal (~> 1.0) - - glog (0.3.5) - - OpenSSL-Universal (1.0.2.13) - - PeerTalk (0.0.2) - - RSocket (0.10.0): - - Folly - - Sonar (0.0.1): - - Folly - - RSocket - - SonarKit (0.0.1): - - CocoaAsyncSocket (~> 7.6) - - Folly - - OpenSSL-Universal (~> 1.0) - - PeerTalk - - Sonar - - SonarKit/SKIOSNetworkPlugin (= 0.0.1) - - SonarKit/SonarKitLayoutComponentKitSupport (= 0.0.1) - - SonarKit/SonarKitLayoutPlugin (= 0.0.1) - - SonarKit/SonarKitNetworkPlugin (= 0.0.1) - - SonarKit/SonarKitNetworkPlugin (= 0.0.1) - - SonarKit/SKIOSNetworkPlugin (0.0.1): - - CocoaAsyncSocket (~> 7.6) - - Folly - - OpenSSL-Universal (~> 1.0) - - PeerTalk - - Sonar - - SonarKit/SonarKitNetworkPlugin - - SonarKit/SonarKitLayoutComponentKitSupport (0.0.1): - - CocoaAsyncSocket (~> 7.6) - - ComponentKit - - Folly - - OpenSSL-Universal (~> 1.0) - - PeerTalk - - Sonar - - SonarKit/SonarKitLayoutPlugin - - Yoga (~> 1.8) - - SonarKit/SonarKitLayoutPlugin (0.0.1): - - CocoaAsyncSocket (~> 7.6) - - Folly - - OpenSSL-Universal (~> 1.0) - - PeerTalk - - Sonar - - Yoga (~> 1.8) - - YogaKit (= 1.8.1) - - SonarKit/SonarKitNetworkPlugin (0.0.1): - - CocoaAsyncSocket (~> 7.6) - - Folly - - OpenSSL-Universal (~> 1.0) - - PeerTalk - - Sonar - - Yoga (1.8.1) - - YogaKit (1.8.1): - - Yoga (~> 1.8.1) - -DEPENDENCIES: - - ComponentKit (from `../third-party-podspecs/ComponentKit.podspec`) - - DoubleConversion (from `../third-party-podspecs/DoubleConversion.podspec`) - - EasyWSClient (from `../third-party-podspecs/EasyWSClient.podspec`) - - Folly (from `../third-party-podspecs/Folly.podspec`) - - glog (from `../third-party-podspecs/glog.podspec`) - - PeerTalk (from `https://github.com/rsms/peertalk`) - - RSocket (from `../third-party-podspecs/RSocket.podspec`) - - Sonar (from `../../xplat/Sonar/SonarKitCPP.podspec`) - - SonarKit (from `../SonarKit.podspec`) - - SonarKit/SKIOSNetworkPlugin (from `../SonarKit.podspec`) - - SonarKit/SonarKitLayoutComponentKitSupport (from `../SonarKit.podspec`) - - Yoga (~> 1.8.1) - -SPEC REPOS: - https://github.com/cocoapods/specs.git: - - boost-for-react-native - - CocoaAsyncSocket - - CocoaLibEvent - - OpenSSL-Universal - - Yoga - - YogaKit - -EXTERNAL SOURCES: - ComponentKit: - :podspec: "../third-party-podspecs/ComponentKit.podspec" - DoubleConversion: - :podspec: "../third-party-podspecs/DoubleConversion.podspec" - EasyWSClient: - :podspec: "../third-party-podspecs/EasyWSClient.podspec" - Folly: - :podspec: "../third-party-podspecs/Folly.podspec" - glog: - :podspec: "../third-party-podspecs/glog.podspec" - PeerTalk: - :git: https://github.com/rsms/peertalk - RSocket: - :podspec: "../third-party-podspecs/RSocket.podspec" - Sonar: - :podspec: "../../xplat/Sonar/SonarKitCPP.podspec" - SonarKit: - :podspec: "../SonarKit.podspec" - -CHECKOUT OPTIONS: - ComponentKit: - :commit: cdb1615aa730370a65baa0cf290b571bbef74cb4 - :git: https://github.com/facebook/ComponentKit.git - EasyWSClient: - :commit: 9b87dc488048900a8cd684f51ddc98143682dbc3 - :git: https://github.com/dhbaird/easywsclient.git - PeerTalk: - :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e - :git: https://github.com/rsms/peertalk - RSocket: - :commit: f3531f877f26d13c81cfa9c73a07919d76a9dddd - :git: https://github.com/rsocket/rsocket-cpp.git - Sonar: - :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 - :git: https://github.com/facebook/Sonar.git - SonarKit: - :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 - :git: https://github.com/facebook/Sonar.git - -SPEC CHECKSUMS: - boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c - CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 - CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f - ComponentKit: 7bd0ad508946aeb68dd52ed8739ced9846ff3671 - DoubleConversion: 9bd61b1134a393694e95e0950c5bf3f99534817f - EasyWSClient: 1527dd5e0c0eb849ece3ee489ac16a0d9316f752 - Folly: ce1c216bcb099ca6cda58fefbba02bf2e9fe0381 - glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 - OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 - PeerTalk: f5389c286e4d477e59b73dfbf25c5c70a2464761 - RSocket: 38b24504db9efbfb018a3b2b23a2d9500140a2a7 - Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 - SonarKit: 85eb1b3ef1875279d44f73ec276e6bbef1b4fc80 - Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 - YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 - -PODFILE CHECKSUM: 036ec88989af4c8db5dcfdcc2e58fa70ba4d0f22 - -COCOAPODS: 1.5.2 diff --git a/iOS/Sample/Sample.xcodeproj/project.pbxproj b/iOS/Sample/Sample.xcodeproj/project.pbxproj index bbe9e8cf1..d1b532e26 100644 --- a/iOS/Sample/Sample.xcodeproj/project.pbxproj +++ b/iOS/Sample/Sample.xcodeproj/project.pbxproj @@ -333,7 +333,6 @@ "\"${PODS_ROOT}/Headers/Public/CocoaAsyncSocket\"", "\"${PODS_ROOT}/Headers/Public/ComponentKit\"", "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"", - "\"${PODS_ROOT}/Headers/Public/EasyWSClient\"", "\"${PODS_ROOT}/Headers/Public/Folly\"", "\"${PODS_ROOT}/Headers/Public/PeerTalk\"", "\"${PODS_ROOT}/Headers/Public/Sonar\"/**", @@ -361,7 +360,6 @@ "-l\"CocoaAsyncSocket\"", "-l\"ComponentKit\"", "-l\"DoubleConversion\"", - "-l\"EasyWSClient\"", "-l\"Folly\"", "-l\"PeerTalk\"", "-l\"Sonar\"", @@ -400,7 +398,6 @@ "\"${PODS_ROOT}/Headers/Public/CocoaAsyncSocket\"", "\"${PODS_ROOT}/Headers/Public/ComponentKit\"", "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"", - "\"${PODS_ROOT}/Headers/Public/EasyWSClient\"", "\"${PODS_ROOT}/Headers/Public/Folly\"", "\"${PODS_ROOT}/Headers/Public/PeerTalk\"", "\"${PODS_ROOT}/Headers/Public/Sonar\"/**", @@ -428,7 +425,6 @@ "-l\"CocoaAsyncSocket\"", "-l\"ComponentKit\"", "-l\"DoubleConversion\"", - "-l\"EasyWSClient\"", "-l\"Folly\"", "-l\"PeerTalk\"", "-l\"Sonar\"", From 4cafc351b5c3b306bb3c8ef99606b51a76f939b6 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 4 Jun 2018 14:32:26 -0400 Subject: [PATCH 05/44] Removed EasyWSClient podspec file --- iOS/Sample/Podfile.lock | 142 ++++++++++++++++++ iOS/third-party-podspecs/EasyWSClient.podspec | 17 --- 2 files changed, 142 insertions(+), 17 deletions(-) create mode 100644 iOS/Sample/Podfile.lock delete mode 100644 iOS/third-party-podspecs/EasyWSClient.podspec diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock new file mode 100644 index 000000000..47fe391cc --- /dev/null +++ b/iOS/Sample/Podfile.lock @@ -0,0 +1,142 @@ +PODS: + - boost-for-react-native (1.63.0) + - CocoaAsyncSocket (7.6.3) + - CocoaLibEvent (1.0.0) + - ComponentKit (0.21): + - Yoga + - DoubleConversion (3.0.0) + - Folly (2018.05.28.00): + - boost-for-react-native + - CocoaLibEvent (~> 1.0) + - DoubleConversion + - glog + - OpenSSL-Universal (~> 1.0) + - glog (0.3.5) + - OpenSSL-Universal (1.0.2.13) + - PeerTalk (0.0.2) + - RSocket (0.10.0): + - Folly + - Sonar (0.0.1): + - Folly + - RSocket + - SonarKit (0.0.1): + - CocoaAsyncSocket (~> 7.6) + - Folly + - OpenSSL-Universal (~> 1.0) + - PeerTalk + - Sonar + - SonarKit/SKIOSNetworkPlugin (= 0.0.1) + - SonarKit/SonarKitLayoutComponentKitSupport (= 0.0.1) + - SonarKit/SonarKitLayoutPlugin (= 0.0.1) + - SonarKit/SonarKitNetworkPlugin (= 0.0.1) + - SonarKit/SonarKitNetworkPlugin (= 0.0.1) + - SonarKit/SKIOSNetworkPlugin (0.0.1): + - CocoaAsyncSocket (~> 7.6) + - Folly + - OpenSSL-Universal (~> 1.0) + - PeerTalk + - Sonar + - SonarKit/SonarKitNetworkPlugin + - SonarKit/SonarKitLayoutComponentKitSupport (0.0.1): + - CocoaAsyncSocket (~> 7.6) + - ComponentKit + - Folly + - OpenSSL-Universal (~> 1.0) + - PeerTalk + - Sonar + - SonarKit/SonarKitLayoutPlugin + - Yoga (~> 1.8) + - SonarKit/SonarKitLayoutPlugin (0.0.1): + - CocoaAsyncSocket (~> 7.6) + - Folly + - OpenSSL-Universal (~> 1.0) + - PeerTalk + - Sonar + - Yoga (~> 1.8) + - YogaKit (= 1.8.1) + - SonarKit/SonarKitNetworkPlugin (0.0.1): + - CocoaAsyncSocket (~> 7.6) + - Folly + - OpenSSL-Universal (~> 1.0) + - PeerTalk + - Sonar + - Yoga (1.8.1) + - YogaKit (1.8.1): + - Yoga (~> 1.8.1) + +DEPENDENCIES: + - ComponentKit (from `../third-party-podspecs/ComponentKit.podspec`) + - DoubleConversion (from `../third-party-podspecs/DoubleConversion.podspec`) + - Folly (from `../third-party-podspecs/Folly.podspec`) + - glog (from `../third-party-podspecs/glog.podspec`) + - PeerTalk (from `https://github.com/rsms/peertalk`) + - RSocket (from `../third-party-podspecs/RSocket.podspec`) + - Sonar (from `../../xplat/Sonar/SonarKitCPP.podspec`) + - SonarKit (from `../SonarKit.podspec`) + - SonarKit/SKIOSNetworkPlugin (from `../SonarKit.podspec`) + - SonarKit/SonarKitLayoutComponentKitSupport (from `../SonarKit.podspec`) + - Yoga (~> 1.8.1) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - boost-for-react-native + - CocoaAsyncSocket + - CocoaLibEvent + - OpenSSL-Universal + - Yoga + - YogaKit + +EXTERNAL SOURCES: + ComponentKit: + :podspec: "../third-party-podspecs/ComponentKit.podspec" + DoubleConversion: + :podspec: "../third-party-podspecs/DoubleConversion.podspec" + Folly: + :podspec: "../third-party-podspecs/Folly.podspec" + glog: + :podspec: "../third-party-podspecs/glog.podspec" + PeerTalk: + :git: https://github.com/rsms/peertalk + RSocket: + :podspec: "../third-party-podspecs/RSocket.podspec" + Sonar: + :podspec: "../../xplat/Sonar/SonarKitCPP.podspec" + SonarKit: + :podspec: "../SonarKit.podspec" + +CHECKOUT OPTIONS: + ComponentKit: + :commit: cdb1615aa730370a65baa0cf290b571bbef74cb4 + :git: https://github.com/facebook/ComponentKit.git + PeerTalk: + :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e + :git: https://github.com/rsms/peertalk + RSocket: + :commit: f3531f877f26d13c81cfa9c73a07919d76a9dddd + :git: https://github.com/rsocket/rsocket-cpp.git + Sonar: + :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 + :git: https://github.com/facebook/Sonar.git + SonarKit: + :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 + :git: https://github.com/facebook/Sonar.git + +SPEC CHECKSUMS: + boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c + CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 + CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f + ComponentKit: 7bd0ad508946aeb68dd52ed8739ced9846ff3671 + DoubleConversion: 9bd61b1134a393694e95e0950c5bf3f99534817f + Folly: ce1c216bcb099ca6cda58fefbba02bf2e9fe0381 + glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 + OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 + PeerTalk: f5389c286e4d477e59b73dfbf25c5c70a2464761 + RSocket: 38b24504db9efbfb018a3b2b23a2d9500140a2a7 + Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 + SonarKit: 85eb1b3ef1875279d44f73ec276e6bbef1b4fc80 + Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 + YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 + +PODFILE CHECKSUM: dfac9036111405250e307ccbd8be7175dec53ede + +COCOAPODS: 1.5.2 diff --git a/iOS/third-party-podspecs/EasyWSClient.podspec b/iOS/third-party-podspecs/EasyWSClient.podspec deleted file mode 100644 index 90cfe2fc8..000000000 --- a/iOS/third-party-podspecs/EasyWSClient.podspec +++ /dev/null @@ -1,17 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'EasyWSClient' - spec.version = '1.0.0' - spec.license = { :type => 'MIT' } - spec.homepage = 'https://github.com/google/double-conversion' - spec.summary = 'Easywsclient is an easy and powerful WebSocket client to get your C++ code connected to a web stack right away.' - spec.authors = 'David Baird' - # spec.prepare_command = 'mv src double-conversion' - spec.source = { :git => 'https://github.com/dhbaird/easywsclient.git', :branch => 'master'} - spec.module_name = 'EasyWSClient' - spec.source_files = '*.{hpp,cpp}' - spec.libraries = "stdc++" - spec.compiler_flags = '-std=c++1y' - # Pinning to the same version as React.podspec. - spec.platforms = { :ios => "8.0"} - -end From a4efaca1a67b7d0e58beb2c87d3306d0a77f558d Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 4 Jun 2018 23:48:37 -0400 Subject: [PATCH 06/44] added peertalksonar and specs folder --- iOS/SonarKit.podspec => SonarKit.podspec | 4 +- Specs/ComponentKit/0.21/ComponentKit.podspec | 21 +++++ .../PeerTalkSonar/0.0.2/PeerTalkSonar.podspec | 16 ++++ Specs/RSocket/0.10.0/RSocket.podspec | 53 +++++++++++++ iOS/Podfile | 6 +- iOS/Podfile.lock | 76 +++++++++++++++++++ iOS/Sample/Podfile | 10 +-- iOS/Sample/Podfile.lock | 42 +++++----- iOS/Sample/Sample.xcodeproj/project.pbxproj | 4 +- iOS/SonarKit.xcodeproj/project.pbxproj | 18 ++++- .../PeerTalkSonar.podspec | 16 ++++ .../{SonarKitCPP.podspec => Sonar.podspec} | 0 12 files changed, 231 insertions(+), 35 deletions(-) rename iOS/SonarKit.podspec => SonarKit.podspec (97%) create mode 100644 Specs/ComponentKit/0.21/ComponentKit.podspec create mode 100644 Specs/PeerTalkSonar/0.0.2/PeerTalkSonar.podspec create mode 100644 Specs/RSocket/0.10.0/RSocket.podspec create mode 100644 iOS/Podfile.lock create mode 100644 iOS/third-party-podspecs/PeerTalkSonar.podspec rename xplat/Sonar/{SonarKitCPP.podspec => Sonar.podspec} (100%) diff --git a/iOS/SonarKit.podspec b/SonarKit.podspec similarity index 97% rename from iOS/SonarKit.podspec rename to SonarKit.podspec index 2e842112e..9f67932c5 100644 --- a/iOS/SonarKit.podspec +++ b/SonarKit.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |spec| spec.dependency 'Folly' spec.dependency 'Sonar' spec.dependency 'CocoaAsyncSocket', '~> 7.6' - spec.dependency 'PeerTalk' + spec.dependency 'PeerTalkSonar' spec.dependency 'OpenSSL-Universal', '~> 1.0' spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}', 'iOS/SonarKit/FBCxxUtils/*.{h, mm}', spec.public_header_files = 'iOS/SonarKit/CppBridge/*.{h}', @@ -31,7 +31,7 @@ Pod::Spec.new do |spec| spec.compiler_flags = '-DFB_SONARKIT_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/ComponentKit\"/**" } + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/PeerTalkSonar\" \"$(PODS_ROOT)/ComponentKit\"/**" } spec.platforms = { :ios => "8.0" } spec.subspec "SonarKitLayoutPlugin" do |ss| diff --git a/Specs/ComponentKit/0.21/ComponentKit.podspec b/Specs/ComponentKit/0.21/ComponentKit.podspec new file mode 100644 index 000000000..d6e54476c --- /dev/null +++ b/Specs/ComponentKit/0.21/ComponentKit.podspec @@ -0,0 +1,21 @@ +Pod::Spec.new do |s| + s.name = 'ComponentKit' + s.version = '0.21' + s.license = 'BSD' + s.summary = 'A React-inspired view framework for iOS' + s.homepage = 'https://componentkit.org' + s.social_media_url = 'https://twitter.com/componentkit' + s.authors = 'adamjernst@fb.com' + s.source = { :git => 'https://github.com/facebook/ComponentKit.git'} + s.ios.deployment_target = '8.1' + s.requires_arc = true + + s.source_files = 'ComponentKit/**/*', 'ComponentTextKit/**/*' + s.frameworks = 'UIKit', 'CoreText' + s.library = 'c++' + s.xcconfig = { + 'CLANG_CXX_LANGUAGE_STANDARD' => 'gnu++14', + 'CLANG_CXX_LIBRARY' => 'libc++', + } + s.dependency 'Yoga' +end diff --git a/Specs/PeerTalkSonar/0.0.2/PeerTalkSonar.podspec b/Specs/PeerTalkSonar/0.0.2/PeerTalkSonar.podspec new file mode 100644 index 000000000..d0a96c588 --- /dev/null +++ b/Specs/PeerTalkSonar/0.0.2/PeerTalkSonar.podspec @@ -0,0 +1,16 @@ +Pod::Spec.new do |spec| + spec.name = 'PeerTalkSonar' + spec.version = '0.0.2' + spec.license = { :type => 'MIT' } + spec.homepage = 'http://rsms.me/peertalk/' + spec.authors = { 'Rasmus Andersson' => 'rasmus@notion.se' } + spec.summary = 'iOS and OS X Cocoa library for communicating over USB and TCP.' + + spec.source = { :git => "https://github.com/rsms/PeerTalk.git", :branch => 'master' } + spec.source_files = 'peertalk/*.{h,m}' + spec.requires_arc = true + spec.ios.deployment_target = '8.4' + spec.osx.deployment_target = '10.10' + + spec.description = " PeerTalk is a iOS and OS X Cocoa library for communicating over USB and TCP.\n\n Highlights:\n\n * Provides you with USB device attach/detach events and attached device's info\n * Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport\n * Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.\n * Tested and designed for libdispatch (aka Grand Central Dispatch).\n" +end diff --git a/Specs/RSocket/0.10.0/RSocket.podspec b/Specs/RSocket/0.10.0/RSocket.podspec new file mode 100644 index 000000000..ee4265d2f --- /dev/null +++ b/Specs/RSocket/0.10.0/RSocket.podspec @@ -0,0 +1,53 @@ +Pod::Spec.new do |spec| + spec.name = 'RSocket' + spec.version = '0.10.0' + spec.license = { :type => 'MIT' } + spec.homepage = 'https://github.com/rsocket/rsocket-cpp' + spec.summary = 'C++ implementation of RSocket' + spec.authors = 'Facebook' + spec.source = { :git => 'https://github.com/rsocket/rsocket-cpp.git', :branch => "master"} + spec.module_name = 'RSocket' + spec.source_files = 'rsocket/benchmarks/*', + 'rsocket/framing/*', + 'rsocket/internal/*', + 'rsocket/statemachine/*', + 'rsocket/transports/*', + 'rsocket/transports/**/*', + 'yarpl/observable/*', + 'yarpl/flowable/*', + 'rsocket/*' + + spec.libraries = "stdc++" + spec.compiler_flags = '-std=c++1y' + spec.dependency 'Folly' + spec.compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti + -fexceptions + -std=c++14 + -Wno-error + -Wno-unused-local-typedefs + -Wno-unused-variable + -Wno-sign-compare + -Wno-comment + -Wno-return-type + -Wno-global-constructors' + spec.preserve_paths = 'rsocket/benchmarks/*.h', + 'rsocket/framing/*.h', + 'rsocket/internal/*.h', + 'rsocket/statemachine/*.h', + 'rsocket/transports/*.h', + 'rsocket/*.h', + 'yarpl/flowable/*.h', + 'yarpl/observable/*.h', + 'yarpl/perf/*.h', + 'yarpl/single/*.h', + 'yarpl/utils/*.h', + 'yarpl/*.h', + '**/*.h' + spec.header_mappings_dir = './*' + spec.header_dir = './*' + spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/DoubleConversion\"/**" } + spec.platforms = { :ios => "8.0" } + +end diff --git a/iOS/Podfile b/iOS/Podfile index 8d31d5990..97231a927 100644 --- a/iOS/Podfile +++ b/iOS/Podfile @@ -10,12 +10,12 @@ target 'SonarKit' do # Pods for SonarKit # Third party deps podspec link - #pod 'EasyWSClient', :podspec => 'third-party-podspecs/EasyWSClient.podspec' + # pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' + pod 'PeerTalkSonar', :podspec => 'third-party-podspecs/PeerTalkSonar.podspec' pod 'RSocket', :podspec => 'third-party-podspecs/RSocket.podspec' - pod 'LibEvent', :podspec => 'third-party-podspecs/LibEvent.podspec' pod 'DoubleConversion', :podspec => 'third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => 'third-party-podspecs/glog.podspec' pod 'Folly', :podspec => 'third-party-podspecs/Folly.podspec' - pod 'Sonar', :podspec => '../xplat/Sonar/SonarKitCPP.podspec' + pod 'Sonar', :podspec => '../xplat/Sonar/Sonar.podspec' pod 'CocoaAsyncSocket' end diff --git a/iOS/Podfile.lock b/iOS/Podfile.lock new file mode 100644 index 000000000..bbc771de5 --- /dev/null +++ b/iOS/Podfile.lock @@ -0,0 +1,76 @@ +PODS: + - boost-for-react-native (1.63.0) + - CocoaAsyncSocket (7.6.3) + - CocoaLibEvent (1.0.0) + - DoubleConversion (3.0.0) + - Folly (2018.05.28.00): + - boost-for-react-native + - CocoaLibEvent (~> 1.0) + - DoubleConversion + - glog + - OpenSSL-Universal (~> 1.0) + - glog (0.3.5) + - OpenSSL-Universal (1.0.2.13) + - PeerTalk (0.0.2) + - RSocket (0.10.0): + - Folly + - Sonar (0.0.1): + - Folly + - RSocket + +DEPENDENCIES: + - CocoaAsyncSocket + - DoubleConversion (from `third-party-podspecs/DoubleConversion.podspec`) + - Folly (from `third-party-podspecs/Folly.podspec`) + - glog (from `third-party-podspecs/glog.podspec`) + - PeerTalk (from `https://github.com/rsms/peertalk`) + - RSocket (from `third-party-podspecs/RSocket.podspec`) + - Sonar (from `../xplat/Sonar/SonarKitCPP.podspec`) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - boost-for-react-native + - CocoaAsyncSocket + - CocoaLibEvent + - OpenSSL-Universal + +EXTERNAL SOURCES: + DoubleConversion: + :podspec: third-party-podspecs/DoubleConversion.podspec + Folly: + :podspec: third-party-podspecs/Folly.podspec + glog: + :podspec: third-party-podspecs/glog.podspec + PeerTalk: + :git: https://github.com/rsms/peertalk + RSocket: + :podspec: third-party-podspecs/RSocket.podspec + Sonar: + :podspec: "../xplat/Sonar/SonarKitCPP.podspec" + +CHECKOUT OPTIONS: + PeerTalk: + :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e + :git: https://github.com/rsms/peertalk + RSocket: + :commit: f3531f877f26d13c81cfa9c73a07919d76a9dddd + :git: https://github.com/rsocket/rsocket-cpp.git + Sonar: + :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 + :git: https://github.com/facebook/Sonar.git + +SPEC CHECKSUMS: + boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c + CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 + CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f + DoubleConversion: 9bd61b1134a393694e95e0950c5bf3f99534817f + Folly: ce1c216bcb099ca6cda58fefbba02bf2e9fe0381 + glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 + OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 + PeerTalk: f5389c286e4d477e59b73dfbf25c5c70a2464761 + RSocket: 38b24504db9efbfb018a3b2b23a2d9500140a2a7 + Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 + +PODFILE CHECKSUM: ea1c982eb3a27e26c91d456fff45930d31f3e115 + +COCOAPODS: 1.5.2 diff --git a/iOS/Sample/Podfile b/iOS/Sample/Podfile index 09d4fcd55..ca10ae207 100644 --- a/iOS/Sample/Podfile +++ b/iOS/Sample/Podfile @@ -10,13 +10,13 @@ target 'Sample' do pod 'DoubleConversion', :podspec => '../third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../third-party-podspecs/Folly.podspec' - pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' + pod 'PeerTalkSonar', :podspec => '../third-party-podspecs/PeerTalkSonar.podspec' pod 'ComponentKit', :podspec => '../third-party-podspecs/ComponentKit.podspec' pod 'Yoga','~>1.8.1', :modular_headers => true - pod 'Sonar', :podspec => '../../xplat/Sonar/SonarKitCPP.podspec' - pod 'SonarKit', :podspec => '../SonarKit.podspec' - pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => '../SonarKit.podspec' - pod 'SonarKit/SKIOSNetworkPlugin', :podspec => '../SonarKit.podspec' + pod 'Sonar', :podspec => '../../xplat/Sonar/Sonar.podspec' + pod 'SonarKit', :podspec => '../../SonarKit.podspec' + pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => '../../SonarKit.podspec' + pod 'SonarKit/SKIOSNetworkPlugin', :podspec => '../../SonarKit.podspec' post_install do |installer| installer.pods_project.targets.each do |target| if ['YogaKit'].include? target.name diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 47fe391cc..1d4cf4cb1 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -13,7 +13,7 @@ PODS: - OpenSSL-Universal (~> 1.0) - glog (0.3.5) - OpenSSL-Universal (1.0.2.13) - - PeerTalk (0.0.2) + - PeerTalkSonar (0.0.2) - RSocket (0.10.0): - Folly - Sonar (0.0.1): @@ -23,7 +23,7 @@ PODS: - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalk + - PeerTalkSonar - Sonar - SonarKit/SKIOSNetworkPlugin (= 0.0.1) - SonarKit/SonarKitLayoutComponentKitSupport (= 0.0.1) @@ -34,7 +34,7 @@ PODS: - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalk + - PeerTalkSonar - Sonar - SonarKit/SonarKitNetworkPlugin - SonarKit/SonarKitLayoutComponentKitSupport (0.0.1): @@ -42,7 +42,7 @@ PODS: - ComponentKit - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalk + - PeerTalkSonar - Sonar - SonarKit/SonarKitLayoutPlugin - Yoga (~> 1.8) @@ -50,7 +50,7 @@ PODS: - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalk + - PeerTalkSonar - Sonar - Yoga (~> 1.8) - YogaKit (= 1.8.1) @@ -58,7 +58,7 @@ PODS: - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalk + - PeerTalkSonar - Sonar - Yoga (1.8.1) - YogaKit (1.8.1): @@ -69,12 +69,12 @@ DEPENDENCIES: - DoubleConversion (from `../third-party-podspecs/DoubleConversion.podspec`) - Folly (from `../third-party-podspecs/Folly.podspec`) - glog (from `../third-party-podspecs/glog.podspec`) - - PeerTalk (from `https://github.com/rsms/peertalk`) + - PeerTalkSonar (from `../third-party-podspecs/PeerTalkSonar.podspec`) - RSocket (from `../third-party-podspecs/RSocket.podspec`) - - Sonar (from `../../xplat/Sonar/SonarKitCPP.podspec`) - - SonarKit (from `../SonarKit.podspec`) - - SonarKit/SKIOSNetworkPlugin (from `../SonarKit.podspec`) - - SonarKit/SonarKitLayoutComponentKitSupport (from `../SonarKit.podspec`) + - Sonar (from `../../xplat/Sonar/Sonar.podspec`) + - SonarKit (from `../../SonarKit.podspec`) + - SonarKit/SKIOSNetworkPlugin (from `../../SonarKit.podspec`) + - SonarKit/SonarKitLayoutComponentKitSupport (from `../../SonarKit.podspec`) - Yoga (~> 1.8.1) SPEC REPOS: @@ -95,22 +95,22 @@ EXTERNAL SOURCES: :podspec: "../third-party-podspecs/Folly.podspec" glog: :podspec: "../third-party-podspecs/glog.podspec" - PeerTalk: - :git: https://github.com/rsms/peertalk + PeerTalkSonar: + :podspec: "../third-party-podspecs/PeerTalkSonar.podspec" RSocket: :podspec: "../third-party-podspecs/RSocket.podspec" Sonar: - :podspec: "../../xplat/Sonar/SonarKitCPP.podspec" + :podspec: "../../xplat/Sonar/Sonar.podspec" SonarKit: - :podspec: "../SonarKit.podspec" + :podspec: "../../SonarKit.podspec" CHECKOUT OPTIONS: ComponentKit: - :commit: cdb1615aa730370a65baa0cf290b571bbef74cb4 + :commit: de618385741aacd659ce3eae5cb27bbf6b5a9963 :git: https://github.com/facebook/ComponentKit.git - PeerTalk: + PeerTalkSonar: :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e - :git: https://github.com/rsms/peertalk + :git: https://github.com/rsms/PeerTalk.git RSocket: :commit: f3531f877f26d13c81cfa9c73a07919d76a9dddd :git: https://github.com/rsocket/rsocket-cpp.git @@ -130,13 +130,13 @@ SPEC CHECKSUMS: Folly: ce1c216bcb099ca6cda58fefbba02bf2e9fe0381 glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 - PeerTalk: f5389c286e4d477e59b73dfbf25c5c70a2464761 + PeerTalkSonar: 648657ad6551ee1214555c8c3f1397a28c588156 RSocket: 38b24504db9efbfb018a3b2b23a2d9500140a2a7 Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 - SonarKit: 85eb1b3ef1875279d44f73ec276e6bbef1b4fc80 + SonarKit: 1314be2c82396a24f9805818c731d931a7c7fef1 Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 -PODFILE CHECKSUM: dfac9036111405250e307ccbd8be7175dec53ede +PODFILE CHECKSUM: 4c4d2b2552aaa91add9481791c49206f4fce7974 COCOAPODS: 1.5.2 diff --git a/iOS/Sample/Sample.xcodeproj/project.pbxproj b/iOS/Sample/Sample.xcodeproj/project.pbxproj index d1b532e26..03c3c3646 100644 --- a/iOS/Sample/Sample.xcodeproj/project.pbxproj +++ b/iOS/Sample/Sample.xcodeproj/project.pbxproj @@ -361,7 +361,7 @@ "-l\"ComponentKit\"", "-l\"DoubleConversion\"", "-l\"Folly\"", - "-l\"PeerTalk\"", + "-l\"PeerTalkSonar\"", "-l\"Sonar\"", "-l\"SonarKit\"", "-l\"Yoga\"", @@ -426,7 +426,7 @@ "-l\"ComponentKit\"", "-l\"DoubleConversion\"", "-l\"Folly\"", - "-l\"PeerTalk\"", + "-l\"PeerTalkSonar\"", "-l\"Sonar\"", "-l\"SonarKit\"", "-l\"Yoga\"", diff --git a/iOS/SonarKit.xcodeproj/project.pbxproj b/iOS/SonarKit.xcodeproj/project.pbxproj index dfc559de8..cd0b7e5c7 100644 --- a/iOS/SonarKit.xcodeproj/project.pbxproj +++ b/iOS/SonarKit.xcodeproj/project.pbxproj @@ -12,7 +12,8 @@ 53D19A2F20A4BABA00A371E3 /* SKPortForwardingServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D19A1D20A4BABA00A371E3 /* SKPortForwardingServer.m */; }; 53D19A3020A4BABA00A371E3 /* SonarCppBridgingConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53D19A1F20A4BABA00A371E3 /* SonarCppBridgingConnection.mm */; }; 53D19A3320A4BABA00A371E3 /* SonarCppBridgingResponder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53D19A2220A4BABA00A371E3 /* SonarCppBridgingResponder.mm */; }; - 53D4C4FC20A5B20000613A96 /* SKUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53D4C4FA20A5B20000613A96 /* SKUtils.mm */; }; + 53D3BBD820C629230022EB45 /* FBCxxFollyDynamicConvert.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53D3BBD620C629230022EB45 /* FBCxxFollyDynamicConvert.mm */; }; + 53D3BBD920C629230022EB45 /* FBCxxFollyDynamicConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D3BBD720C629230022EB45 /* FBCxxFollyDynamicConvert.h */; }; 53D4C50620A5B72800613A96 /* SonarCppWrapperPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A2020A4BABA00A371E3 /* SonarCppWrapperPlugin.h */; }; 53D4C50720A5B72800613A96 /* SonarCppBridgingConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A2120A4BABA00A371E3 /* SonarCppBridgingConnection.h */; }; 53D4C50820A5B72800613A96 /* SonarCppBridgingResponder.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A2320A4BABA00A371E3 /* SonarCppBridgingResponder.h */; }; @@ -47,6 +48,8 @@ 53D19A2120A4BABA00A371E3 /* SonarCppBridgingConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarCppBridgingConnection.h; sourceTree = ""; }; 53D19A2220A4BABA00A371E3 /* SonarCppBridgingResponder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SonarCppBridgingResponder.mm; sourceTree = ""; }; 53D19A2320A4BABA00A371E3 /* SonarCppBridgingResponder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarCppBridgingResponder.h; sourceTree = ""; }; + 53D3BBD620C629230022EB45 /* FBCxxFollyDynamicConvert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FBCxxFollyDynamicConvert.mm; sourceTree = ""; }; + 53D3BBD720C629230022EB45 /* FBCxxFollyDynamicConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBCxxFollyDynamicConvert.h; sourceTree = ""; }; 53D4C4F920A5B20000613A96 /* SKUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SKUtils.h; path = SonarKit/SKUtils.h; sourceTree = SOURCE_ROOT; }; 53D4C4FA20A5B20000613A96 /* SKUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SKUtils.mm; path = SonarKit/SKUtils.mm; sourceTree = SOURCE_ROOT; }; 53D4C51120A5B89900613A96 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -97,6 +100,7 @@ 53D19A0720A4BA3600A371E3 /* SonarKit */ = { isa = PBXGroup; children = ( + 53D3BBD520C629230022EB45 /* FBCxxUtils */, 53D19A1E20A4BABA00A371E3 /* CppBridge */, 53D19A1020A4BAB900A371E3 /* SKMacros.h */, 53D19A1120A4BAB900A371E3 /* SonarClient.h */, @@ -143,6 +147,15 @@ path = CppBridge; sourceTree = ""; }; + 53D3BBD520C629230022EB45 /* FBCxxUtils */ = { + isa = PBXGroup; + children = ( + 53D3BBD620C629230022EB45 /* FBCxxFollyDynamicConvert.mm */, + 53D3BBD720C629230022EB45 /* FBCxxFollyDynamicConvert.h */, + ); + path = FBCxxUtils; + sourceTree = ""; + }; 716CE00064F59AEDC5DB6AA8 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -166,6 +179,7 @@ 53D4C50820A5B72800613A96 /* SonarCppBridgingResponder.h in Headers */, 53D4C50920A5B72800613A96 /* SKMacros.h in Headers */, 53D4C50A20A5B72800613A96 /* SonarClient.h in Headers */, + 53D3BBD920C629230022EB45 /* FBCxxFollyDynamicConvert.h in Headers */, 53D4C50C20A5B72800613A96 /* SonarPlugin.h in Headers */, 53D4C50E20A5B72800613A96 /* SKUtils.h in Headers */, 53D4C50F20A5B72800613A96 /* SKPortForwardingServer.h in Headers */, @@ -263,8 +277,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 53D3BBD820C629230022EB45 /* FBCxxFollyDynamicConvert.mm in Sources */, 53D19A3320A4BABA00A371E3 /* SonarCppBridgingResponder.mm in Sources */, - 53D4C4FC20A5B20000613A96 /* SKUtils.mm in Sources */, 53D19A2F20A4BABA00A371E3 /* SKPortForwardingServer.m in Sources */, 53D19A3020A4BABA00A371E3 /* SonarCppBridgingConnection.mm in Sources */, 53D19A2620A4BABA00A371E3 /* SonarClient.mm in Sources */, diff --git a/iOS/third-party-podspecs/PeerTalkSonar.podspec b/iOS/third-party-podspecs/PeerTalkSonar.podspec new file mode 100644 index 000000000..d0a96c588 --- /dev/null +++ b/iOS/third-party-podspecs/PeerTalkSonar.podspec @@ -0,0 +1,16 @@ +Pod::Spec.new do |spec| + spec.name = 'PeerTalkSonar' + spec.version = '0.0.2' + spec.license = { :type => 'MIT' } + spec.homepage = 'http://rsms.me/peertalk/' + spec.authors = { 'Rasmus Andersson' => 'rasmus@notion.se' } + spec.summary = 'iOS and OS X Cocoa library for communicating over USB and TCP.' + + spec.source = { :git => "https://github.com/rsms/PeerTalk.git", :branch => 'master' } + spec.source_files = 'peertalk/*.{h,m}' + spec.requires_arc = true + spec.ios.deployment_target = '8.4' + spec.osx.deployment_target = '10.10' + + spec.description = " PeerTalk is a iOS and OS X Cocoa library for communicating over USB and TCP.\n\n Highlights:\n\n * Provides you with USB device attach/detach events and attached device's info\n * Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport\n * Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.\n * Tested and designed for libdispatch (aka Grand Central Dispatch).\n" +end diff --git a/xplat/Sonar/SonarKitCPP.podspec b/xplat/Sonar/Sonar.podspec similarity index 100% rename from xplat/Sonar/SonarKitCPP.podspec rename to xplat/Sonar/Sonar.podspec From 9846aed138eda7585ce1deb738a7168a1e8b9998 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 5 Jun 2018 00:12:38 -0400 Subject: [PATCH 07/44] remove spec --- Specs/ComponentKit/0.21/ComponentKit.podspec | 21 -------- .../PeerTalkSonar/0.0.2/PeerTalkSonar.podspec | 16 ------ Specs/RSocket/0.10.0/RSocket.podspec | 53 ------------------- 3 files changed, 90 deletions(-) delete mode 100644 Specs/ComponentKit/0.21/ComponentKit.podspec delete mode 100644 Specs/PeerTalkSonar/0.0.2/PeerTalkSonar.podspec delete mode 100644 Specs/RSocket/0.10.0/RSocket.podspec diff --git a/Specs/ComponentKit/0.21/ComponentKit.podspec b/Specs/ComponentKit/0.21/ComponentKit.podspec deleted file mode 100644 index d6e54476c..000000000 --- a/Specs/ComponentKit/0.21/ComponentKit.podspec +++ /dev/null @@ -1,21 +0,0 @@ -Pod::Spec.new do |s| - s.name = 'ComponentKit' - s.version = '0.21' - s.license = 'BSD' - s.summary = 'A React-inspired view framework for iOS' - s.homepage = 'https://componentkit.org' - s.social_media_url = 'https://twitter.com/componentkit' - s.authors = 'adamjernst@fb.com' - s.source = { :git => 'https://github.com/facebook/ComponentKit.git'} - s.ios.deployment_target = '8.1' - s.requires_arc = true - - s.source_files = 'ComponentKit/**/*', 'ComponentTextKit/**/*' - s.frameworks = 'UIKit', 'CoreText' - s.library = 'c++' - s.xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'gnu++14', - 'CLANG_CXX_LIBRARY' => 'libc++', - } - s.dependency 'Yoga' -end diff --git a/Specs/PeerTalkSonar/0.0.2/PeerTalkSonar.podspec b/Specs/PeerTalkSonar/0.0.2/PeerTalkSonar.podspec deleted file mode 100644 index d0a96c588..000000000 --- a/Specs/PeerTalkSonar/0.0.2/PeerTalkSonar.podspec +++ /dev/null @@ -1,16 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'PeerTalkSonar' - spec.version = '0.0.2' - spec.license = { :type => 'MIT' } - spec.homepage = 'http://rsms.me/peertalk/' - spec.authors = { 'Rasmus Andersson' => 'rasmus@notion.se' } - spec.summary = 'iOS and OS X Cocoa library for communicating over USB and TCP.' - - spec.source = { :git => "https://github.com/rsms/PeerTalk.git", :branch => 'master' } - spec.source_files = 'peertalk/*.{h,m}' - spec.requires_arc = true - spec.ios.deployment_target = '8.4' - spec.osx.deployment_target = '10.10' - - spec.description = " PeerTalk is a iOS and OS X Cocoa library for communicating over USB and TCP.\n\n Highlights:\n\n * Provides you with USB device attach/detach events and attached device's info\n * Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport\n * Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.\n * Tested and designed for libdispatch (aka Grand Central Dispatch).\n" -end diff --git a/Specs/RSocket/0.10.0/RSocket.podspec b/Specs/RSocket/0.10.0/RSocket.podspec deleted file mode 100644 index ee4265d2f..000000000 --- a/Specs/RSocket/0.10.0/RSocket.podspec +++ /dev/null @@ -1,53 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'RSocket' - spec.version = '0.10.0' - spec.license = { :type => 'MIT' } - spec.homepage = 'https://github.com/rsocket/rsocket-cpp' - spec.summary = 'C++ implementation of RSocket' - spec.authors = 'Facebook' - spec.source = { :git => 'https://github.com/rsocket/rsocket-cpp.git', :branch => "master"} - spec.module_name = 'RSocket' - spec.source_files = 'rsocket/benchmarks/*', - 'rsocket/framing/*', - 'rsocket/internal/*', - 'rsocket/statemachine/*', - 'rsocket/transports/*', - 'rsocket/transports/**/*', - 'yarpl/observable/*', - 'yarpl/flowable/*', - 'rsocket/*' - - spec.libraries = "stdc++" - spec.compiler_flags = '-std=c++1y' - spec.dependency 'Folly' - spec.compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti - -fexceptions - -std=c++14 - -Wno-error - -Wno-unused-local-typedefs - -Wno-unused-variable - -Wno-sign-compare - -Wno-comment - -Wno-return-type - -Wno-global-constructors' - spec.preserve_paths = 'rsocket/benchmarks/*.h', - 'rsocket/framing/*.h', - 'rsocket/internal/*.h', - 'rsocket/statemachine/*.h', - 'rsocket/transports/*.h', - 'rsocket/*.h', - 'yarpl/flowable/*.h', - 'yarpl/observable/*.h', - 'yarpl/perf/*.h', - 'yarpl/single/*.h', - 'yarpl/utils/*.h', - 'yarpl/*.h', - '**/*.h' - spec.header_mappings_dir = './*' - spec.header_dir = './*' - spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/DoubleConversion\"/**" } - spec.platforms = { :ios => "8.0" } - -end From 43086d9c939349355c14a206af831212d5d9d0bd Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 5 Jun 2018 15:16:03 -0400 Subject: [PATCH 08/44] update --- SonarKit.podspec | 2 +- iOS/Podfile | 2 +- iOS/Podfile.lock | 18 +++++------ iOS/Sample/Podfile | 2 +- iOS/Sample/Podfile.lock | 30 +++++++++---------- iOS/Sample/Sample.xcodeproj/project.pbxproj | 4 +-- ...PeerTalkSonar.podspec => PeerTalk.podspec} | 7 +++-- 7 files changed, 34 insertions(+), 31 deletions(-) rename iOS/third-party-podspecs/{PeerTalkSonar.podspec => PeerTalk.podspec} (84%) diff --git a/SonarKit.podspec b/SonarKit.podspec index 9f67932c5..76ac44b59 100644 --- a/SonarKit.podspec +++ b/SonarKit.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |spec| spec.dependency 'Folly' spec.dependency 'Sonar' spec.dependency 'CocoaAsyncSocket', '~> 7.6' - spec.dependency 'PeerTalkSonar' + spec.dependency 'PeerTalk' spec.dependency 'OpenSSL-Universal', '~> 1.0' spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}', 'iOS/SonarKit/FBCxxUtils/*.{h, mm}', spec.public_header_files = 'iOS/SonarKit/CppBridge/*.{h}', diff --git a/iOS/Podfile b/iOS/Podfile index 97231a927..88b7f0547 100644 --- a/iOS/Podfile +++ b/iOS/Podfile @@ -11,7 +11,7 @@ target 'SonarKit' do # Third party deps podspec link # pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' - pod 'PeerTalkSonar', :podspec => 'third-party-podspecs/PeerTalkSonar.podspec' + pod 'PeerTalk', :podspec => 'third-party-podspecs/PeerTalk.podspec' pod 'RSocket', :podspec => 'third-party-podspecs/RSocket.podspec' pod 'DoubleConversion', :podspec => 'third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => 'third-party-podspecs/glog.podspec' diff --git a/iOS/Podfile.lock b/iOS/Podfile.lock index bbc771de5..d9e806e7b 100644 --- a/iOS/Podfile.lock +++ b/iOS/Podfile.lock @@ -11,7 +11,7 @@ PODS: - OpenSSL-Universal (~> 1.0) - glog (0.3.5) - OpenSSL-Universal (1.0.2.13) - - PeerTalk (0.0.2) + - PeerTalk (1.0.0) - RSocket (0.10.0): - Folly - Sonar (0.0.1): @@ -23,9 +23,9 @@ DEPENDENCIES: - DoubleConversion (from `third-party-podspecs/DoubleConversion.podspec`) - Folly (from `third-party-podspecs/Folly.podspec`) - glog (from `third-party-podspecs/glog.podspec`) - - PeerTalk (from `https://github.com/rsms/peertalk`) + - PeerTalk (from `third-party-podspecs/PeerTalk.podspec`) - RSocket (from `third-party-podspecs/RSocket.podspec`) - - Sonar (from `../xplat/Sonar/SonarKitCPP.podspec`) + - Sonar (from `../xplat/Sonar/Sonar.podspec`) SPEC REPOS: https://github.com/cocoapods/specs.git: @@ -42,18 +42,18 @@ EXTERNAL SOURCES: glog: :podspec: third-party-podspecs/glog.podspec PeerTalk: - :git: https://github.com/rsms/peertalk + :podspec: third-party-podspecs/PeerTalk.podspec RSocket: :podspec: third-party-podspecs/RSocket.podspec Sonar: - :podspec: "../xplat/Sonar/SonarKitCPP.podspec" + :podspec: "../xplat/Sonar/Sonar.podspec" CHECKOUT OPTIONS: PeerTalk: :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e - :git: https://github.com/rsms/peertalk + :git: https://github.com/rsms/PeerTalk.git RSocket: - :commit: f3531f877f26d13c81cfa9c73a07919d76a9dddd + :commit: 193002818e53e7a7d73ee362627ddf1fdabc4493 :git: https://github.com/rsocket/rsocket-cpp.git Sonar: :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 @@ -67,10 +67,10 @@ SPEC CHECKSUMS: Folly: ce1c216bcb099ca6cda58fefbba02bf2e9fe0381 glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 - PeerTalk: f5389c286e4d477e59b73dfbf25c5c70a2464761 + PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 RSocket: 38b24504db9efbfb018a3b2b23a2d9500140a2a7 Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 -PODFILE CHECKSUM: ea1c982eb3a27e26c91d456fff45930d31f3e115 +PODFILE CHECKSUM: a6a7b2201d324f787ef4956b045f021e7152fddf COCOAPODS: 1.5.2 diff --git a/iOS/Sample/Podfile b/iOS/Sample/Podfile index ca10ae207..2e86e349a 100644 --- a/iOS/Sample/Podfile +++ b/iOS/Sample/Podfile @@ -10,7 +10,7 @@ target 'Sample' do pod 'DoubleConversion', :podspec => '../third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../third-party-podspecs/Folly.podspec' - pod 'PeerTalkSonar', :podspec => '../third-party-podspecs/PeerTalkSonar.podspec' + pod 'PeerTalk', :podspec => '../third-party-podspecs/PeerTalk.podspec' pod 'ComponentKit', :podspec => '../third-party-podspecs/ComponentKit.podspec' pod 'Yoga','~>1.8.1', :modular_headers => true pod 'Sonar', :podspec => '../../xplat/Sonar/Sonar.podspec' diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 1d4cf4cb1..1188bfdfc 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -13,7 +13,7 @@ PODS: - OpenSSL-Universal (~> 1.0) - glog (0.3.5) - OpenSSL-Universal (1.0.2.13) - - PeerTalkSonar (0.0.2) + - PeerTalk (1.0.0) - RSocket (0.10.0): - Folly - Sonar (0.0.1): @@ -23,7 +23,7 @@ PODS: - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalkSonar + - PeerTalk - Sonar - SonarKit/SKIOSNetworkPlugin (= 0.0.1) - SonarKit/SonarKitLayoutComponentKitSupport (= 0.0.1) @@ -34,7 +34,7 @@ PODS: - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalkSonar + - PeerTalk - Sonar - SonarKit/SonarKitNetworkPlugin - SonarKit/SonarKitLayoutComponentKitSupport (0.0.1): @@ -42,7 +42,7 @@ PODS: - ComponentKit - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalkSonar + - PeerTalk - Sonar - SonarKit/SonarKitLayoutPlugin - Yoga (~> 1.8) @@ -50,7 +50,7 @@ PODS: - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalkSonar + - PeerTalk - Sonar - Yoga (~> 1.8) - YogaKit (= 1.8.1) @@ -58,7 +58,7 @@ PODS: - CocoaAsyncSocket (~> 7.6) - Folly - OpenSSL-Universal (~> 1.0) - - PeerTalkSonar + - PeerTalk - Sonar - Yoga (1.8.1) - YogaKit (1.8.1): @@ -69,7 +69,7 @@ DEPENDENCIES: - DoubleConversion (from `../third-party-podspecs/DoubleConversion.podspec`) - Folly (from `../third-party-podspecs/Folly.podspec`) - glog (from `../third-party-podspecs/glog.podspec`) - - PeerTalkSonar (from `../third-party-podspecs/PeerTalkSonar.podspec`) + - PeerTalk (from `../third-party-podspecs/PeerTalk.podspec`) - RSocket (from `../third-party-podspecs/RSocket.podspec`) - Sonar (from `../../xplat/Sonar/Sonar.podspec`) - SonarKit (from `../../SonarKit.podspec`) @@ -95,8 +95,8 @@ EXTERNAL SOURCES: :podspec: "../third-party-podspecs/Folly.podspec" glog: :podspec: "../third-party-podspecs/glog.podspec" - PeerTalkSonar: - :podspec: "../third-party-podspecs/PeerTalkSonar.podspec" + PeerTalk: + :podspec: "../third-party-podspecs/PeerTalk.podspec" RSocket: :podspec: "../third-party-podspecs/RSocket.podspec" Sonar: @@ -106,13 +106,13 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ComponentKit: - :commit: de618385741aacd659ce3eae5cb27bbf6b5a9963 + :commit: 368a8b74e1940b9c86b1a883cd7668bc5a204536 :git: https://github.com/facebook/ComponentKit.git - PeerTalkSonar: + PeerTalk: :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e :git: https://github.com/rsms/PeerTalk.git RSocket: - :commit: f3531f877f26d13c81cfa9c73a07919d76a9dddd + :commit: 193002818e53e7a7d73ee362627ddf1fdabc4493 :git: https://github.com/rsocket/rsocket-cpp.git Sonar: :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 @@ -130,13 +130,13 @@ SPEC CHECKSUMS: Folly: ce1c216bcb099ca6cda58fefbba02bf2e9fe0381 glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 - PeerTalkSonar: 648657ad6551ee1214555c8c3f1397a28c588156 + PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 RSocket: 38b24504db9efbfb018a3b2b23a2d9500140a2a7 Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 - SonarKit: 1314be2c82396a24f9805818c731d931a7c7fef1 + SonarKit: 748eeb4e6f10af7abe946e11d087dd2a2d5b514c Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 -PODFILE CHECKSUM: 4c4d2b2552aaa91add9481791c49206f4fce7974 +PODFILE CHECKSUM: 7c2600fc131a2b041c967e8d6ffc2bd1a0383733 COCOAPODS: 1.5.2 diff --git a/iOS/Sample/Sample.xcodeproj/project.pbxproj b/iOS/Sample/Sample.xcodeproj/project.pbxproj index 03c3c3646..d1b532e26 100644 --- a/iOS/Sample/Sample.xcodeproj/project.pbxproj +++ b/iOS/Sample/Sample.xcodeproj/project.pbxproj @@ -361,7 +361,7 @@ "-l\"ComponentKit\"", "-l\"DoubleConversion\"", "-l\"Folly\"", - "-l\"PeerTalkSonar\"", + "-l\"PeerTalk\"", "-l\"Sonar\"", "-l\"SonarKit\"", "-l\"Yoga\"", @@ -426,7 +426,7 @@ "-l\"ComponentKit\"", "-l\"DoubleConversion\"", "-l\"Folly\"", - "-l\"PeerTalkSonar\"", + "-l\"PeerTalk\"", "-l\"Sonar\"", "-l\"SonarKit\"", "-l\"Yoga\"", diff --git a/iOS/third-party-podspecs/PeerTalkSonar.podspec b/iOS/third-party-podspecs/PeerTalk.podspec similarity index 84% rename from iOS/third-party-podspecs/PeerTalkSonar.podspec rename to iOS/third-party-podspecs/PeerTalk.podspec index d0a96c588..eeac92540 100644 --- a/iOS/third-party-podspecs/PeerTalkSonar.podspec +++ b/iOS/third-party-podspecs/PeerTalk.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| - spec.name = 'PeerTalkSonar' - spec.version = '0.0.2' + spec.name = 'PeerTalk' + spec.version = '1.0.0' spec.license = { :type => 'MIT' } spec.homepage = 'http://rsms.me/peertalk/' spec.authors = { 'Rasmus Andersson' => 'rasmus@notion.se' } @@ -13,4 +13,7 @@ Pod::Spec.new do |spec| spec.osx.deployment_target = '10.10' spec.description = " PeerTalk is a iOS and OS X Cocoa library for communicating over USB and TCP.\n\n Highlights:\n\n * Provides you with USB device attach/detach events and attached device's info\n * Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport\n * Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.\n * Tested and designed for libdispatch (aka Grand Central Dispatch).\n" + spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/**" } + end From 541a4f1b98685c6bccf064e4feb384b2d3597f9d Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 5 Jun 2018 17:02:01 -0400 Subject: [PATCH 09/44] update --- SonarKit.podspec | 4 +- iOS/Podfile.lock | 2 +- iOS/Sample/Podfile.lock | 24 +- .../PortForwarding/SKPortForwardingServer.h | 36 +- .../PortForwarding/SKPortForwardingServer.m | 380 +++++++++--------- iOS/third-party-podspecs/Folly.podspec | 4 +- iOS/third-party-podspecs/RSocket.podspec | 4 +- xplat/Sonar/Sonar.podspec | 2 +- 8 files changed, 228 insertions(+), 228 deletions(-) diff --git a/SonarKit.podspec b/SonarKit.podspec index 76ac44b59..3b449eccb 100644 --- a/SonarKit.podspec +++ b/SonarKit.podspec @@ -12,13 +12,13 @@ Pod::Spec.new do |spec| spec.static_framework = true # spec.prepare_command = 'mv src double-conversion' spec.source = { :git => 'https://github.com/facebook/Sonar.git', - :branch=> "master" } + :branch=> "iOS-OSS" } spec.module_name = 'SonarKit' spec.dependency 'Folly' spec.dependency 'Sonar' spec.dependency 'CocoaAsyncSocket', '~> 7.6' spec.dependency 'PeerTalk' - spec.dependency 'OpenSSL-Universal', '~> 1.0' + spec.dependency 'OpenSSL-Static', '1.0.2.c1' spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}', 'iOS/SonarKit/FBCxxUtils/*.{h, mm}', spec.public_header_files = 'iOS/SonarKit/CppBridge/*.{h}', 'iOS/SonarKit/FBCxxUtils/*.{h}', diff --git a/iOS/Podfile.lock b/iOS/Podfile.lock index d9e806e7b..b3ef3b191 100644 --- a/iOS/Podfile.lock +++ b/iOS/Podfile.lock @@ -68,7 +68,7 @@ SPEC CHECKSUMS: glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 - RSocket: 38b24504db9efbfb018a3b2b23a2d9500140a2a7 + RSocket: e9ee232080f995ba8f403ccf4cb61238a5646cb6 Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 PODFILE CHECKSUM: a6a7b2201d324f787ef4956b045f021e7152fddf diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 1188bfdfc..e37b3891d 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -10,9 +10,9 @@ PODS: - CocoaLibEvent (~> 1.0) - DoubleConversion - glog - - OpenSSL-Universal (~> 1.0) + - OpenSSL-Static (= 1.0.2.c1) - glog (0.3.5) - - OpenSSL-Universal (1.0.2.13) + - OpenSSL-Static (1.0.2.c1) - PeerTalk (1.0.0) - RSocket (0.10.0): - Folly @@ -22,7 +22,7 @@ PODS: - SonarKit (0.0.1): - CocoaAsyncSocket (~> 7.6) - Folly - - OpenSSL-Universal (~> 1.0) + - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - SonarKit/SKIOSNetworkPlugin (= 0.0.1) @@ -33,7 +33,7 @@ PODS: - SonarKit/SKIOSNetworkPlugin (0.0.1): - CocoaAsyncSocket (~> 7.6) - Folly - - OpenSSL-Universal (~> 1.0) + - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - SonarKit/SonarKitNetworkPlugin @@ -41,7 +41,7 @@ PODS: - CocoaAsyncSocket (~> 7.6) - ComponentKit - Folly - - OpenSSL-Universal (~> 1.0) + - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - SonarKit/SonarKitLayoutPlugin @@ -49,7 +49,7 @@ PODS: - SonarKit/SonarKitLayoutPlugin (0.0.1): - CocoaAsyncSocket (~> 7.6) - Folly - - OpenSSL-Universal (~> 1.0) + - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - Yoga (~> 1.8) @@ -57,7 +57,7 @@ PODS: - SonarKit/SonarKitNetworkPlugin (0.0.1): - CocoaAsyncSocket (~> 7.6) - Folly - - OpenSSL-Universal (~> 1.0) + - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - Yoga (1.8.1) @@ -82,7 +82,7 @@ SPEC REPOS: - boost-for-react-native - CocoaAsyncSocket - CocoaLibEvent - - OpenSSL-Universal + - OpenSSL-Static - Yoga - YogaKit @@ -127,13 +127,13 @@ SPEC CHECKSUMS: CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f ComponentKit: 7bd0ad508946aeb68dd52ed8739ced9846ff3671 DoubleConversion: 9bd61b1134a393694e95e0950c5bf3f99534817f - Folly: ce1c216bcb099ca6cda58fefbba02bf2e9fe0381 + Folly: 551752534f77d816ebf69195405d9d0fbd3efcc0 glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 - OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 + OpenSSL-Static: bd17e34564a8591ad76b740318683a6caa19a13e PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 - RSocket: 38b24504db9efbfb018a3b2b23a2d9500140a2a7 + RSocket: e9ee232080f995ba8f403ccf4cb61238a5646cb6 Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 - SonarKit: 748eeb4e6f10af7abe946e11d087dd2a2d5b514c + SonarKit: f127bb6582dd1d2590e91937bea9793e95d8a159 Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 diff --git a/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.h b/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.h index 72d4514a7..3118a523b 100644 --- a/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.h +++ b/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.h @@ -1,18 +1,18 @@ -/* - * Copyright (c) 2018-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the LICENSE - * file in the root directory of this source tree. - * - */ -#import - -@interface SKPortForwardingServer : NSObject - -- (instancetype)init; - -- (void)listenForMultiplexingChannelOnPort:(NSUInteger)port; -- (void)forwardConnectionsFromPort:(NSUInteger)port; -- (void)close; - -@end +// /* +// * Copyright (c) 2018-present, Facebook, Inc. +// * +// * This source code is licensed under the MIT license found in the LICENSE +// * file in the root directory of this source tree. +// * +// */ +// #import +// +// @interface SKPortForwardingServer : NSObject +// +// - (instancetype)init; +// +// - (void)listenForMultiplexingChannelOnPort:(NSUInteger)port; +// - (void)forwardConnectionsFromPort:(NSUInteger)port; +// - (void)close; +// +// @end diff --git a/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.m b/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.m index 7bb61075a..f83ca06fd 100644 --- a/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.m +++ b/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.m @@ -1,190 +1,190 @@ -/* - * Copyright (c) 2018-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the LICENSE - * file in the root directory of this source tree. - * - */ -#import "SKPortForwardingServer.h" - -#import - -#import -#import - -#import "SKMacros.h" -#import "SKPortForwardingCommon.h" - -@interface SKPortForwardingServer () - -@property (nonatomic, weak) PTChannel *serverChannel; -@property (nonatomic, weak) PTChannel *peerChannel; - -@property (nonatomic, strong) GCDAsyncSocket *serverSocket; -@property (nonatomic, strong) NSMutableDictionary *clientSockets; -@property (nonatomic, assign) UInt32 lastClientSocketTag; -@property (nonatomic, strong) dispatch_queue_t socketQueue; -@property (nonatomic, strong) PTProtocol *protocol; - -@end - -@implementation SKPortForwardingServer - -- (instancetype)init -{ - if (self = [super init]) { - _socketQueue = dispatch_queue_create("SKPortForwardingServer", DISPATCH_QUEUE_SERIAL); - _lastClientSocketTag = 0; - _clientSockets = [NSMutableDictionary dictionary]; - _protocol = [[PTProtocol alloc] initWithDispatchQueue:_socketQueue]; - } - return self; -} - -- (void)dealloc -{ - [self close]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (void)forwardConnectionsFromPort:(NSUInteger)port -{ - [self _forwardConnectionsFromPort:port reportError:YES]; - [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - [self _forwardConnectionsFromPort:port reportError:NO]; - }]; -} - -- (void)_forwardConnectionsFromPort:(NSUInteger)port reportError:(BOOL)shouldReportError -{ - GCDAsyncSocket *serverSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:_socketQueue]; - NSError *listenError; - if ([serverSocket acceptOnPort:port error:&listenError]) { - self.serverSocket = serverSocket; - } else { - if (shouldReportError) { - SKLog(@"Failed to listen: %@", listenError); - } - } -} - -- (void)listenForMultiplexingChannelOnPort:(NSUInteger)port -{ - [self _listenForMultiplexingChannelOnPort:port reportError:YES]; - [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification *note) { - [self _listenForMultiplexingChannelOnPort:port reportError:NO]; - }]; -} - -- (void)_listenForMultiplexingChannelOnPort:(NSUInteger)port reportError:(BOOL)shouldReportError -{ - PTChannel *channel = [[PTChannel alloc] initWithProtocol:_protocol delegate:self]; - [channel listenOnPort:port IPv4Address:INADDR_LOOPBACK callback:^(NSError *error) { - if (error) { - if (shouldReportError) { - SKLog(@"Failed to listen on 127.0.0.1:%lu: %@", (unsigned long)port, error); - } - } else { - SKTrace(@"Listening on 127.0.0.1:%lu", (unsigned long)port); - self.serverChannel = channel; - } - }]; -} - -- (void)close -{ - if (self.serverChannel) { - [self.serverChannel close]; - self.serverChannel = nil; - } - [self.serverSocket disconnect]; -} - -#pragma mark - PTChannelDelegate - -- (void)ioFrameChannel:(PTChannel *)channel didAcceptConnection:(PTChannel *)otherChannel fromAddress:(PTAddress *)address { - // Cancel any other connection. We are FIFO, so the last connection - // established will cancel any previous connection and "take its place". - if (self.peerChannel) { - [self.peerChannel cancel]; - } - - // Weak pointer to current connection. Connection objects live by themselves - // (owned by its parent dispatch queue) until they are closed. - self.peerChannel = otherChannel; - self.peerChannel.userInfo = address; - SKTrace(@"Connected to %@", address); -} - -- (void)ioFrameChannel:(PTChannel *)channel didReceiveFrameOfType:(uint32_t)type tag:(uint32_t)tag payload:(PTData *)payload { - //NSLog(@"didReceiveFrameOfType: %u, %u, %@", type, tag, payload); - if (type == SKPortForwardingFrameTypeWriteToPipe) { - GCDAsyncSocket *sock = self.clientSockets[@(tag)]; - [sock writeData:[NSData dataWithBytes:payload.data length:payload.length] withTimeout:-1 tag:0]; - SKTrace(@"channel -> socket (%d), %zu bytes", tag, payload.length); - } - - if (type == SKPortForwardingFrameTypeClosePipe) { - GCDAsyncSocket *sock = self.clientSockets[@(tag)]; - [sock disconnectAfterWriting]; - } -} - -- (void)ioFrameChannel:(PTChannel *)channel didEndWithError:(NSError *)error { - for (GCDAsyncSocket *sock in [_clientSockets objectEnumerator]) { - [sock setDelegate:nil]; - [sock disconnect]; - } - [self.clientSockets removeAllObjects]; - SKTrace(@"Disconnected from %@, error = %@", channel.userInfo, error); -} - - -#pragma mark - GCDAsyncSocketDelegate - -- (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket -{ - dispatch_block_t block = ^() { - if (!self.peerChannel) { - [newSocket setDelegate:nil]; - [newSocket disconnect]; - } - - UInt32 tag = ++self->_lastClientSocketTag; - newSocket.userData = @(tag); - newSocket.delegate = self; - self.clientSockets[@(tag)] = newSocket; - [self.peerChannel sendFrameOfType:SKPortForwardingFrameTypeOpenPipe tag:self->_lastClientSocketTag withPayload:nil callback:^(NSError *error) { - SKTrace(@"open socket (%d), error = %@", (unsigned int)tag, error); - [newSocket readDataWithTimeout:-1 tag:0]; - }]; - }; - - if (_peerChannel) { - block(); - } else { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), _socketQueue, block); - } -} - -- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)_ -{ - UInt32 tag = [[sock userData] unsignedIntValue]; - SKTrace(@"Incoming data on socket (%d) - %lu bytes", (unsigned int)tag, (unsigned long)data.length); - [_peerChannel sendFrameOfType:SKPortForwardingFrameTypeWriteToPipe tag:tag withPayload:NSDataToGCDData(data) callback:^(NSError *error) { - SKTrace(@"socket (%d) -> channel %lu bytes, error = %@", (unsigned int)tag, (unsigned long)data.length, error); - [sock readDataWithTimeout:-1 tag:_]; - }]; -} - -- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err -{ - UInt32 tag = [sock.userData unsignedIntValue]; - [_clientSockets removeObjectForKey:@(tag)]; - [_peerChannel sendFrameOfType:SKPortForwardingFrameTypeClosePipe tag:tag withPayload:nil callback:^(NSError *error) { - SKTrace(@"socket (%d) disconnected, err = %@, peer error = %@", (unsigned int)tag, err, error); - }]; -} - - -@end +// /* +// * Copyright (c) 2018-present, Facebook, Inc. +// * +// * This source code is licensed under the MIT license found in the LICENSE +// * file in the root directory of this source tree. +// * +// */ +// #import "SKPortForwardingServer.h" +// +// #import +// +// #import +// #import +// +// #import "SKMacros.h" +// #import "SKPortForwardingCommon.h" +// +// @interface SKPortForwardingServer () +// +// @property (nonatomic, weak) PTChannel *serverChannel; +// @property (nonatomic, weak) PTChannel *peerChannel; +// +// @property (nonatomic, strong) GCDAsyncSocket *serverSocket; +// @property (nonatomic, strong) NSMutableDictionary *clientSockets; +// @property (nonatomic, assign) UInt32 lastClientSocketTag; +// @property (nonatomic, strong) dispatch_queue_t socketQueue; +// @property (nonatomic, strong) PTProtocol *protocol; +// +// @end +// +// @implementation SKPortForwardingServer +// +// - (instancetype)init +// { +// if (self = [super init]) { +// _socketQueue = dispatch_queue_create("SKPortForwardingServer", DISPATCH_QUEUE_SERIAL); +// _lastClientSocketTag = 0; +// _clientSockets = [NSMutableDictionary dictionary]; +// _protocol = [[PTProtocol alloc] initWithDispatchQueue:_socketQueue]; +// } +// return self; +// } +// +// - (void)dealloc +// { +// [self close]; +// [[NSNotificationCenter defaultCenter] removeObserver:self]; +// } +// +// - (void)forwardConnectionsFromPort:(NSUInteger)port +// { +// [self _forwardConnectionsFromPort:port reportError:YES]; +// [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification *note) { +// [self _forwardConnectionsFromPort:port reportError:NO]; +// }]; +// } +// +// - (void)_forwardConnectionsFromPort:(NSUInteger)port reportError:(BOOL)shouldReportError +// { +// GCDAsyncSocket *serverSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:_socketQueue]; +// NSError *listenError; +// if ([serverSocket acceptOnPort:port error:&listenError]) { +// self.serverSocket = serverSocket; +// } else { +// if (shouldReportError) { +// SKLog(@"Failed to listen: %@", listenError); +// } +// } +// } +// +// - (void)listenForMultiplexingChannelOnPort:(NSUInteger)port +// { +// [self _listenForMultiplexingChannelOnPort:port reportError:YES]; +// [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification *note) { +// [self _listenForMultiplexingChannelOnPort:port reportError:NO]; +// }]; +// } +// +// - (void)_listenForMultiplexingChannelOnPort:(NSUInteger)port reportError:(BOOL)shouldReportError +// { +// PTChannel *channel = [[PTChannel alloc] initWithProtocol:_protocol delegate:self]; +// [channel listenOnPort:port IPv4Address:INADDR_LOOPBACK callback:^(NSError *error) { +// if (error) { +// if (shouldReportError) { +// SKLog(@"Failed to listen on 127.0.0.1:%lu: %@", (unsigned long)port, error); +// } +// } else { +// SKTrace(@"Listening on 127.0.0.1:%lu", (unsigned long)port); +// self.serverChannel = channel; +// } +// }]; +// } +// +// - (void)close +// { +// if (self.serverChannel) { +// [self.serverChannel close]; +// self.serverChannel = nil; +// } +// [self.serverSocket disconnect]; +// } +// +// #pragma mark - PTChannelDelegate +// +// - (void)ioFrameChannel:(PTChannel *)channel didAcceptConnection:(PTChannel *)otherChannel fromAddress:(PTAddress *)address { +// // Cancel any other connection. We are FIFO, so the last connection +// // established will cancel any previous connection and "take its place". +// if (self.peerChannel) { +// [self.peerChannel cancel]; +// } +// +// // Weak pointer to current connection. Connection objects live by themselves +// // (owned by its parent dispatch queue) until they are closed. +// self.peerChannel = otherChannel; +// self.peerChannel.userInfo = address; +// SKTrace(@"Connected to %@", address); +// } +// +// - (void)ioFrameChannel:(PTChannel *)channel didReceiveFrameOfType:(uint32_t)type tag:(uint32_t)tag payload:(PTData *)payload { +// //NSLog(@"didReceiveFrameOfType: %u, %u, %@", type, tag, payload); +// if (type == SKPortForwardingFrameTypeWriteToPipe) { +// GCDAsyncSocket *sock = self.clientSockets[@(tag)]; +// [sock writeData:[NSData dataWithBytes:payload.data length:payload.length] withTimeout:-1 tag:0]; +// SKTrace(@"channel -> socket (%d), %zu bytes", tag, payload.length); +// } +// +// if (type == SKPortForwardingFrameTypeClosePipe) { +// GCDAsyncSocket *sock = self.clientSockets[@(tag)]; +// [sock disconnectAfterWriting]; +// } +// } +// +// - (void)ioFrameChannel:(PTChannel *)channel didEndWithError:(NSError *)error { +// for (GCDAsyncSocket *sock in [_clientSockets objectEnumerator]) { +// [sock setDelegate:nil]; +// [sock disconnect]; +// } +// [self.clientSockets removeAllObjects]; +// SKTrace(@"Disconnected from %@, error = %@", channel.userInfo, error); +// } +// +// +// #pragma mark - GCDAsyncSocketDelegate +// +// - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket +// { +// dispatch_block_t block = ^() { +// if (!self.peerChannel) { +// [newSocket setDelegate:nil]; +// [newSocket disconnect]; +// } +// +// UInt32 tag = ++self->_lastClientSocketTag; +// newSocket.userData = @(tag); +// newSocket.delegate = self; +// self.clientSockets[@(tag)] = newSocket; +// [self.peerChannel sendFrameOfType:SKPortForwardingFrameTypeOpenPipe tag:self->_lastClientSocketTag withPayload:nil callback:^(NSError *error) { +// SKTrace(@"open socket (%d), error = %@", (unsigned int)tag, error); +// [newSocket readDataWithTimeout:-1 tag:0]; +// }]; +// }; +// +// if (_peerChannel) { +// block(); +// } else { +// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), _socketQueue, block); +// } +// } +// +// - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)_ +// { +// UInt32 tag = [[sock userData] unsignedIntValue]; +// SKTrace(@"Incoming data on socket (%d) - %lu bytes", (unsigned int)tag, (unsigned long)data.length); +// [_peerChannel sendFrameOfType:SKPortForwardingFrameTypeWriteToPipe tag:tag withPayload:NSDataToGCDData(data) callback:^(NSError *error) { +// SKTrace(@"socket (%d) -> channel %lu bytes, error = %@", (unsigned int)tag, (unsigned long)data.length, error); +// [sock readDataWithTimeout:-1 tag:_]; +// }]; +// } +// +// - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err +// { +// UInt32 tag = [sock.userData unsignedIntValue]; +// [_clientSockets removeObjectForKey:@(tag)]; +// [_peerChannel sendFrameOfType:SKPortForwardingFrameTypeClosePipe tag:tag withPayload:nil callback:^(NSError *error) { +// SKTrace(@"socket (%d) disconnected, err = %@, peer error = %@", (unsigned int)tag, err, error); +// }]; +// } +// +// +// @end diff --git a/iOS/third-party-podspecs/Folly.podspec b/iOS/third-party-podspecs/Folly.podspec index 1673d6f1d..150250f2f 100755 --- a/iOS/third-party-podspecs/Folly.podspec +++ b/iOS/third-party-podspecs/Folly.podspec @@ -11,8 +11,8 @@ Pod::Spec.new do |spec| spec.dependency 'boost-for-react-native' spec.dependency 'DoubleConversion' spec.dependency 'glog' - spec.dependency 'OpenSSL-Universal', '~> 1.0' - spec.dependency 'CocoaLibEvent', '~> 1.0' + #spec.dependency 'OpenSSL-Static', '1.0.2.c1' + #spec.dependency 'CocoaLibEvent', '~> 1.0' spec.compiler_flags = '-DFOLLY_HAVE_PTHREAD=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti -fexceptions -std=c++14 diff --git a/iOS/third-party-podspecs/RSocket.podspec b/iOS/third-party-podspecs/RSocket.podspec index ee4265d2f..ac127e1aa 100644 --- a/iOS/third-party-podspecs/RSocket.podspec +++ b/iOS/third-party-podspecs/RSocket.podspec @@ -43,8 +43,8 @@ Pod::Spec.new do |spec| 'yarpl/utils/*.h', 'yarpl/*.h', '**/*.h' - spec.header_mappings_dir = './*' - spec.header_dir = './*' + spec.header_mappings_dir = 'rsocket' + spec.header_dir = 'rsocket' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/DoubleConversion\"/**" } diff --git a/xplat/Sonar/Sonar.podspec b/xplat/Sonar/Sonar.podspec index ad45fba03..b766908bd 100644 --- a/xplat/Sonar/Sonar.podspec +++ b/xplat/Sonar/Sonar.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |spec| spec.authors = 'Facebook' # spec.prepare_command = 'mv src double-conversion' spec.source = { :git => 'https://github.com/facebook/Sonar.git', - :branch => 'master' } + :branch => 'iOS-OSS' } spec.module_name = 'Sonar' spec.public_header_files = 'xplat/Sonar/*.h' spec.source_files = 'xplat/Sonar/*.{h,cpp,m,mm}' From f1a3e6c1bdbae8df4fa787fb8f51a622baab0f5e Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 5 Jun 2018 17:02:27 -0400 Subject: [PATCH 10/44] update --- SonarKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SonarKit.podspec b/SonarKit.podspec index 3b449eccb..11b5bcb3c 100644 --- a/SonarKit.podspec +++ b/SonarKit.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |spec| spec.dependency 'Folly' spec.dependency 'Sonar' spec.dependency 'CocoaAsyncSocket', '~> 7.6' - spec.dependency 'PeerTalk' + # spec.dependency 'PeerTalk' spec.dependency 'OpenSSL-Static', '1.0.2.c1' spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}', 'iOS/SonarKit/FBCxxUtils/*.{h, mm}', spec.public_header_files = 'iOS/SonarKit/CppBridge/*.{h}', From 03ffb3640a7ee21620fc62f9dcccb13b2f5af03c Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Thu, 7 Jun 2018 14:15:34 -0400 Subject: [PATCH 11/44] make everything build --- SonarKit.podspec | 2 +- iOS/Sample/Podfile.lock | 12 +- .../PortForwarding/SKPortForwardingServer.h | 36 +- .../PortForwarding/SKPortForwardingServer.m | 380 +++++++++--------- iOS/third-party-podspecs/Folly.podspec | 4 +- 5 files changed, 217 insertions(+), 217 deletions(-) diff --git a/SonarKit.podspec b/SonarKit.podspec index 11b5bcb3c..3b449eccb 100644 --- a/SonarKit.podspec +++ b/SonarKit.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |spec| spec.dependency 'Folly' spec.dependency 'Sonar' spec.dependency 'CocoaAsyncSocket', '~> 7.6' - # spec.dependency 'PeerTalk' + spec.dependency 'PeerTalk' spec.dependency 'OpenSSL-Static', '1.0.2.c1' spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}', 'iOS/SonarKit/FBCxxUtils/*.{h, mm}', spec.public_header_files = 'iOS/SonarKit/CppBridge/*.{h}', diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index e37b3891d..790647b0b 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -106,19 +106,19 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ComponentKit: - :commit: 368a8b74e1940b9c86b1a883cd7668bc5a204536 + :commit: 73acd7995610ad6b009a9a74b8290a54dab7c716 :git: https://github.com/facebook/ComponentKit.git PeerTalk: :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e :git: https://github.com/rsms/PeerTalk.git RSocket: - :commit: 193002818e53e7a7d73ee362627ddf1fdabc4493 + :commit: 89b368ce04d9b319593815c6a69ad0a681596146 :git: https://github.com/rsocket/rsocket-cpp.git Sonar: - :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 + :commit: f1a3e6c1bdbae8df4fa787fb8f51a622baab0f5e :git: https://github.com/facebook/Sonar.git SonarKit: - :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 + :commit: f1a3e6c1bdbae8df4fa787fb8f51a622baab0f5e :git: https://github.com/facebook/Sonar.git SPEC CHECKSUMS: @@ -132,8 +132,8 @@ SPEC CHECKSUMS: OpenSSL-Static: bd17e34564a8591ad76b740318683a6caa19a13e PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 RSocket: e9ee232080f995ba8f403ccf4cb61238a5646cb6 - Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 - SonarKit: f127bb6582dd1d2590e91937bea9793e95d8a159 + Sonar: a7d8648c0536858abf352d481d57957adf01859b + SonarKit: 926549191a4b239da9274539d8ff28b761b4b1f3 Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 diff --git a/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.h b/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.h index 3118a523b..72d4514a7 100644 --- a/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.h +++ b/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.h @@ -1,18 +1,18 @@ -// /* -// * Copyright (c) 2018-present, Facebook, Inc. -// * -// * This source code is licensed under the MIT license found in the LICENSE -// * file in the root directory of this source tree. -// * -// */ -// #import -// -// @interface SKPortForwardingServer : NSObject -// -// - (instancetype)init; -// -// - (void)listenForMultiplexingChannelOnPort:(NSUInteger)port; -// - (void)forwardConnectionsFromPort:(NSUInteger)port; -// - (void)close; -// -// @end +/* + * Copyright (c) 2018-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#import + +@interface SKPortForwardingServer : NSObject + +- (instancetype)init; + +- (void)listenForMultiplexingChannelOnPort:(NSUInteger)port; +- (void)forwardConnectionsFromPort:(NSUInteger)port; +- (void)close; + +@end diff --git a/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.m b/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.m index f83ca06fd..7bb61075a 100644 --- a/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.m +++ b/iOS/SonarKit/Utilities/PortForwarding/SKPortForwardingServer.m @@ -1,190 +1,190 @@ -// /* -// * Copyright (c) 2018-present, Facebook, Inc. -// * -// * This source code is licensed under the MIT license found in the LICENSE -// * file in the root directory of this source tree. -// * -// */ -// #import "SKPortForwardingServer.h" -// -// #import -// -// #import -// #import -// -// #import "SKMacros.h" -// #import "SKPortForwardingCommon.h" -// -// @interface SKPortForwardingServer () -// -// @property (nonatomic, weak) PTChannel *serverChannel; -// @property (nonatomic, weak) PTChannel *peerChannel; -// -// @property (nonatomic, strong) GCDAsyncSocket *serverSocket; -// @property (nonatomic, strong) NSMutableDictionary *clientSockets; -// @property (nonatomic, assign) UInt32 lastClientSocketTag; -// @property (nonatomic, strong) dispatch_queue_t socketQueue; -// @property (nonatomic, strong) PTProtocol *protocol; -// -// @end -// -// @implementation SKPortForwardingServer -// -// - (instancetype)init -// { -// if (self = [super init]) { -// _socketQueue = dispatch_queue_create("SKPortForwardingServer", DISPATCH_QUEUE_SERIAL); -// _lastClientSocketTag = 0; -// _clientSockets = [NSMutableDictionary dictionary]; -// _protocol = [[PTProtocol alloc] initWithDispatchQueue:_socketQueue]; -// } -// return self; -// } -// -// - (void)dealloc -// { -// [self close]; -// [[NSNotificationCenter defaultCenter] removeObserver:self]; -// } -// -// - (void)forwardConnectionsFromPort:(NSUInteger)port -// { -// [self _forwardConnectionsFromPort:port reportError:YES]; -// [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification *note) { -// [self _forwardConnectionsFromPort:port reportError:NO]; -// }]; -// } -// -// - (void)_forwardConnectionsFromPort:(NSUInteger)port reportError:(BOOL)shouldReportError -// { -// GCDAsyncSocket *serverSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:_socketQueue]; -// NSError *listenError; -// if ([serverSocket acceptOnPort:port error:&listenError]) { -// self.serverSocket = serverSocket; -// } else { -// if (shouldReportError) { -// SKLog(@"Failed to listen: %@", listenError); -// } -// } -// } -// -// - (void)listenForMultiplexingChannelOnPort:(NSUInteger)port -// { -// [self _listenForMultiplexingChannelOnPort:port reportError:YES]; -// [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification *note) { -// [self _listenForMultiplexingChannelOnPort:port reportError:NO]; -// }]; -// } -// -// - (void)_listenForMultiplexingChannelOnPort:(NSUInteger)port reportError:(BOOL)shouldReportError -// { -// PTChannel *channel = [[PTChannel alloc] initWithProtocol:_protocol delegate:self]; -// [channel listenOnPort:port IPv4Address:INADDR_LOOPBACK callback:^(NSError *error) { -// if (error) { -// if (shouldReportError) { -// SKLog(@"Failed to listen on 127.0.0.1:%lu: %@", (unsigned long)port, error); -// } -// } else { -// SKTrace(@"Listening on 127.0.0.1:%lu", (unsigned long)port); -// self.serverChannel = channel; -// } -// }]; -// } -// -// - (void)close -// { -// if (self.serverChannel) { -// [self.serverChannel close]; -// self.serverChannel = nil; -// } -// [self.serverSocket disconnect]; -// } -// -// #pragma mark - PTChannelDelegate -// -// - (void)ioFrameChannel:(PTChannel *)channel didAcceptConnection:(PTChannel *)otherChannel fromAddress:(PTAddress *)address { -// // Cancel any other connection. We are FIFO, so the last connection -// // established will cancel any previous connection and "take its place". -// if (self.peerChannel) { -// [self.peerChannel cancel]; -// } -// -// // Weak pointer to current connection. Connection objects live by themselves -// // (owned by its parent dispatch queue) until they are closed. -// self.peerChannel = otherChannel; -// self.peerChannel.userInfo = address; -// SKTrace(@"Connected to %@", address); -// } -// -// - (void)ioFrameChannel:(PTChannel *)channel didReceiveFrameOfType:(uint32_t)type tag:(uint32_t)tag payload:(PTData *)payload { -// //NSLog(@"didReceiveFrameOfType: %u, %u, %@", type, tag, payload); -// if (type == SKPortForwardingFrameTypeWriteToPipe) { -// GCDAsyncSocket *sock = self.clientSockets[@(tag)]; -// [sock writeData:[NSData dataWithBytes:payload.data length:payload.length] withTimeout:-1 tag:0]; -// SKTrace(@"channel -> socket (%d), %zu bytes", tag, payload.length); -// } -// -// if (type == SKPortForwardingFrameTypeClosePipe) { -// GCDAsyncSocket *sock = self.clientSockets[@(tag)]; -// [sock disconnectAfterWriting]; -// } -// } -// -// - (void)ioFrameChannel:(PTChannel *)channel didEndWithError:(NSError *)error { -// for (GCDAsyncSocket *sock in [_clientSockets objectEnumerator]) { -// [sock setDelegate:nil]; -// [sock disconnect]; -// } -// [self.clientSockets removeAllObjects]; -// SKTrace(@"Disconnected from %@, error = %@", channel.userInfo, error); -// } -// -// -// #pragma mark - GCDAsyncSocketDelegate -// -// - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket -// { -// dispatch_block_t block = ^() { -// if (!self.peerChannel) { -// [newSocket setDelegate:nil]; -// [newSocket disconnect]; -// } -// -// UInt32 tag = ++self->_lastClientSocketTag; -// newSocket.userData = @(tag); -// newSocket.delegate = self; -// self.clientSockets[@(tag)] = newSocket; -// [self.peerChannel sendFrameOfType:SKPortForwardingFrameTypeOpenPipe tag:self->_lastClientSocketTag withPayload:nil callback:^(NSError *error) { -// SKTrace(@"open socket (%d), error = %@", (unsigned int)tag, error); -// [newSocket readDataWithTimeout:-1 tag:0]; -// }]; -// }; -// -// if (_peerChannel) { -// block(); -// } else { -// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), _socketQueue, block); -// } -// } -// -// - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)_ -// { -// UInt32 tag = [[sock userData] unsignedIntValue]; -// SKTrace(@"Incoming data on socket (%d) - %lu bytes", (unsigned int)tag, (unsigned long)data.length); -// [_peerChannel sendFrameOfType:SKPortForwardingFrameTypeWriteToPipe tag:tag withPayload:NSDataToGCDData(data) callback:^(NSError *error) { -// SKTrace(@"socket (%d) -> channel %lu bytes, error = %@", (unsigned int)tag, (unsigned long)data.length, error); -// [sock readDataWithTimeout:-1 tag:_]; -// }]; -// } -// -// - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err -// { -// UInt32 tag = [sock.userData unsignedIntValue]; -// [_clientSockets removeObjectForKey:@(tag)]; -// [_peerChannel sendFrameOfType:SKPortForwardingFrameTypeClosePipe tag:tag withPayload:nil callback:^(NSError *error) { -// SKTrace(@"socket (%d) disconnected, err = %@, peer error = %@", (unsigned int)tag, err, error); -// }]; -// } -// -// -// @end +/* + * Copyright (c) 2018-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#import "SKPortForwardingServer.h" + +#import + +#import +#import + +#import "SKMacros.h" +#import "SKPortForwardingCommon.h" + +@interface SKPortForwardingServer () + +@property (nonatomic, weak) PTChannel *serverChannel; +@property (nonatomic, weak) PTChannel *peerChannel; + +@property (nonatomic, strong) GCDAsyncSocket *serverSocket; +@property (nonatomic, strong) NSMutableDictionary *clientSockets; +@property (nonatomic, assign) UInt32 lastClientSocketTag; +@property (nonatomic, strong) dispatch_queue_t socketQueue; +@property (nonatomic, strong) PTProtocol *protocol; + +@end + +@implementation SKPortForwardingServer + +- (instancetype)init +{ + if (self = [super init]) { + _socketQueue = dispatch_queue_create("SKPortForwardingServer", DISPATCH_QUEUE_SERIAL); + _lastClientSocketTag = 0; + _clientSockets = [NSMutableDictionary dictionary]; + _protocol = [[PTProtocol alloc] initWithDispatchQueue:_socketQueue]; + } + return self; +} + +- (void)dealloc +{ + [self close]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (void)forwardConnectionsFromPort:(NSUInteger)port +{ + [self _forwardConnectionsFromPort:port reportError:YES]; + [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification *note) { + [self _forwardConnectionsFromPort:port reportError:NO]; + }]; +} + +- (void)_forwardConnectionsFromPort:(NSUInteger)port reportError:(BOOL)shouldReportError +{ + GCDAsyncSocket *serverSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:_socketQueue]; + NSError *listenError; + if ([serverSocket acceptOnPort:port error:&listenError]) { + self.serverSocket = serverSocket; + } else { + if (shouldReportError) { + SKLog(@"Failed to listen: %@", listenError); + } + } +} + +- (void)listenForMultiplexingChannelOnPort:(NSUInteger)port +{ + [self _listenForMultiplexingChannelOnPort:port reportError:YES]; + [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification *note) { + [self _listenForMultiplexingChannelOnPort:port reportError:NO]; + }]; +} + +- (void)_listenForMultiplexingChannelOnPort:(NSUInteger)port reportError:(BOOL)shouldReportError +{ + PTChannel *channel = [[PTChannel alloc] initWithProtocol:_protocol delegate:self]; + [channel listenOnPort:port IPv4Address:INADDR_LOOPBACK callback:^(NSError *error) { + if (error) { + if (shouldReportError) { + SKLog(@"Failed to listen on 127.0.0.1:%lu: %@", (unsigned long)port, error); + } + } else { + SKTrace(@"Listening on 127.0.0.1:%lu", (unsigned long)port); + self.serverChannel = channel; + } + }]; +} + +- (void)close +{ + if (self.serverChannel) { + [self.serverChannel close]; + self.serverChannel = nil; + } + [self.serverSocket disconnect]; +} + +#pragma mark - PTChannelDelegate + +- (void)ioFrameChannel:(PTChannel *)channel didAcceptConnection:(PTChannel *)otherChannel fromAddress:(PTAddress *)address { + // Cancel any other connection. We are FIFO, so the last connection + // established will cancel any previous connection and "take its place". + if (self.peerChannel) { + [self.peerChannel cancel]; + } + + // Weak pointer to current connection. Connection objects live by themselves + // (owned by its parent dispatch queue) until they are closed. + self.peerChannel = otherChannel; + self.peerChannel.userInfo = address; + SKTrace(@"Connected to %@", address); +} + +- (void)ioFrameChannel:(PTChannel *)channel didReceiveFrameOfType:(uint32_t)type tag:(uint32_t)tag payload:(PTData *)payload { + //NSLog(@"didReceiveFrameOfType: %u, %u, %@", type, tag, payload); + if (type == SKPortForwardingFrameTypeWriteToPipe) { + GCDAsyncSocket *sock = self.clientSockets[@(tag)]; + [sock writeData:[NSData dataWithBytes:payload.data length:payload.length] withTimeout:-1 tag:0]; + SKTrace(@"channel -> socket (%d), %zu bytes", tag, payload.length); + } + + if (type == SKPortForwardingFrameTypeClosePipe) { + GCDAsyncSocket *sock = self.clientSockets[@(tag)]; + [sock disconnectAfterWriting]; + } +} + +- (void)ioFrameChannel:(PTChannel *)channel didEndWithError:(NSError *)error { + for (GCDAsyncSocket *sock in [_clientSockets objectEnumerator]) { + [sock setDelegate:nil]; + [sock disconnect]; + } + [self.clientSockets removeAllObjects]; + SKTrace(@"Disconnected from %@, error = %@", channel.userInfo, error); +} + + +#pragma mark - GCDAsyncSocketDelegate + +- (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket +{ + dispatch_block_t block = ^() { + if (!self.peerChannel) { + [newSocket setDelegate:nil]; + [newSocket disconnect]; + } + + UInt32 tag = ++self->_lastClientSocketTag; + newSocket.userData = @(tag); + newSocket.delegate = self; + self.clientSockets[@(tag)] = newSocket; + [self.peerChannel sendFrameOfType:SKPortForwardingFrameTypeOpenPipe tag:self->_lastClientSocketTag withPayload:nil callback:^(NSError *error) { + SKTrace(@"open socket (%d), error = %@", (unsigned int)tag, error); + [newSocket readDataWithTimeout:-1 tag:0]; + }]; + }; + + if (_peerChannel) { + block(); + } else { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), _socketQueue, block); + } +} + +- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)_ +{ + UInt32 tag = [[sock userData] unsignedIntValue]; + SKTrace(@"Incoming data on socket (%d) - %lu bytes", (unsigned int)tag, (unsigned long)data.length); + [_peerChannel sendFrameOfType:SKPortForwardingFrameTypeWriteToPipe tag:tag withPayload:NSDataToGCDData(data) callback:^(NSError *error) { + SKTrace(@"socket (%d) -> channel %lu bytes, error = %@", (unsigned int)tag, (unsigned long)data.length, error); + [sock readDataWithTimeout:-1 tag:_]; + }]; +} + +- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err +{ + UInt32 tag = [sock.userData unsignedIntValue]; + [_clientSockets removeObjectForKey:@(tag)]; + [_peerChannel sendFrameOfType:SKPortForwardingFrameTypeClosePipe tag:tag withPayload:nil callback:^(NSError *error) { + SKTrace(@"socket (%d) disconnected, err = %@, peer error = %@", (unsigned int)tag, err, error); + }]; +} + + +@end diff --git a/iOS/third-party-podspecs/Folly.podspec b/iOS/third-party-podspecs/Folly.podspec index 150250f2f..1623e2bfd 100755 --- a/iOS/third-party-podspecs/Folly.podspec +++ b/iOS/third-party-podspecs/Folly.podspec @@ -11,8 +11,8 @@ Pod::Spec.new do |spec| spec.dependency 'boost-for-react-native' spec.dependency 'DoubleConversion' spec.dependency 'glog' - #spec.dependency 'OpenSSL-Static', '1.0.2.c1' - #spec.dependency 'CocoaLibEvent', '~> 1.0' + spec.dependency 'OpenSSL-Static', '1.0.2.c1' + spec.dependency 'CocoaLibEvent', '~> 1.0' spec.compiler_flags = '-DFOLLY_HAVE_PTHREAD=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti -fexceptions -std=c++14 From 4a989cf8ef6acb21f427c13bd6210bd392053538 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Thu, 7 Jun 2018 15:13:18 -0400 Subject: [PATCH 12/44] update glog podspec --- iOS/Podfile.lock | 16 +++++------ iOS/Sample/Podfile.lock | 4 +-- iOS/scripts/ios-configure-glog.sh | 41 --------------------------- iOS/third-party-podspecs/glog.podspec | 2 +- 4 files changed, 11 insertions(+), 52 deletions(-) delete mode 100644 iOS/scripts/ios-configure-glog.sh diff --git a/iOS/Podfile.lock b/iOS/Podfile.lock index b3ef3b191..f4309de83 100644 --- a/iOS/Podfile.lock +++ b/iOS/Podfile.lock @@ -8,9 +8,9 @@ PODS: - CocoaLibEvent (~> 1.0) - DoubleConversion - glog - - OpenSSL-Universal (~> 1.0) + - OpenSSL-Static (= 1.0.2.c1) - glog (0.3.5) - - OpenSSL-Universal (1.0.2.13) + - OpenSSL-Static (1.0.2.c1) - PeerTalk (1.0.0) - RSocket (0.10.0): - Folly @@ -32,7 +32,7 @@ SPEC REPOS: - boost-for-react-native - CocoaAsyncSocket - CocoaLibEvent - - OpenSSL-Universal + - OpenSSL-Static EXTERNAL SOURCES: DoubleConversion: @@ -53,10 +53,10 @@ CHECKOUT OPTIONS: :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e :git: https://github.com/rsms/PeerTalk.git RSocket: - :commit: 193002818e53e7a7d73ee362627ddf1fdabc4493 + :commit: 89b368ce04d9b319593815c6a69ad0a681596146 :git: https://github.com/rsocket/rsocket-cpp.git Sonar: - :commit: 8d48f5a3eb26c6e982abefa30f5a8e0c19b5b4a6 + :commit: 03ffb3640a7ee21620fc62f9dcccb13b2f5af03c :git: https://github.com/facebook/Sonar.git SPEC CHECKSUMS: @@ -64,12 +64,12 @@ SPEC CHECKSUMS: CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: 9bd61b1134a393694e95e0950c5bf3f99534817f - Folly: ce1c216bcb099ca6cda58fefbba02bf2e9fe0381 + Folly: 551752534f77d816ebf69195405d9d0fbd3efcc0 glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 - OpenSSL-Universal: 401888162f11c33ebbd46f782d9229da35c61327 + OpenSSL-Static: bd17e34564a8591ad76b740318683a6caa19a13e PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 RSocket: e9ee232080f995ba8f403ccf4cb61238a5646cb6 - Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 + Sonar: a7d8648c0536858abf352d481d57957adf01859b PODFILE CHECKSUM: a6a7b2201d324f787ef4956b045f021e7152fddf diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 790647b0b..906438daa 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -115,10 +115,10 @@ CHECKOUT OPTIONS: :commit: 89b368ce04d9b319593815c6a69ad0a681596146 :git: https://github.com/rsocket/rsocket-cpp.git Sonar: - :commit: f1a3e6c1bdbae8df4fa787fb8f51a622baab0f5e + :commit: 03ffb3640a7ee21620fc62f9dcccb13b2f5af03c :git: https://github.com/facebook/Sonar.git SonarKit: - :commit: f1a3e6c1bdbae8df4fa787fb8f51a622baab0f5e + :commit: 03ffb3640a7ee21620fc62f9dcccb13b2f5af03c :git: https://github.com/facebook/Sonar.git SPEC CHECKSUMS: diff --git a/iOS/scripts/ios-configure-glog.sh b/iOS/scripts/ios-configure-glog.sh deleted file mode 100644 index e6a15febb..000000000 --- a/iOS/scripts/ios-configure-glog.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -set -e - -PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}" -CURRENT_ARCH="${CURRENT_ARCH:-armv7}" - -export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)" -export CXX="$CC" - -# Remove automake symlink if it exists -if [ -h "test-driver" ]; then - rm test-driver -fi - -./configure --host arm-apple-darwin - -# Fix build for tvOS -cat << EOF >> src/config.h - -/* Add in so we have Apple Target Conditionals */ -#ifdef __APPLE__ -#include -#include -#endif - -/* Special configuration for AppleTVOS */ -#if TARGET_OS_TV -#undef HAVE_SYSCALL_H -#undef HAVE_SYS_SYSCALL_H -#undef OS_MACOSX -#endif - -/* Special configuration for ucontext */ -#undef HAVE_UCONTEXT_H -#undef PC_FROM_UCONTEXT -#if defined(__x86_64__) -#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip -#elif defined(__i386__) -#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip -#endif -EOF diff --git a/iOS/third-party-podspecs/glog.podspec b/iOS/third-party-podspecs/glog.podspec index e0dbd2f2d..3524ba47e 100755 --- a/iOS/third-party-podspecs/glog.podspec +++ b/iOS/third-party-podspecs/glog.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |spec| spec.homepage = 'https://github.com/google/glog' spec.summary = 'Google logging module' spec.authors = 'Google' - spec.prepare_command = File.read("../scripts/ios-configure-glog.sh") + spec.prepare_command = "#!/bin/bash\nset -e\n\nPLATFORM_NAME=\"${PLATFORM_NAME:-iphoneos}\"\nCURRENT_ARCH=\"${CURRENT_ARCH:-armv7}\"\n\nexport CC=\"$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)\"\nexport CXX=\"$CC\"\n\n# Remove automake symlink if it exists\nif [ -h \"test-driver\" ]; then\n rm test-driver\nfi\n\n./configure --host arm-apple-darwin\n\n# Fix build for tvOS\ncat << EOF >> src/config.h\n\n/* Add in so we have Apple Target Conditionals */\n#ifdef __APPLE__\n#include \n#include \n#endif\n\n/* Special configuration for AppleTVOS */\n#if TARGET_OS_TV\n#undef HAVE_SYSCALL_H\n#undef HAVE_SYS_SYSCALL_H\n#undef OS_MACOSX\n#endif\n\n/* Special configuration for ucontext */\n#undef HAVE_UCONTEXT_H\n#undef PC_FROM_UCONTEXT\n#if defined(__x86_64__)\n#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip\n#elif defined(__i386__)\n#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip\n#endif\nEOF" spec.source = { :git => 'https://github.com/google/glog.git', :tag => "v#{spec.version}" } spec.module_name = 'glog' From 6463ce890c0d8816657182a295018ee9f161c466 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 11 Jun 2018 11:58:28 +0100 Subject: [PATCH 13/44] update the reference from iOS-OSS to master --- SonarKit.podspec | 3 +-- iOS/Podfile | 2 -- iOS/Podfile.lock | 8 ++++---- xplat/Sonar/Sonar.podspec | 4 +--- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/SonarKit.podspec b/SonarKit.podspec index 3b449eccb..238aecde2 100644 --- a/SonarKit.podspec +++ b/SonarKit.podspec @@ -10,9 +10,8 @@ Pod::Spec.new do |spec| spec.summary = 'Sonar iOS podspec' spec.authors = 'Facebook' spec.static_framework = true - # spec.prepare_command = 'mv src double-conversion' spec.source = { :git => 'https://github.com/facebook/Sonar.git', - :branch=> "iOS-OSS" } + :branch=> "master" } spec.module_name = 'SonarKit' spec.dependency 'Folly' spec.dependency 'Sonar' diff --git a/iOS/Podfile b/iOS/Podfile index 88b7f0547..63a63d759 100644 --- a/iOS/Podfile +++ b/iOS/Podfile @@ -9,8 +9,6 @@ target 'SonarKit' do # Pods for SonarKit - # Third party deps podspec link - # pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' pod 'PeerTalk', :podspec => 'third-party-podspecs/PeerTalk.podspec' pod 'RSocket', :podspec => 'third-party-podspecs/RSocket.podspec' pod 'DoubleConversion', :podspec => 'third-party-podspecs/DoubleConversion.podspec' diff --git a/iOS/Podfile.lock b/iOS/Podfile.lock index f4309de83..1cf648505 100644 --- a/iOS/Podfile.lock +++ b/iOS/Podfile.lock @@ -53,10 +53,10 @@ CHECKOUT OPTIONS: :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e :git: https://github.com/rsms/PeerTalk.git RSocket: - :commit: 89b368ce04d9b319593815c6a69ad0a681596146 + :commit: 11491fb22aaaf29b2702a1723561db51b314dd0f :git: https://github.com/rsocket/rsocket-cpp.git Sonar: - :commit: 03ffb3640a7ee21620fc62f9dcccb13b2f5af03c + :commit: e6f1e3f018cb4eb8d1d1bfd09851a780f08656fd :git: https://github.com/facebook/Sonar.git SPEC CHECKSUMS: @@ -69,8 +69,8 @@ SPEC CHECKSUMS: OpenSSL-Static: bd17e34564a8591ad76b740318683a6caa19a13e PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 RSocket: e9ee232080f995ba8f403ccf4cb61238a5646cb6 - Sonar: a7d8648c0536858abf352d481d57957adf01859b + Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 -PODFILE CHECKSUM: a6a7b2201d324f787ef4956b045f021e7152fddf +PODFILE CHECKSUM: c3be9232e8e3190250398e3f9b310c5585d7d26b COCOAPODS: 1.5.2 diff --git a/xplat/Sonar/Sonar.podspec b/xplat/Sonar/Sonar.podspec index b766908bd..e32744c57 100644 --- a/xplat/Sonar/Sonar.podspec +++ b/xplat/Sonar/Sonar.podspec @@ -5,9 +5,8 @@ Pod::Spec.new do |spec| spec.homepage = 'https://github.com/facebook/sonar' spec.summary = 'SonarKit core cpp code with network implementation' spec.authors = 'Facebook' - # spec.prepare_command = 'mv src double-conversion' spec.source = { :git => 'https://github.com/facebook/Sonar.git', - :branch => 'iOS-OSS' } + :branch => 'master' } spec.module_name = 'Sonar' spec.public_header_files = 'xplat/Sonar/*.h' spec.source_files = 'xplat/Sonar/*.{h,cpp,m,mm}' @@ -22,4 +21,3 @@ Pod::Spec.new do |spec| "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/RSocket\" \"$(PODS_ROOT)/DoubleConversion\"" } end -# \"/usr/local/include\" \"/usr/local/Cellar/openssl/1.0.2o_1/include\" From 4ae30bd786afc79d522a7fc2edd9895832018b5a Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 11 Jun 2018 14:28:33 +0100 Subject: [PATCH 14/44] remove duplicate code block --- SonarKit.podspec | 10 ---------- iOS/Sample/Podfile.lock | 11 +++++------ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/SonarKit.podspec b/SonarKit.podspec index 238aecde2..c5746c65f 100644 --- a/SonarKit.podspec +++ b/SonarKit.podspec @@ -75,16 +75,6 @@ Pod::Spec.new do |spec| "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } end - spec.subspec "SonarKitNetworkPlugin" do |ss| - ss.public_header_files = 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SonarKitNetworkPlugin.h', - 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKBufferingPlugin.h', - 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKDispatchQueue.h', - 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKNetworkReporter.h' - ss.source_files = "iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/*.{h,cpp,m,mm}" - ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } - end - spec.subspec "SKIOSNetworkPlugin" do |ss| ss.dependency 'SonarKit/SonarKitNetworkPlugin' ss.public_header_files = 'iOS/Plugins/SonarKitNetworkPlugin/SKIOSNetworkPlugin/SKIOSNetworkAdapter.h' diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 906438daa..9fce57f8c 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -29,7 +29,6 @@ PODS: - SonarKit/SonarKitLayoutComponentKitSupport (= 0.0.1) - SonarKit/SonarKitLayoutPlugin (= 0.0.1) - SonarKit/SonarKitNetworkPlugin (= 0.0.1) - - SonarKit/SonarKitNetworkPlugin (= 0.0.1) - SonarKit/SKIOSNetworkPlugin (0.0.1): - CocoaAsyncSocket (~> 7.6) - Folly @@ -112,13 +111,13 @@ CHECKOUT OPTIONS: :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e :git: https://github.com/rsms/PeerTalk.git RSocket: - :commit: 89b368ce04d9b319593815c6a69ad0a681596146 + :commit: 11491fb22aaaf29b2702a1723561db51b314dd0f :git: https://github.com/rsocket/rsocket-cpp.git Sonar: - :commit: 03ffb3640a7ee21620fc62f9dcccb13b2f5af03c + :commit: a0959cf41cb51e7571066877ee2b7090659913b8 :git: https://github.com/facebook/Sonar.git SonarKit: - :commit: 03ffb3640a7ee21620fc62f9dcccb13b2f5af03c + :commit: a0959cf41cb51e7571066877ee2b7090659913b8 :git: https://github.com/facebook/Sonar.git SPEC CHECKSUMS: @@ -132,8 +131,8 @@ SPEC CHECKSUMS: OpenSSL-Static: bd17e34564a8591ad76b740318683a6caa19a13e PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 RSocket: e9ee232080f995ba8f403ccf4cb61238a5646cb6 - Sonar: a7d8648c0536858abf352d481d57957adf01859b - SonarKit: 926549191a4b239da9274539d8ff28b761b4b1f3 + Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 + SonarKit: ac1fff5cc54ddb394282e78542ae67a781dab4f5 Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 From 1cc2d46be9097eb73cf99f300105c1a719b908d9 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Mon, 11 Jun 2018 08:25:15 -0700 Subject: [PATCH 15/44] Create CNAME --- CNAME | 1 + 1 file changed, 1 insertion(+) create mode 100644 CNAME diff --git a/CNAME b/CNAME new file mode 100644 index 000000000..cd7f9e71a --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +fbsonar.com \ No newline at end of file From f7d487dd7607226858ecb3380b889969d5e9a073 Mon Sep 17 00:00:00 2001 From: Daniel Buchele Date: Tue, 12 Jun 2018 03:39:09 -0700 Subject: [PATCH 16/44] fbshipit-source-id: 2cd940396d650342920b28835f6e672febe6b55c --- CNAME | 1 - android/sample/AndroidManifest.xml | 3 +- build.gradle | 2 +- docs/getting-started.md | 59 +- flow-typed/electron-menu.js | 35 +- .../CKComponent+Sonar.mm | 25 +- iOS/Podfile | 7 +- iOS/Podfile.lock | 76 - iOS/Sample/Podfile | 13 +- iOS/Sample/Podfile.lock | 101 +- iOS/Sample/Sample.xcodeproj/project.pbxproj | 4 + SonarKit.podspec => iOS/SonarKit.podspec | 30 +- iOS/SonarKit.xcodeproj/project.pbxproj | 1245 +++++++++-------- .../CppBridge/SonarCppBridgingConnection.mm | 7 +- .../CppBridge/SonarCppBridgingResponder.mm | 6 +- .../FBCxxUtils/FBCxxFollyDynamicConvert.h | 14 - iOS/SonarKit/Info.plist | 24 - iOS/SonarKit/SKUtils.h | 52 + ...FBCxxFollyDynamicConvert.mm => SKUtils.mm} | 172 ++- iOS/SonarKit/SonarClient.mm | 14 +- iOS/scripts/ios-configure-glog.sh | 41 + .../DoubleConversion.podspec | 2 +- iOS/third-party-podspecs/EasyWSClient.podspec | 17 + iOS/third-party-podspecs/Folly.podspec | 43 +- iOS/third-party-podspecs/LibEvent.podspec | 29 - iOS/third-party-podspecs/PeerTalk.podspec | 19 - iOS/third-party-podspecs/RSocket.podspec | 53 - iOS/third-party-podspecs/glog.podspec | 4 +- package.json | 2 +- scripts/public-build.sh | 6 +- src/device-plugins/screen/index.js | 8 +- src/server.js | 2 +- src/ui/components/VirtualList.js | 2 +- src/ui/components/desktop-toolbar.js | 4 +- src/ui/components/table/TableHead.js | 2 +- src/utils/openssl-wrapper-with-promises.js | 3 +- src/utils/snap.js | 2 +- website/core/Footer.js | 2 +- website/static/css/custom.css | 6 + .../{Sonar.podspec => SonarKitCPP.podspec} | 18 +- xplat/Sonar/SonarWebSocketImpl.cpp | 19 +- yarn.lock | 6 +- 42 files changed, 1100 insertions(+), 1080 deletions(-) delete mode 100644 CNAME delete mode 100644 iOS/Podfile.lock rename SonarKit.podspec => iOS/SonarKit.podspec (79%) delete mode 100644 iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.h delete mode 100644 iOS/SonarKit/Info.plist create mode 100644 iOS/SonarKit/SKUtils.h rename iOS/SonarKit/{FBCxxUtils/FBCxxFollyDynamicConvert.mm => SKUtils.mm} (63%) create mode 100644 iOS/scripts/ios-configure-glog.sh create mode 100644 iOS/third-party-podspecs/EasyWSClient.podspec delete mode 100644 iOS/third-party-podspecs/LibEvent.podspec delete mode 100644 iOS/third-party-podspecs/PeerTalk.podspec delete mode 100644 iOS/third-party-podspecs/RSocket.podspec rename xplat/Sonar/{Sonar.podspec => SonarKitCPP.podspec} (67%) diff --git a/CNAME b/CNAME deleted file mode 100644 index cd7f9e71a..000000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -fbsonar.com \ No newline at end of file diff --git a/android/sample/AndroidManifest.xml b/android/sample/AndroidManifest.xml index 5d52b59f9..afce9381e 100644 --- a/android/sample/AndroidManifest.xml +++ b/android/sample/AndroidManifest.xml @@ -16,7 +16,8 @@ android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:allowBackup="false" - android:theme="@style/NoTitleBarWhiteBG"> + android:theme="@style/NoTitleBarWhiteBG" + android:debuggable="true"> diff --git a/build.gradle b/build.gradle index 6a444bec6..66b141600 100644 --- a/build.gradle +++ b/build.gradle @@ -25,8 +25,8 @@ buildscript { subprojects { repositories { - jcenter() google() + jcenter() } } diff --git a/docs/getting-started.md b/docs/getting-started.md index 6b4428817..452e25df1 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -23,11 +23,7 @@ Once you start Sonar and launch an emulator/simulator or connect a device, you w ### Setup your Android app -#### Including Sonar via jcenter - -**Sonar is still being deployed to jcenter so you may need to include the .aar manually.** - -Add dependencies to your `build.gradle` file. +Sonar is distributed via JCenter. Add dependencies to your `build.gradle` file. ``` repositories { @@ -39,23 +35,6 @@ dependencies { } ``` -#### Manually including sonar.aar - -Download the latest .aar from [GitHub releases](https://github.com/facebook/Sonar/releases) and put it in your app's libs/ folder. - -``` -repositories { - jcenter() - flatDir { - dirs 'libs' - } -} - -dependencies { - debugCompile(name:'sonar-0.0.1', ext:'aar') -} -``` - Now you can initialize Sonar in your Application's `onCreate`-method like this: ```java @@ -76,20 +55,42 @@ public class MyApplication extends Application { ### Setup your iOS app -To integrate with our iOS app, you can use [CocoaPods](https://cocoapods.org). Add the mobile Sonar SDK to your `Podfile`: +To integrate with an iOS app, you can use [CocoaPods](https://cocoapods.org). Add the mobile Sonar SDK and its dependencies to your `Podfile`: ```ruby platform :ios, '8.0' +swift_version = '4.1' target 'MyApp' do - pod 'Sonar', '~> 0.0.1' -en + + pod 'RSocket', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/RSocket.podspec?token=ADr9NE_I05Vu8g7oq_g6g_9FLx784NFmks5bJ5LvwA%3D%3D' + pod 'DoubleConversion', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/DoubleConversion.podspec?token=ADr9NOxtIEmr5ODP9PWq6-sht-Ye6UYGks5bJ5MjwA%3D%3D' + pod 'glog', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/glog.podspec?token=ADr9NBHbrlbkFR3DQTPzj0CnZdria4jvks5bJ5M3wA%3D%3D' + pod 'Folly', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/Folly.podspec?token=ADr9NNTjwJ8xqLFwc3Qz3xB3GsCk-Esmks5bJ5NGwA%3D%3D' + pod 'PeerTalk', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/PeerTalk.podspec?token=ADr9NB8frQTrUWytsMXtdv_P8km7jV_Mks5bJ5NbwA%3D%3D' + pod 'Yoga','~>1.8.1', :modular_headers => true + pod 'Sonar', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/xplat/Sonar/Sonar.podspec?token=ADr9NFO7byH9uAuhGAIEYuoJeBNyBxf6ks5bJ5N8wA%3D%3D' + pod 'SonarKit', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/SonarKit.podspec?token=ADr9NBuYoodM_NeysQg899hkxXw0WZ7Xks5bJ5OVwA%3D%3D' + pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/SonarKit.podspec?token=ADr9NBuYoodM_NeysQg899hkxXw0WZ7Xks5bJ5OVwA%3D%3D' + pod 'SonarKit/SKIOSNetworkPlugin', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/SonarKit.podspec?token=ADr9NBuYoodM_NeysQg899hkxXw0WZ7Xks5bJ5OVwA%3D%3D' + pod 'ComponentKit', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/ComponentKit.podspec?token=ADr9NNV9gqkpFTUKaHpCiYOZIG3Ev-Hyks5bJ5O-wA%3D%3D' + post_install do |installer| + installer.pods_project.targets.each do |target| + if ['YogaKit'].include? target.name + target.build_configurations.each do |config| + config.build_settings['SWIFT_VERSION'] = swift_version + end + end + end + end +end + ``` and install the dependencies by running `pod install`. When you open the Xcode workspace file for your app, you now can import and initialize Sonar in your AppDelegate. ```objective-c -#import +#import @implementation AppDelegate @@ -104,6 +105,12 @@ and install the dependencies by running `pod install`. When you open the Xcode w } @end ``` +
+ +* We haven't released the dependency to CocoaPods, because we weren't able to successfully validate the podspec of SonarKit. You could help us out by fixing this [issue](https://github.com/facebook/Sonar/issues/11) by submitting a PR to the repo. +* If you do not use CocoaPods as a dependency management tool then currently there is no way to integrate SonarKit other than manually including all the dependencies and building it. +* Also Sonar doesn't work with swift projects as its written in C++ and had C++ dependencies. But we are working on supporting sonar for swift projects. You can find this issue [here](https://github.com/facebook/Sonar/issues/13) +
## Ready for takeoff diff --git a/flow-typed/electron-menu.js b/flow-typed/electron-menu.js index c18519784..46a34b912 100644 --- a/flow-typed/electron-menu.js +++ b/flow-typed/electron-menu.js @@ -31,7 +31,12 @@ type Electron$MenuRoles = | 'help' | 'services'; -type Electron$MenuType = 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'; +type Electron$MenuType = + | 'normal' + | 'separator' + | 'submenu' + | 'checkbox' + | 'radio'; type Electron$MenuItemOptions = { click?: ( @@ -54,25 +59,27 @@ type Electron$MenuItemOptions = { }; declare class Electron$MenuItem { - constructor: (options: Electron$MenuItemOptions) => void, - enabled: boolean, - visible: boolean, - checked: boolean, + constructor: (options: Electron$MenuItemOptions) => void; + enabled: boolean; + visible: boolean; + checked: boolean; } declare class Electron$Menu { - static setApplicationMenu: (menu: Electron$Menu) => void, - static getApplicationMenu: () => ?Electron$Menu, - static sendActionToFirstResponder: (action: string) => void, - static buildFromTemplate: (templates: Array) => Electron$Menu, + static setApplicationMenu: (menu: Electron$Menu) => void; + static getApplicationMenu: () => ?Electron$Menu; + static sendActionToFirstResponder: (action: string) => void; + static buildFromTemplate: ( + templates: Array, + ) => Electron$Menu; popup: ( browserWindow: Object, x?: number, y?: number, positioningItem?: number, - ) => void, - popup: (x?: number, y?: number, positioningItem?: number) => void, - append: (menuItem: Electron$MenuItem) => void, - insert: (pos: number, menuItem: Electron$MenuItem) => void, - items: Array, + ) => void; + popup: (x?: number, y?: number, positioningItem?: number) => void; + append: (menuItem: Electron$MenuItem) => void; + insert: (pos: number, menuItem: Electron$MenuItem) => void; + items: Array; } diff --git a/iOS/Plugins/SonarKitLayoutPlugin/SonarKitLayoutComponentKitSupport/CKComponent+Sonar.mm b/iOS/Plugins/SonarKitLayoutPlugin/SonarKitLayoutComponentKitSupport/CKComponent+Sonar.mm index 22e34ab78..8cf04e1ee 100644 --- a/iOS/Plugins/SonarKitLayoutPlugin/SonarKitLayoutComponentKitSupport/CKComponent+Sonar.mm +++ b/iOS/Plugins/SonarKitLayoutPlugin/SonarKitLayoutComponentKitSupport/CKComponent+Sonar.mm @@ -115,14 +115,23 @@ FB_LINKABLE(CKComponent_Sonar) } for (auto responder : action.second) { - id initialTarget = _CKTypedComponentDebugInitialTarget(responder).get(self); - const CKActionInfo actionInfo = CKActionFind(responder.selector(), initialTarget); - [responders addObject: @{ - @"initialTarget": SKObject(NSStringFromClass([initialTarget class])), - @"identifier": SKObject(@(responder.identifier().c_str())), - @"handler": SKObject(NSStringFromClass([actionInfo.responder class])), - @"selector": SKObject(NSStringFromSelector(responder.selector())), - }]; + auto debugTarget = _CKTypedComponentDebugInitialTarget(responder); + if (debugTarget.isBlockBaseAction()) { + [responders addObject: @{ + @"identifier": SKObject(@(responder.identifier().c_str())), + @"selector": SKObject(NSStringFromSelector(responder.selector())), + }]; + + } else { + id initialTarget = debugTarget.get(self); + const CKActionInfo actionInfo = CKActionFind(responder.selector(), initialTarget); + [responders addObject: @{ + @"initialTarget": SKObject(NSStringFromClass([initialTarget class])), + @"identifier": SKObject(@(responder.identifier().c_str())), + @"handler": SKObject(NSStringFromClass([actionInfo.responder class])), + @"selector": SKObject(NSStringFromSelector(responder.selector())), + }]; + } } } diff --git a/iOS/Podfile b/iOS/Podfile index 63a63d759..056604147 100644 --- a/iOS/Podfile +++ b/iOS/Podfile @@ -9,11 +9,12 @@ target 'SonarKit' do # Pods for SonarKit - pod 'PeerTalk', :podspec => 'third-party-podspecs/PeerTalk.podspec' - pod 'RSocket', :podspec => 'third-party-podspecs/RSocket.podspec' + # Third party deps podspec link + pod 'EasyWSClient', :podspec => 'third-party-podspecs/EasyWSClient.podspec' pod 'DoubleConversion', :podspec => 'third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => 'third-party-podspecs/glog.podspec' pod 'Folly', :podspec => 'third-party-podspecs/Folly.podspec' - pod 'Sonar', :podspec => '../xplat/Sonar/Sonar.podspec' + pod 'Sonar', :podspec => '../xplat/Sonar/SonarKitCPP.podspec' pod 'CocoaAsyncSocket' + pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' end diff --git a/iOS/Podfile.lock b/iOS/Podfile.lock deleted file mode 100644 index 1cf648505..000000000 --- a/iOS/Podfile.lock +++ /dev/null @@ -1,76 +0,0 @@ -PODS: - - boost-for-react-native (1.63.0) - - CocoaAsyncSocket (7.6.3) - - CocoaLibEvent (1.0.0) - - DoubleConversion (3.0.0) - - Folly (2018.05.28.00): - - boost-for-react-native - - CocoaLibEvent (~> 1.0) - - DoubleConversion - - glog - - OpenSSL-Static (= 1.0.2.c1) - - glog (0.3.5) - - OpenSSL-Static (1.0.2.c1) - - PeerTalk (1.0.0) - - RSocket (0.10.0): - - Folly - - Sonar (0.0.1): - - Folly - - RSocket - -DEPENDENCIES: - - CocoaAsyncSocket - - DoubleConversion (from `third-party-podspecs/DoubleConversion.podspec`) - - Folly (from `third-party-podspecs/Folly.podspec`) - - glog (from `third-party-podspecs/glog.podspec`) - - PeerTalk (from `third-party-podspecs/PeerTalk.podspec`) - - RSocket (from `third-party-podspecs/RSocket.podspec`) - - Sonar (from `../xplat/Sonar/Sonar.podspec`) - -SPEC REPOS: - https://github.com/cocoapods/specs.git: - - boost-for-react-native - - CocoaAsyncSocket - - CocoaLibEvent - - OpenSSL-Static - -EXTERNAL SOURCES: - DoubleConversion: - :podspec: third-party-podspecs/DoubleConversion.podspec - Folly: - :podspec: third-party-podspecs/Folly.podspec - glog: - :podspec: third-party-podspecs/glog.podspec - PeerTalk: - :podspec: third-party-podspecs/PeerTalk.podspec - RSocket: - :podspec: third-party-podspecs/RSocket.podspec - Sonar: - :podspec: "../xplat/Sonar/Sonar.podspec" - -CHECKOUT OPTIONS: - PeerTalk: - :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e - :git: https://github.com/rsms/PeerTalk.git - RSocket: - :commit: 11491fb22aaaf29b2702a1723561db51b314dd0f - :git: https://github.com/rsocket/rsocket-cpp.git - Sonar: - :commit: e6f1e3f018cb4eb8d1d1bfd09851a780f08656fd - :git: https://github.com/facebook/Sonar.git - -SPEC CHECKSUMS: - boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c - CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 - CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f - DoubleConversion: 9bd61b1134a393694e95e0950c5bf3f99534817f - Folly: 551752534f77d816ebf69195405d9d0fbd3efcc0 - glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 - OpenSSL-Static: bd17e34564a8591ad76b740318683a6caa19a13e - PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 - RSocket: e9ee232080f995ba8f403ccf4cb61238a5646cb6 - Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 - -PODFILE CHECKSUM: c3be9232e8e3190250398e3f9b310c5585d7d26b - -COCOAPODS: 1.5.2 diff --git a/iOS/Sample/Podfile b/iOS/Sample/Podfile index 2e86e349a..70f73b4a3 100644 --- a/iOS/Sample/Podfile +++ b/iOS/Sample/Podfile @@ -6,17 +6,18 @@ swift_version = "4.1" target 'Sample' do - pod 'RSocket', :podspec => '../third-party-podspecs/RSocket.podspec' + pod 'EasyWSClient', :podspec => '../third-party-podspecs/EasyWSClient.podspec' pod 'DoubleConversion', :podspec => '../third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../third-party-podspecs/Folly.podspec' - pod 'PeerTalk', :podspec => '../third-party-podspecs/PeerTalk.podspec' + pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' pod 'ComponentKit', :podspec => '../third-party-podspecs/ComponentKit.podspec' pod 'Yoga','~>1.8.1', :modular_headers => true - pod 'Sonar', :podspec => '../../xplat/Sonar/Sonar.podspec' - pod 'SonarKit', :podspec => '../../SonarKit.podspec' - pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => '../../SonarKit.podspec' - pod 'SonarKit/SKIOSNetworkPlugin', :podspec => '../../SonarKit.podspec' + pod 'Sonar', :podspec => '../../xplat/Sonar/SonarKitCPP.podspec' + pod 'SonarKit', :podspec => '../SonarKit.podspec' + pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => '../SonarKit.podspec' + pod 'SonarKit/SKIOSNetworkPlugin', :podspec => '../SonarKit.podspec' + post_install do |installer| installer.pods_project.targets.each do |target| if ['YogaKit'].include? target.name diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 9fce57f8c..399025b3e 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -1,62 +1,53 @@ PODS: - boost-for-react-native (1.63.0) - CocoaAsyncSocket (7.6.3) - - CocoaLibEvent (1.0.0) - ComponentKit (0.21): - Yoga - DoubleConversion (3.0.0) - - Folly (2018.05.28.00): + - EasyWSClient (1.0.0) + - Folly (2018.05.07.00): - boost-for-react-native - - CocoaLibEvent (~> 1.0) - DoubleConversion - glog - - OpenSSL-Static (= 1.0.2.c1) - glog (0.3.5) - - OpenSSL-Static (1.0.2.c1) - - PeerTalk (1.0.0) - - RSocket (0.10.0): + - PeerTalk (0.0.2) + - Sonar (1.0.0): + - EasyWSClient - Folly - - Sonar (0.0.1): - - Folly - - RSocket - - SonarKit (0.0.1): + - SonarKit (1.0.0): - CocoaAsyncSocket (~> 7.6) - Folly - - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - - SonarKit/SKIOSNetworkPlugin (= 0.0.1) - - SonarKit/SonarKitLayoutComponentKitSupport (= 0.0.1) - - SonarKit/SonarKitLayoutPlugin (= 0.0.1) - - SonarKit/SonarKitNetworkPlugin (= 0.0.1) - - SonarKit/SKIOSNetworkPlugin (0.0.1): + - SonarKit/SKIOSNetworkPlugin (= 1.0.0) + - SonarKit/SonarKitLayoutComponentKitSupport (= 1.0.0) + - SonarKit/SonarKitLayoutPlugin (= 1.0.0) + - SonarKit/SonarKitNetworkPlugin (= 1.0.0) + - SonarKit/SonarKitNetworkPlugin (= 1.0.0) + - SonarKit/SKIOSNetworkPlugin (1.0.0): - CocoaAsyncSocket (~> 7.6) - Folly - - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - SonarKit/SonarKitNetworkPlugin - - SonarKit/SonarKitLayoutComponentKitSupport (0.0.1): + - SonarKit/SonarKitLayoutComponentKitSupport (1.0.0): - CocoaAsyncSocket (~> 7.6) - ComponentKit - Folly - - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - SonarKit/SonarKitLayoutPlugin - - Yoga (~> 1.8) - - SonarKit/SonarKitLayoutPlugin (0.0.1): + - Yoga (= 1.8.1) + - SonarKit/SonarKitLayoutPlugin (1.0.0): - CocoaAsyncSocket (~> 7.6) - Folly - - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - - Yoga (~> 1.8) + - Yoga (= 1.8.1) - YogaKit (= 1.8.1) - - SonarKit/SonarKitNetworkPlugin (0.0.1): + - SonarKit/SonarKitNetworkPlugin (1.0.0): - CocoaAsyncSocket (~> 7.6) - Folly - - OpenSSL-Static (= 1.0.2.c1) - PeerTalk - Sonar - Yoga (1.8.1) @@ -66,22 +57,20 @@ PODS: DEPENDENCIES: - ComponentKit (from `../third-party-podspecs/ComponentKit.podspec`) - DoubleConversion (from `../third-party-podspecs/DoubleConversion.podspec`) + - EasyWSClient (from `../third-party-podspecs/EasyWSClient.podspec`) - Folly (from `../third-party-podspecs/Folly.podspec`) - glog (from `../third-party-podspecs/glog.podspec`) - - PeerTalk (from `../third-party-podspecs/PeerTalk.podspec`) - - RSocket (from `../third-party-podspecs/RSocket.podspec`) - - Sonar (from `../../xplat/Sonar/Sonar.podspec`) - - SonarKit (from `../../SonarKit.podspec`) - - SonarKit/SKIOSNetworkPlugin (from `../../SonarKit.podspec`) - - SonarKit/SonarKitLayoutComponentKitSupport (from `../../SonarKit.podspec`) + - PeerTalk (from `https://github.com/rsms/peertalk`) + - Sonar (from `../../xplat/Sonar/SonarKitCPP.podspec`) + - SonarKit (from `../SonarKit.podspec`) + - SonarKit/SKIOSNetworkPlugin (from `../SonarKit.podspec`) + - SonarKit/SonarKitLayoutComponentKitSupport (from `../SonarKit.podspec`) - Yoga (~> 1.8.1) SPEC REPOS: https://github.com/cocoapods/specs.git: - boost-for-react-native - CocoaAsyncSocket - - CocoaLibEvent - - OpenSSL-Static - Yoga - YogaKit @@ -90,52 +79,50 @@ EXTERNAL SOURCES: :podspec: "../third-party-podspecs/ComponentKit.podspec" DoubleConversion: :podspec: "../third-party-podspecs/DoubleConversion.podspec" + EasyWSClient: + :podspec: "../third-party-podspecs/EasyWSClient.podspec" Folly: :podspec: "../third-party-podspecs/Folly.podspec" glog: :podspec: "../third-party-podspecs/glog.podspec" PeerTalk: - :podspec: "../third-party-podspecs/PeerTalk.podspec" - RSocket: - :podspec: "../third-party-podspecs/RSocket.podspec" + :git: https://github.com/rsms/peertalk Sonar: - :podspec: "../../xplat/Sonar/Sonar.podspec" + :podspec: "../../xplat/Sonar/SonarKitCPP.podspec" SonarKit: - :podspec: "../../SonarKit.podspec" + :podspec: "../SonarKit.podspec" CHECKOUT OPTIONS: ComponentKit: - :commit: 73acd7995610ad6b009a9a74b8290a54dab7c716 + :commit: f801317e71f88fbb5a398cd726fc0375255f43ba :git: https://github.com/facebook/ComponentKit.git + EasyWSClient: + :commit: 9b87dc488048900a8cd684f51ddc98143682dbc3 + :git: https://github.com/dhbaird/easywsclient.git PeerTalk: :commit: 588303b43efa5082d654b6f75d1b84a6ba4b5b9e - :git: https://github.com/rsms/PeerTalk.git - RSocket: - :commit: 11491fb22aaaf29b2702a1723561db51b314dd0f - :git: https://github.com/rsocket/rsocket-cpp.git + :git: https://github.com/rsms/peertalk Sonar: - :commit: a0959cf41cb51e7571066877ee2b7090659913b8 + :commit: 26c298ad3401157ac2b7336218c1dde63260dc0c :git: https://github.com/facebook/Sonar.git SonarKit: - :commit: a0959cf41cb51e7571066877ee2b7090659913b8 + :commit: 26c298ad3401157ac2b7336218c1dde63260dc0c :git: https://github.com/facebook/Sonar.git SPEC CHECKSUMS: boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 - CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f ComponentKit: 7bd0ad508946aeb68dd52ed8739ced9846ff3671 - DoubleConversion: 9bd61b1134a393694e95e0950c5bf3f99534817f - Folly: 551752534f77d816ebf69195405d9d0fbd3efcc0 - glog: fdb5d40eb83acd6a4d5d61d95ecc583f5970a119 - OpenSSL-Static: bd17e34564a8591ad76b740318683a6caa19a13e - PeerTalk: aadc42bc7d7f19e89f817b59ef8196305a711504 - RSocket: e9ee232080f995ba8f403ccf4cb61238a5646cb6 - Sonar: 29d8fb9b010e56fa1358be996d68d4b436dd8c21 - SonarKit: ac1fff5cc54ddb394282e78542ae67a781dab4f5 + DoubleConversion: 310ccd7cdf00175c32883664f84fe026025604df + EasyWSClient: 7ec8effe7d86f6061a47d19a55355769c9edfd2f + Folly: 2d29ed217455246ae583ff1980f9ce882af31e80 + glog: f175af2df1f453be65bd355b287a07c842927a99 + PeerTalk: f5389c286e4d477e59b73dfbf25c5c70a2464761 + Sonar: 815b6c6357c78564d9132f6389605b285a06f052 + SonarKit: 29b45073b54d7f5db13e53b7afe6fb6f36c6bea7 Yoga: e6f1fed82138c17da5332e15e5770abf0e9cc386 YogaKit: bb90d11e297e06abef7e0cfb20e035a6bd00cdc4 -PODFILE CHECKSUM: 7c2600fc131a2b041c967e8d6ffc2bd1a0383733 +PODFILE CHECKSUM: cab936292346d86ef8900c8f67d3c707dc421709 -COCOAPODS: 1.5.2 +COCOAPODS: 1.5.2 \ No newline at end of file diff --git a/iOS/Sample/Sample.xcodeproj/project.pbxproj b/iOS/Sample/Sample.xcodeproj/project.pbxproj index d1b532e26..bbe9e8cf1 100644 --- a/iOS/Sample/Sample.xcodeproj/project.pbxproj +++ b/iOS/Sample/Sample.xcodeproj/project.pbxproj @@ -333,6 +333,7 @@ "\"${PODS_ROOT}/Headers/Public/CocoaAsyncSocket\"", "\"${PODS_ROOT}/Headers/Public/ComponentKit\"", "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"", + "\"${PODS_ROOT}/Headers/Public/EasyWSClient\"", "\"${PODS_ROOT}/Headers/Public/Folly\"", "\"${PODS_ROOT}/Headers/Public/PeerTalk\"", "\"${PODS_ROOT}/Headers/Public/Sonar\"/**", @@ -360,6 +361,7 @@ "-l\"CocoaAsyncSocket\"", "-l\"ComponentKit\"", "-l\"DoubleConversion\"", + "-l\"EasyWSClient\"", "-l\"Folly\"", "-l\"PeerTalk\"", "-l\"Sonar\"", @@ -398,6 +400,7 @@ "\"${PODS_ROOT}/Headers/Public/CocoaAsyncSocket\"", "\"${PODS_ROOT}/Headers/Public/ComponentKit\"", "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"", + "\"${PODS_ROOT}/Headers/Public/EasyWSClient\"", "\"${PODS_ROOT}/Headers/Public/Folly\"", "\"${PODS_ROOT}/Headers/Public/PeerTalk\"", "\"${PODS_ROOT}/Headers/Public/Sonar\"/**", @@ -425,6 +428,7 @@ "-l\"CocoaAsyncSocket\"", "-l\"ComponentKit\"", "-l\"DoubleConversion\"", + "-l\"EasyWSClient\"", "-l\"Folly\"", "-l\"PeerTalk\"", "-l\"Sonar\"", diff --git a/SonarKit.podspec b/iOS/SonarKit.podspec similarity index 79% rename from SonarKit.podspec rename to iOS/SonarKit.podspec index c5746c65f..80136339f 100644 --- a/SonarKit.podspec +++ b/iOS/SonarKit.podspec @@ -1,15 +1,15 @@ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0' -yoga_version = '~> 1.8' +yoga_version = '1.8.1' yogakit_version = '1.8.1' Pod::Spec.new do |spec| spec.name = 'SonarKit' - spec.version = '0.0.1' + spec.version = '1.0.0' spec.license = { :type => 'MIT' } spec.homepage = 'https://github.com/facebook/Sonar' spec.summary = 'Sonar iOS podspec' spec.authors = 'Facebook' - spec.static_framework = true + # spec.prepare_command = 'mv src double-conversion' spec.source = { :git => 'https://github.com/facebook/Sonar.git', :branch=> "master" } spec.module_name = 'SonarKit' @@ -17,10 +17,8 @@ Pod::Spec.new do |spec| spec.dependency 'Sonar' spec.dependency 'CocoaAsyncSocket', '~> 7.6' spec.dependency 'PeerTalk' - spec.dependency 'OpenSSL-Static', '1.0.2.c1' - spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}', 'iOS/SonarKit/FBCxxUtils/*.{h, mm}', + spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}' spec.public_header_files = 'iOS/SonarKit/CppBridge/*.{h}', - 'iOS/SonarKit/FBCxxUtils/*.{h}', 'iOS/SonarKit/SonarClient.h', 'iOS/SonarKit/SonarDeviceData.h', 'iOS/SonarKit/SonarPlugin.h', @@ -28,10 +26,12 @@ Pod::Spec.new do |spec| 'iOS/SonarKit/SonarConnection.h', 'iOS/SonarKit/SKMacros.h' + spec.private_header_files = 'iOS/Sample/' spec.compiler_flags = '-DFB_SONARKIT_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/PeerTalkSonar\" \"$(PODS_ROOT)/ComponentKit\"/**" } - spec.platforms = { :ios => "8.0" } + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/ComponentKit\"/**" } + spec.platforms = { :ios => "8.0", :tvos => "9.2" } spec.subspec "SonarKitLayoutPlugin" do |ss| ss.dependency "Yoga", yoga_version @@ -62,6 +62,7 @@ Pod::Spec.new do |spec| ss.source_files = "iOS/Plugins/SonarKitLayoutPlugin/SonarKitLayoutComponentKitSupport/**/*.{h,cpp,m,mm}" ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } end @@ -72,6 +73,18 @@ Pod::Spec.new do |spec| 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKNetworkReporter.h' ss.source_files = "iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/*.{h,cpp,m,mm}" ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } + end + + spec.subspec "SonarKitNetworkPlugin" do |ss| + ss.public_header_files = 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SonarKitNetworkPlugin.h', + 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKBufferingPlugin.h', + 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKDispatchQueue.h', + 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKNetworkReporter.h' + ss.source_files = "iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/*.{h,cpp,m,mm}" + ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } end @@ -80,6 +93,7 @@ Pod::Spec.new do |spec| ss.public_header_files = 'iOS/Plugins/SonarKitNetworkPlugin/SKIOSNetworkPlugin/SKIOSNetworkAdapter.h' ss.source_files = "iOS/Plugins/SonarKitNetworkPlugin/SKIOSNetworkPlugin/**/*.{h,cpp,m,mm}" ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } end end diff --git a/iOS/SonarKit.xcodeproj/project.pbxproj b/iOS/SonarKit.xcodeproj/project.pbxproj index cd0b7e5c7..bbcb046f2 100644 --- a/iOS/SonarKit.xcodeproj/project.pbxproj +++ b/iOS/SonarKit.xcodeproj/project.pbxproj @@ -1,577 +1,668 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 48; - objects = { - -/* Begin PBXBuildFile section */ - 53D19A2620A4BABA00A371E3 /* SonarClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53D19A1220A4BAB900A371E3 /* SonarClient.mm */; }; - 53D19A2820A4BABA00A371E3 /* SonarUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D19A1420A4BAB900A371E3 /* SonarUtil.m */; }; - 53D19A2F20A4BABA00A371E3 /* SKPortForwardingServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D19A1D20A4BABA00A371E3 /* SKPortForwardingServer.m */; }; - 53D19A3020A4BABA00A371E3 /* SonarCppBridgingConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53D19A1F20A4BABA00A371E3 /* SonarCppBridgingConnection.mm */; }; - 53D19A3320A4BABA00A371E3 /* SonarCppBridgingResponder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53D19A2220A4BABA00A371E3 /* SonarCppBridgingResponder.mm */; }; - 53D3BBD820C629230022EB45 /* FBCxxFollyDynamicConvert.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53D3BBD620C629230022EB45 /* FBCxxFollyDynamicConvert.mm */; }; - 53D3BBD920C629230022EB45 /* FBCxxFollyDynamicConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D3BBD720C629230022EB45 /* FBCxxFollyDynamicConvert.h */; }; - 53D4C50620A5B72800613A96 /* SonarCppWrapperPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A2020A4BABA00A371E3 /* SonarCppWrapperPlugin.h */; }; - 53D4C50720A5B72800613A96 /* SonarCppBridgingConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A2120A4BABA00A371E3 /* SonarCppBridgingConnection.h */; }; - 53D4C50820A5B72800613A96 /* SonarCppBridgingResponder.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A2320A4BABA00A371E3 /* SonarCppBridgingResponder.h */; }; - 53D4C50920A5B72800613A96 /* SKMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1020A4BAB900A371E3 /* SKMacros.h */; }; - 53D4C50A20A5B72800613A96 /* SonarClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1120A4BAB900A371E3 /* SonarClient.h */; }; - 53D4C50B20A5B72800613A96 /* SonarConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1820A4BAB900A371E3 /* SonarConnection.h */; }; - 53D4C50C20A5B72800613A96 /* SonarPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1620A4BAB900A371E3 /* SonarPlugin.h */; }; - 53D4C50D20A5B72800613A96 /* SonarResponder.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1320A4BAB900A371E3 /* SonarResponder.h */; }; - 53D4C50E20A5B72800613A96 /* SKUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D4C4F920A5B20000613A96 /* SKUtils.h */; }; - 53D4C50F20A5B72800613A96 /* SKPortForwardingServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1B20A4BABA00A371E3 /* SKPortForwardingServer.h */; }; - 53D4C51020A5B72800613A96 /* SKPortForwardingCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1C20A4BABA00A371E3 /* SKPortForwardingCommon.h */; }; - 53D4C51220A5B89900613A96 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 53D4C51120A5B89900613A96 /* Foundation.framework */; }; - 6AE55F0A77A5644AADF2CEA6 /* libPods-SonarKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 104CB87D17FDFDC934630C14 /* libPods-SonarKit.a */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 104CB87D17FDFDC934630C14 /* libPods-SonarKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SonarKit.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 53D19A0520A4BA3600A371E3 /* SonarKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SonarKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 53D19A0920A4BA3600A371E3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 53D19A1020A4BAB900A371E3 /* SKMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKMacros.h; sourceTree = ""; }; - 53D19A1120A4BAB900A371E3 /* SonarClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarClient.h; sourceTree = ""; }; - 53D19A1220A4BAB900A371E3 /* SonarClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SonarClient.mm; sourceTree = ""; }; - 53D19A1320A4BAB900A371E3 /* SonarResponder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarResponder.h; sourceTree = ""; }; - 53D19A1420A4BAB900A371E3 /* SonarUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SonarUtil.m; sourceTree = ""; }; - 53D19A1620A4BAB900A371E3 /* SonarPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarPlugin.h; sourceTree = ""; }; - 53D19A1820A4BAB900A371E3 /* SonarConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarConnection.h; sourceTree = ""; }; - 53D19A1B20A4BABA00A371E3 /* SKPortForwardingServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKPortForwardingServer.h; sourceTree = ""; }; - 53D19A1C20A4BABA00A371E3 /* SKPortForwardingCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKPortForwardingCommon.h; sourceTree = ""; }; - 53D19A1D20A4BABA00A371E3 /* SKPortForwardingServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKPortForwardingServer.m; sourceTree = ""; }; - 53D19A1F20A4BABA00A371E3 /* SonarCppBridgingConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SonarCppBridgingConnection.mm; sourceTree = ""; }; - 53D19A2020A4BABA00A371E3 /* SonarCppWrapperPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarCppWrapperPlugin.h; sourceTree = ""; }; - 53D19A2120A4BABA00A371E3 /* SonarCppBridgingConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarCppBridgingConnection.h; sourceTree = ""; }; - 53D19A2220A4BABA00A371E3 /* SonarCppBridgingResponder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SonarCppBridgingResponder.mm; sourceTree = ""; }; - 53D19A2320A4BABA00A371E3 /* SonarCppBridgingResponder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarCppBridgingResponder.h; sourceTree = ""; }; - 53D3BBD620C629230022EB45 /* FBCxxFollyDynamicConvert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FBCxxFollyDynamicConvert.mm; sourceTree = ""; }; - 53D3BBD720C629230022EB45 /* FBCxxFollyDynamicConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBCxxFollyDynamicConvert.h; sourceTree = ""; }; - 53D4C4F920A5B20000613A96 /* SKUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SKUtils.h; path = SonarKit/SKUtils.h; sourceTree = SOURCE_ROOT; }; - 53D4C4FA20A5B20000613A96 /* SKUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SKUtils.mm; path = SonarKit/SKUtils.mm; sourceTree = SOURCE_ROOT; }; - 53D4C51120A5B89900613A96 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 5B3C0104984F1A2F624E5394 /* Pods-SonarKit.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SonarKit.release.xcconfig"; path = "Pods/Target Support Files/Pods-SonarKit/Pods-SonarKit.release.xcconfig"; sourceTree = ""; }; - C6253FA5661121EDD200B8A9 /* Pods-SonarKit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SonarKit.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SonarKit/Pods-SonarKit.debug.xcconfig"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 53D19A0120A4BA3600A371E3 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 53D4C51220A5B89900613A96 /* Foundation.framework in Frameworks */, - 6AE55F0A77A5644AADF2CEA6 /* libPods-SonarKit.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 256B672257477FB71D3FAD20 /* Pods */ = { - isa = PBXGroup; - children = ( - C6253FA5661121EDD200B8A9 /* Pods-SonarKit.debug.xcconfig */, - 5B3C0104984F1A2F624E5394 /* Pods-SonarKit.release.xcconfig */, - ); - name = Pods; - sourceTree = ""; - }; - 53D199FB20A4BA3600A371E3 = { - isa = PBXGroup; - children = ( - 53D19A0720A4BA3600A371E3 /* SonarKit */, - 53D19A0620A4BA3600A371E3 /* Products */, - 256B672257477FB71D3FAD20 /* Pods */, - 716CE00064F59AEDC5DB6AA8 /* Frameworks */, - ); - sourceTree = ""; - }; - 53D19A0620A4BA3600A371E3 /* Products */ = { - isa = PBXGroup; - children = ( - 53D19A0520A4BA3600A371E3 /* SonarKit.framework */, - ); - name = Products; - sourceTree = ""; - }; - 53D19A0720A4BA3600A371E3 /* SonarKit */ = { - isa = PBXGroup; - children = ( - 53D3BBD520C629230022EB45 /* FBCxxUtils */, - 53D19A1E20A4BABA00A371E3 /* CppBridge */, - 53D19A1020A4BAB900A371E3 /* SKMacros.h */, - 53D19A1120A4BAB900A371E3 /* SonarClient.h */, - 53D19A1220A4BAB900A371E3 /* SonarClient.mm */, - 53D19A1820A4BAB900A371E3 /* SonarConnection.h */, - 53D19A1620A4BAB900A371E3 /* SonarPlugin.h */, - 53D19A1320A4BAB900A371E3 /* SonarResponder.h */, - 53D19A1420A4BAB900A371E3 /* SonarUtil.m */, - 53D4C4F920A5B20000613A96 /* SKUtils.h */, - 53D4C4FA20A5B20000613A96 /* SKUtils.mm */, - 53D19A1920A4BABA00A371E3 /* Utilities */, - 53D19A0920A4BA3600A371E3 /* Info.plist */, - ); - path = SonarKit; - sourceTree = ""; - }; - 53D19A1920A4BABA00A371E3 /* Utilities */ = { - isa = PBXGroup; - children = ( - 53D19A1A20A4BABA00A371E3 /* PortForwarding */, - ); - path = Utilities; - sourceTree = ""; - }; - 53D19A1A20A4BABA00A371E3 /* PortForwarding */ = { - isa = PBXGroup; - children = ( - 53D19A1B20A4BABA00A371E3 /* SKPortForwardingServer.h */, - 53D19A1C20A4BABA00A371E3 /* SKPortForwardingCommon.h */, - 53D19A1D20A4BABA00A371E3 /* SKPortForwardingServer.m */, - ); - path = PortForwarding; - sourceTree = ""; - }; - 53D19A1E20A4BABA00A371E3 /* CppBridge */ = { - isa = PBXGroup; - children = ( - 53D19A1F20A4BABA00A371E3 /* SonarCppBridgingConnection.mm */, - 53D19A2020A4BABA00A371E3 /* SonarCppWrapperPlugin.h */, - 53D19A2120A4BABA00A371E3 /* SonarCppBridgingConnection.h */, - 53D19A2220A4BABA00A371E3 /* SonarCppBridgingResponder.mm */, - 53D19A2320A4BABA00A371E3 /* SonarCppBridgingResponder.h */, - ); - path = CppBridge; - sourceTree = ""; - }; - 53D3BBD520C629230022EB45 /* FBCxxUtils */ = { - isa = PBXGroup; - children = ( - 53D3BBD620C629230022EB45 /* FBCxxFollyDynamicConvert.mm */, - 53D3BBD720C629230022EB45 /* FBCxxFollyDynamicConvert.h */, - ); - path = FBCxxUtils; - sourceTree = ""; - }; - 716CE00064F59AEDC5DB6AA8 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 53D4C51120A5B89900613A96 /* Foundation.framework */, - 104CB87D17FDFDC934630C14 /* libPods-SonarKit.a */, - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 53D19A0220A4BA3600A371E3 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 53D4C50B20A5B72800613A96 /* SonarConnection.h in Headers */, - 53D4C50D20A5B72800613A96 /* SonarResponder.h in Headers */, - 53D4C50620A5B72800613A96 /* SonarCppWrapperPlugin.h in Headers */, - 53D4C50720A5B72800613A96 /* SonarCppBridgingConnection.h in Headers */, - 53D4C50820A5B72800613A96 /* SonarCppBridgingResponder.h in Headers */, - 53D4C50920A5B72800613A96 /* SKMacros.h in Headers */, - 53D4C50A20A5B72800613A96 /* SonarClient.h in Headers */, - 53D3BBD920C629230022EB45 /* FBCxxFollyDynamicConvert.h in Headers */, - 53D4C50C20A5B72800613A96 /* SonarPlugin.h in Headers */, - 53D4C50E20A5B72800613A96 /* SKUtils.h in Headers */, - 53D4C50F20A5B72800613A96 /* SKPortForwardingServer.h in Headers */, - 53D4C51020A5B72800613A96 /* SKPortForwardingCommon.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 53D19A0420A4BA3600A371E3 /* SonarKit */ = { - isa = PBXNativeTarget; - buildConfigurationList = 53D19A0D20A4BA3600A371E3 /* Build configuration list for PBXNativeTarget "SonarKit" */; - buildPhases = ( - CC935574E023944658E3DB85 /* [CP] Check Pods Manifest.lock */, - 53D19A0020A4BA3600A371E3 /* Sources */, - 53D19A0120A4BA3600A371E3 /* Frameworks */, - 53D19A0220A4BA3600A371E3 /* Headers */, - 53D19A0320A4BA3600A371E3 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = SonarKit; - productName = SonarKit; - productReference = 53D19A0520A4BA3600A371E3 /* SonarKit.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 53D199FC20A4BA3600A371E3 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0940; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 53D19A0420A4BA3600A371E3 = { - CreatedOnToolsVersion = 9.2; - ProvisioningStyle = Automatic; - }; - }; - }; - buildConfigurationList = 53D199FF20A4BA3600A371E3 /* Build configuration list for PBXProject "SonarKit" */; - compatibilityVersion = "Xcode 8.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 53D199FB20A4BA3600A371E3; - productRefGroup = 53D19A0620A4BA3600A371E3 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 53D19A0420A4BA3600A371E3 /* SonarKit */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 53D19A0320A4BA3600A371E3 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - CC935574E023944658E3DB85 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-SonarKit-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/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# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 53D19A0020A4BA3600A371E3 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 53D3BBD820C629230022EB45 /* FBCxxFollyDynamicConvert.mm in Sources */, - 53D19A3320A4BABA00A371E3 /* SonarCppBridgingResponder.mm in Sources */, - 53D19A2F20A4BABA00A371E3 /* SKPortForwardingServer.m in Sources */, - 53D19A3020A4BABA00A371E3 /* SonarCppBridgingConnection.mm in Sources */, - 53D19A2620A4BABA00A371E3 /* SonarClient.mm in Sources */, - 53D19A2820A4BABA00A371E3 /* SonarUtil.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 53D19A0B20A4BA3600A371E3 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_CXX_LIBRARY = "compiler-default"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_CXX0X_EXTENSIONS = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = "compiler-default"; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 53D19A0C20A4BA3600A371E3 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_CXX_LIBRARY = "compiler-default"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_CXX0X_EXTENSIONS = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = "compiler-default"; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - 53D19A0E20A4BA3600A371E3 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = C6253FA5661121EDD200B8A9 /* Pods-SonarKit.debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - ); - GCC_USE_STANDARD_INCLUDE_SEARCHING = YES; - HEADER_SEARCH_PATHS = ( - "${SRCROOT}/SonarKit/**", - "${SRCROOT}/../xplat/**", - "$(inherited)", - "${PODS_ROOT}/Headers/Public/DoubleConversion/**", - "${PODS_ROOT}/boost-for-react-native", - "${PODS_ROOT}/Headers/Public/Folly", - "${PODS_ROOT}/DoubleConversion", - "${PODS_ROOT}/Headers/Public/glog", - "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket", - /usr/local/Cellar/openssl/1.0.2o_1/include, - ); - INFOPLIST_FILE = SonarKit/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - OTHER_CPLUSPLUSFLAGS = ( - "$(OTHER_CFLAGS)", - "-DFOLLY_NO_CONFIG=1", - "-DFOLLY_USE_LIBCPP=1", - "-DFOLLY_MOBILE=1", - "-DFOLLY_HAVE_LIBGFLAGS=0", - "-DFOLLY_FORCE_EXCEPTION_COUNT_USE_STD=1", - "-DFOLLY_USE_SYMBOLIZER=0", - "-DFOLLY_HAVE_TFO=0", - "-DFOLLY_HAVE_PWRITEV=0", - "-DFOLLY_HAVE_PREADV=0", - "-DFOLLY_HAVE_LIBJEMALLOC=0", - ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-l\"DoubleConversion\"", - "-l\"Folly\"", - "-l\"glog\"", - "-l\"stdc++\"", - "-DFOLLY_NO_CONFIG=1", - "-DFOLLY_MOBILE=1", - "-DFOLLY_USE_LIBCPP=1", - "-DFOLLY_HAVE_LIBGFLAGS=0", - "-DFOLLY_HAVE_LIBJEMALLOC=0", - "-DFOLLY_HAVE_PREADV=0", - "-DFOLLY_HAVE_TFO=0", - "-DFOLLY_FORCE_EXCEPTION_COUNT_USE_STD=1", - "-DFOLLY_USE_SYMBOLIZER=0", - "-DFOLLY_HAVE_PWRITEV=0", - ); - OTHER_LIBTOOLFLAGS = ""; - PRODUCT_BUNDLE_IDENTIFIER = FB.SonarKit; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ""; - "USER_HEADER_SEARCH_PATHS[arch=*]" = "${SRCROOT}/SonarKit/** ${SRCROOT}/../xplat/**"; - USE_HEADERMAP = YES; - }; - name = Debug; - }; - 53D19A0F20A4BA3600A371E3 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 5B3C0104984F1A2F624E5394 /* Pods-SonarKit.release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_USE_STANDARD_INCLUDE_SEARCHING = YES; - HEADER_SEARCH_PATHS = ( - "${SRCROOT}/SonarKit/**", - "${SRCROOT}/../xplat/**", - "$(inherited)", - "${PODS_ROOT}/Headers/Public/DoubleConversion/**", - "${PODS_ROOT}/boost-for-react-native", - "${PODS_ROOT}/Headers/Public/Folly", - "${PODS_ROOT}/DoubleConversion", - "${PODS_ROOT}/Headers/Public/glog", - "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket", - /usr/local/Cellar/openssl/1.0.2o_1/include, - ); - INFOPLIST_FILE = SonarKit/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - OTHER_CPLUSPLUSFLAGS = ( - "$(OTHER_CFLAGS)", - "-DFOLLY_NO_CONFIG=1", - "-DFOLLY_USE_LIBCPP=1", - "-DFOLLY_MOBILE=1", - "-DFOLLY_HAVE_LIBGFLAGS=0", - "-DFOLLY_FORCE_EXCEPTION_COUNT_USE_STD=1", - "-DFOLLY_USE_SYMBOLIZER=0", - "-DFOLLY_HAVE_TFO=0", - "-DFOLLY_HAVE_PWRITEV=0", - "-DFOLLY_HAVE_PREADV=0", - "-DFOLLY_HAVE_LIBJEMALLOC=0", - ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-l\"DoubleConversion\"", - "-l\"Folly\"", - "-l\"glog\"", - "-l\"stdc++\"", - "-DFOLLY_NO_CONFIG=1", - "-DFOLLY_MOBILE=1", - "-DFOLLY_USE_LIBCPP=1", - "-DFOLLY_HAVE_LIBGFLAGS=0", - "-DFOLLY_HAVE_LIBJEMALLOC=0", - "-DFOLLY_HAVE_PREADV=0", - "-DFOLLY_HAVE_TFO=0", - "-DFOLLY_FORCE_EXCEPTION_COUNT_USE_STD=1", - "-DFOLLY_USE_SYMBOLIZER=0", - "-DFOLLY_HAVE_PWRITEV=0", - ); - OTHER_LIBTOOLFLAGS = ""; - PRODUCT_BUNDLE_IDENTIFIER = FB.SonarKit; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ""; - USE_HEADERMAP = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 53D199FF20A4BA3600A371E3 /* Build configuration list for PBXProject "SonarKit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 53D19A0B20A4BA3600A371E3 /* Debug */, - 53D19A0C20A4BA3600A371E3 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 53D19A0D20A4BA3600A371E3 /* Build configuration list for PBXNativeTarget "SonarKit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 53D19A0E20A4BA3600A371E3 /* Debug */, - 53D19A0F20A4BA3600A371E3 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 53D199FC20A4BA3600A371E3 /* Project object */; -} + + + + + archiveVersion + 1 + classes + + + objectVersion + 46 + objects + + 1DD70E29AEDF69A200000000 + + isa + PBXFileReference + name + SonarKit-Debug.xcconfig + path + ../../buck-out/gen/Libraries/SonarKit/SonarKit-Debug.xcconfig + sourceTree + SOURCE_ROOT + explicitFileType + text.xcconfig + + 1DD70E2959CE208C00000000 + + isa + PBXFileReference + name + SonarKit-Profile.xcconfig + path + ../../buck-out/gen/Libraries/SonarKit/SonarKit-Profile.xcconfig + sourceTree + SOURCE_ROOT + explicitFileType + text.xcconfig + + 1DD70E29CD64CBEE00000000 + + isa + PBXFileReference + name + SonarKit-Release.xcconfig + path + ../../buck-out/gen/Libraries/SonarKit/SonarKit-Release.xcconfig + sourceTree + SOURCE_ROOT + explicitFileType + text.xcconfig + + B401C9792F7F325000000000 + + isa + PBXGroup + name + Buck (Do Not Modify) + sourceTree + ]]> + children + + 1DD70E29AEDF69A200000000 + 1DD70E2959CE208C00000000 + 1DD70E29CD64CBEE00000000 + + + B401C979B781F65D00000000 + + isa + PBXGroup + name + Configurations + sourceTree + ]]> + children + + B401C9792F7F325000000000 + + + 1DD70E291F97291900000000 + + isa + PBXFileReference + name + libSonarKit--916269148.a + path + libSonarKit--916269148.a + sourceTree + BUILT_PRODUCTS_DIR + explicitFileType + archive.ar + + B401C979C806358400000000 + + isa + PBXGroup + name + Products + sourceTree + ]]> + children + + 1DD70E291F97291900000000 + + + 1DD70E29001F47FB00000000 + + isa + PBXFileReference + name + BUCK + path + BUCK + sourceTree + SOURCE_ROOT + explicitFileType + text.script.python + + 1DD70E295D9C4C1E00000000 + + isa + PBXFileReference + name + SonarCppBridgingConnection.h + path + SonarKit/CppBridge/SonarCppBridgingConnection.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E2955ED38AA00000000 + + isa + PBXFileReference + name + SonarCppBridgingConnection.mm + path + SonarKit/CppBridge/SonarCppBridgingConnection.mm + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.cpp.objcpp + + 1DD70E29B6F151F600000000 + + isa + PBXFileReference + name + SonarCppBridgingResponder.h + path + SonarKit/CppBridge/SonarCppBridgingResponder.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E292738EDD200000000 + + isa + PBXFileReference + name + SonarCppBridgingResponder.mm + path + SonarKit/CppBridge/SonarCppBridgingResponder.mm + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.cpp.objcpp + + 1DD70E298E830C8000000000 + + isa + PBXFileReference + name + SonarCppWrapperPlugin.h + path + SonarKit/CppBridge/SonarCppWrapperPlugin.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + B401C979DC3E2AEC00000000 + + isa + PBXGroup + name + CppBridge + path + SonarKit/CppBridge + sourceTree + SOURCE_ROOT + children + + 1DD70E295D9C4C1E00000000 + 1DD70E2955ED38AA00000000 + 1DD70E29B6F151F600000000 + 1DD70E292738EDD200000000 + 1DD70E298E830C8000000000 + + + 1DD70E29978C461B00000000 + + isa + PBXFileReference + name + SKPortForwardingCommon.h + path + SonarKit/Utilities/PortForwarding/SKPortForwardingCommon.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E290DA3557300000000 + + isa + PBXFileReference + name + SKPortForwardingServer.h + path + SonarKit/Utilities/PortForwarding/SKPortForwardingServer.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E290DA3557800000000 + + isa + PBXFileReference + name + SKPortForwardingServer.m + path + SonarKit/Utilities/PortForwarding/SKPortForwardingServer.m + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.objc + + B401C9797FE3A67E00000000 + + isa + PBXGroup + name + PortForwarding + path + SonarKit/Utilities/PortForwarding + sourceTree + SOURCE_ROOT + children + + 1DD70E29978C461B00000000 + 1DD70E290DA3557300000000 + 1DD70E290DA3557800000000 + + + B401C979BD78D6EA00000000 + + isa + PBXGroup + name + Utilities + path + SonarKit/Utilities + sourceTree + SOURCE_ROOT + children + + B401C9797FE3A67E00000000 + + + 1DD70E299D3D8CD900000000 + + isa + PBXFileReference + name + SKMacros.h + path + SonarKit/SKMacros.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E29DD8668F300000000 + + isa + PBXFileReference + name + SKUtils.h + path + SonarKit/SKUtils.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E29D346B67500000000 + + isa + PBXFileReference + name + SKUtils.mm + path + SonarKit/SKUtils.mm + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.cpp.objcpp + + 1DD70E297513814800000000 + + isa + PBXFileReference + name + SonarClient.h + path + SonarKit/SonarClient.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E292D5CA8C000000000 + + isa + PBXFileReference + name + SonarClient.mm + path + SonarKit/SonarClient.mm + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.cpp.objcpp + + 1DD70E29D967BA1B00000000 + + isa + PBXFileReference + name + SonarConnection.h + path + SonarKit/SonarConnection.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E29D016C2B000000000 + + isa + PBXFileReference + name + SonarPlugin.h + path + SonarKit/SonarPlugin.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E29C331B05900000000 + + isa + PBXFileReference + name + SonarResponder.h + path + SonarKit/SonarResponder.h + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.h + + 1DD70E2969DE008400000000 + + isa + PBXFileReference + name + SonarUtil.m + path + SonarKit/SonarUtil.m + sourceTree + SOURCE_ROOT + lastKnownFileType + sourcecode.c.objc + + B401C979EAB5339800000000 + + isa + PBXGroup + name + Sources + sourceTree + ]]> + children + + B401C979DC3E2AEC00000000 + B401C979BD78D6EA00000000 + 1DD70E299D3D8CD900000000 + 1DD70E29DD8668F300000000 + 1DD70E29D346B67500000000 + 1DD70E297513814800000000 + 1DD70E292D5CA8C000000000 + 1DD70E29D967BA1B00000000 + 1DD70E29D016C2B000000000 + 1DD70E29C331B05900000000 + 1DD70E2969DE008400000000 + + + B401C9795F1632B300000000 + + isa + PBXGroup + name + SonarKit + sourceTree + ]]> + children + + 1DD70E29001F47FB00000000 + B401C979EAB5339800000000 + + + B401C979EFB6AC4600000000 + + isa + PBXGroup + name + mainGroup + sourceTree + ]]> + children + + B401C979B781F65D00000000 + B401C979C806358400000000 + B401C9795F1632B300000000 + + + E7A30F0455ED38AA00000000 + + isa + PBXBuildFile + fileRef + 1DD70E2955ED38AA00000000 + settings + + COMPILER_FLAGS + -stdlib=libc++ -D_LIBCPP_HAS_NO_STRONG_ENUMS=1 + + + E7A30F042738EDD200000000 + + isa + PBXBuildFile + fileRef + 1DD70E292738EDD200000000 + settings + + COMPILER_FLAGS + -stdlib=libc++ -D_LIBCPP_HAS_NO_STRONG_ENUMS=1 + + + E7A30F040DA3557800000000 + + isa + PBXBuildFile + fileRef + 1DD70E290DA3557800000000 + settings + + COMPILER_FLAGS + -stdlib=libc++ -D_LIBCPP_HAS_NO_STRONG_ENUMS=1 + + + E7A30F04D346B67500000000 + + isa + PBXBuildFile + fileRef + 1DD70E29D346B67500000000 + settings + + COMPILER_FLAGS + -stdlib=libc++ -D_LIBCPP_HAS_NO_STRONG_ENUMS=1 + + + E7A30F042D5CA8C000000000 + + isa + PBXBuildFile + fileRef + 1DD70E292D5CA8C000000000 + settings + + COMPILER_FLAGS + -stdlib=libc++ -D_LIBCPP_HAS_NO_STRONG_ENUMS=1 + + + E7A30F0469DE008400000000 + + isa + PBXBuildFile + fileRef + 1DD70E2969DE008400000000 + settings + + COMPILER_FLAGS + -stdlib=libc++ -D_LIBCPP_HAS_NO_STRONG_ENUMS=1 + + + 1870857F0000000000000000 + + isa + PBXSourcesBuildPhase + files + + E7A30F0455ED38AA00000000 + E7A30F042738EDD200000000 + E7A30F040DA3557800000000 + E7A30F04D346B67500000000 + E7A30F042D5CA8C000000000 + E7A30F0469DE008400000000 + + + 4952437303EDA63300000000 + + isa + XCBuildConfiguration + name + Debug + buildSettings + + + baseConfigurationReference + 1DD70E29AEDF69A200000000 + + 4952437350C7218900000000 + + isa + XCBuildConfiguration + name + Profile + buildSettings + + + baseConfigurationReference + 1DD70E2959CE208C00000000 + + 49524373A439BFE700000000 + + isa + XCBuildConfiguration + name + Release + buildSettings + + + baseConfigurationReference + 1DD70E29CD64CBEE00000000 + + 218C37090000000000000000 + + isa + XCConfigurationList + buildConfigurations + + 4952437303EDA63300000000 + 4952437350C7218900000000 + 49524373A439BFE700000000 + + defaultConfigurationIsVisible + + + E66DC04E5F1632B300000000 + + isa + PBXNativeTarget + name + SonarKit + productName + SonarKit--916269148 + productReference + 1DD70E291F97291900000000 + productType + com.apple.product-type.library.static + dependencies + + + buildPhases + + 1870857F0000000000000000 + + buildConfigurationList + 218C37090000000000000000 + + 4952437303EDA63300000001 + + isa + XCBuildConfiguration + name + Debug + buildSettings + + + + 4952437350C7218900000001 + + isa + XCBuildConfiguration + name + Profile + buildSettings + + + + 49524373A439BFE700000001 + + isa + XCBuildConfiguration + name + Release + buildSettings + + + + 218C37090000000000000001 + + isa + XCConfigurationList + buildConfigurations + + 4952437303EDA63300000001 + 4952437350C7218900000001 + 49524373A439BFE700000001 + + defaultConfigurationIsVisible + + + 96C847935F1632B300000000 + + isa + PBXProject + mainGroup + B401C979EFB6AC4600000000 + targets + + E66DC04E5F1632B300000000 + + buildConfigurationList + 218C37090000000000000001 + compatibilityVersion + Xcode 3.2 + attributes + + LastUpgradeCheck + 9999 + + + + rootObject + 96C847935F1632B300000000 + + \ No newline at end of file diff --git a/iOS/SonarKit/CppBridge/SonarCppBridgingConnection.mm b/iOS/SonarKit/CppBridge/SonarCppBridgingConnection.mm index 031cdbca7..c2518f328 100644 --- a/iOS/SonarKit/CppBridge/SonarCppBridgingConnection.mm +++ b/iOS/SonarKit/CppBridge/SonarCppBridgingConnection.mm @@ -7,8 +7,7 @@ */ #import "SonarCppBridgingConnection.h" -#import - +#import "SKUtils.h" #import "SonarCppBridgingResponder.h" @implementation SonarCppBridgingConnection @@ -28,7 +27,7 @@ - (void)send:(NSString *)method withParams:(NSDictionary *)params { - conn_->send([method UTF8String], facebook::cxxutils::convertIdToFollyDynamic(params)); + conn_->send([method UTF8String], [SKUtils convertIdToFollyDynamic:params]); } - (void)receive:(NSString *)method withBlock:(SonarReceiver)receiver @@ -37,7 +36,7 @@ std::unique_ptr responder) { SonarCppBridgingResponder *const objCResponder = [[SonarCppBridgingResponder alloc] initWithCppResponder:std::move(responder)]; - receiver(facebook::cxxutils::convertFollyDynamicToId(message), objCResponder); + receiver([SKUtils convertFollyDynamicToId: message], objCResponder); }; conn_->receive([method UTF8String], lambda); } diff --git a/iOS/SonarKit/CppBridge/SonarCppBridgingResponder.mm b/iOS/SonarKit/CppBridge/SonarCppBridgingResponder.mm index 0b3714fb4..b43701980 100644 --- a/iOS/SonarKit/CppBridge/SonarCppBridgingResponder.mm +++ b/iOS/SonarKit/CppBridge/SonarCppBridgingResponder.mm @@ -7,7 +7,7 @@ */ #import "SonarCppBridgingResponder.h" -#import +#import "SKUtils.h" @implementation SonarCppBridgingResponder { std::unique_ptr responder_; @@ -28,8 +28,8 @@ #pragma mark - SonarResponder -- (void)success:(NSDictionary *)response { responder_->success(facebook::cxxutils::convertIdToFollyDynamic(response)); } +- (void)success:(NSDictionary *)response { responder_->success([SKUtils convertIdToFollyDynamic:response]); } -- (void)error:(NSDictionary *)response { responder_->error(facebook::cxxutils::convertIdToFollyDynamic(response)); } +- (void)error:(NSDictionary *)response { responder_->error([SKUtils convertIdToFollyDynamic:response]); } @end diff --git a/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.h b/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.h deleted file mode 100644 index dd83b9df3..000000000 --- a/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2004-present Facebook. All Rights Reserved. -#pragma once - -#import - -#include - -namespace facebook { -namespace cxxutils { - -folly::dynamic convertIdToFollyDynamic(id json); -id convertFollyDynamicToId(const folly::dynamic &dyn); - -} } diff --git a/iOS/SonarKit/Info.plist b/iOS/SonarKit/Info.plist deleted file mode 100644 index 1007fd9dd..000000000 --- a/iOS/SonarKit/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - NSPrincipalClass - - - diff --git a/iOS/SonarKit/SKUtils.h b/iOS/SonarKit/SKUtils.h new file mode 100644 index 000000000..7cd13eb41 --- /dev/null +++ b/iOS/SonarKit/SKUtils.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#import + +#import + +namespace facebook { namespace sonar { +#define _C_ID '@' +#define _C_CLASS '#' +#define _C_SEL ':' +#define _C_CHR 'c' +#define _C_UCHR 'C' +#define _C_SHT 's' +#define _C_USHT 'S' +#define _C_INT 'i' +#define _C_UINT 'I' +#define _C_LNG 'l' +#define _C_ULNG 'L' +#define _C_LNG_LNG 'q' +#define _C_ULNG_LNG 'Q' +#define _C_FLT 'f' +#define _C_DBL 'd' +#define _C_BFLD 'b' +#define _C_BOOL 'B' +#define _C_VOID 'v' +#define _C_UNDEF '?' +#define _C_PTR '^' +#define _C_CHARPTR '*' +#define _C_ATOM '%' +#define _C_ARY_B '[' +#define _C_ARY_E ']' +#define _C_UNION_B '(' +#define _C_UNION_E ')' +#define _C_STRUCT_B '{' +#define _C_STRUCT_E '}' +#define _C_VECTOR '!' +#define _C_CONST 'r' +} +} + +@interface SKUtils: NSObject ++ (folly::dynamic)convertIdToFollyDynamic:(id)json; ++ (id)convertFollyDynamicToId:(const folly::dynamic &)dyn; + +@end diff --git a/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.mm b/iOS/SonarKit/SKUtils.mm similarity index 63% rename from iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.mm rename to iOS/SonarKit/SKUtils.mm index b19405511..82c8b9699 100644 --- a/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.mm +++ b/iOS/SonarKit/SKUtils.mm @@ -1,17 +1,97 @@ -// Copyright 2004-present Facebook. All Rights Reserved. - -#import "FBCxxFollyDynamicConvert.h" - -#import - -namespace facebook { -namespace cxxutils { - /* - * The implementation is taken from RCTFollyConvert(https://fburl.com/vzw8ql2q) + * Copyright (c) 2018-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * */ +#include "SKUtils.h" -id convertFollyDynamicToId(const folly::dynamic &dyn) { +#include + +#import + +using namespace facebook::sonar; + +@implementation SKUtils + ++ (folly::dynamic)convertIdToFollyDynamic:(id)json +{ + if (json == nil || json == (id)kCFNull) { + return nullptr; + } else if ([json isKindOfClass:[NSNumber class]]) { + const char *objCType = [json objCType]; + switch (objCType[0]) { + // This is a c++ bool or C99 _Bool. On some platforms, BOOL is a bool. + case _C_BOOL: + return (bool) [json boolValue]; + case _C_CHR: + // On some platforms, objc BOOL is a signed char, but it + // might also be a small number. Use the same hack JSC uses + // to distinguish them: + // https://phabricator.intern.facebook.com/diffusion/FBS/browse/master/fbobjc/xplat/third-party/jsc/safari-600-1-4-17/JavaScriptCore/API/JSValue.mm;b8ee03916489f8b12143cd5c0bca546da5014fc9$901 + if ([json isKindOfClass:[@YES class]]) { + return (bool) [json boolValue]; + } else { + const auto value = [json longLongValue]; + if (isnan(value) || isinf(value)) { + return nullptr; + } + return value; + } + case _C_UCHR: + case _C_SHT: + case _C_USHT: + case _C_INT: + case _C_UINT: + case _C_LNG: + case _C_ULNG: + case _C_LNG_LNG: + case _C_ULNG_LNG: { + const auto value = [json longLongValue]; + if (isnan(value) || isinf(value)) { + return nullptr; + } + return value; + } + + case _C_FLT: + case _C_DBL: { + const auto value = [json doubleValue]; + if (isnan(value) || isinf(value)) { + return nullptr; + } + return value; + } + + // default: + // fall through + } + } else if ([json isKindOfClass:[NSString class]]) { + NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding]; + return std::string(reinterpret_cast(data.bytes), + data.length); + } else if ([json isKindOfClass:[NSArray class]]) { + folly::dynamic array = folly::dynamic::array; + for (id element in json) { + array.push_back([self convertIdToFollyDynamic:element]); + } + return array; + } else if ([json isKindOfClass:[NSDictionary class]]) { + __block folly::dynamic object = folly::dynamic::object(); + + [json enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, __unused BOOL *stop) { + object.insert([self convertIdToFollyDynamic:key], + [self convertIdToFollyDynamic:value]); + }]; + + return object; + } + + return nil; +} + ++ (id)convertFollyDynamicToId:(const folly::dynamic &)dyn { // I could imagine an implementation which avoids copies by wrapping the // dynamic in a derived class of NSDictionary. We can do that if profiling // implies it will help. @@ -27,84 +107,22 @@ id convertFollyDynamicToId(const folly::dynamic &dyn) { return @(dyn.getDouble()); case folly::dynamic::STRING: return [[NSString alloc] initWithBytes:dyn.c_str() length:dyn.size() - encoding:NSUTF8StringEncoding]; + encoding:NSUTF8StringEncoding]; case folly::dynamic::ARRAY: { NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:dyn.size()]; for (auto &elem : dyn) { - [array addObject:convertFollyDynamicToId(elem)]; + [array addObject:[self convertFollyDynamicToId: elem]]; } return array; } case folly::dynamic::OBJECT: { NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:dyn.size()]; for (auto &elem : dyn.items()) { - dict[convertFollyDynamicToId(elem.first)] = convertFollyDynamicToId(elem.second); + dict[[self convertFollyDynamicToId:elem.first]] = [self convertFollyDynamicToId:elem.second]; } return dict; } } } -folly::dynamic convertIdToFollyDynamic(id json) -{ - if (json == nil || json == (id)kCFNull) { - return nullptr; - } else if ([json isKindOfClass:[NSNumber class]]) { - const char *objCType = [json objCType]; - switch (objCType[0]) { - // This is a c++ bool or C99 _Bool. On some platforms, BOOL is a bool. - case _C_BOOL: - return (bool) [json boolValue]; - case _C_CHR: - // On some platforms, objc BOOL is a signed char, but it - // might also be a small number. Use the same hack JSC uses - // to distinguish them: - // https://phabricator.intern.facebook.com/diffusion/FBS/browse/master/fbobjc/xplat/third-party/jsc/safari-600-1-4-17/JavaScriptCore/API/JSValue.mm;b8ee03916489f8b12143cd5c0bca546da5014fc9$901 - if ([json isKindOfClass:[@YES class]]) { - return (bool) [json boolValue]; - } else { - return [json longLongValue]; - } - case _C_UCHR: - case _C_SHT: - case _C_USHT: - case _C_INT: - case _C_UINT: - case _C_LNG: - case _C_ULNG: - case _C_LNG_LNG: - case _C_ULNG_LNG: - return [json longLongValue]; - - case _C_FLT: - case _C_DBL: - return [json doubleValue]; - - // default: - // fall through - } - } else if ([json isKindOfClass:[NSString class]]) { - NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding]; - return std::string(reinterpret_cast(data.bytes), - data.length); - } else if ([json isKindOfClass:[NSArray class]]) { - folly::dynamic array = folly::dynamic::array; - for (id element in json) { - array.push_back(convertIdToFollyDynamic(element)); - } - return array; - } else if ([json isKindOfClass:[NSDictionary class]]) { - __block folly::dynamic object = folly::dynamic::object(); - - [json enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, __unused BOOL *stop) { - object.insert(convertIdToFollyDynamic(key), - convertIdToFollyDynamic(value)); - }]; - - return object; - } - - return nil; -} - -} } +@end diff --git a/iOS/SonarKit/SonarClient.mm b/iOS/SonarKit/SonarClient.mm index 46766bcb2..14a62745d 100644 --- a/iOS/SonarKit/SonarClient.mm +++ b/iOS/SonarKit/SonarClient.mm @@ -15,7 +15,7 @@ #import #if !TARGET_OS_SIMULATOR -// #import "SKPortForwardingServer.h" +#import "SKPortForwardingServer.h" #endif using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; @@ -24,7 +24,7 @@ using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; facebook::sonar::SonarClient *_cppClient; folly::ScopedEventBaseThread eventBaseThread; #if !TARGET_OS_SIMULATOR - // SKPortForwardingServer *_server; + SKPortForwardingServer *_server; #endif } @@ -103,9 +103,9 @@ using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; - (void)start; { #if !TARGET_OS_SIMULATOR - // _server = [SKPortForwardingServer new]; - // [_server forwardConnectionsFromPort:8088]; - // [_server listenForMultiplexingChannelOnPort:8078]; + _server = [SKPortForwardingServer new]; + [_server forwardConnectionsFromPort:8088]; + [_server listenForMultiplexingChannelOnPort:8078]; #endif _cppClient->start(); } @@ -114,8 +114,8 @@ using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; { _cppClient->stop(); #if !TARGET_OS_SIMULATOR - // [_server close]; - // _server = nil; + [_server close]; + _server = nil; #endif } diff --git a/iOS/scripts/ios-configure-glog.sh b/iOS/scripts/ios-configure-glog.sh new file mode 100644 index 000000000..e6a15febb --- /dev/null +++ b/iOS/scripts/ios-configure-glog.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -e + +PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}" +CURRENT_ARCH="${CURRENT_ARCH:-armv7}" + +export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)" +export CXX="$CC" + +# Remove automake symlink if it exists +if [ -h "test-driver" ]; then + rm test-driver +fi + +./configure --host arm-apple-darwin + +# Fix build for tvOS +cat << EOF >> src/config.h + +/* Add in so we have Apple Target Conditionals */ +#ifdef __APPLE__ +#include +#include +#endif + +/* Special configuration for AppleTVOS */ +#if TARGET_OS_TV +#undef HAVE_SYSCALL_H +#undef HAVE_SYS_SYSCALL_H +#undef OS_MACOSX +#endif + +/* Special configuration for ucontext */ +#undef HAVE_UCONTEXT_H +#undef PC_FROM_UCONTEXT +#if defined(__x86_64__) +#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip +#elif defined(__i386__) +#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip +#endif +EOF diff --git a/iOS/third-party-podspecs/DoubleConversion.podspec b/iOS/third-party-podspecs/DoubleConversion.podspec index 95ba81257..91f4f819b 100755 --- a/iOS/third-party-podspecs/DoubleConversion.podspec +++ b/iOS/third-party-podspecs/DoubleConversion.podspec @@ -13,6 +13,6 @@ Pod::Spec.new do |spec| spec.libraries = "stdc++" spec.compiler_flags = '-std=c++1y' # Pinning to the same version as React.podspec. - spec.platforms = { :ios => "8.0" } + spec.platforms = { :ios => "8.0", :tvos => "9.2" } end diff --git a/iOS/third-party-podspecs/EasyWSClient.podspec b/iOS/third-party-podspecs/EasyWSClient.podspec new file mode 100644 index 000000000..0b3edeba9 --- /dev/null +++ b/iOS/third-party-podspecs/EasyWSClient.podspec @@ -0,0 +1,17 @@ +Pod::Spec.new do |spec| + spec.name = 'EasyWSClient' + spec.version = '1.0.0' + spec.license = { :type => 'MIT' } + spec.homepage = 'https://github.com/google/double-conversion' + spec.summary = 'Easywsclient is an easy and powerful WebSocket client to get your C++ code connected to a web stack right away.' + spec.authors = 'David Baird' + # spec.prepare_command = 'mv src double-conversion' + spec.source = { :git => 'https://github.com/dhbaird/easywsclient.git', :branch => 'master'} + spec.module_name = 'EasyWSClient' + spec.source_files = '*.{hpp,cpp}' + spec.libraries = "stdc++" + spec.compiler_flags = '-std=c++1y' + # Pinning to the same version as React.podspec. + spec.platforms = { :ios => "8.0", :tvos => "9.2" } + +end diff --git a/iOS/third-party-podspecs/Folly.podspec b/iOS/third-party-podspecs/Folly.podspec index 1623e2bfd..4732038d7 100755 --- a/iOS/third-party-podspecs/Folly.podspec +++ b/iOS/third-party-podspecs/Folly.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'Folly' - spec.version = '2018.05.28.00' + spec.version = '2018.05.07.00' spec.license = { :type => 'Apache License, Version 2.0' } spec.homepage = 'https://github.com/facebook/folly' spec.summary = 'An open-source C++ library developed and used at Facebook.' @@ -11,9 +11,7 @@ Pod::Spec.new do |spec| spec.dependency 'boost-for-react-native' spec.dependency 'DoubleConversion' spec.dependency 'glog' - spec.dependency 'OpenSSL-Static', '1.0.2.c1' - spec.dependency 'CocoaLibEvent', '~> 1.0' - spec.compiler_flags = '-DFOLLY_HAVE_PTHREAD=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti + spec.compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti -fexceptions -std=c++14 -Wno-error @@ -27,27 +25,10 @@ Pod::Spec.new do |spec| 'folly/memory/detail/MallocImpl.cpp', 'folly/String.cpp', 'folly/*.cpp', - 'folly/detail/*.cpp', - 'folly/hash/*.cpp', - 'folly/portability/*.cpp', 'folly/ScopeGuard.h', 'folly/lang/ColdClass.cpp', 'folly/lang/Assume.h', - 'folly/lang/Assume.cpp', - 'folly/io/async/*.cpp', - 'folly/io/async/ssl/*.cpp', - 'folly/io/*.cpp', - 'folly/synchronization/*.cpp', - 'folly/lang/*.cpp', - 'folly/memory/*.cpp', - 'folly/futures/*.cpp', - 'folly/futures/detail/*.cpp', - 'folly/experimental/hazptr/*.cpp', - 'folly/executors/*.cpp', - 'folly/concurrency/*.cpp', - 'folly/ssl/*.cpp', - 'folly/ssl/detail/*.cpp', - 'folly/system/*.cpp' + 'folly/lang/Assume.cpp' # workaround for https://github.com/facebook/react-native/issues/14326 spec.preserve_paths = 'folly/*.h', @@ -57,16 +38,16 @@ Pod::Spec.new do |spec| 'folly/detail/*.h', 'folly/hash/*.h', 'folly/memory/*.h', - 'folly/**/*.h', - 'folly/futures/detail/*.h', - 'folly/futures/*.h' + 'folly/**/*.h' spec.header_mappings_dir = 'folly' spec.header_dir = 'folly' spec.libraries = "stdc++" spec.private_header_files = 'folly/portability/Stdlib.h', - 'folly/portability/Stdio.h' - + 'folly/portability/Malloc.h', + 'folly/portability/Stdlib.h', + 'folly/portability/Stdio.h', + 'folly/portability/PThread.h' spec.public_header_files = 'folly/portability/Config.h', 'folly/Executor.h', 'folly/Function.h', @@ -100,19 +81,15 @@ Pod::Spec.new do |spec| 'folly/FBString.h', 'folly/hash/Hash.h', 'folly/memory/Malloc.h', - 'folly/io/async/AsyncTimeout.h', 'folly/**/*.h', 'folly/memory/detail/MallocImpl.h', 'folly/String.h', - 'folly/*.h', - 'folly/portability/PThread.h', - 'folly/futures/*.h', - 'folly/futures/detail/*.h' + 'folly/*.h' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++11", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\"" } # Pinning to the same version as React.podspec. - spec.platforms = { :ios => "8.0"} + spec.platforms = { :ios => "8.0", :tvos => "10.0" } end diff --git a/iOS/third-party-podspecs/LibEvent.podspec b/iOS/third-party-podspecs/LibEvent.podspec deleted file mode 100644 index 3dc29d42b..000000000 --- a/iOS/third-party-podspecs/LibEvent.podspec +++ /dev/null @@ -1,29 +0,0 @@ -Pod::Spec.new do |s| - - s.name = "libevent" - s.version = "1.0" - s.summary = "Unofficial libevent mirror for Cocoapods" - - s.description = <<-DESC - This is a binary distribution of the libevent library built for iOS. - The library uses configure which makes it a bit tricky to cross compile. - DESC - - s.homepage = "http://libevent.org/" - s.license = "BSD" - s.authors = { "liguangming" => "cute@liguangming.com" } - s.social_media_url = "http://twitter.com/liguangming" - s.ios.deployment_target = "6.0" - s.source = { :git => "https://github.com/cute/libevent.git", :tag => "1.0" } - s.header_dir = "event2" - s.source_files = "include/**/*.h" - s.ios.library = "event" - s.preserve_paths = "include", "lib" - s.requires_arc = false - s.xcconfig = { - "HEADER_SEARCH_PATHS" => "$(PODS_ROOT)/libevent/include", - "HEADER_SEARCH_PATHS" => "$(PODS_ROOT)/libevent/include/event2", - "LIBRARY_SEARCH_PATHS" => "$(PODS_ROOT)/libevent/lib", - } - -end diff --git a/iOS/third-party-podspecs/PeerTalk.podspec b/iOS/third-party-podspecs/PeerTalk.podspec deleted file mode 100644 index eeac92540..000000000 --- a/iOS/third-party-podspecs/PeerTalk.podspec +++ /dev/null @@ -1,19 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'PeerTalk' - spec.version = '1.0.0' - spec.license = { :type => 'MIT' } - spec.homepage = 'http://rsms.me/peertalk/' - spec.authors = { 'Rasmus Andersson' => 'rasmus@notion.se' } - spec.summary = 'iOS and OS X Cocoa library for communicating over USB and TCP.' - - spec.source = { :git => "https://github.com/rsms/PeerTalk.git", :branch => 'master' } - spec.source_files = 'peertalk/*.{h,m}' - spec.requires_arc = true - spec.ios.deployment_target = '8.4' - spec.osx.deployment_target = '10.10' - - spec.description = " PeerTalk is a iOS and OS X Cocoa library for communicating over USB and TCP.\n\n Highlights:\n\n * Provides you with USB device attach/detach events and attached device's info\n * Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport\n * Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.\n * Tested and designed for libdispatch (aka Grand Central Dispatch).\n" - spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/**" } - -end diff --git a/iOS/third-party-podspecs/RSocket.podspec b/iOS/third-party-podspecs/RSocket.podspec deleted file mode 100644 index ac127e1aa..000000000 --- a/iOS/third-party-podspecs/RSocket.podspec +++ /dev/null @@ -1,53 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'RSocket' - spec.version = '0.10.0' - spec.license = { :type => 'MIT' } - spec.homepage = 'https://github.com/rsocket/rsocket-cpp' - spec.summary = 'C++ implementation of RSocket' - spec.authors = 'Facebook' - spec.source = { :git => 'https://github.com/rsocket/rsocket-cpp.git', :branch => "master"} - spec.module_name = 'RSocket' - spec.source_files = 'rsocket/benchmarks/*', - 'rsocket/framing/*', - 'rsocket/internal/*', - 'rsocket/statemachine/*', - 'rsocket/transports/*', - 'rsocket/transports/**/*', - 'yarpl/observable/*', - 'yarpl/flowable/*', - 'rsocket/*' - - spec.libraries = "stdc++" - spec.compiler_flags = '-std=c++1y' - spec.dependency 'Folly' - spec.compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti - -fexceptions - -std=c++14 - -Wno-error - -Wno-unused-local-typedefs - -Wno-unused-variable - -Wno-sign-compare - -Wno-comment - -Wno-return-type - -Wno-global-constructors' - spec.preserve_paths = 'rsocket/benchmarks/*.h', - 'rsocket/framing/*.h', - 'rsocket/internal/*.h', - 'rsocket/statemachine/*.h', - 'rsocket/transports/*.h', - 'rsocket/*.h', - 'yarpl/flowable/*.h', - 'yarpl/observable/*.h', - 'yarpl/perf/*.h', - 'yarpl/single/*.h', - 'yarpl/utils/*.h', - 'yarpl/*.h', - '**/*.h' - spec.header_mappings_dir = 'rsocket' - spec.header_dir = 'rsocket' - spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/DoubleConversion\"/**" } - spec.platforms = { :ios => "8.0" } - -end diff --git a/iOS/third-party-podspecs/glog.podspec b/iOS/third-party-podspecs/glog.podspec index 3524ba47e..a68659fa0 100755 --- a/iOS/third-party-podspecs/glog.podspec +++ b/iOS/third-party-podspecs/glog.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |spec| spec.homepage = 'https://github.com/google/glog' spec.summary = 'Google logging module' spec.authors = 'Google' - spec.prepare_command = "#!/bin/bash\nset -e\n\nPLATFORM_NAME=\"${PLATFORM_NAME:-iphoneos}\"\nCURRENT_ARCH=\"${CURRENT_ARCH:-armv7}\"\n\nexport CC=\"$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)\"\nexport CXX=\"$CC\"\n\n# Remove automake symlink if it exists\nif [ -h \"test-driver\" ]; then\n rm test-driver\nfi\n\n./configure --host arm-apple-darwin\n\n# Fix build for tvOS\ncat << EOF >> src/config.h\n\n/* Add in so we have Apple Target Conditionals */\n#ifdef __APPLE__\n#include \n#include \n#endif\n\n/* Special configuration for AppleTVOS */\n#if TARGET_OS_TV\n#undef HAVE_SYSCALL_H\n#undef HAVE_SYS_SYSCALL_H\n#undef OS_MACOSX\n#endif\n\n/* Special configuration for ucontext */\n#undef HAVE_UCONTEXT_H\n#undef PC_FROM_UCONTEXT\n#if defined(__x86_64__)\n#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip\n#elif defined(__i386__)\n#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip\n#endif\nEOF" + spec.prepare_command = File.read("../scripts/ios-configure-glog.sh") spec.source = { :git => 'https://github.com/google/glog.git', :tag => "v#{spec.version}" } spec.module_name = 'glog' @@ -36,6 +36,6 @@ Pod::Spec.new do |spec| } spec.compiler_flags = '-std=c++1y' spec.libraries = "stdc++" - spec.platforms = { :ios => "8.0"} + spec.platforms = { :ios => "8.0", :tvos => "9.2" } end diff --git a/package.json b/package.json index e4c78c4d7..33df6b4b7 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "eslint-plugin-relay": "^0.0.20", "flow-bin": "^0.69.0", "glob": "^7.1.2", - "prettier": "1.12.1" + "prettier": "1.13.4" }, "dependencies": { "JSONStream": "^1.3.1", diff --git a/scripts/public-build.sh b/scripts/public-build.sh index 59b3d6843..aae5f60e9 100755 --- a/scripts/public-build.sh +++ b/scripts/public-build.sh @@ -11,11 +11,13 @@ function jsonValue() { git -c http.proxy=fwdproxy:8080 -c https.proxy=fwdproxy:8080 clone https://github.com/facebook/Sonar.git sonar-public cp sonar/scripts/sandcastle-build.sh sonar-public/scripts/sandcastle-build.sh +# third-party dependencies are not on github, so we need to copy them in place +cp -r sonar/third-party sonar-public/third-party cd sonar-public/scripts && ./sandcastle-build.sh "$(git rev-list HEAD --count || echo 0)" VERSION=$(plutil -p ./sonar-public/dist/mac/Sonar.app/Contents/Info.plist | awk '/CFBundleShortVersionString/ {print substr($3, 2, length($3)-2)}') -RELEASE_JSON=$(curl $(fwdproxy-config curl) --silent --data '{ +RELEASE_JSON=$(curl -x fwdproxy:8080 --silent --data '{ "tag_name": "v'$VERSION'", "target_commitish": "master", "name": "v'$VERSION'", @@ -33,7 +35,7 @@ fi echo "Created GitHub release ID: $RELEASE_ID" UPLOAD_URL=$(echo $RELEASE_JSON | jsonValue upload_url| sed -e 's#{?name,label}##') -ASSET_JSON=$(curl $(fwdproxy-config curl) --silent $UPLOAD_URL'?access_token='$TOKEN'&name=Sonar.zip' --header 'Content-Type: application/zip' --upload-file ./sonar-public/dist/Sonar.zip -X POST) +ASSET_JSON=$(curl -x fwdproxy:8080 --silent $UPLOAD_URL'?access_token='$TOKEN'&name=Sonar.zip' --header 'Content-Type: application/zip' --upload-file ./sonar-public/dist/Sonar.zip -X POST) DOWNLOAD_URL=$(echo $ASSET_JSON | jsonValue browser_download_url) diff --git a/src/device-plugins/screen/index.js b/src/device-plugins/screen/index.js index 086f566da..59d12e67f 100644 --- a/src/device-plugins/screen/index.js +++ b/src/device-plugins/screen/index.js @@ -202,9 +202,11 @@ export default class ScreenPlugin extends SonarDevicePlugin { pullingData: true, }); }) - .then((): Promise => { - return self.pullFromDevice(`/sdcard/${VIDEO_FILE_NAME}`, VIDEO_PATH); - }) + .then( + (): Promise => { + return self.pullFromDevice(`/sdcard/${VIDEO_FILE_NAME}`, VIDEO_PATH); + }, + ) .then(openFile) .then(() => { self.executeShell(`rm /sdcard/${VIDEO_FILE_NAME}`); diff --git a/src/server.js b/src/server.js index 664905b23..e98da0e5f 100644 --- a/src/server.js +++ b/src/server.js @@ -443,7 +443,7 @@ export class Server extends EventEmitter { this.certificateProvider.processCertificateSigningRequest( csr, connectionParameters.os, - destination + destination, ); } }, diff --git a/src/ui/components/VirtualList.js b/src/ui/components/VirtualList.js index 1c5d8dc63..fe4c67d58 100644 --- a/src/ui/components/VirtualList.js +++ b/src/ui/components/VirtualList.js @@ -113,7 +113,7 @@ export default class VirtualList extends Component< // Overscan: render blocks of rows modulo an overscan row count // This dramatically reduces DOM writes during scrolling if (overscanCount) { - start = Math.max(0, start - start % overscanCount); + start = Math.max(0, start - (start % overscanCount)); visibleRowCount += overscanCount; } diff --git a/src/ui/components/desktop-toolbar.js b/src/ui/components/desktop-toolbar.js index abc7df2c8..c634fc526 100644 --- a/src/ui/components/desktop-toolbar.js +++ b/src/ui/components/desktop-toolbar.js @@ -65,8 +65,8 @@ const DesktopDropdownItemContainer = styled.view( type DesktopDropdownItemState = {|hovered: boolean|}; type DesktopDropdownItemProps = { - onClick?: false | ?(event: SyntheticMouseEvent<>) => void, - onHover?: false | ?() => React$Node, + onClick?: false | ?((event: SyntheticMouseEvent<>) => void), + onHover?: false | ?(() => React$Node), children?: React$Node, deactivate?: () => void, }; diff --git a/src/ui/components/table/TableHead.js b/src/ui/components/table/TableHead.js index f44a1e0ed..c62df84a9 100644 --- a/src/ui/components/table/TableHead.js +++ b/src/ui/components/table/TableHead.js @@ -86,7 +86,7 @@ const TableHeadColumnContainer = styled.view( const RIGHT_RESIZABLE = {right: true}; function calculatePercentage(parentWidth: number, selfWidth: number): string { - return `${100 / parentWidth * selfWidth}%`; + return `${(100 / parentWidth) * selfWidth}%`; } class TableHeadColumn extends PureComponent<{ diff --git a/src/utils/openssl-wrapper-with-promises.js b/src/utils/openssl-wrapper-with-promises.js index 52ff58cd2..763bfd67d 100644 --- a/src/utils/openssl-wrapper-with-promises.js +++ b/src/utils/openssl-wrapper-with-promises.js @@ -1,9 +1,10 @@ /** - * Copyright 2004-present Facebook. + * Copyright 2018-present Facebook. * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * @format */ + import {exec as opensslWithCallback} from 'openssl-wrapper'; export function openssl(action: string, options: {}): Promise { diff --git a/src/utils/snap.js b/src/utils/snap.js index 1b8e74577..723caabb1 100644 --- a/src/utils/snap.js +++ b/src/utils/snap.js @@ -10,7 +10,7 @@ import type {Rect} from './geometry.js'; export const SNAP_SIZE = 16; export function snapGrid(val: number): number { - return val - val % SNAP_SIZE; + return val - (val % SNAP_SIZE); } export function getPossibleSnappedPosition( diff --git a/website/core/Footer.js b/website/core/Footer.js index 1b187d243..0ab50ec55 100644 --- a/website/core/Footer.js +++ b/website/core/Footer.js @@ -47,7 +47,7 @@ class Footer extends React.Component {
More
- Twitter + Twitter GitHub 'MIT' } spec.homepage = 'https://github.com/facebook/sonar' spec.summary = 'SonarKit core cpp code with network implementation' spec.authors = 'Facebook' + # spec.prepare_command = 'mv src double-conversion' spec.source = { :git => 'https://github.com/facebook/Sonar.git', :branch => 'master' } spec.module_name = 'Sonar' @@ -12,12 +13,21 @@ Pod::Spec.new do |spec| spec.source_files = 'xplat/Sonar/*.{h,cpp,m,mm}' spec.libraries = "stdc++" spec.dependency 'Folly' - spec.dependency 'RSocket' + spec.dependency 'EasyWSClient' + # spec.dependency 'boost-for-react-native' + # + # spec.dependency 'DoubleConversion' + # spec.dependency 'Folly' + # spec.dependency 'glog' spec.compiler_flags = '-DFB_SONARKIT_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -Wall -std=c++14 -Wno-global-constructors' - spec.platforms = { :ios => "8.0" } + # spec.header_mappings_dir = 'folly' + # spec.header_dir = 'folly' + # spec.preserve_paths = 'xplat/**/*' + # Pinning to the same version as React.podspec. + spec.platforms = { :ios => "8.0", :tvos => "9.2" } spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/RSocket\" \"$(PODS_ROOT)/DoubleConversion\"" } + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/EasyWSClient\" \"$(PODS_ROOT)/DoubleConversion\"" } end diff --git a/xplat/Sonar/SonarWebSocketImpl.cpp b/xplat/Sonar/SonarWebSocketImpl.cpp index 30d64339e..78b3d1338 100644 --- a/xplat/Sonar/SonarWebSocketImpl.cpp +++ b/xplat/Sonar/SonarWebSocketImpl.cpp @@ -35,7 +35,7 @@ #define PRIVATE_KEY_FILE "privateKey.pem" static constexpr int reconnectIntervalSeconds = 2; -static constexpr int connectionKeepaliveSeconds = 2; +static constexpr int connectionKeepaliveSeconds = 10; static constexpr int securePort = 8088; static constexpr int insecurePort = 8089; @@ -97,7 +97,7 @@ SonarWebSocketImpl::~SonarWebSocketImpl() { void SonarWebSocketImpl::start() { folly::makeFuture() .via(worker_->getEventBase()) - .delayed(std::chrono::milliseconds(0)) + .delayedUnsafe(std::chrono::milliseconds(0)) .then([this]() { startSync(); }); } @@ -113,18 +113,13 @@ void SonarWebSocketImpl::startSync() { } connectSecurely(); - } catch (const std::exception& e) { - std::string errors = folly::SSLContext::getErrors(); - SONAR_LOG("Error connecting to sonar"); - SONAR_LOG(e.what()); - SONAR_LOG(errors.c_str()); + } catch (const std::exception&) { failedConnectionAttempts_++; reconnect(); } } void SonarWebSocketImpl::doCertificateExchange() { - SONAR_LOG("Starting certificate exchange"); rsocket::SetupParameters parameters; folly::SocketAddress address; @@ -187,7 +182,7 @@ void SonarWebSocketImpl::connectSecurely() { void SonarWebSocketImpl::reconnect() { folly::makeFuture() .via(worker_->getEventBase()) - .delayed(std::chrono::seconds(reconnectIntervalSeconds)) + .delayedUnsafe(std::chrono::seconds(reconnectIntervalSeconds)) .then([this]() { startSync(); }); } @@ -216,11 +211,6 @@ void SonarWebSocketImpl::sendMessage(const folly::dynamic& message) { bool SonarWebSocketImpl::isCertificateExchangeNeeded() { if (failedConnectionAttempts_ >= 2) { - auto format = - "Requesting fresh certificate exchange after %d failed connection attempts"; - char buff[strlen(format) + 1]; - sprintf(buff, format, failedConnectionAttempts_); - SONAR_LOG(buff); return true; } @@ -238,7 +228,6 @@ bool SonarWebSocketImpl::isCertificateExchangeNeeded() { } void SonarWebSocketImpl::requestSignedCertFromSonar() { - SONAR_LOG("Requesting new client certificate from Sonar"); std::string csr = loadStringFromFile(absoluteFilePath(CSR_FILE_NAME)); if (csr == "") { generateCertSigningRequest( diff --git a/yarn.lock b/yarn.lock index c2d4bdabd..31b4e7147 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3874,9 +3874,9 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier@1.12.1: - version "1.12.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325" +prettier@1.13.4: + version "1.13.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.4.tgz#31bbae6990f13b1093187c731766a14036fa72e6" pretty-bytes@^1.0.2: version "1.0.4" From 8e5647725a0421cb27bd6de875d4f301fcce3039 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 12 Jun 2018 03:41:25 -0700 Subject: [PATCH 17/44] Replace test runner in sample Summary: WithDefaultsTestRunner is FB-specific. Let's replace that with its base class. Reviewed By: danielbuechele Differential Revision: D8355145 fbshipit-source-id: 4d87ad00a82d1e2d5b536289f247910c6139df07 --- docs/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing.md b/docs/testing.md index 3817d32b9..cc82f147a 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -11,7 +11,7 @@ Developer tools are only used if they work. We have built APIs to test plugins. Start by creating your first test file in this directory `MySonarPluginTest.java`. In the test method body we create our plugin which we want to test as well as a `SonarConnectionMock`. In this contrived example we simply assert that our plugin's connected status is what we expect. ```java -@RunWith(WithTestDefaultsRunner.class) +@RunWith(RobolectricTestRunner.class) public class MySonarPluginTest { @Test From 8af2af6558c7e9650260a212c62b335eeead9ca9 Mon Sep 17 00:00:00 2001 From: John Knox Date: Tue, 12 Jun 2018 03:43:04 -0700 Subject: [PATCH 18/44] Never reuse CSR files Summary: If the app has an old CSR with data that is incompatible with sonar, we can't use it. An example of this happening is when we moved the package name from organisation to common name in the certificate subject. To get around this, always create a new one to guarantee it contains what we expect. Reviewed By: emilsjolander Differential Revision: D8350247 fbshipit-source-id: e53148fcddc47aa60e3daef5bbf36ce330a3b4e9 --- xplat/Sonar/SonarWebSocketImpl.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xplat/Sonar/SonarWebSocketImpl.cpp b/xplat/Sonar/SonarWebSocketImpl.cpp index 78b3d1338..26419b99d 100644 --- a/xplat/Sonar/SonarWebSocketImpl.cpp +++ b/xplat/Sonar/SonarWebSocketImpl.cpp @@ -228,15 +228,12 @@ bool SonarWebSocketImpl::isCertificateExchangeNeeded() { } void SonarWebSocketImpl::requestSignedCertFromSonar() { + generateCertSigningRequest( + deviceData_.appId.c_str(), + absoluteFilePath(CSR_FILE_NAME).c_str(), + absoluteFilePath(PRIVATE_KEY_FILE).c_str()); std::string csr = loadStringFromFile(absoluteFilePath(CSR_FILE_NAME)); - if (csr == "") { - generateCertSigningRequest( - deviceData_.appId.c_str(), - absoluteFilePath(CSR_FILE_NAME).c_str(), - absoluteFilePath(PRIVATE_KEY_FILE).c_str()); - csr = loadStringFromFile(absoluteFilePath(CSR_FILE_NAME)); - } - // Send CSR to Sonar desktop + folly::dynamic message = folly::dynamic::object("method", "signCertificate")( "csr", csr.c_str())("destination", absoluteFilePath("").c_str()); worker_->add([this, message]() { From 4fbe638adf39f413e8fb5a20e4de6833a8bbbdd2 Mon Sep 17 00:00:00 2001 From: John Knox Date: Tue, 12 Jun 2018 03:43:05 -0700 Subject: [PATCH 19/44] Silence expected error logs Summary: When an app with sonar is run for the first time, the necessary files don't exist. This is expected, so don't output an error, only error if they do exist but there's some other problem. Reviewed By: emilsjolander Differential Revision: D8350995 fbshipit-source-id: ff0a4f0e7a73848f6172c6108a0caee6efb43553 --- xplat/Sonar/SonarWebSocketImpl.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xplat/Sonar/SonarWebSocketImpl.cpp b/xplat/Sonar/SonarWebSocketImpl.cpp index 26419b99d..cc81efcc4 100644 --- a/xplat/Sonar/SonarWebSocketImpl.cpp +++ b/xplat/Sonar/SonarWebSocketImpl.cpp @@ -42,6 +42,8 @@ static constexpr int insecurePort = 8089; namespace facebook { namespace sonar { +bool fileExists(std::string fileName); + class ConnectionEvents : public rsocket::RSocketConnectionEvents { private: SonarWebSocketImpl* websocket_; @@ -249,6 +251,9 @@ void SonarWebSocketImpl::requestSignedCertFromSonar() { } std::string SonarWebSocketImpl::loadStringFromFile(std::string fileName) { + if (!fileExists(fileName)) { + return ""; + } std::stringstream buffer; std::ifstream stream; std::string line; @@ -283,5 +288,10 @@ bool SonarWebSocketImpl::ensureSonarDirExists() { } } +bool fileExists(std::string fileName) { + struct stat buffer; + return stat(fileName.c_str(), &buffer) == 0; +} + } // namespace sonar } // namespace facebook From 86d266e75cafb69a9f69bdf15c7f7cce363ed9bf Mon Sep 17 00:00:00 2001 From: Michael Evans Date: Tue, 12 Jun 2018 04:59:53 -0700 Subject: [PATCH 20/44] Fix yarn lint failures Summary: Closes https://github.com/facebook/Sonar/pull/20 Reviewed By: jknoxville Differential Revision: D8378657 Pulled By: danielbuechele fbshipit-source-id: 51dcc4621d657dee089949caf3ebf1961eb3dd6d --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 841ea8d90..4373cd483 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,7 +8,7 @@ const fbjs = require('eslint-config-fbjs'); // enforces copyright header and @format directive to be present in every file -const pattern = /^\*\n \* Copyright 2018-present Facebook\.\n \* This source code is licensed under the MIT license found in the\n \* LICENSE file in the root directory of this source tree\.\n \* @format\n./; +const pattern = /^\*\n \* Copyright 20\d{2}-present Facebook\.\n \* This source code is licensed under the MIT license found in the\n \* LICENSE file in the root directory of this source tree\.\n \* @format\n./; module.exports = { extends: 'fbjs', From dba07a33c7e71f3f5249fc6ba0017954ed567275 Mon Sep 17 00:00:00 2001 From: Michael Evans Date: Tue, 12 Jun 2018 05:11:18 -0700 Subject: [PATCH 21/44] Fix typo in ui-components docs Summary: Closes https://github.com/facebook/Sonar/pull/26 Differential Revision: D8379209 Pulled By: danielbuechele fbshipit-source-id: b5f2fe8de84e48a9cd43bb8cd3e79e21e6be470f --- docs/ui-components.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ui-components.md b/docs/ui-components.md index 2e4150ccf..b121d5cd1 100644 --- a/docs/ui-components.md +++ b/docs/ui-components.md @@ -4,7 +4,7 @@ title: UI Components sidebar_label: UI Components --- -Sonar has a lot of built in React components to build UIs. You can find all of these in [`src/ui/components`](https://github.com/facebook/Sonar/tree/master/src/ui/components) and can import them directly using `import {Buttom} from 'sonar'`. +Sonar has a lot of built in React components to build UIs. You can find all of these in [`src/ui/components`](https://github.com/facebook/Sonar/tree/master/src/ui/components) and can import them directly using `import {Button} from 'sonar'`. ## FlexBox From 1fa0eb3ad2485f6ed519229cb24fb167fdb07df0 Mon Sep 17 00:00:00 2001 From: sungjk Date: Tue, 12 Jun 2018 06:05:49 -0700 Subject: [PATCH 22/44] Fix typo in reducers (#34) Summary: Fixed typos in reducers Closes https://github.com/facebook/Sonar/pull/34 Differential Revision: D8379211 Pulled By: danielbuechele fbshipit-source-id: d1dc6ff80963b931a3d8b1e4abe0f40ade3ba67f --- src/reducers/application.js | 4 ++-- src/reducers/devices.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/reducers/application.js b/src/reducers/application.js index 357dccff4..528847deb 100644 --- a/src/reducers/application.js +++ b/src/reducers/application.js @@ -29,7 +29,7 @@ export type Action = { payload?: boolean, }; -const INITAL_STATE: State = { +const INITIAL_STATE: State = { leftSidebarVisible: true, rightSidebarVisible: true, rightSidebarAvailable: false, @@ -39,7 +39,7 @@ const INITAL_STATE: State = { }; export default function reducer( - state: State = INITAL_STATE, + state: State = INITIAL_STATE, action: Action, ): State { const newValue = diff --git a/src/reducers/devices.js b/src/reducers/devices.js index 17e2a8d05..763d68c13 100644 --- a/src/reducers/devices.js +++ b/src/reducers/devices.js @@ -18,10 +18,10 @@ export type Action = payload: BaseDevice, }; -const INITAL_STATE: State = []; +const INITIAL_STATE: State = []; export default function reducer( - state: State = INITAL_STATE, + state: State = INITIAL_STATE, action: Action, ): State { switch (action.type) { From 521cca5e47a364479f8c99464dae3241c88644f6 Mon Sep 17 00:00:00 2001 From: Romain Le Quellec Date: Tue, 12 Jun 2018 06:06:18 -0700 Subject: [PATCH 23/44] docs: rename communicating filename (#44) Summary: Just a small typo in the filename Closes https://github.com/facebook/Sonar/pull/44 Differential Revision: D8379387 Pulled By: danielbuechele fbshipit-source-id: ae855068098360805c8ec56a1544a3cbea22f2c0 --- docs/{communitcating.md => communicating.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{communitcating.md => communicating.md} (100%) diff --git a/docs/communitcating.md b/docs/communicating.md similarity index 100% rename from docs/communitcating.md rename to docs/communicating.md From 2f6508ca03dfac55e2fe5ff9674e4dd1a0021d93 Mon Sep 17 00:00:00 2001 From: Jay Newstrom Date: Tue, 12 Jun 2018 06:18:29 -0700 Subject: [PATCH 24/44] Fix typo in stetho documentation. Summary: Closes https://github.com/facebook/Sonar/pull/17 Differential Revision: D8379391 Pulled By: danielbuechele fbshipit-source-id: 3eef14299f64b590c0e68624b17468f45111921c --- docs/stetho.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stetho.md b/docs/stetho.md index 2ff631642..eff3e7592 100644 --- a/docs/stetho.md +++ b/docs/stetho.md @@ -4,7 +4,7 @@ title: Stetho Guidance sidebar_label: Stetho Guidance --- -In 2015, we introduced [Stetho](http://facebook.github.io/stetho/), an Android debugging bridge built on top of Chrome dev tools. While it was a valuable tool to us and many members of the community, we felt that it limited us in what we could do with it. Stetho is Android-only and while Chrome dev tools gave us a nice foundation to build upon, they also limited us in what we could build. Stetho is an Android tool and Chrome dev tools is built for web developers. This means we can only provide a good experience for the intersection of those two development environments, which was very limiting. With Sonar being built as a standalone app, we can do more things, like handling adb connections and supporting iOS, which wouldn't easily achievable with stetho. +In 2015, we introduced [Stetho](http://facebook.github.io/stetho/), an Android debugging bridge built on top of Chrome dev tools. While it was a valuable tool to us and many members of the community, we felt that it limited us in what we could do with it. Stetho is Android-only and while Chrome dev tools gave us a nice foundation to build upon, they also limited us in what we could build. Stetho is an Android tool and Chrome dev tools is built for web developers. This means we can only provide a good experience for the intersection of those two development environments, which was very limiting. With Sonar being built as a standalone app, we can do more things, like handling adb connections and supporting iOS, which wasn't easily achievable with stetho. This is why we built Sonar. We wanted to create a platform that gives us all the flexibility we need to build more advanced features and support for iOS. One of Sonar's core concept is it's extensibility using [plugins](create-plugin.md). Plugins are written in react and we provide a set of ready-to-use UI components that allows developers to build great plugin UIs with a few lines of code. From 1edffabd05012e8e96554ad60045b6d8dfde611e Mon Sep 17 00:00:00 2001 From: Andrei Verdes Date: Tue, 12 Jun 2018 06:31:52 -0700 Subject: [PATCH 25/44] Fix GH-22 wrong method for Android docs (#23) Summary: As per GH-14 comment, the docs were pointing to an internal `private` method to check if `Sonar` should be enabled Closes https://github.com/facebook/Sonar/pull/23 Reviewed By: danielbuechele Differential Revision: D8379336 Pulled By: jknoxville fbshipit-source-id: bc580dc40a1994a2f4a30544d77f86b60e9353f6 --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 452e25df1..f4900bd81 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -44,7 +44,7 @@ public class MyApplication extends Application { public void onCreate() { super.onCreate(); - if (BuildConfig.DEBUG && SonarUtils.isMainProcess(mApplicationContext)) { + if (BuildConfig.DEBUG && SonarUtils.shouldEnableSonar(this)) { final SonarClient client = AndroidSonarClient.getInstance(this); client.addPlugin(new MySonarPlugin()); client.start(); From 28be3c7cd85c43880f37f170b14c39403e07458e Mon Sep 17 00:00:00 2001 From: Daniel Buchele Date: Tue, 12 Jun 2018 11:42:02 -0700 Subject: [PATCH 26/44] fbshipit-source-id: cad5f527363fe09c2eea5b05ce1f3f2ecb86941b --- CNAME | 1 + docs/getting-started.md | 1 + iOS/Podfile | 7 ++- iOS/Sample/Podfile | 7 ++- iOS/Sample/Sample.xcodeproj/project.pbxproj | 4 -- iOS/SonarKit.podspec | 29 +++------- .../CppBridge/SonarCppBridgingConnection.mm | 7 +-- .../CppBridge/SonarCppBridgingResponder.mm | 6 +-- iOS/SonarKit/Info.plist | 24 +++++++++ iOS/SonarKit/SonarClient.mm | 14 ++--- iOS/scripts/ios-configure-glog.sh | 41 -------------- .../DoubleConversion.podspec | 4 +- iOS/third-party-podspecs/EasyWSClient.podspec | 17 ------ iOS/third-party-podspecs/Folly.podspec | 43 +++++++++++---- iOS/third-party-podspecs/PeerTalk.podspec | 19 +++++++ iOS/third-party-podspecs/RSocket.podspec | 53 +++++++++++++++++++ iOS/third-party-podspecs/glog.podspec | 4 +- .../com/facebook/jni/HybridClassBase.java | 14 +++++ src/plugins/layout/index.js | 21 ++++---- src/utils/CertificateProvider.js | 17 +++++- src/utils/openssl-wrapper-with-promises.js | 5 ++ .../{SonarKitCPP.podspec => Sonar.podspec} | 18 ++----- 22 files changed, 208 insertions(+), 148 deletions(-) create mode 100644 CNAME create mode 100644 iOS/SonarKit/Info.plist delete mode 100644 iOS/scripts/ios-configure-glog.sh delete mode 100644 iOS/third-party-podspecs/EasyWSClient.podspec create mode 100644 iOS/third-party-podspecs/PeerTalk.podspec create mode 100644 iOS/third-party-podspecs/RSocket.podspec create mode 100644 libs/fbjni/src/main/java/com/facebook/jni/HybridClassBase.java rename xplat/Sonar/{SonarKitCPP.podspec => Sonar.podspec} (67%) diff --git a/CNAME b/CNAME new file mode 100644 index 000000000..c5fa5f686 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +fbsonar.com diff --git a/docs/getting-started.md b/docs/getting-started.md index f4900bd81..b8e736b0b 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -43,6 +43,7 @@ public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); + SoLoader.init(this, 0); if (BuildConfig.DEBUG && SonarUtils.shouldEnableSonar(this)) { final SonarClient client = AndroidSonarClient.getInstance(this); diff --git a/iOS/Podfile b/iOS/Podfile index 056604147..63a63d759 100644 --- a/iOS/Podfile +++ b/iOS/Podfile @@ -9,12 +9,11 @@ target 'SonarKit' do # Pods for SonarKit - # Third party deps podspec link - pod 'EasyWSClient', :podspec => 'third-party-podspecs/EasyWSClient.podspec' + pod 'PeerTalk', :podspec => 'third-party-podspecs/PeerTalk.podspec' + pod 'RSocket', :podspec => 'third-party-podspecs/RSocket.podspec' pod 'DoubleConversion', :podspec => 'third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => 'third-party-podspecs/glog.podspec' pod 'Folly', :podspec => 'third-party-podspecs/Folly.podspec' - pod 'Sonar', :podspec => '../xplat/Sonar/SonarKitCPP.podspec' + pod 'Sonar', :podspec => '../xplat/Sonar/Sonar.podspec' pod 'CocoaAsyncSocket' - pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' end diff --git a/iOS/Sample/Podfile b/iOS/Sample/Podfile index 70f73b4a3..e8a1995e0 100644 --- a/iOS/Sample/Podfile +++ b/iOS/Sample/Podfile @@ -6,18 +6,17 @@ swift_version = "4.1" target 'Sample' do - pod 'EasyWSClient', :podspec => '../third-party-podspecs/EasyWSClient.podspec' + pod 'RSocket', :podspec => '../third-party-podspecs/RSocket.podspec' pod 'DoubleConversion', :podspec => '../third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../third-party-podspecs/Folly.podspec' - pod 'PeerTalk', :git => 'https://github.com/rsms/peertalk' + pod 'PeerTalk', :podspec => '../third-party-podspecs/PeerTalk.podspec' pod 'ComponentKit', :podspec => '../third-party-podspecs/ComponentKit.podspec' pod 'Yoga','~>1.8.1', :modular_headers => true - pod 'Sonar', :podspec => '../../xplat/Sonar/SonarKitCPP.podspec' + pod 'Sonar', :podspec => '../../xplat/Sonar/Sonar.podspec' pod 'SonarKit', :podspec => '../SonarKit.podspec' pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => '../SonarKit.podspec' pod 'SonarKit/SKIOSNetworkPlugin', :podspec => '../SonarKit.podspec' - post_install do |installer| installer.pods_project.targets.each do |target| if ['YogaKit'].include? target.name diff --git a/iOS/Sample/Sample.xcodeproj/project.pbxproj b/iOS/Sample/Sample.xcodeproj/project.pbxproj index bbe9e8cf1..d1b532e26 100644 --- a/iOS/Sample/Sample.xcodeproj/project.pbxproj +++ b/iOS/Sample/Sample.xcodeproj/project.pbxproj @@ -333,7 +333,6 @@ "\"${PODS_ROOT}/Headers/Public/CocoaAsyncSocket\"", "\"${PODS_ROOT}/Headers/Public/ComponentKit\"", "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"", - "\"${PODS_ROOT}/Headers/Public/EasyWSClient\"", "\"${PODS_ROOT}/Headers/Public/Folly\"", "\"${PODS_ROOT}/Headers/Public/PeerTalk\"", "\"${PODS_ROOT}/Headers/Public/Sonar\"/**", @@ -361,7 +360,6 @@ "-l\"CocoaAsyncSocket\"", "-l\"ComponentKit\"", "-l\"DoubleConversion\"", - "-l\"EasyWSClient\"", "-l\"Folly\"", "-l\"PeerTalk\"", "-l\"Sonar\"", @@ -400,7 +398,6 @@ "\"${PODS_ROOT}/Headers/Public/CocoaAsyncSocket\"", "\"${PODS_ROOT}/Headers/Public/ComponentKit\"", "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"", - "\"${PODS_ROOT}/Headers/Public/EasyWSClient\"", "\"${PODS_ROOT}/Headers/Public/Folly\"", "\"${PODS_ROOT}/Headers/Public/PeerTalk\"", "\"${PODS_ROOT}/Headers/Public/Sonar\"/**", @@ -428,7 +425,6 @@ "-l\"CocoaAsyncSocket\"", "-l\"ComponentKit\"", "-l\"DoubleConversion\"", - "-l\"EasyWSClient\"", "-l\"Folly\"", "-l\"PeerTalk\"", "-l\"Sonar\"", diff --git a/iOS/SonarKit.podspec b/iOS/SonarKit.podspec index 80136339f..c884c2d98 100644 --- a/iOS/SonarKit.podspec +++ b/iOS/SonarKit.podspec @@ -1,15 +1,15 @@ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0' -yoga_version = '1.8.1' +yoga_version = '~> 1.8' yogakit_version = '1.8.1' Pod::Spec.new do |spec| spec.name = 'SonarKit' - spec.version = '1.0.0' + spec.version = '0.0.1' spec.license = { :type => 'MIT' } spec.homepage = 'https://github.com/facebook/Sonar' spec.summary = 'Sonar iOS podspec' spec.authors = 'Facebook' - # spec.prepare_command = 'mv src double-conversion' + spec.static_framework = true spec.source = { :git => 'https://github.com/facebook/Sonar.git', :branch=> "master" } spec.module_name = 'SonarKit' @@ -17,7 +17,8 @@ Pod::Spec.new do |spec| spec.dependency 'Sonar' spec.dependency 'CocoaAsyncSocket', '~> 7.6' spec.dependency 'PeerTalk' - spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}' + spec.dependency 'OpenSSL-Static', '1.0.2.c1' + spec.source_files = 'iOS/FBDefines/*.{h,cpp,m,mm}', 'iOS/SonarKit/**/*.{h,cpp,m,mm}', 'iOS/SonarKit/FBCxxUtils/*.{h, mm}', spec.public_header_files = 'iOS/SonarKit/CppBridge/*.{h}', 'iOS/SonarKit/SonarClient.h', 'iOS/SonarKit/SonarDeviceData.h', @@ -26,12 +27,10 @@ Pod::Spec.new do |spec| 'iOS/SonarKit/SonarConnection.h', 'iOS/SonarKit/SKMacros.h' - spec.private_header_files = 'iOS/Sample/' spec.compiler_flags = '-DFB_SONARKIT_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/ComponentKit\"/**" } - spec.platforms = { :ios => "8.0", :tvos => "9.2" } + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/PeerTalkSonar\" \"$(PODS_ROOT)/ComponentKit\"/**" } + spec.platforms = { :ios => "8.0" } spec.subspec "SonarKitLayoutPlugin" do |ss| ss.dependency "Yoga", yoga_version @@ -62,7 +61,6 @@ Pod::Spec.new do |spec| ss.source_files = "iOS/Plugins/SonarKitLayoutPlugin/SonarKitLayoutComponentKitSupport/**/*.{h,cpp,m,mm}" ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } end @@ -73,18 +71,6 @@ Pod::Spec.new do |spec| 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKNetworkReporter.h' ss.source_files = "iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/*.{h,cpp,m,mm}" ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } - end - - spec.subspec "SonarKitNetworkPlugin" do |ss| - ss.public_header_files = 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SonarKitNetworkPlugin.h', - 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKBufferingPlugin.h', - 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKDispatchQueue.h', - 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKNetworkReporter.h' - ss.source_files = "iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/*.{h,cpp,m,mm}" - ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } end @@ -93,7 +79,6 @@ Pod::Spec.new do |spec| ss.public_header_files = 'iOS/Plugins/SonarKitNetworkPlugin/SKIOSNetworkPlugin/SKIOSNetworkAdapter.h' ss.source_files = "iOS/Plugins/SonarKitNetworkPlugin/SKIOSNetworkPlugin/**/*.{h,cpp,m,mm}" ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"" } end end diff --git a/iOS/SonarKit/CppBridge/SonarCppBridgingConnection.mm b/iOS/SonarKit/CppBridge/SonarCppBridgingConnection.mm index c2518f328..031cdbca7 100644 --- a/iOS/SonarKit/CppBridge/SonarCppBridgingConnection.mm +++ b/iOS/SonarKit/CppBridge/SonarCppBridgingConnection.mm @@ -7,7 +7,8 @@ */ #import "SonarCppBridgingConnection.h" -#import "SKUtils.h" +#import + #import "SonarCppBridgingResponder.h" @implementation SonarCppBridgingConnection @@ -27,7 +28,7 @@ - (void)send:(NSString *)method withParams:(NSDictionary *)params { - conn_->send([method UTF8String], [SKUtils convertIdToFollyDynamic:params]); + conn_->send([method UTF8String], facebook::cxxutils::convertIdToFollyDynamic(params)); } - (void)receive:(NSString *)method withBlock:(SonarReceiver)receiver @@ -36,7 +37,7 @@ std::unique_ptr responder) { SonarCppBridgingResponder *const objCResponder = [[SonarCppBridgingResponder alloc] initWithCppResponder:std::move(responder)]; - receiver([SKUtils convertFollyDynamicToId: message], objCResponder); + receiver(facebook::cxxutils::convertFollyDynamicToId(message), objCResponder); }; conn_->receive([method UTF8String], lambda); } diff --git a/iOS/SonarKit/CppBridge/SonarCppBridgingResponder.mm b/iOS/SonarKit/CppBridge/SonarCppBridgingResponder.mm index b43701980..0b3714fb4 100644 --- a/iOS/SonarKit/CppBridge/SonarCppBridgingResponder.mm +++ b/iOS/SonarKit/CppBridge/SonarCppBridgingResponder.mm @@ -7,7 +7,7 @@ */ #import "SonarCppBridgingResponder.h" -#import "SKUtils.h" +#import @implementation SonarCppBridgingResponder { std::unique_ptr responder_; @@ -28,8 +28,8 @@ #pragma mark - SonarResponder -- (void)success:(NSDictionary *)response { responder_->success([SKUtils convertIdToFollyDynamic:response]); } +- (void)success:(NSDictionary *)response { responder_->success(facebook::cxxutils::convertIdToFollyDynamic(response)); } -- (void)error:(NSDictionary *)response { responder_->error([SKUtils convertIdToFollyDynamic:response]); } +- (void)error:(NSDictionary *)response { responder_->error(facebook::cxxutils::convertIdToFollyDynamic(response)); } @end diff --git a/iOS/SonarKit/Info.plist b/iOS/SonarKit/Info.plist new file mode 100644 index 000000000..1007fd9dd --- /dev/null +++ b/iOS/SonarKit/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/iOS/SonarKit/SonarClient.mm b/iOS/SonarKit/SonarClient.mm index 14a62745d..c4915bfc3 100644 --- a/iOS/SonarKit/SonarClient.mm +++ b/iOS/SonarKit/SonarClient.mm @@ -15,7 +15,7 @@ #import #if !TARGET_OS_SIMULATOR -#import "SKPortForwardingServer.h" +//#import "SKPortForwardingServer.h" #endif using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; @@ -24,7 +24,7 @@ using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; facebook::sonar::SonarClient *_cppClient; folly::ScopedEventBaseThread eventBaseThread; #if !TARGET_OS_SIMULATOR - SKPortForwardingServer *_server; + // SKPortForwardingServer *_server; #endif } @@ -103,9 +103,9 @@ using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; - (void)start; { #if !TARGET_OS_SIMULATOR - _server = [SKPortForwardingServer new]; - [_server forwardConnectionsFromPort:8088]; - [_server listenForMultiplexingChannelOnPort:8078]; + // _server = [SKPortForwardingServer new]; + // [_server forwardConnectionsFromPort:8088]; + // [_server listenForMultiplexingChannelOnPort:8078]; #endif _cppClient->start(); } @@ -114,8 +114,8 @@ using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; { _cppClient->stop(); #if !TARGET_OS_SIMULATOR - [_server close]; - _server = nil; + // [_server close]; + // _server = nil; #endif } diff --git a/iOS/scripts/ios-configure-glog.sh b/iOS/scripts/ios-configure-glog.sh deleted file mode 100644 index e6a15febb..000000000 --- a/iOS/scripts/ios-configure-glog.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -set -e - -PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}" -CURRENT_ARCH="${CURRENT_ARCH:-armv7}" - -export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)" -export CXX="$CC" - -# Remove automake symlink if it exists -if [ -h "test-driver" ]; then - rm test-driver -fi - -./configure --host arm-apple-darwin - -# Fix build for tvOS -cat << EOF >> src/config.h - -/* Add in so we have Apple Target Conditionals */ -#ifdef __APPLE__ -#include -#include -#endif - -/* Special configuration for AppleTVOS */ -#if TARGET_OS_TV -#undef HAVE_SYSCALL_H -#undef HAVE_SYS_SYSCALL_H -#undef OS_MACOSX -#endif - -/* Special configuration for ucontext */ -#undef HAVE_UCONTEXT_H -#undef PC_FROM_UCONTEXT -#if defined(__x86_64__) -#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip -#elif defined(__i386__) -#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip -#endif -EOF diff --git a/iOS/third-party-podspecs/DoubleConversion.podspec b/iOS/third-party-podspecs/DoubleConversion.podspec index 91f4f819b..41a048859 100755 --- a/iOS/third-party-podspecs/DoubleConversion.podspec +++ b/iOS/third-party-podspecs/DoubleConversion.podspec @@ -5,14 +5,12 @@ Pod::Spec.new do |spec| spec.homepage = 'https://github.com/google/double-conversion' spec.summary = 'Efficient binary-decimal and decimal-binary conversion routines for IEEE doubles' spec.authors = 'Google' - # spec.prepare_command = 'mv src double-conversion' spec.source = { :git => 'https://github.com/google/double-conversion.git', :tag => "v#{spec.version}" } spec.module_name = 'DoubleConversion' spec.source_files = 'double-conversion/*.{h,cc}' spec.libraries = "stdc++" spec.compiler_flags = '-std=c++1y' - # Pinning to the same version as React.podspec. - spec.platforms = { :ios => "8.0", :tvos => "9.2" } + spec.platforms = { :ios => "8.0" } end diff --git a/iOS/third-party-podspecs/EasyWSClient.podspec b/iOS/third-party-podspecs/EasyWSClient.podspec deleted file mode 100644 index 0b3edeba9..000000000 --- a/iOS/third-party-podspecs/EasyWSClient.podspec +++ /dev/null @@ -1,17 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'EasyWSClient' - spec.version = '1.0.0' - spec.license = { :type => 'MIT' } - spec.homepage = 'https://github.com/google/double-conversion' - spec.summary = 'Easywsclient is an easy and powerful WebSocket client to get your C++ code connected to a web stack right away.' - spec.authors = 'David Baird' - # spec.prepare_command = 'mv src double-conversion' - spec.source = { :git => 'https://github.com/dhbaird/easywsclient.git', :branch => 'master'} - spec.module_name = 'EasyWSClient' - spec.source_files = '*.{hpp,cpp}' - spec.libraries = "stdc++" - spec.compiler_flags = '-std=c++1y' - # Pinning to the same version as React.podspec. - spec.platforms = { :ios => "8.0", :tvos => "9.2" } - -end diff --git a/iOS/third-party-podspecs/Folly.podspec b/iOS/third-party-podspecs/Folly.podspec index 4732038d7..1623e2bfd 100755 --- a/iOS/third-party-podspecs/Folly.podspec +++ b/iOS/third-party-podspecs/Folly.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'Folly' - spec.version = '2018.05.07.00' + spec.version = '2018.05.28.00' spec.license = { :type => 'Apache License, Version 2.0' } spec.homepage = 'https://github.com/facebook/folly' spec.summary = 'An open-source C++ library developed and used at Facebook.' @@ -11,7 +11,9 @@ Pod::Spec.new do |spec| spec.dependency 'boost-for-react-native' spec.dependency 'DoubleConversion' spec.dependency 'glog' - spec.compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti + spec.dependency 'OpenSSL-Static', '1.0.2.c1' + spec.dependency 'CocoaLibEvent', '~> 1.0' + spec.compiler_flags = '-DFOLLY_HAVE_PTHREAD=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti -fexceptions -std=c++14 -Wno-error @@ -25,10 +27,27 @@ Pod::Spec.new do |spec| 'folly/memory/detail/MallocImpl.cpp', 'folly/String.cpp', 'folly/*.cpp', + 'folly/detail/*.cpp', + 'folly/hash/*.cpp', + 'folly/portability/*.cpp', 'folly/ScopeGuard.h', 'folly/lang/ColdClass.cpp', 'folly/lang/Assume.h', - 'folly/lang/Assume.cpp' + 'folly/lang/Assume.cpp', + 'folly/io/async/*.cpp', + 'folly/io/async/ssl/*.cpp', + 'folly/io/*.cpp', + 'folly/synchronization/*.cpp', + 'folly/lang/*.cpp', + 'folly/memory/*.cpp', + 'folly/futures/*.cpp', + 'folly/futures/detail/*.cpp', + 'folly/experimental/hazptr/*.cpp', + 'folly/executors/*.cpp', + 'folly/concurrency/*.cpp', + 'folly/ssl/*.cpp', + 'folly/ssl/detail/*.cpp', + 'folly/system/*.cpp' # workaround for https://github.com/facebook/react-native/issues/14326 spec.preserve_paths = 'folly/*.h', @@ -38,16 +57,16 @@ Pod::Spec.new do |spec| 'folly/detail/*.h', 'folly/hash/*.h', 'folly/memory/*.h', - 'folly/**/*.h' + 'folly/**/*.h', + 'folly/futures/detail/*.h', + 'folly/futures/*.h' spec.header_mappings_dir = 'folly' spec.header_dir = 'folly' spec.libraries = "stdc++" spec.private_header_files = 'folly/portability/Stdlib.h', - 'folly/portability/Malloc.h', - 'folly/portability/Stdlib.h', - 'folly/portability/Stdio.h', - 'folly/portability/PThread.h' + 'folly/portability/Stdio.h' + spec.public_header_files = 'folly/portability/Config.h', 'folly/Executor.h', 'folly/Function.h', @@ -81,15 +100,19 @@ Pod::Spec.new do |spec| 'folly/FBString.h', 'folly/hash/Hash.h', 'folly/memory/Malloc.h', + 'folly/io/async/AsyncTimeout.h', 'folly/**/*.h', 'folly/memory/detail/MallocImpl.h', 'folly/String.h', - 'folly/*.h' + 'folly/*.h', + 'folly/portability/PThread.h', + 'folly/futures/*.h', + 'folly/futures/detail/*.h' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++11", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\"" } # Pinning to the same version as React.podspec. - spec.platforms = { :ios => "8.0", :tvos => "10.0" } + spec.platforms = { :ios => "8.0"} end diff --git a/iOS/third-party-podspecs/PeerTalk.podspec b/iOS/third-party-podspecs/PeerTalk.podspec new file mode 100644 index 000000000..eeac92540 --- /dev/null +++ b/iOS/third-party-podspecs/PeerTalk.podspec @@ -0,0 +1,19 @@ +Pod::Spec.new do |spec| + spec.name = 'PeerTalk' + spec.version = '1.0.0' + spec.license = { :type => 'MIT' } + spec.homepage = 'http://rsms.me/peertalk/' + spec.authors = { 'Rasmus Andersson' => 'rasmus@notion.se' } + spec.summary = 'iOS and OS X Cocoa library for communicating over USB and TCP.' + + spec.source = { :git => "https://github.com/rsms/PeerTalk.git", :branch => 'master' } + spec.source_files = 'peertalk/*.{h,m}' + spec.requires_arc = true + spec.ios.deployment_target = '8.4' + spec.osx.deployment_target = '10.10' + + spec.description = " PeerTalk is a iOS and OS X Cocoa library for communicating over USB and TCP.\n\n Highlights:\n\n * Provides you with USB device attach/detach events and attached device's info\n * Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport\n * Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.\n * Tested and designed for libdispatch (aka Grand Central Dispatch).\n" + spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/**" } + +end diff --git a/iOS/third-party-podspecs/RSocket.podspec b/iOS/third-party-podspecs/RSocket.podspec new file mode 100644 index 000000000..ac127e1aa --- /dev/null +++ b/iOS/third-party-podspecs/RSocket.podspec @@ -0,0 +1,53 @@ +Pod::Spec.new do |spec| + spec.name = 'RSocket' + spec.version = '0.10.0' + spec.license = { :type => 'MIT' } + spec.homepage = 'https://github.com/rsocket/rsocket-cpp' + spec.summary = 'C++ implementation of RSocket' + spec.authors = 'Facebook' + spec.source = { :git => 'https://github.com/rsocket/rsocket-cpp.git', :branch => "master"} + spec.module_name = 'RSocket' + spec.source_files = 'rsocket/benchmarks/*', + 'rsocket/framing/*', + 'rsocket/internal/*', + 'rsocket/statemachine/*', + 'rsocket/transports/*', + 'rsocket/transports/**/*', + 'yarpl/observable/*', + 'yarpl/flowable/*', + 'rsocket/*' + + spec.libraries = "stdc++" + spec.compiler_flags = '-std=c++1y' + spec.dependency 'Folly' + spec.compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -frtti + -fexceptions + -std=c++14 + -Wno-error + -Wno-unused-local-typedefs + -Wno-unused-variable + -Wno-sign-compare + -Wno-comment + -Wno-return-type + -Wno-global-constructors' + spec.preserve_paths = 'rsocket/benchmarks/*.h', + 'rsocket/framing/*.h', + 'rsocket/internal/*.h', + 'rsocket/statemachine/*.h', + 'rsocket/transports/*.h', + 'rsocket/*.h', + 'yarpl/flowable/*.h', + 'yarpl/observable/*.h', + 'yarpl/perf/*.h', + 'yarpl/single/*.h', + 'yarpl/utils/*.h', + 'yarpl/*.h', + '**/*.h' + spec.header_mappings_dir = 'rsocket' + spec.header_dir = 'rsocket' + spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\"/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/DoubleConversion\"/**" } + spec.platforms = { :ios => "8.0" } + +end diff --git a/iOS/third-party-podspecs/glog.podspec b/iOS/third-party-podspecs/glog.podspec index a68659fa0..3524ba47e 100755 --- a/iOS/third-party-podspecs/glog.podspec +++ b/iOS/third-party-podspecs/glog.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |spec| spec.homepage = 'https://github.com/google/glog' spec.summary = 'Google logging module' spec.authors = 'Google' - spec.prepare_command = File.read("../scripts/ios-configure-glog.sh") + spec.prepare_command = "#!/bin/bash\nset -e\n\nPLATFORM_NAME=\"${PLATFORM_NAME:-iphoneos}\"\nCURRENT_ARCH=\"${CURRENT_ARCH:-armv7}\"\n\nexport CC=\"$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)\"\nexport CXX=\"$CC\"\n\n# Remove automake symlink if it exists\nif [ -h \"test-driver\" ]; then\n rm test-driver\nfi\n\n./configure --host arm-apple-darwin\n\n# Fix build for tvOS\ncat << EOF >> src/config.h\n\n/* Add in so we have Apple Target Conditionals */\n#ifdef __APPLE__\n#include \n#include \n#endif\n\n/* Special configuration for AppleTVOS */\n#if TARGET_OS_TV\n#undef HAVE_SYSCALL_H\n#undef HAVE_SYS_SYSCALL_H\n#undef OS_MACOSX\n#endif\n\n/* Special configuration for ucontext */\n#undef HAVE_UCONTEXT_H\n#undef PC_FROM_UCONTEXT\n#if defined(__x86_64__)\n#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip\n#elif defined(__i386__)\n#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip\n#endif\nEOF" spec.source = { :git => 'https://github.com/google/glog.git', :tag => "v#{spec.version}" } spec.module_name = 'glog' @@ -36,6 +36,6 @@ Pod::Spec.new do |spec| } spec.compiler_flags = '-std=c++1y' spec.libraries = "stdc++" - spec.platforms = { :ios => "8.0", :tvos => "9.2" } + spec.platforms = { :ios => "8.0"} end diff --git a/libs/fbjni/src/main/java/com/facebook/jni/HybridClassBase.java b/libs/fbjni/src/main/java/com/facebook/jni/HybridClassBase.java new file mode 100644 index 000000000..76a5e652f --- /dev/null +++ b/libs/fbjni/src/main/java/com/facebook/jni/HybridClassBase.java @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2004-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ + +package com.facebook.jni; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public abstract class HybridClassBase extends HybridData {} diff --git a/src/plugins/layout/index.js b/src/plugins/layout/index.js index 65da5dd74..0b051ef92 100644 --- a/src/plugins/layout/index.js +++ b/src/plugins/layout/index.js @@ -9,7 +9,6 @@ import type {ElementID, Element, ElementSearchResultSet} from 'sonar'; import { colors, Glyph, - GK, FlexRow, FlexColumn, Toolbar, @@ -540,17 +539,15 @@ export default class Layout extends SonarPlugin { } /> - {GK.get('sonar_layout_search') && ( - - - - {outstandingSearchQuery && } - - )} + + + + {outstandingSearchQuery && } + {initialised ? ( diff --git a/src/utils/CertificateProvider.js b/src/utils/CertificateProvider.js index 9df809b53..93b5d980e 100644 --- a/src/utils/CertificateProvider.js +++ b/src/utils/CertificateProvider.js @@ -8,7 +8,10 @@ import LogManager from '../fb-stubs/Logger'; const fs = require('fs'); const adb = require('adbkit-fb'); -import {openssl} from './openssl-wrapper-with-promises'; +import { + openssl, + isInstalled as opensslInstalled, +} from './openssl-wrapper-with-promises'; const path = require('path'); // Desktop file paths @@ -68,6 +71,7 @@ export default class CertificateProvider { os: string, appDirectory: string, ): Promise { + this.ensureOpenSSLIsAvailable(); if (!appDirectory.match(allowedAppDirectoryRegex)) { return Promise.reject( new Error( @@ -98,6 +102,15 @@ export default class CertificateProvider { ); } + ensureOpenSSLIsAvailable(): void { + if (!opensslInstalled()) { + const e = Error( + "It looks like you don't have OpenSSL installed. Please install it to continue.", + ); + this.server.emit('error', e); + } + } + getCACertificate(): Promise { return new Promise((resolve, reject) => { fs.readFile(caCert, (err, data) => { @@ -121,7 +134,7 @@ export default class CertificateProvider { CAkey: caKey, CAcreateserial: true, }).then(cert => { - fs.unlink(csrFile); + fs.unlinkSync(csrFile); return cert; }); } diff --git a/src/utils/openssl-wrapper-with-promises.js b/src/utils/openssl-wrapper-with-promises.js index 763bfd67d..5d21452a5 100644 --- a/src/utils/openssl-wrapper-with-promises.js +++ b/src/utils/openssl-wrapper-with-promises.js @@ -6,6 +6,7 @@ */ import {exec as opensslWithCallback} from 'openssl-wrapper'; +const child_process = require('child_process'); export function openssl(action: string, options: {}): Promise { return new Promise((resolve, reject) => { @@ -17,3 +18,7 @@ export function openssl(action: string, options: {}): Promise { }); }); } + +export function isInstalled(): boolean { + return !child_process.spawnSync('openssl', ['version']).error; +} diff --git a/xplat/Sonar/SonarKitCPP.podspec b/xplat/Sonar/Sonar.podspec similarity index 67% rename from xplat/Sonar/SonarKitCPP.podspec rename to xplat/Sonar/Sonar.podspec index 3fe3e83bf..e32744c57 100644 --- a/xplat/Sonar/SonarKitCPP.podspec +++ b/xplat/Sonar/Sonar.podspec @@ -1,11 +1,10 @@ Pod::Spec.new do |spec| spec.name = 'Sonar' - spec.version = '1.0.0' + spec.version = '0.0.1' spec.license = { :type => 'MIT' } spec.homepage = 'https://github.com/facebook/sonar' spec.summary = 'SonarKit core cpp code with network implementation' spec.authors = 'Facebook' - # spec.prepare_command = 'mv src double-conversion' spec.source = { :git => 'https://github.com/facebook/Sonar.git', :branch => 'master' } spec.module_name = 'Sonar' @@ -13,21 +12,12 @@ Pod::Spec.new do |spec| spec.source_files = 'xplat/Sonar/*.{h,cpp,m,mm}' spec.libraries = "stdc++" spec.dependency 'Folly' - spec.dependency 'EasyWSClient' - # spec.dependency 'boost-for-react-native' - # - # spec.dependency 'DoubleConversion' - # spec.dependency 'Folly' - # spec.dependency 'glog' + spec.dependency 'RSocket' spec.compiler_flags = '-DFB_SONARKIT_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -Wall -std=c++14 -Wno-global-constructors' - # spec.header_mappings_dir = 'folly' - # spec.header_dir = 'folly' - # spec.preserve_paths = 'xplat/**/*' - # Pinning to the same version as React.podspec. - spec.platforms = { :ios => "8.0", :tvos => "9.2" } + spec.platforms = { :ios => "8.0" } spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/EasyWSClient\" \"$(PODS_ROOT)/DoubleConversion\"" } + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/RSocket\" \"$(PODS_ROOT)/DoubleConversion\"" } end From 5c779b91766b32fe96bc6cdd915ddc8a75fcb934 Mon Sep 17 00:00:00 2001 From: Michael Evans Date: Tue, 12 Jun 2018 12:23:12 -0700 Subject: [PATCH 27/44] Remove hardcoded path to Android SDK directory Summary: Closes https://github.com/facebook/Sonar/pull/19 Differential Revision: D8383484 Pulled By: danielbuechele fbshipit-source-id: cabf6daed9c0919c186f88eb154d201818723ed6 --- src/chrome/DevicesButton.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chrome/DevicesButton.js b/src/chrome/DevicesButton.js index 4f5f420e4..cfa2b3222 100644 --- a/src/chrome/DevicesButton.js +++ b/src/chrome/DevicesButton.js @@ -145,7 +145,7 @@ class DevicesButton extends Component { getEmulatorNames(): Promise> { return new Promise((resolve, reject) => { child_process.exec( - '/opt/android_sdk/tools/emulator -list-avds', + '$ANDROID_HOME/tools/emulator -list-avds', (error: ?Error, data: ?string) => { if (error == null && data != null) { resolve(data.split('\n').filter(name => name !== '')); @@ -190,7 +190,7 @@ class DevicesButton extends Component { launchEmulator = (name: string) => { child_process.exec( - `/opt/android_sdk/tools/emulator @${name}`, + `$ANDROID_HOME/tools/emulator @${name}`, this.updateEmulatorState, ); }; From 7cbeaa5c7bc14f44318598f5f1f0d6d7481c5ad5 Mon Sep 17 00:00:00 2001 From: Daniel Buchele Date: Wed, 13 Jun 2018 03:34:18 -0700 Subject: [PATCH 28/44] fbshipit-source-id: 632f0ef2f5b776665dc1fd82fe0402a6008022a0 --- libs/folly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/folly b/libs/folly index 711b3fdc6..54b202c06 160000 --- a/libs/folly +++ b/libs/folly @@ -1 +1 @@ -Subproject commit 711b3fdc69f5ed8db5d21008551e0e9cb2cbc566 +Subproject commit 54b202c06dc1a9e5ab354659b537feab4f4984a2 From 8db609ab9b6574762b6a2ae317543a3e5e34aea2 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Wed, 13 Jun 2018 04:05:37 -0700 Subject: [PATCH 29/44] Folly will track master Summary: OSS used an older release and our code base got updated to some new folly api which was added few days back, so it broke OSS. So this diff will track Folly to master Reviewed By: danielbuechele Differential Revision: D8385398 fbshipit-source-id: 9be9a1313b1488fa8b1ca1f681010d0ff7819414 --- iOS/third-party-podspecs/Folly.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOS/third-party-podspecs/Folly.podspec b/iOS/third-party-podspecs/Folly.podspec index 1623e2bfd..1366e0f35 100755 --- a/iOS/third-party-podspecs/Folly.podspec +++ b/iOS/third-party-podspecs/Folly.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |spec| spec.name = 'Folly' - spec.version = '2018.05.28.00' + spec.version = '1.0.0' spec.license = { :type => 'Apache License, Version 2.0' } spec.homepage = 'https://github.com/facebook/folly' spec.summary = 'An open-source C++ library developed and used at Facebook.' spec.authors = 'Facebook' spec.source = { :git => 'https://github.com/facebook/folly.git', - :tag => "v#{spec.version}" } + :branch => "master" } spec.module_name = 'folly' spec.dependency 'boost-for-react-native' spec.dependency 'DoubleConversion' From 32382b29993152a0574e0925d9c6f59395086de8 Mon Sep 17 00:00:00 2001 From: svcscm Date: Wed, 13 Jun 2018 08:18:24 -0700 Subject: [PATCH 30/44] Updating submodules Reviewed By: cdelahousse fbshipit-source-id: 461c869dec1bbe6683f3ae0fe3298bc1bcde1600 --- libs/folly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/folly b/libs/folly index 54b202c06..b51d7408b 160000 --- a/libs/folly +++ b/libs/folly @@ -1 +1 @@ -Subproject commit 54b202c06dc1a9e5ab354659b537feab4f4984a2 +Subproject commit b51d7408bbdf1468048b64456d377530301bbfe3 From 50490b9435c2ad405ec675479434c6a03ac3215d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Wed, 13 Jun 2018 09:01:36 -0700 Subject: [PATCH 31/44] Linux and Windows builds Summary: Adds windows and linux builds to Sandcastle allow-large-files Reviewed By: jknoxville Differential Revision: D8379581 fbshipit-source-id: 94c80fc91c69f43b7dc0c7eb8b2ee5ace4daf888 --- .travis.yml | 17 +++-------------- README.md | 4 +--- package.json | 3 ++- scripts/build-release.js | 25 +++++++++++++------------ yarn.lock | 4 ++++ 5 files changed, 23 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91a50b339..db6279dbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,14 +15,11 @@ matrix: script: - yarn lint - - yarn build macOnly build-number=$TRAVIS_BUILD_NUMBER + - yarn build --mac --version=$TRAVIS_BUILD_NUMBER - cd website - yarn build - cd .. - before_deploy: - - export SONAR_VERSION="v$(plutil -p $TRAVIS_BUILD_DIR/dist/mac/Sonar.app/Contents/Info.plist | awk '/CFBundleShortVersionString/ {print substr($3, 2, length($3)-2)}')" - deploy: - provider: pages skip-cleanup: true @@ -32,17 +29,9 @@ matrix: keep-history: true on: branch: master - - provider: releases - api_key: $GITHUB_TOKEN - file: dist/Sonar.zip - name: $SONAR_VERSION - draft: true - skip_cleanup: true - on: - branch: master - language: objective-c - + before_install: - pod repo update @@ -53,4 +42,4 @@ matrix: script: - cd iOS/Sample - - xcodebuild clean build -workspace Sample.xcworkspace -scheme Pods-Sample \ No newline at end of file + - xcodebuild clean build -workspace Sample.xcworkspace -scheme Pods-Sample diff --git a/README.md b/README.md index eb302888a..364474bcd 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,9 @@ yarn start ## Building the desktop app ``` -yarn build [macOnly] [build-number=$buildNumber] +yarn build --mac --version $buildNumber ``` -A binary for macOS is created in `dist/mac`. `macOnly` and `build-number` are optional params. - ## Documentation Find the full documentation for this project at [fbsonar.com](https://fbsonar.com/docs). diff --git a/package.json b/package.json index 33df6b4b7..bf2a9026c 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "build": { "appId": "sonar", "productName": "Sonar", - "artifactName": "Sonar.${ext}", + "artifactName": "Sonar-${os}.${ext}", "mac": { "category": "public.app-category.developer-tools" }, @@ -22,6 +22,7 @@ } }, "devDependencies": { + "7zip-bin-mac": "^1.0.1", "babel-eslint": "^8.2.1", "electron": "^2.0.1", "electron-builder": "^19.49.0", diff --git a/scripts/build-release.js b/scripts/build-release.js index 07e150010..d8d6fcca4 100755 --- a/scripts/build-release.js +++ b/scripts/build-release.js @@ -52,14 +52,11 @@ function modifyPackageManifest(buildFolder) { manifest.dependencies = manifestStatic.dependencies; manifest.main = 'index.js'; - const BUILD_NUMBER_ARG = 'build-number='; - const buildNumber = ( - process.argv.find(arg => arg.startsWith(BUILD_NUMBER_ARG)) || '' - ).replace(BUILD_NUMBER_ARG, ''); - if (buildNumber) { + const buildNumber = process.argv.join(' ').match(/--version=(\d+)/); + if (buildNumber && buildNumber.length > 0) { manifest.version = [ ...manifest.version.split('.').slice(0, 2), - buildNumber, + buildNumber[1], ].join('.'); } @@ -80,14 +77,18 @@ function modifyPackageManifest(buildFolder) { function buildDist(buildFolder) { const targetsRaw = []; - targetsRaw.push(Platform.MAC.createTarget(['zip'])); - if (process.argv.slice(2).indexOf('macOnly') === -1) { - targetsRaw.push(Platform.LINUX.createTarget(['dir'])); - targetsRaw.push(Platform.WINDOWS.createTarget(['dir'])); - } + if (process.argv.indexOf('--mac') > -1) { + targetsRaw.push(Platform.MAC.createTarget(['zip'])); + } + if (process.argv.indexOf('--linux') > -1) { + targetsRaw.push(Platform.LINUX.createTarget(['zip'])); + } + if (process.argv.indexOf('--win') > -1) { + targetsRaw.push(Platform.WINDOWS.createTarget(['zip'])); + } if (!targetsRaw.length) { - throw new Error('No targets specified. eg. --osx pkg,dmg --linux tar.gz'); + throw new Error('No targets specified. eg. --mac, --win, or --linux'); } // merge all target maps into a single map diff --git a/yarn.lock b/yarn.lock index 31b4e7147..9330219f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,10 @@ # yarn lockfile v1 +"7zip-bin-mac@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/7zip-bin-mac/-/7zip-bin-mac-1.0.1.tgz#3e68778bbf0926adc68159427074505d47555c02" + "7zip-bin@~3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/7zip-bin/-/7zip-bin-3.0.0.tgz#17416dc542f41511b26a9667b92847d75ef150fe" From 5bd6869aeb227e76f43d7bd3d4e6e5e77b319e96 Mon Sep 17 00:00:00 2001 From: Daniel Buchele Date: Wed, 13 Jun 2018 11:17:05 -0700 Subject: [PATCH 32/44] fbshipit-source-id: d0f4b1833968aae403b114119f4e8cda184361c9 --- .../FBCxxUtils/FBCxxFollyDynamicConvert.h | 20 + .../FBCxxFollyDynamicConvert.mm} | 172 ++--- iOS/SonarKit/SKUtils.h | 52 -- libs/fbjni/src/main/cpp/include/fb/ALog.h | 81 ++ .../fbjni/src/main/cpp/include/fb/Countable.h | 45 ++ libs/fbjni/src/main/cpp/include/fb/Doxyfile | 18 + .../src/main/cpp/include/fb/Environment.h | 75 ++ .../src/main/cpp/include/fb/ProgramLocation.h | 48 ++ libs/fbjni/src/main/cpp/include/fb/RefPtr.h | 272 +++++++ .../main/cpp/include/fb/StaticInitialized.h | 38 + .../src/main/cpp/include/fb/ThreadLocal.h | 116 +++ libs/fbjni/src/main/cpp/include/fb/assert.h | 34 + libs/fbjni/src/main/cpp/include/fb/fbjni.h | 23 + .../src/main/cpp/include/fb/fbjni/Boxed.h | 63 ++ .../main/cpp/include/fb/fbjni/ByteBuffer.h | 32 + .../src/main/cpp/include/fb/fbjni/Common.h | 104 +++ .../src/main/cpp/include/fb/fbjni/Context.h | 33 + .../cpp/include/fb/fbjni/CoreClasses-inl.h | 689 ++++++++++++++++++ .../main/cpp/include/fb/fbjni/CoreClasses.h | 607 +++++++++++++++ .../main/cpp/include/fb/fbjni/Exceptions.h | 116 +++ .../src/main/cpp/include/fb/fbjni/File.h | 28 + .../src/main/cpp/include/fb/fbjni/Hybrid.h | 231 ++++++ .../main/cpp/include/fb/fbjni/Iterator-inl.h | 197 +++++ .../src/main/cpp/include/fb/fbjni/Iterator.h | 144 ++++ .../src/main/cpp/include/fb/fbjni/JThread.h | 37 + .../main/cpp/include/fb/fbjni/JThrowable.h | 15 + .../main/cpp/include/fb/fbjni/Meta-forward.h | 34 + .../src/main/cpp/include/fb/fbjni/Meta-inl.h | 430 +++++++++++ .../src/main/cpp/include/fb/fbjni/Meta.h | 338 +++++++++ .../main/cpp/include/fb/fbjni/MetaConvert.h | 127 ++++ .../cpp/include/fb/fbjni/NativeRunnable.h | 45 ++ .../fb/fbjni/ReferenceAllocators-inl.h | 118 +++ .../include/fb/fbjni/ReferenceAllocators.h | 60 ++ .../cpp/include/fb/fbjni/References-forward.h | 65 ++ .../cpp/include/fb/fbjni/References-inl.h | 508 +++++++++++++ .../main/cpp/include/fb/fbjni/References.h | 585 +++++++++++++++ .../cpp/include/fb/fbjni/Registration-inl.h | 184 +++++ .../main/cpp/include/fb/fbjni/Registration.h | 85 +++ .../main/cpp/include/fb/fbjni/TypeTraits.h | 158 ++++ libs/fbjni/src/main/cpp/include/fb/log.h | 337 +++++++++ libs/fbjni/src/main/cpp/include/fb/lyra.h | 173 +++++ .../src/main/cpp/include/fb/noncopyable.h | 19 + .../src/main/cpp/include/fb/nonmovable.h | 19 + .../src/main/cpp/include/fb/visibility.h | 10 + libs/folly | 2 +- 45 files changed, 6439 insertions(+), 148 deletions(-) create mode 100644 iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.h rename iOS/SonarKit/{SKUtils.mm => FBCxxUtils/FBCxxFollyDynamicConvert.mm} (63%) delete mode 100644 iOS/SonarKit/SKUtils.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/ALog.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/Countable.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/Doxyfile create mode 100644 libs/fbjni/src/main/cpp/include/fb/Environment.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/ProgramLocation.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/RefPtr.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/StaticInitialized.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/ThreadLocal.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/assert.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Boxed.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/ByteBuffer.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Common.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Context.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/CoreClasses-inl.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/CoreClasses.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Exceptions.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/File.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Hybrid.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Iterator-inl.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Iterator.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/JThread.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/JThrowable.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Meta-forward.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Meta-inl.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Meta.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/MetaConvert.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/NativeRunnable.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/ReferenceAllocators-inl.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/ReferenceAllocators.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/References-forward.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/References-inl.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/References.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Registration-inl.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/Registration.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/fbjni/TypeTraits.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/log.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/lyra.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/noncopyable.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/nonmovable.h create mode 100644 libs/fbjni/src/main/cpp/include/fb/visibility.h diff --git a/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.h b/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.h new file mode 100644 index 000000000..1cc1bd1ed --- /dev/null +++ b/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2004-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#import + +#include + +namespace facebook { +namespace cxxutils { + +folly::dynamic convertIdToFollyDynamic(id json); +id convertFollyDynamicToId(const folly::dynamic &dyn); + +} } diff --git a/iOS/SonarKit/SKUtils.mm b/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.mm similarity index 63% rename from iOS/SonarKit/SKUtils.mm rename to iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.mm index 82c8b9699..b19405511 100644 --- a/iOS/SonarKit/SKUtils.mm +++ b/iOS/SonarKit/FBCxxUtils/FBCxxFollyDynamicConvert.mm @@ -1,97 +1,17 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#import "FBCxxFollyDynamicConvert.h" + +#import + +namespace facebook { +namespace cxxutils { + /* - * Copyright (c) 2018-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the LICENSE - * file in the root directory of this source tree. - * + * The implementation is taken from RCTFollyConvert(https://fburl.com/vzw8ql2q) */ -#include "SKUtils.h" -#include - -#import - -using namespace facebook::sonar; - -@implementation SKUtils - -+ (folly::dynamic)convertIdToFollyDynamic:(id)json -{ - if (json == nil || json == (id)kCFNull) { - return nullptr; - } else if ([json isKindOfClass:[NSNumber class]]) { - const char *objCType = [json objCType]; - switch (objCType[0]) { - // This is a c++ bool or C99 _Bool. On some platforms, BOOL is a bool. - case _C_BOOL: - return (bool) [json boolValue]; - case _C_CHR: - // On some platforms, objc BOOL is a signed char, but it - // might also be a small number. Use the same hack JSC uses - // to distinguish them: - // https://phabricator.intern.facebook.com/diffusion/FBS/browse/master/fbobjc/xplat/third-party/jsc/safari-600-1-4-17/JavaScriptCore/API/JSValue.mm;b8ee03916489f8b12143cd5c0bca546da5014fc9$901 - if ([json isKindOfClass:[@YES class]]) { - return (bool) [json boolValue]; - } else { - const auto value = [json longLongValue]; - if (isnan(value) || isinf(value)) { - return nullptr; - } - return value; - } - case _C_UCHR: - case _C_SHT: - case _C_USHT: - case _C_INT: - case _C_UINT: - case _C_LNG: - case _C_ULNG: - case _C_LNG_LNG: - case _C_ULNG_LNG: { - const auto value = [json longLongValue]; - if (isnan(value) || isinf(value)) { - return nullptr; - } - return value; - } - - case _C_FLT: - case _C_DBL: { - const auto value = [json doubleValue]; - if (isnan(value) || isinf(value)) { - return nullptr; - } - return value; - } - - // default: - // fall through - } - } else if ([json isKindOfClass:[NSString class]]) { - NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding]; - return std::string(reinterpret_cast(data.bytes), - data.length); - } else if ([json isKindOfClass:[NSArray class]]) { - folly::dynamic array = folly::dynamic::array; - for (id element in json) { - array.push_back([self convertIdToFollyDynamic:element]); - } - return array; - } else if ([json isKindOfClass:[NSDictionary class]]) { - __block folly::dynamic object = folly::dynamic::object(); - - [json enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, __unused BOOL *stop) { - object.insert([self convertIdToFollyDynamic:key], - [self convertIdToFollyDynamic:value]); - }]; - - return object; - } - - return nil; -} - -+ (id)convertFollyDynamicToId:(const folly::dynamic &)dyn { +id convertFollyDynamicToId(const folly::dynamic &dyn) { // I could imagine an implementation which avoids copies by wrapping the // dynamic in a derived class of NSDictionary. We can do that if profiling // implies it will help. @@ -107,22 +27,84 @@ using namespace facebook::sonar; return @(dyn.getDouble()); case folly::dynamic::STRING: return [[NSString alloc] initWithBytes:dyn.c_str() length:dyn.size() - encoding:NSUTF8StringEncoding]; + encoding:NSUTF8StringEncoding]; case folly::dynamic::ARRAY: { NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:dyn.size()]; for (auto &elem : dyn) { - [array addObject:[self convertFollyDynamicToId: elem]]; + [array addObject:convertFollyDynamicToId(elem)]; } return array; } case folly::dynamic::OBJECT: { NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:dyn.size()]; for (auto &elem : dyn.items()) { - dict[[self convertFollyDynamicToId:elem.first]] = [self convertFollyDynamicToId:elem.second]; + dict[convertFollyDynamicToId(elem.first)] = convertFollyDynamicToId(elem.second); } return dict; } } } -@end +folly::dynamic convertIdToFollyDynamic(id json) +{ + if (json == nil || json == (id)kCFNull) { + return nullptr; + } else if ([json isKindOfClass:[NSNumber class]]) { + const char *objCType = [json objCType]; + switch (objCType[0]) { + // This is a c++ bool or C99 _Bool. On some platforms, BOOL is a bool. + case _C_BOOL: + return (bool) [json boolValue]; + case _C_CHR: + // On some platforms, objc BOOL is a signed char, but it + // might also be a small number. Use the same hack JSC uses + // to distinguish them: + // https://phabricator.intern.facebook.com/diffusion/FBS/browse/master/fbobjc/xplat/third-party/jsc/safari-600-1-4-17/JavaScriptCore/API/JSValue.mm;b8ee03916489f8b12143cd5c0bca546da5014fc9$901 + if ([json isKindOfClass:[@YES class]]) { + return (bool) [json boolValue]; + } else { + return [json longLongValue]; + } + case _C_UCHR: + case _C_SHT: + case _C_USHT: + case _C_INT: + case _C_UINT: + case _C_LNG: + case _C_ULNG: + case _C_LNG_LNG: + case _C_ULNG_LNG: + return [json longLongValue]; + + case _C_FLT: + case _C_DBL: + return [json doubleValue]; + + // default: + // fall through + } + } else if ([json isKindOfClass:[NSString class]]) { + NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding]; + return std::string(reinterpret_cast(data.bytes), + data.length); + } else if ([json isKindOfClass:[NSArray class]]) { + folly::dynamic array = folly::dynamic::array; + for (id element in json) { + array.push_back(convertIdToFollyDynamic(element)); + } + return array; + } else if ([json isKindOfClass:[NSDictionary class]]) { + __block folly::dynamic object = folly::dynamic::object(); + + [json enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, __unused BOOL *stop) { + object.insert(convertIdToFollyDynamic(key), + convertIdToFollyDynamic(value)); + }]; + + return object; + } + + return nil; +} + +} } diff --git a/iOS/SonarKit/SKUtils.h b/iOS/SonarKit/SKUtils.h deleted file mode 100644 index 7cd13eb41..000000000 --- a/iOS/SonarKit/SKUtils.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the LICENSE - * file in the root directory of this source tree. - * - */ -#pragma once - -#import - -#import - -namespace facebook { namespace sonar { -#define _C_ID '@' -#define _C_CLASS '#' -#define _C_SEL ':' -#define _C_CHR 'c' -#define _C_UCHR 'C' -#define _C_SHT 's' -#define _C_USHT 'S' -#define _C_INT 'i' -#define _C_UINT 'I' -#define _C_LNG 'l' -#define _C_ULNG 'L' -#define _C_LNG_LNG 'q' -#define _C_ULNG_LNG 'Q' -#define _C_FLT 'f' -#define _C_DBL 'd' -#define _C_BFLD 'b' -#define _C_BOOL 'B' -#define _C_VOID 'v' -#define _C_UNDEF '?' -#define _C_PTR '^' -#define _C_CHARPTR '*' -#define _C_ATOM '%' -#define _C_ARY_B '[' -#define _C_ARY_E ']' -#define _C_UNION_B '(' -#define _C_UNION_E ')' -#define _C_STRUCT_B '{' -#define _C_STRUCT_E '}' -#define _C_VECTOR '!' -#define _C_CONST 'r' -} -} - -@interface SKUtils: NSObject -+ (folly::dynamic)convertIdToFollyDynamic:(id)json; -+ (id)convertFollyDynamicToId:(const folly::dynamic &)dyn; - -@end diff --git a/libs/fbjni/src/main/cpp/include/fb/ALog.h b/libs/fbjni/src/main/cpp/include/fb/ALog.h new file mode 100644 index 000000000..e9cfb8351 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/ALog.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +/** @file ALog.h + * + * Very simple android only logging. Define LOG_TAG to enable the macros. + */ + +#pragma once + +#ifdef __ANDROID__ + +#include + +namespace facebook { +namespace alog { + +template +inline void log(int level, const char* tag, const char* msg, ARGS... args) noexcept { + __android_log_print(level, tag, msg, args...); +} + +template +inline void log(int level, const char* tag, const char* msg) noexcept { + __android_log_write(level, tag, msg); +} + +template +inline void logv(const char* tag, const char* msg, ARGS... args) noexcept { + log(ANDROID_LOG_VERBOSE, tag, msg, args...); +} + +template +inline void logd(const char* tag, const char* msg, ARGS... args) noexcept { + log(ANDROID_LOG_DEBUG, tag, msg, args...); +} + +template +inline void logi(const char* tag, const char* msg, ARGS... args) noexcept { + log(ANDROID_LOG_INFO, tag, msg, args...); +} + +template +inline void logw(const char* tag, const char* msg, ARGS... args) noexcept { + log(ANDROID_LOG_WARN, tag, msg, args...); +} + +template +inline void loge(const char* tag, const char* msg, ARGS... args) noexcept { + log(ANDROID_LOG_ERROR, tag, msg, args...); +} + +template +inline void logf(const char* tag, const char* msg, ARGS... args) noexcept { + log(ANDROID_LOG_FATAL, tag, msg, args...); +} + + +#ifdef LOG_TAG +# define ALOGV(...) ::facebook::alog::logv(LOG_TAG, __VA_ARGS__) +# define ALOGD(...) ::facebook::alog::logd(LOG_TAG, __VA_ARGS__) +# define ALOGI(...) ::facebook::alog::logi(LOG_TAG, __VA_ARGS__) +# define ALOGW(...) ::facebook::alog::logw(LOG_TAG, __VA_ARGS__) +# define ALOGE(...) ::facebook::alog::loge(LOG_TAG, __VA_ARGS__) +# define ALOGF(...) ::facebook::alog::logf(LOG_TAG, __VA_ARGS__) +#endif + +}} + +#else +# define ALOGV(...) ((void)0) +# define ALOGD(...) ((void)0) +# define ALOGI(...) ((void)0) +# define ALOGW(...) ((void)0) +# define ALOGE(...) ((void)0) +# define ALOGF(...) ((void)0) +#endif diff --git a/libs/fbjni/src/main/cpp/include/fb/Countable.h b/libs/fbjni/src/main/cpp/include/fb/Countable.h new file mode 100644 index 000000000..e50298ba1 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/Countable.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once +#include +#include +#include +#include +#include + +namespace facebook { + +class Countable : public noncopyable, public nonmovable { +public: + // RefPtr expects refcount to start at 0 + Countable() : m_refcount(0) {} + virtual ~Countable() + { + FBASSERT(m_refcount == 0); + } + +private: + void ref() { + ++m_refcount; + } + + void unref() { + if (0 == --m_refcount) { + delete this; + } + } + + bool hasOnlyOneRef() const { + return m_refcount == 1; + } + + template friend class RefPtr; + std::atomic m_refcount; +}; + +} diff --git a/libs/fbjni/src/main/cpp/include/fb/Doxyfile b/libs/fbjni/src/main/cpp/include/fb/Doxyfile new file mode 100644 index 000000000..8b4df6a7c --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/Doxyfile @@ -0,0 +1,18 @@ +PROJECT_NAME = "Facebook JNI" +PROJECT_BRIEF = "Helper library to provide safe and convenient access to JNI with very low overhead" +JAVADOC_AUTOBRIEF = YES +EXTRACT_ALL = YES +RECURSIVE = YES +EXCLUDE = tests Asserts.h Countable.h GlobalReference.h LocalReference.h LocalString.h Registration.h WeakReference.h jni_helpers.h Environment.h +EXCLUDE_PATTERNS = *-inl.h *.cpp +GENERATE_HTML = YES +GENERATE_LATEX = NO +ENABLE_PREPROCESSING = YES +HIDE_UNDOC_MEMBERS = YES +HIDE_SCOPE_NAMES = YES +HIDE_FRIEND_COMPOUNDS = YES +HIDE_UNDOC_CLASSES = YES +SHOW_INCLUDE_FILES = NO +PREDEFINED = LOG_TAG=fbjni +EXAMPLE_PATH = samples +#ENABLED_SECTIONS = INTERNAL diff --git a/libs/fbjni/src/main/cpp/include/fb/Environment.h b/libs/fbjni/src/main/cpp/include/fb/Environment.h new file mode 100644 index 000000000..4d56c2960 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/Environment.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once +#include +#include +#include + +#include + +namespace facebook { +namespace jni { + +// Keeps a thread-local reference to the current thread's JNIEnv. +struct Environment { + // May be null if this thread isn't attached to the JVM + FBEXPORT static JNIEnv* current(); + static void initialize(JavaVM* vm); + + // There are subtle issues with calling the next functions directly. It is + // much better to always use a ThreadScope to manage attaching/detaching for + // you. + FBEXPORT static JNIEnv* ensureCurrentThreadIsAttached(); + FBEXPORT static void detachCurrentThread(); +}; + +/** + * RAII Object that attaches a thread to the JVM. Failing to detach from a thread before it + * exits will cause a crash, as will calling Detach an extra time, and this guard class helps + * keep that straight. In addition, it remembers whether it performed the attach or not, so it + * is safe to nest it with itself or with non-fbjni code that manages the attachment correctly. + * + * Potential concerns: + * - Attaching to the JVM is fast (~100us on MotoG), but ideally you would attach while the + * app is not busy. + * - Having a thread detach at arbitrary points is not safe in Dalvik; you need to be sure that + * there is no Java code on the current stack or you run the risk of a crash like: + * ERROR: detaching thread with interp frames (count=18) + * (More detail at https://groups.google.com/forum/#!topic/android-ndk/2H8z5grNqjo) + * ThreadScope won't do a detach if the thread was already attached before the guard is + * instantiated, but there's probably some usage that could trip this up. + * - Newly attached C++ threads only get the bootstrap class loader -- i.e. java language + * classes, not any of our application's classes. This will be different behavior than threads + * that were initiated on the Java side. A workaround is to pass a global reference for a + * class or instance to the new thread; this bypasses the need for the class loader. + * (See http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html#attach_current_thread) + * If you need access to the application's classes, you can use ThreadScope::WithClassLoader. + */ +class FBEXPORT ThreadScope { + public: + ThreadScope(); + ThreadScope(ThreadScope&) = delete; + ThreadScope(ThreadScope&&) = default; + ThreadScope& operator=(ThreadScope&) = delete; + ThreadScope& operator=(ThreadScope&&) = delete; + ~ThreadScope(); + + /** + * This runs the closure in a scope with fbjni's classloader. This should be + * the same classloader as the rest of the application and thus anything + * running in the closure will have access to the same classes as in a normal + * java-create thread. + */ + static void WithClassLoader(std::function&& runnable); + + static void OnLoad(); + private: + bool attachedWithThisScope_; +}; +} +} diff --git a/libs/fbjni/src/main/cpp/include/fb/ProgramLocation.h b/libs/fbjni/src/main/cpp/include/fb/ProgramLocation.h new file mode 100644 index 000000000..d8785c118 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/ProgramLocation.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once +#include +#include +#include + +namespace facebook { + +#define FROM_HERE facebook::ProgramLocation(__FUNCTION__, __FILE__, __LINE__) + +class ProgramLocation { +public: + ProgramLocation() : m_functionName("Unspecified"), m_fileName("Unspecified"), m_lineNumber(0) {} + + ProgramLocation(const char* functionName, const char* fileName, int line) : + m_functionName(functionName), + m_fileName(fileName), + m_lineNumber(line) + {} + + const char* functionName() const { return m_functionName; } + const char* fileName() const { return m_fileName; } + int lineNumber() const { return m_lineNumber; } + + std::string asFormattedString() const { + std::stringstream str; + str << "Function " << m_functionName << " in file " << m_fileName << ":" << m_lineNumber; + return str.str(); + } + + bool operator==(const ProgramLocation& other) const { + // Assumes that the strings are static + return (m_functionName == other.m_functionName) && (m_fileName == other.m_fileName) && m_lineNumber == other.m_lineNumber; + } + +private: + const char* m_functionName; + const char* m_fileName; + int m_lineNumber; +}; + +} diff --git a/libs/fbjni/src/main/cpp/include/fb/RefPtr.h b/libs/fbjni/src/main/cpp/include/fb/RefPtr.h new file mode 100644 index 000000000..4930fd4f6 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/RefPtr.h @@ -0,0 +1,272 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once +#include +#include + +namespace facebook { + +// Reference counting smart pointer. This is designed to work with the +// Countable class or other implementations in the future. It is designed in a +// way to be both efficient and difficult to misuse. Typical usage is very +// simple once you learn the patterns (and the compiler will help!): +// +// By default, the internal pointer is null. +// RefPtr ref; +// +// Object creation requires explicit construction: +// RefPtr ref = createNew(...); +// +// Or if the constructor is not public: +// RefPtr ref = adoptRef(new Foo(...)); +// +// But you can implicitly create from nullptr: +// RefPtr maybeRef = cond ? ref : nullptr; +// +// Move/Copy Construction/Assignment are straightforward: +// RefPtr ref2 = ref; +// ref = std::move(ref2); +// +// Destruction automatically drops the RefPtr's reference as expected. +// +// Upcasting is implicit but downcasting requires an explicit cast: +// struct Bar : public Foo {}; +// RefPtr barRef = static_cast>(ref); +// ref = barRef; +// +template +class RefPtr { +public: + constexpr RefPtr() : + m_ptr(nullptr) + {} + + // Allow implicit construction from a pointer only from nullptr + constexpr RefPtr(std::nullptr_t ptr) : + m_ptr(nullptr) + {} + + RefPtr(const RefPtr& ref) : + m_ptr(ref.m_ptr) + { + refIfNecessary(m_ptr); + } + + // Only allow implicit upcasts. A downcast will result in a compile error + // unless you use static_cast (which will end up invoking the explicit + // operator below). + template + RefPtr(const RefPtr& ref, typename std::enable_if::value, U>::type* = nullptr) : + m_ptr(ref.get()) + { + refIfNecessary(m_ptr); + } + + RefPtr(RefPtr&& ref) : + m_ptr(nullptr) + { + *this = std::move(ref); + } + + // Only allow implicit upcasts. A downcast will result in a compile error + // unless you use static_cast (which will end up invoking the explicit + // operator below). + template + RefPtr(RefPtr&& ref, typename std::enable_if::value, U>::type* = nullptr) : + m_ptr(nullptr) + { + *this = std::move(ref); + } + + ~RefPtr() { + unrefIfNecessary(m_ptr); + m_ptr = nullptr; + } + + RefPtr& operator=(const RefPtr& ref) { + if (m_ptr != ref.m_ptr) { + unrefIfNecessary(m_ptr); + m_ptr = ref.m_ptr; + refIfNecessary(m_ptr); + } + return *this; + } + + // The STL assumes rvalue references are unique and for simplicity's sake, we + // make the same assumption here, that &ref != this. + RefPtr& operator=(RefPtr&& ref) { + unrefIfNecessary(m_ptr); + m_ptr = ref.m_ptr; + ref.m_ptr = nullptr; + return *this; + } + + template + RefPtr& operator=(RefPtr&& ref) { + unrefIfNecessary(m_ptr); + m_ptr = ref.m_ptr; + ref.m_ptr = nullptr; + return *this; + } + + void reset() { + unrefIfNecessary(m_ptr); + m_ptr = nullptr; + } + + T* get() const { + return m_ptr; + } + + T* operator->() const { + return m_ptr; + } + + T& operator*() const { + return *m_ptr; + } + + template + explicit operator RefPtr () const; + + explicit operator bool() const { + return m_ptr ? true : false; + } + + bool isTheLastRef() const { + FBASSERT(m_ptr); + return m_ptr->hasOnlyOneRef(); + } + + // Creates a strong reference from a raw pointer, assuming that is already + // referenced from some other RefPtr. This should be used sparingly. + static inline RefPtr assumeAlreadyReffed(T* ptr) { + return RefPtr(ptr, ConstructionMode::External); + } + + // Creates a strong reference from a raw pointer, assuming that it points to a + // freshly-created object. See the documentation for RefPtr for usage. + static inline RefPtr adoptRef(T* ptr) { + return RefPtr(ptr, ConstructionMode::Adopted); + } + +private: + enum class ConstructionMode { + Adopted, + External + }; + + RefPtr(T* ptr, ConstructionMode mode) : + m_ptr(ptr) + { + FBASSERTMSGF(ptr, "Got null pointer in %s construction mode", mode == ConstructionMode::Adopted ? "adopted" : "external"); + ptr->ref(); + if (mode == ConstructionMode::Adopted) { + FBASSERT(ptr->hasOnlyOneRef()); + } + } + + static inline void refIfNecessary(T* ptr) { + if (ptr) { + ptr->ref(); + } + } + static inline void unrefIfNecessary(T* ptr) { + if (ptr) { + ptr->unref(); + } + } + + template friend class RefPtr; + + T* m_ptr; +}; + +// Creates a strong reference from a raw pointer, assuming that is already +// referenced from some other RefPtr and that it is non-null. This should be +// used sparingly. +template +static inline RefPtr assumeAlreadyReffed(T* ptr) { + return RefPtr::assumeAlreadyReffed(ptr); +} + +// As above, but tolerant of nullptr. +template +static inline RefPtr assumeAlreadyReffedOrNull(T* ptr) { + return ptr ? RefPtr::assumeAlreadyReffed(ptr) : nullptr; +} + +// Creates a strong reference from a raw pointer, assuming that it points to a +// freshly-created object. See the documentation for RefPtr for usage. +template +static inline RefPtr adoptRef(T* ptr) { + return RefPtr::adoptRef(ptr); +} + +template +static inline RefPtr createNew(Args&&... arguments) { + return RefPtr::adoptRef(new T(std::forward(arguments)...)); +} + +template template +RefPtr::operator RefPtr() const { + static_assert(std::is_base_of::value, "Invalid static cast"); + return assumeAlreadyReffedOrNull(static_cast(m_ptr)); +} + +template +inline bool operator==(const RefPtr& a, const RefPtr& b) { + return a.get() == b.get(); +} + +template +inline bool operator!=(const RefPtr& a, const RefPtr& b) { + return a.get() != b.get(); +} + +template +inline bool operator==(const RefPtr& ref, U* ptr) { + return ref.get() == ptr; +} + +template +inline bool operator!=(const RefPtr& ref, U* ptr) { + return ref.get() != ptr; +} + +template +inline bool operator==(U* ptr, const RefPtr& ref) { + return ref.get() == ptr; +} + +template +inline bool operator!=(U* ptr, const RefPtr& ref) { + return ref.get() != ptr; +} + +template +inline bool operator==(const RefPtr& ref, std::nullptr_t ptr) { + return ref.get() == ptr; +} + +template +inline bool operator!=(const RefPtr& ref, std::nullptr_t ptr) { + return ref.get() != ptr; +} + +template +inline bool operator==(std::nullptr_t ptr, const RefPtr& ref) { + return ref.get() == ptr; +} + +template +inline bool operator!=(std::nullptr_t ptr, const RefPtr& ref) { + return ref.get() != ptr; +} + +} diff --git a/libs/fbjni/src/main/cpp/include/fb/StaticInitialized.h b/libs/fbjni/src/main/cpp/include/fb/StaticInitialized.h new file mode 100644 index 000000000..c9e848b17 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/StaticInitialized.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once +#include +#include + +namespace facebook { + +// Class that lets you declare a global but does not add a static constructor +// to the binary. Eventually I'd like to have this auto-initialize in a +// multithreaded environment but for now it's easiest just to use manual +// initialization. +template +class StaticInitialized { +public: + constexpr StaticInitialized() : + m_instance(nullptr) + {} + + template + void initialize(Args&&... arguments) { + FBASSERT(!m_instance); + m_instance = new T(std::forward(arguments)...); + } + + T* operator->() const { + return m_instance; + } +private: + T* m_instance; +}; + +} diff --git a/libs/fbjni/src/main/cpp/include/fb/ThreadLocal.h b/libs/fbjni/src/main/cpp/include/fb/ThreadLocal.h new file mode 100644 index 000000000..53672e196 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/ThreadLocal.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include +#include + +#include + +namespace facebook { + +/////////////////////////////////////////////////////////////////////////////// + +/** + * A thread-local object is a "global" object within a thread. This is useful + * for writing apartment-threaded code, where nothing is actullay shared + * between different threads (hence no locking) but those variables are not + * on stack in local scope. To use it, just do something like this, + * + * ThreadLocal static_object; + * static_object->data_ = ...; + * static_object->doSomething(); + * + * ThreadLocal static_number; + * int value = *static_number; + * + * So, syntax-wise it's similar to pointers. T can be primitive types, and if + * it's a class, there has to be a default constructor. + */ +template +class ThreadLocal { +public: + /** + * Constructor that has to be called from a thread-neutral place. + */ + ThreadLocal() : + m_key(0), + m_cleanup(OnThreadExit) { + initialize(); + } + + /** + * As above but with a custom cleanup function + */ + typedef void (*CleanupFunction)(void* obj); + explicit ThreadLocal(CleanupFunction cleanup) : + m_key(0), + m_cleanup(cleanup) { + FBASSERT(cleanup); + initialize(); + } + + /** + * Access object's member or method through this operator overload. + */ + T *operator->() const { + return get(); + } + + T &operator*() const { + return *get(); + } + + T *get() const { + return (T*)pthread_getspecific(m_key); + } + + T* release() { + T* obj = get(); + pthread_setspecific(m_key, NULL); + return obj; + } + + void reset(T* other = NULL) { + T* old = (T*)pthread_getspecific(m_key); + if (old != other) { + FBASSERT(m_cleanup); + m_cleanup(old); + pthread_setspecific(m_key, other); + } + } + +private: + void initialize() { + int ret = pthread_key_create(&m_key, m_cleanup); + if (ret != 0) { + const char *msg = "(unknown error)"; + switch (ret) { + case EAGAIN: + msg = "PTHREAD_KEYS_MAX (1024) is exceeded"; + break; + case ENOMEM: + msg = "Out-of-memory"; + break; + } + (void) msg; + FBASSERTMSGF(0, "pthread_key_create failed: %d %s", ret, msg); + } + } + + static void OnThreadExit(void *obj) { + if (NULL != obj) { + delete (T*)obj; + } + } + + pthread_key_t m_key; + CleanupFunction m_cleanup; +}; + +} diff --git a/libs/fbjni/src/main/cpp/include/fb/assert.h b/libs/fbjni/src/main/cpp/include/fb/assert.h new file mode 100644 index 000000000..ed91efa4d --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/assert.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#ifndef FBASSERT_H +#define FBASSERT_H + +#include + +namespace facebook { +#define ENABLE_FBASSERT 1 + +#if ENABLE_FBASSERT +#define FBASSERTMSGF(expr, msg, ...) !(expr) ? facebook::assertInternal("Assert (%s:%d): " msg, __FILE__, __LINE__, ##__VA_ARGS__) : (void) 0 +#else +#define FBASSERTMSGF(expr, msg, ...) +#endif // ENABLE_FBASSERT + +#define FBASSERT(expr) FBASSERTMSGF(expr, "%s", #expr) + +#define FBCRASH(msg, ...) facebook::assertInternal("Fatal error (%s:%d): " msg, __FILE__, __LINE__, ##__VA_ARGS__) +#define FBUNREACHABLE() facebook::assertInternal("This code should be unreachable (%s:%d)", __FILE__, __LINE__) + +FBEXPORT void assertInternal(const char* formatstr, ...) __attribute__((noreturn)); + +// This allows storing the assert message before the current process terminates due to a crash +typedef void (*AssertHandler)(const char* message); +void setAssertHandler(AssertHandler assertHandler); + +} // namespace facebook +#endif // FBASSERT_H diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni.h b/libs/fbjni/src/main/cpp/include/fb/fbjni.h new file mode 100644 index 000000000..230713346 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Boxed.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Boxed.h new file mode 100644 index 000000000..9ab0071e8 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Boxed.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include "CoreClasses.h" + +namespace facebook { +namespace jni { + +namespace detail { +template +struct JPrimitive : JavaClass { + using typename JavaClass::javaobject; + using JavaClass::javaClassStatic; + static local_ref valueOf(jprim val) { + static auto cls = javaClassStatic(); + static auto method = + cls->template getStaticMethod("valueOf"); + return method(cls, val); + } + jprim value() const { + static auto method = + javaClassStatic()->template getMethod(T::kValueMethod); + return method(this->self()); + } +}; + +} // namespace detail + + +#define DEFINE_BOXED_PRIMITIVE(LITTLE, BIG) \ + struct J ## BIG : detail::JPrimitive { \ + static auto constexpr kJavaDescriptor = "Ljava/lang/" #BIG ";"; \ + static auto constexpr kValueMethod = #LITTLE "Value"; \ + j ## LITTLE LITTLE ## Value() const { \ + return value(); \ + } \ + }; \ + inline local_ref autobox(j ## LITTLE val) { \ + return J ## BIG::valueOf(val); \ + } + +DEFINE_BOXED_PRIMITIVE(boolean, Boolean) +DEFINE_BOXED_PRIMITIVE(byte, Byte) +DEFINE_BOXED_PRIMITIVE(char, Character) +DEFINE_BOXED_PRIMITIVE(short, Short) +DEFINE_BOXED_PRIMITIVE(int, Integer) +DEFINE_BOXED_PRIMITIVE(long, Long) +DEFINE_BOXED_PRIMITIVE(float, Float) +DEFINE_BOXED_PRIMITIVE(double, Double) + +#undef DEFINE_BOXED_PRIMITIVE + +inline local_ref autobox(alias_ref val) { + return make_local(val); +} + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/ByteBuffer.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/ByteBuffer.h new file mode 100644 index 000000000..7c10de344 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/ByteBuffer.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include + +#include "CoreClasses.h" +#include "References-forward.h" + +namespace facebook { +namespace jni { + +// JNI's NIO support has some awkward preconditions and error reporting. This +// class provides much more user-friendly access. +class FBEXPORT JByteBuffer : public JavaClass { + public: + static constexpr const char* kJavaDescriptor = "Ljava/nio/ByteBuffer;"; + + static local_ref wrapBytes(uint8_t* data, size_t size); + + bool isDirect() const; + + uint8_t* getDirectBytes() const; + size_t getDirectSize() const; +}; + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Common.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Common.h new file mode 100644 index 000000000..ee00299ce --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Common.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +/** @file Common.h + * + * Defining the stuff that don't deserve headers of their own... + */ + +#pragma once + +#include + +#include + +#include +#include + +#ifdef FBJNI_DEBUG_REFS +# ifdef __ANDROID__ +# include +# else +# include +# endif +#endif + +// If a pending JNI Java exception is found, wraps it in a JniException object and throws it as +// a C++ exception. +#define FACEBOOK_JNI_THROW_PENDING_EXCEPTION() \ + ::facebook::jni::throwPendingJniExceptionAsCppException() + +// If the condition is true, throws a JniException object, which wraps the pending JNI Java +// exception if any. If no pending exception is found, throws a JniException object that wraps a +// RuntimeException throwable.  +#define FACEBOOK_JNI_THROW_EXCEPTION_IF(CONDITION) \ + ::facebook::jni::throwCppExceptionIf(CONDITION) + +/// @cond INTERNAL + +namespace facebook { +namespace jni { + +FBEXPORT void throwPendingJniExceptionAsCppException(); +FBEXPORT void throwCppExceptionIf(bool condition); + +[[noreturn]] FBEXPORT void throwNewJavaException(jthrowable); +[[noreturn]] FBEXPORT void throwNewJavaException(const char* throwableName, const char* msg); +template +[[noreturn]] void throwNewJavaException(const char* throwableName, const char* fmt, Args... args); + + +/** + * This needs to be called at library load time, typically in your JNI_OnLoad method. + * + * The intended use is to return the result of initialize() directly + * from JNI_OnLoad and to do nothing else there. Library specific + * initialization code should go in the function passed to initialize + * (which can be, and probably should be, a C++ lambda). This approach + * provides correct error handling and translation errors during + * initialization into Java exceptions when appropriate. + * + * Failure to call this will cause your code to crash in a remarkably + * unhelpful way (typically a segfault) while trying to handle an exception + * which occurs later. + */ +FBEXPORT jint initialize(JavaVM*, std::function&&) noexcept; + +namespace internal { + +/** + * Retrieve a pointer the JNI environment of the current thread. + * + * @pre The current thread must be attached to the VM + */ +inline JNIEnv* getEnv() noexcept { + // TODO(T6594868) Benchmark against raw JNI access + return Environment::current(); +} + +// Define to get extremely verbose logging of references and to enable reference stats +#ifdef FBJNI_DEBUG_REFS +template +inline void dbglog(const char* msg, Args... args) { +# ifdef __ANDROID__ + __android_log_print(ANDROID_LOG_VERBOSE, "fbjni_dbg", msg, args...); +# else + std::fprintf(stderr, msg, args...); +# endif +} + +#else + +template +inline void dbglog(const char*, Args...) { +} + +#endif + +}}} + +/// @endcond diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Context.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Context.h new file mode 100644 index 000000000..90e4b4a6c --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Context.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include "CoreClasses.h" +#include "File.h" + +namespace facebook { +namespace jni { + +class AContext : public JavaClass { + public: + static constexpr const char* kJavaDescriptor = "Landroid/content/Context;"; + + // Define a method that calls into the represented Java class + local_ref getCacheDir() { + static auto method = getClass()->getMethod("getCacheDir"); + return method(self()); + } + + local_ref getFilesDir() { + static auto method = getClass()->getMethod("getFilesDir"); + return method(self()); + } +}; + +} +} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/CoreClasses-inl.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/CoreClasses-inl.h new file mode 100644 index 000000000..aeda7d7ac --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/CoreClasses-inl.h @@ -0,0 +1,689 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include +#include +#include + +#include "Common.h" +#include "Exceptions.h" +#include "Meta.h" +#include "MetaConvert.h" + +namespace facebook { +namespace jni { + +// jobject ///////////////////////////////////////////////////////////////////////////////////////// + +inline bool isSameObject(alias_ref lhs, alias_ref rhs) noexcept { + return internal::getEnv()->IsSameObject(lhs.get(), rhs.get()) != JNI_FALSE; +} + +inline local_ref JObject::getClass() const noexcept { + return adopt_local(internal::getEnv()->GetObjectClass(self())); +} + +inline bool JObject::isInstanceOf(alias_ref cls) const noexcept { + return internal::getEnv()->IsInstanceOf(self(), cls.get()) != JNI_FALSE; +} + +template +inline T JObject::getFieldValue(JField field) const noexcept { + return field.get(self()); +} + +template +inline local_ref JObject::getFieldValue(JField field) const noexcept { + return adopt_local(field.get(self())); +} + +template +inline void JObject::setFieldValue(JField field, T value) noexcept { + field.set(self(), value); +} + +inline std::string JObject::toString() const { + static auto method = findClassLocal("java/lang/Object")->getMethod("toString"); + + return method(self())->toStdString(); +} + + +// Class is here instead of CoreClasses.h because we need +// alias_ref to be complete. +class MonitorLock { + public: + inline MonitorLock() noexcept; + inline MonitorLock(alias_ref object) noexcept; + inline ~MonitorLock() noexcept; + + inline MonitorLock(MonitorLock&& other) noexcept; + inline MonitorLock& operator=(MonitorLock&& other) noexcept; + + inline MonitorLock(const MonitorLock&) = delete; + inline MonitorLock& operator=(const MonitorLock&) = delete; + + private: + inline void reset() noexcept; + alias_ref owned_; +}; + +MonitorLock::MonitorLock() noexcept : owned_(nullptr) {} + +MonitorLock::MonitorLock(alias_ref object) noexcept + : owned_(object) { + internal::getEnv()->MonitorEnter(object.get()); +} + +void MonitorLock::reset() noexcept { + if (owned_) { + internal::getEnv()->MonitorExit(owned_.get()); + if (internal::getEnv()->ExceptionCheck()) { + abort(); // Lock mismatch + } + owned_ = nullptr; + } +} + +MonitorLock::~MonitorLock() noexcept { + reset(); +} + +MonitorLock::MonitorLock(MonitorLock&& other) noexcept + : owned_(other.owned_) +{ + other.owned_ = nullptr; +} + +MonitorLock& MonitorLock::operator=(MonitorLock&& other) noexcept { + reset(); + owned_ = other.owned_; + other.owned_ = nullptr; + return *this; +} + +inline MonitorLock JObject::lock() const noexcept { + return MonitorLock(this_); +} + +inline jobject JObject::self() const noexcept { + return this_; +} + +inline void swap(JObject& a, JObject& b) noexcept { + using std::swap; + swap(a.this_, b.this_); +} + +// JavaClass /////////////////////////////////////////////////////////////////////////////////////// + +namespace detail { +template +static local_ref newInstance(Args... args) { + static auto cls = JC::javaClassStatic(); + static auto constructor = cls->template getConstructor(); + return cls->newObject(constructor, args...); +} +} + + +template +auto JavaClass::self() const noexcept -> javaobject { + return static_cast(JObject::self()); +} + +// jclass ////////////////////////////////////////////////////////////////////////////////////////// + +namespace detail { + +// This is not a real type. It is used so people won't accidentally +// use a void* to initialize a NativeMethod. +struct NativeMethodWrapper; + +} + +struct NativeMethod { + const char* name; + std::string descriptor; + detail::NativeMethodWrapper* wrapper; +}; + +inline local_ref JClass::getSuperclass() const noexcept { + return adopt_local(internal::getEnv()->GetSuperclass(self())); +} + +inline void JClass::registerNatives(std::initializer_list methods) { + const auto env = internal::getEnv(); + + JNINativeMethod jnimethods[methods.size()]; + size_t i = 0; + for (auto it = methods.begin(); it < methods.end(); ++it, ++i) { + jnimethods[i].name = it->name; + jnimethods[i].signature = it->descriptor.c_str(); + jnimethods[i].fnPtr = reinterpret_cast(it->wrapper); + } + + auto result = env->RegisterNatives(self(), jnimethods, methods.size()); + FACEBOOK_JNI_THROW_EXCEPTION_IF(result != JNI_OK); +} + +inline bool JClass::isAssignableFrom(alias_ref other) const noexcept { + const auto env = internal::getEnv(); + const auto result = env->IsAssignableFrom(self(), other.get()); + return result; +} + +template +inline JConstructor JClass::getConstructor() const { + return getConstructor(jmethod_traits_from_cxx::constructor_descriptor().c_str()); +} + +template +inline JConstructor JClass::getConstructor(const char* descriptor) const { + constexpr auto constructor_method_name = ""; + return getMethod(constructor_method_name, descriptor); +} + +template +inline JMethod JClass::getMethod(const char* name) const { + return getMethod(name, jmethod_traits_from_cxx::descriptor().c_str()); +} + +template +inline JMethod JClass::getMethod( + const char* name, + const char* descriptor) const { + const auto env = internal::getEnv(); + const auto method = env->GetMethodID(self(), name, descriptor); + FACEBOOK_JNI_THROW_EXCEPTION_IF(!method); + return JMethod{method}; +} + +template +inline JStaticMethod JClass::getStaticMethod(const char* name) const { + return getStaticMethod(name, jmethod_traits_from_cxx::descriptor().c_str()); +} + +template +inline JStaticMethod JClass::getStaticMethod( + const char* name, + const char* descriptor) const { + const auto env = internal::getEnv(); + const auto method = env->GetStaticMethodID(self(), name, descriptor); + FACEBOOK_JNI_THROW_EXCEPTION_IF(!method); + return JStaticMethod{method}; +} + +template +inline JNonvirtualMethod JClass::getNonvirtualMethod(const char* name) const { + return getNonvirtualMethod(name, jmethod_traits_from_cxx::descriptor().c_str()); +} + +template +inline JNonvirtualMethod JClass::getNonvirtualMethod( + const char* name, + const char* descriptor) const { + const auto env = internal::getEnv(); + const auto method = env->GetMethodID(self(), name, descriptor); + FACEBOOK_JNI_THROW_EXCEPTION_IF(!method); + return JNonvirtualMethod{method}; +} + +template +inline JField(), T>> +JClass::getField(const char* name) const { + return getField(name, jtype_traits::descriptor().c_str()); +} + +template +inline JField(), T>> JClass::getField( + const char* name, + const char* descriptor) const { + const auto env = internal::getEnv(); + auto field = env->GetFieldID(self(), name, descriptor); + FACEBOOK_JNI_THROW_EXCEPTION_IF(!field); + return JField{field}; +} + +template +inline JStaticField(), T>> JClass::getStaticField( + const char* name) const { + return getStaticField(name, jtype_traits::descriptor().c_str()); +} + +template +inline JStaticField(), T>> JClass::getStaticField( + const char* name, + const char* descriptor) const { + const auto env = internal::getEnv(); + auto field = env->GetStaticFieldID(self(), name, descriptor); + FACEBOOK_JNI_THROW_EXCEPTION_IF(!field); + return JStaticField{field}; +} + +template +inline T JClass::getStaticFieldValue(JStaticField field) const noexcept { + return field.get(self()); +} + +template +inline local_ref JClass::getStaticFieldValue(JStaticField field) noexcept { + return adopt_local(field.get(self())); +} + +template +inline void JClass::setStaticFieldValue(JStaticField field, T value) noexcept { + field.set(self(), value); +} + +template +inline local_ref JClass::newObject( + JConstructor constructor, + Args... args) const { + const auto env = internal::getEnv(); + auto object = env->NewObject(self(), constructor.getId(), + detail::callToJni( + detail::Convert::type>::toCall(args))...); + FACEBOOK_JNI_THROW_EXCEPTION_IF(!object); + return adopt_local(static_cast(object)); +} + +inline jclass JClass::self() const noexcept { + return static_cast(JObject::self()); +} + +inline void registerNatives(const char* name, std::initializer_list methods) { + findClassLocal(name)->registerNatives(methods); +} + + +// jstring ///////////////////////////////////////////////////////////////////////////////////////// + +inline local_ref make_jstring(const std::string& modifiedUtf8) { + return make_jstring(modifiedUtf8.c_str()); +} + +namespace detail { +// convert to std::string from jstring +template <> +struct Convert { + typedef jstring jniType; + static std::string fromJni(jniType t) { + return wrap_alias(t)->toStdString(); + } + static jniType toJniRet(const std::string& t) { + return make_jstring(t).release(); + } + static local_ref toCall(const std::string& t) { + return make_jstring(t); + } +}; + +// convert return from const char* +template <> +struct Convert { + typedef jstring jniType; + // no automatic synthesis of const char*. (It can't be freed.) + static jniType toJniRet(const char* t) { + return make_jstring(t).release(); + } + static local_ref toCall(const char* t) { + return make_jstring(t); + } +}; +} + +// JStackTrace ////////////////////////////////////////////////////////////////////////////////////// + +inline auto JStackTraceElement::create( + const std::string& declaringClass, const std::string& methodName, const std::string& file, int line) + -> local_ref { + return newInstance(declaringClass, methodName, file, line); +} + +inline std::string JStackTraceElement::getClassName() const { + static auto meth = javaClassStatic()->getMethod()>("getClassName"); + return meth(self())->toStdString(); +} + +inline std::string JStackTraceElement::getMethodName() const { + static auto meth = javaClassStatic()->getMethod()>("getMethodName"); + return meth(self())->toStdString(); +} + +inline std::string JStackTraceElement::getFileName() const { + static auto meth = javaClassStatic()->getMethod()>("getFileName"); + return meth(self())->toStdString(); +} + +inline int JStackTraceElement::getLineNumber() const { + static auto meth = javaClassStatic()->getMethod("getLineNumber"); + return meth(self()); +} + +// jthrowable ////////////////////////////////////////////////////////////////////////////////////// + +inline local_ref JThrowable::initCause(alias_ref cause) { + static auto meth = javaClassStatic()->getMethod("initCause"); + return meth(self(), cause.get()); +} + +// jtypeArray ////////////////////////////////////////////////////////////////////////////////////// + +namespace detail { +inline size_t JArray::size() const noexcept { + const auto env = internal::getEnv(); + return env->GetArrayLength(self()); +} +} + +namespace detail { +template +inline ElementProxy::ElementProxy( + Target* target, + size_t idx) + : target_{target}, idx_{idx} {} + +template +inline ElementProxy& ElementProxy::operator=(const T& o) { + target_->setElement(idx_, o); + return *this; +} + +template +inline ElementProxy& ElementProxy::operator=(alias_ref& o) { + target_->setElement(idx_, o.get()); + return *this; +} + +template +inline ElementProxy& ElementProxy::operator=(alias_ref&& o) { + target_->setElement(idx_, o.get()); + return *this; +} + +template +inline ElementProxy& ElementProxy::operator=(const ElementProxy& o) { + auto src = o.target_->getElement(o.idx_); + target_->setElement(idx_, src.get()); + return *this; +} + +template +inline ElementProxy::ElementProxy::operator const local_ref () const { + return target_->getElement(idx_); +} + +template +inline ElementProxy::ElementProxy::operator local_ref () { + return target_->getElement(idx_); +} +} + +template +std::string JArrayClass::get_instantiated_java_descriptor() { + return "[" + jtype_traits::descriptor(); +}; + +template +std::string JArrayClass::get_instantiated_base_name() { + return get_instantiated_java_descriptor(); +}; + +template +auto JArrayClass::newArray(size_t size) -> local_ref { + static auto elementClass = findClassStatic(jtype_traits::base_name().c_str()); + const auto env = internal::getEnv(); + auto rawArray = env->NewObjectArray(size, elementClass.get(), nullptr); + FACEBOOK_JNI_THROW_EXCEPTION_IF(!rawArray); + return adopt_local(static_cast(rawArray)); +} + +template +inline void JArrayClass::setElement(size_t idx, const T& value) { + const auto env = internal::getEnv(); + env->SetObjectArrayElement(this->self(), idx, value); +} + +template +inline local_ref JArrayClass::getElement(size_t idx) { + const auto env = internal::getEnv(); + auto rawElement = env->GetObjectArrayElement(this->self(), idx); + return adopt_local(static_cast(rawElement)); +} + +template +inline detail::ElementProxy> JArrayClass::operator[](size_t index) { + return detail::ElementProxy>(this, index); +} + +// jarray ///////////////////////////////////////////////////////////////////////////////////////// + +template +auto JPrimitiveArray::getRegion(jsize start, jsize length) + -> std::unique_ptr { + using T = typename jtype_traits::entry_type; + auto buf = std::unique_ptr{new T[length]}; + getRegion(start, length, buf.get()); + return buf; +} + +template +std::string JPrimitiveArray::get_instantiated_java_descriptor() { + return jtype_traits::descriptor(); +} +template +std::string JPrimitiveArray::get_instantiated_base_name() { + return JPrimitiveArray::get_instantiated_java_descriptor(); +} + +template +auto JPrimitiveArray::pin() -> PinnedPrimitiveArray> { + return PinnedPrimitiveArray>{this->self(), 0, 0}; +} + +template +auto JPrimitiveArray::pinRegion(jsize start, jsize length) + -> PinnedPrimitiveArray> { + return PinnedPrimitiveArray>{this->self(), start, length}; +} + +template +auto JPrimitiveArray::pinCritical() + -> PinnedPrimitiveArray> { + return PinnedPrimitiveArray>{this->self(), 0, 0}; +} + +template +class PinnedArrayAlloc { + public: + static void allocate( + alias_ref::array_type> array, + jsize start, + jsize length, + T** elements, + size_t* size, + jboolean* isCopy) { + (void) start; + (void) length; + *elements = array->getElements(isCopy); + *size = array->size(); + } + static void release( + alias_ref::array_type> array, + T* elements, + jint start, + jint size, + jint mode) { + (void) start; + (void) size; + array->releaseElements(elements, mode); + } +}; + +template +class PinnedCriticalAlloc { + public: + static void allocate( + alias_ref::array_type> array, + jsize start, + jsize length, + T** elements, + size_t* size, + jboolean* isCopy) { + const auto env = internal::getEnv(); + *elements = static_cast(env->GetPrimitiveArrayCritical(array.get(), isCopy)); + FACEBOOK_JNI_THROW_EXCEPTION_IF(!elements); + *size = array->size(); + } + static void release( + alias_ref::array_type> array, + T* elements, + jint start, + jint size, + jint mode) { + const auto env = internal::getEnv(); + env->ReleasePrimitiveArrayCritical(array.get(), elements, mode); + } +}; + +template +class PinnedRegionAlloc { + public: + static void allocate( + alias_ref::array_type> array, + jsize start, + jsize length, + T** elements, + size_t* size, + jboolean* isCopy) { + auto buf = array->getRegion(start, length); + FACEBOOK_JNI_THROW_EXCEPTION_IF(!buf); + *elements = buf.release(); + *size = length; + *isCopy = true; + } + static void release( + alias_ref::array_type> array, + T* elements, + jint start, + jint size, + jint mode) { + std::unique_ptr holder; + if (mode == 0 || mode == JNI_ABORT) { + holder.reset(elements); + } + if (mode == 0 || mode == JNI_COMMIT) { + array->setRegion(start, size, elements); + } + } +}; + +// PinnedPrimitiveArray /////////////////////////////////////////////////////////////////////////// + +template +PinnedPrimitiveArray::PinnedPrimitiveArray(PinnedPrimitiveArray&& o) { + *this = std::move(o); +} + +template +PinnedPrimitiveArray& +PinnedPrimitiveArray::operator=(PinnedPrimitiveArray&& o) { + if (array_) { + release(); + } + array_ = std::move(o.array_); + elements_ = o.elements_; + isCopy_ = o.isCopy_; + size_ = o.size_; + start_ = o.start_; + o.clear(); + return *this; +} + +template +T* PinnedPrimitiveArray::get() { + return elements_; +} + +template +inline void PinnedPrimitiveArray::release() { + releaseImpl(0); + clear(); +} + +template +inline void PinnedPrimitiveArray::commit() { + releaseImpl(JNI_COMMIT); +} + +template +inline void PinnedPrimitiveArray::abort() { + releaseImpl(JNI_ABORT); + clear(); +} + +template +inline void PinnedPrimitiveArray::releaseImpl(jint mode) { + FACEBOOK_JNI_THROW_EXCEPTION_IF(array_.get() == nullptr); + Alloc::release(array_, elements_, start_, size_, mode); +} + +template +inline void PinnedPrimitiveArray::clear() noexcept { + array_ = nullptr; + elements_ = nullptr; + isCopy_ = false; + start_ = 0; + size_ = 0; +} + +template +inline T& PinnedPrimitiveArray::operator[](size_t index) { + FACEBOOK_JNI_THROW_EXCEPTION_IF(elements_ == nullptr); + return elements_[index]; +} + +template +inline bool PinnedPrimitiveArray::isCopy() const noexcept { + return isCopy_ == JNI_TRUE; +} + +template +inline size_t PinnedPrimitiveArray::size() const noexcept { + return size_; +} + +template +inline PinnedPrimitiveArray::~PinnedPrimitiveArray() noexcept { + if (elements_) { + release(); + } +} + +template +inline PinnedPrimitiveArray::PinnedPrimitiveArray(alias_ref::array_type> array, jint start, jint length) { + array_ = array; + start_ = start; + Alloc::allocate(array, start, length, &elements_, &size_, &isCopy_); +} + +template +inline alias_ref JavaClass::javaClassStatic() { + static auto cls = findClassStatic(jtype_traits::base_name().c_str()); + return cls; +} + +template +inline local_ref JavaClass::javaClassLocal() { + std::string className(jtype_traits::base_name().c_str()); + return findClassLocal(className.c_str()); +} + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/CoreClasses.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/CoreClasses.h new file mode 100644 index 000000000..e73f9f5e7 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/CoreClasses.h @@ -0,0 +1,607 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +/** @file CoreClasses.h + * + * In CoreClasses.h wrappers for the core classes (jobject, jclass, and jstring) is defined + * to provide access to corresponding JNI functions + some conveniance. + */ + +#include "References-forward.h" +#include "Meta-forward.h" +#include "TypeTraits.h" +#include + +#include + +#include + +#include + +namespace facebook { +namespace jni { + +class JClass; +class JObject; + +/// Lookup a class by name. Note this functions returns an alias_ref that +/// points to a leaked global reference. This is appropriate for classes +/// that are never unloaded (which is any class in an Android app and most +/// Java programs). +/// +/// The most common use case for this is storing the result +/// in a "static auto" variable, or a static global. +/// +/// @return Returns a leaked global reference to the class +FBEXPORT alias_ref findClassStatic(const char* name); + +/// Lookup a class by name. Note this functions returns a local reference, +/// which means that it must not be stored in a static variable. +/// +/// The most common use case for this is one-time initialization +/// (like caching method ids). +/// +/// @return Returns a global reference to the class +FBEXPORT local_ref findClassLocal(const char* name); + +/// Check to see if two references refer to the same object. Comparison with nullptr +/// returns true if and only if compared to another nullptr. A weak reference that +/// refers to a reclaimed object count as nullptr. +FBEXPORT bool isSameObject(alias_ref lhs, alias_ref rhs) noexcept; + +// Together, these classes allow convenient use of any class with the fbjni +// helpers. To use: +// +// struct MyClass : public JavaClass { +// constexpr static auto kJavaDescriptor = "Lcom/example/package/MyClass;"; +// }; +// +// Then, an alias_ref will be backed by an instance of +// MyClass. JavaClass provides a convenient way to add functionality to these +// smart references. +// +// For example: +// +// struct MyClass : public JavaClass { +// constexpr static auto kJavaDescriptor = "Lcom/example/package/MyClass;"; +// +// void foo() { +// static auto method = javaClassStatic()->getMethod("foo"); +// method(self()); +// } +// +// static local_ref create(int i) { +// return newInstance(i); +// } +// }; +// +// auto obj = MyClass::create(10); +// obj->foo(); +// +// While users of a JavaClass-type can lookup methods and fields through the +// underlying JClass, those calls can only be checked at runtime. It is recommended +// that the JavaClass-type instead explicitly expose it's methods as in the example +// above. + +namespace detail { +template +static local_ref newInstance(Args... args); +} + +class MonitorLock; + +class FBEXPORT JObject : detail::JObjectBase { +public: + static constexpr auto kJavaDescriptor = "Ljava/lang/Object;"; + + static constexpr const char* get_instantiated_java_descriptor() { return nullptr; } + static constexpr const char* get_instantiated_base_name() { return nullptr; } + + /// Get a @ref local_ref of the object's class + local_ref getClass() const noexcept; + + /// Checks if the object is an instance of a class + bool isInstanceOf(alias_ref cls) const noexcept; + + /// Get the primitive value of a field + template + T getFieldValue(JField field) const noexcept; + + /// Get and wrap the value of a field in a @ref local_ref + template + local_ref getFieldValue(JField field) const noexcept; + + /// Set the value of field. Any Java type is accepted, including the primitive types + /// and raw reference types. + template + void setFieldValue(JField field, T value) noexcept; + + /// Convenience method to create a std::string representing the object + std::string toString() const; + + // Take this object's monitor lock + MonitorLock lock() const noexcept; + + typedef _jobject _javaobject; + typedef _javaobject* javaobject; + +protected: + jobject self() const noexcept; +private: + friend void swap(JObject& a, JObject& b) noexcept; + template + friend struct detail::ReprAccess; + template + friend class JavaClass; + + template + friend class JObjectWrapper; +}; + +// This is only to maintain backwards compatibility with things that are +// already providing a specialization of JObjectWrapper. Any such instances +// should be updated to use a JavaClass. +template<> +class JObjectWrapper : public JObject { +}; + + +namespace detail { +template +struct JTypeFor { + static_assert( + std::is_base_of< + std::remove_pointer::type, + typename std::remove_pointer::type + >::value, ""); + using _javaobject = typename std::remove_pointer::type; + using javaobject = JType; +}; + +template +struct JTypeFor { + // JNI pattern for jobject assignable pointer + struct _javaobject : Base::_javaobject { + // This allows us to map back to the defining type (in ReprType, for + // example). + typedef T JniRefRepr; + }; + using javaobject = _javaobject*; +}; +} + +// JavaClass provides a method to inform fbjni about user-defined Java types. +// Given a class: +// struct Foo : JavaClass { +// static constexpr auto kJavaDescriptor = "Lcom/example/package/Foo;"; +// }; +// fbjni can determine the java type/method signatures for Foo::javaobject and +// smart refs (like alias_ref) will hold an instance of Foo +// and provide access to it through the -> and * operators. +// +// The "Base" template argument can be used to specify the JavaClass superclass +// of this type (for instance, JString's Base is JObject). +// +// The "JType" template argument is used to provide a jni type (like jstring, +// jthrowable) to be used as javaobject. This should only be necessary for +// built-in jni types and not user-defined ones. +template +class FBEXPORT JavaClass : public Base { + using JObjType = typename detail::JTypeFor; +public: + using _javaobject = typename JObjType::_javaobject; + using javaobject = typename JObjType::javaobject; + + using JavaBase = JavaClass; + + static alias_ref javaClassStatic(); + static local_ref javaClassLocal(); +protected: + /// Allocates a new object and invokes the specified constructor + /// Like JClass's getConstructor, this function can only check at runtime if + /// the class actually has a constructor that accepts the corresponding types. + /// While a JavaClass-type can expose this function directly, it is recommended + /// to instead to use this to explicitly only expose those constructors that + /// the Java class actually has (i.e. with static create() functions). + template + static local_ref newInstance(Args... args) { + return detail::newInstance(args...); + } + + javaobject self() const noexcept; +}; + +/// Wrapper to provide functionality to jclass references +struct NativeMethod; + +class FBEXPORT JClass : public JavaClass { + public: + /// Java type descriptor + static constexpr const char* kJavaDescriptor = "Ljava/lang/Class;"; + + /// Get a @local_ref to the super class of this class + local_ref getSuperclass() const noexcept; + + /// Register native methods for the class. Usage looks like this: + /// + /// classRef->registerNatives({ + /// makeNativeMethod("nativeMethodWithAutomaticDescriptor", + /// methodWithAutomaticDescriptor), + /// makeNativeMethod("nativeMethodWithExplicitDescriptor", + /// "(Lcom/facebook/example/MyClass;)V", + /// methodWithExplicitDescriptor), + /// }); + /// + /// By default, C++ exceptions raised will be converted to Java exceptions. + /// To avoid this and get the "standard" JNI behavior of a crash when a C++ + /// exception is crashing out of the JNI method, declare the method noexcept. + void registerNatives(std::initializer_list methods); + + /// Check to see if the class is assignable from another class + /// @pre cls != nullptr + bool isAssignableFrom(alias_ref cls) const noexcept; + + /// Convenience method to lookup the constructor with descriptor as specified by the + /// type arguments + template + JConstructor getConstructor() const; + + /// Convenience method to lookup the constructor with specified descriptor + template + JConstructor getConstructor(const char* descriptor) const; + + /// Look up the method with given name and descriptor as specified with the type arguments + template + JMethod getMethod(const char* name) const; + + /// Look up the method with given name and descriptor + template + JMethod getMethod(const char* name, const char* descriptor) const; + + /// Lookup the field with the given name and deduced descriptor + template + JField(), T>> getField(const char* name) const; + + /// Lookup the field with the given name and descriptor + template + JField(), T>> getField(const char* name, const char* descriptor) const; + + /// Lookup the static field with the given name and deduced descriptor + template + JStaticField(), T>> getStaticField(const char* name) const; + + /// Lookup the static field with the given name and descriptor + template + JStaticField(), T>> getStaticField( + const char* name, + const char* descriptor) const; + + /// Get the primitive value of a static field + template + T getStaticFieldValue(JStaticField field) const noexcept; + + /// Get and wrap the value of a field in a @ref local_ref + template + local_ref getStaticFieldValue(JStaticField field) noexcept; + + /// Set the value of field. Any Java type is accepted, including the primitive types + /// and raw reference types. + template + void setStaticFieldValue(JStaticField field, T value) noexcept; + + /// Allocates a new object and invokes the specified constructor + template + local_ref newObject(JConstructor constructor, Args... args) const; + + /// Look up the static method with given name and descriptor as specified with the type arguments + template + JStaticMethod getStaticMethod(const char* name) const; + + /// Look up the static method with given name and descriptor + template + JStaticMethod getStaticMethod(const char* name, const char* descriptor) const; + + /// Look up the non virtual method with given name and descriptor as specified with the + /// type arguments + template + JNonvirtualMethod getNonvirtualMethod(const char* name) const; + + /// Look up the non virtual method with given name and descriptor + template + JNonvirtualMethod getNonvirtualMethod(const char* name, const char* descriptor) const; + +private: + jclass self() const noexcept; +}; + +// Convenience method to register methods on a class without holding +// onto the class object. +void registerNatives(const char* name, std::initializer_list methods); + +/// Wrapper to provide functionality to jstring references +class FBEXPORT JString : public JavaClass { + public: + /// Java type descriptor + static constexpr const char* kJavaDescriptor = "Ljava/lang/String;"; + + /// Convenience method to convert a jstring object to a std::string + std::string toStdString() const; +}; + +/// Convenience functions to convert a std::string or const char* into a @ref local_ref to a +/// jstring +FBEXPORT local_ref make_jstring(const char* modifiedUtf8); +FBEXPORT local_ref make_jstring(const std::string& modifiedUtf8); + +namespace detail { +template +class ElementProxy { + private: + Target* target_; + size_t idx_; + + public: + using T = typename Target::javaentry; + ElementProxy(Target* target, size_t idx); + + ElementProxy& operator=(const T& o); + + ElementProxy& operator=(alias_ref& o); + + ElementProxy& operator=(alias_ref&& o); + + ElementProxy& operator=(const ElementProxy& o); + + operator const local_ref () const; + + operator local_ref (); +}; +} + +namespace detail { +class FBEXPORT JArray : public JavaClass { + public: + // This cannot be used in a scope that derives a descriptor (like in a method + // signature). Use a more derived type instead (like JArrayInt or + // JArrayClass). + static constexpr const char* kJavaDescriptor = nullptr; + size_t size() const noexcept; +}; + +// This is used so that the JArrayClass javaobject extends jni's +// jobjectArray. This class should not be used directly. A general Object[] +// should use JArrayClass. +class FBEXPORT JTypeArray : public JavaClass { + // This cannot be used in a scope that derives a descriptor (like in a method + // signature). + static constexpr const char* kJavaDescriptor = nullptr; +}; +} + +template +class JArrayClass : public JavaClass, detail::JTypeArray> { + public: + static_assert(is_plain_jni_reference(), ""); + // javaentry is the jni type of an entry in the array (i.e. jint). + using javaentry = T; + // javaobject is the jni type of the array. + using javaobject = typename JavaClass, detail::JTypeArray>::javaobject; + static constexpr const char* kJavaDescriptor = nullptr; + static std::string get_instantiated_java_descriptor(); + static std::string get_instantiated_base_name(); + + /// Allocate a new array from Java heap, for passing as a JNI parameter or return value. + /// NOTE: if using as a return value, you want to call release() instead of get() on the + /// smart pointer. + static local_ref newArray(size_t count); + + /// Assign an object to the array. + /// Typically you will use the shorthand (*ref)[idx]=value; + void setElement(size_t idx, const T& value); + + /// Read an object from the array. + /// Typically you will use the shorthand + /// T value = (*ref)[idx]; + /// If you use auto, you'll get an ElementProxy, which may need to be cast. + local_ref getElement(size_t idx); + + /// EXPERIMENTAL SUBSCRIPT SUPPORT + /// This implementation of [] returns a proxy object which then has a bunch of specializations + /// (adopt_local free function, operator= and casting overloads on the ElementProxy) that can + /// make code look like it is dealing with a T rather than an obvious proxy. In particular, the + /// proxy in this iteration does not read a value and therefore does not create a LocalRef + /// until one of these other operators is used. There are certainly holes that you may find + /// by using idioms that haven't been tried yet. Consider yourself warned. On the other hand, + /// it does make for some idiomatic assignment code; see TestBuildStringArray in fbjni_tests + /// for some examples. + detail::ElementProxy operator[](size_t idx); +}; + +template +using jtypeArray = typename JArrayClass::javaobject; + +template +local_ref::javaobject> adopt_local_array(jobjectArray ref) { + return adopt_local(static_cast::javaobject>(ref)); +} + +template +local_ref adopt_local(detail::ElementProxy elementProxy) { + return static_cast>(elementProxy); +} + + +struct FBEXPORT JStackTraceElement : JavaClass { + static auto constexpr kJavaDescriptor = "Ljava/lang/StackTraceElement;"; + + static local_ref create(const std::string& declaringClass, const std::string& methodName, const std::string& file, int line); + + std::string getClassName() const; + std::string getMethodName() const; + std::string getFileName() const; + int getLineNumber() const; +}; + +/// Wrapper to provide functionality to jthrowable references +class FBEXPORT JThrowable : public JavaClass { + public: + static constexpr const char* kJavaDescriptor = "Ljava/lang/Throwable;"; + local_ref initCause(alias_ref cause); + using JStackTrace = JArrayClass; + local_ref getStackTrace(); +}; + +template +class PinnedPrimitiveArray; + +template class PinnedArrayAlloc; +template class PinnedRegionAlloc; +template class PinnedCriticalAlloc; + +/// Wrapper to provide functionality to jarray references. +/// This is an empty holder by itself. Construct a PinnedPrimitiveArray to actually interact with +/// the elements of the array. +template +class FBEXPORT JPrimitiveArray : + public JavaClass, detail::JArray, JArrayType> { + static_assert(is_jni_primitive_array(), ""); + public: + static constexpr const char* kJavaDescriptor = nullptr; + static std::string get_instantiated_java_descriptor(); + static std::string get_instantiated_base_name(); + + using T = typename jtype_traits::entry_type; + + static local_ref newArray(size_t count); + + void getRegion(jsize start, jsize length, T* buf); + std::unique_ptr getRegion(jsize start, jsize length); + void setRegion(jsize start, jsize length, const T* buf); + + /// Returns a view of the underlying array. This will either be a "pinned" + /// version of the array (in which case changes to one immediately affect the + /// other) or a copy of the array (in which cases changes to the view will take + /// affect when destroyed or on calls to release()/commit()). + PinnedPrimitiveArray> pin(); + + /// Returns a view of part of the underlying array. A pinned region is always + /// backed by a copy of the region. + PinnedPrimitiveArray> pinRegion(jsize start, jsize length); + + /// Returns a view of the underlying array like pin(). However, while the pin + /// is held, the code is considered within a "critical region". In a critical + /// region, native code must not call JNI functions or make any calls that may + /// block on other Java threads. These restrictions make it more likely that + /// the view will be "pinned" rather than copied (for example, the VM may + /// suspend garbage collection within a critical region). + PinnedPrimitiveArray> pinCritical(); + +private: + friend class PinnedArrayAlloc; + T* getElements(jboolean* isCopy); + void releaseElements(T* elements, jint mode); +}; + +FBEXPORT local_ref make_boolean_array(jsize size); +FBEXPORT local_ref make_byte_array(jsize size); +FBEXPORT local_ref make_char_array(jsize size); +FBEXPORT local_ref make_short_array(jsize size); +FBEXPORT local_ref make_int_array(jsize size); +FBEXPORT local_ref make_long_array(jsize size); +FBEXPORT local_ref make_float_array(jsize size); +FBEXPORT local_ref make_double_array(jsize size); + +using JArrayBoolean = JPrimitiveArray; +using JArrayByte = JPrimitiveArray; +using JArrayChar = JPrimitiveArray; +using JArrayShort = JPrimitiveArray; +using JArrayInt = JPrimitiveArray; +using JArrayLong = JPrimitiveArray; +using JArrayFloat = JPrimitiveArray; +using JArrayDouble = JPrimitiveArray; + +/// RAII class for pinned primitive arrays +/// This currently only supports read/write access to existing java arrays. You can't create a +/// primitive array this way yet. This class also pins the entire array into memory during the +/// lifetime of the PinnedPrimitiveArray. If you need to unpin the array manually, call the +/// release() or abort() functions. During a long-running block of code, you +/// should unpin the array as soon as you're done with it, to avoid holding up +/// the Java garbage collector. +template +class PinnedPrimitiveArray { + public: + static_assert(is_jni_primitive::value, + "PinnedPrimitiveArray requires primitive jni type."); + + using ArrayType = typename jtype_traits::array_type; + + PinnedPrimitiveArray(PinnedPrimitiveArray&&); + PinnedPrimitiveArray(const PinnedPrimitiveArray&) = delete; + ~PinnedPrimitiveArray() noexcept; + + PinnedPrimitiveArray& operator=(PinnedPrimitiveArray&&); + PinnedPrimitiveArray& operator=(const PinnedPrimitiveArray&) = delete; + + T* get(); + void release(); + /// Unpins the array. If the array is a copy, pending changes are discarded. + void abort(); + /// If the array is a copy, copies pending changes to the underlying java array. + void commit(); + + bool isCopy() const noexcept; + + const T& operator[](size_t index) const; + T& operator[](size_t index); + size_t size() const noexcept; + + private: + alias_ref array_; + size_t start_; + T* elements_; + jboolean isCopy_; + size_t size_; + + void allocate(alias_ref, jint start, jint length); + void releaseImpl(jint mode); + void clear() noexcept; + + PinnedPrimitiveArray(alias_ref, jint start, jint length); + + friend class JPrimitiveArray::array_type>; +}; + +#pragma push_macro("PlainJniRefMap") +#undef PlainJniRefMap +#define PlainJniRefMap(rtype, jtype) \ +namespace detail { \ +template<> \ +struct RefReprType { \ + using type = rtype; \ +}; \ +} + +PlainJniRefMap(JArrayBoolean, jbooleanArray); +PlainJniRefMap(JArrayByte, jbyteArray); +PlainJniRefMap(JArrayChar, jcharArray); +PlainJniRefMap(JArrayShort, jshortArray); +PlainJniRefMap(JArrayInt, jintArray); +PlainJniRefMap(JArrayLong, jlongArray); +PlainJniRefMap(JArrayFloat, jfloatArray); +PlainJniRefMap(JArrayDouble, jdoubleArray); +PlainJniRefMap(JObject, jobject); +PlainJniRefMap(JClass, jclass); +PlainJniRefMap(JString, jstring); +PlainJniRefMap(JThrowable, jthrowable); + +#pragma pop_macro("PlainJniRefMap") + +}} + +#include "CoreClasses-inl.h" diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Exceptions.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Exceptions.h new file mode 100644 index 000000000..663667aea --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Exceptions.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +/** + * @file Exceptions.h + * + * After invoking a JNI function that can throw a Java exception, the macro + * @ref FACEBOOK_JNI_THROW_PENDING_EXCEPTION() or @ref FACEBOOK_JNI_THROW_EXCEPTION_IF() + * should be invoked. + * + * IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! + * To use these methods you MUST call initExceptionHelpers() when your library is loaded. + */ + +#pragma once + +#include +#include +#include + +#include + +#include + +#include "Common.h" +#include "References.h" +#include "CoreClasses.h" + +namespace facebook { +namespace jni { + +class JThrowable; + +class JCppException : public JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/CppException;"; + + static local_ref create(const char* str) { + return newInstance(make_jstring(str)); + } + + static local_ref create(const std::exception& ex) { + return newInstance(make_jstring(ex.what())); + } +}; + +// JniException //////////////////////////////////////////////////////////////////////////////////// + +/** + * This class wraps a Java exception into a C++ exception; if the exception is routed back + * to the Java side, it can be unwrapped and just look like a pure Java interaction. The class + * is resilient to errors while creating the exception, falling back to some pre-allocated + * exceptions if a new one cannot be allocated or populated. + * + * Note: the what() method of this class is not thread-safe (t6900503). + */ +class FBEXPORT JniException : public std::exception { + public: + JniException(); + ~JniException(); + + explicit JniException(alias_ref throwable); + + JniException(JniException &&rhs); + + JniException(const JniException &other); + + local_ref getThrowable() const noexcept; + + virtual const char* what() const noexcept; + + void setJavaException() const noexcept; + + private: + global_ref throwable_; + mutable std::string what_; + mutable bool isMessageExtracted_; + const static std::string kExceptionMessageFailure_; + + void populateWhat() const noexcept; +}; + +// Exception throwing & translating functions ////////////////////////////////////////////////////// + +// Functions that throw C++ exceptions + +static const int kMaxExceptionMessageBufferSize = 512; + +// These methods are the preferred way to throw a Java exception from +// a C++ function. They create and throw a C++ exception which wraps +// a Java exception, so the C++ flow is interrupted. Then, when +// translatePendingCppExceptionToJavaException is called at the +// topmost level of the native stack, the wrapped Java exception is +// thrown to the java caller. +template +[[noreturn]] void throwNewJavaException(const char* throwableName, const char* fmt, Args... args) { + int msgSize = snprintf(nullptr, 0, fmt, args...); + + char *msg = (char*) alloca(msgSize + 1); + snprintf(msg, kMaxExceptionMessageBufferSize, fmt, args...); + throwNewJavaException(throwableName, msg); +} + +// Identifies any pending C++ exception and throws it as a Java exception. If the exception can't +// be thrown, it aborts the program. This is a noexcept function at C++ level. +FBEXPORT void translatePendingCppExceptionToJavaException() noexcept; + +// For convenience, some exception names in java.lang are available here. + +const char* const gJavaLangIllegalArgumentException = "java/lang/IllegalArgumentException"; + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/File.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/File.h new file mode 100644 index 000000000..658ccb780 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/File.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2016-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include "CoreClasses.h" + +namespace facebook { +namespace jni { + +class JFile : public JavaClass { + public: + static constexpr const char* kJavaDescriptor = "Ljava/io/File;"; + + // Define a method that calls into the represented Java class + std::string getAbsolutePath() { + static auto method = getClass()->getMethod("getAbsolutePath"); + return method(self())->toStdString(); + } + +}; + +} +} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Hybrid.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Hybrid.h new file mode 100644 index 000000000..a95a44f51 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Hybrid.h @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include +#include + +#include +#include + +#include "CoreClasses.h" + +namespace facebook { +namespace jni { + +namespace detail { + +class BaseHybridClass { +public: + virtual ~BaseHybridClass() {} +}; + +struct FBEXPORT HybridData : public JavaClass { + constexpr static auto kJavaDescriptor = "Lcom/facebook/jni/HybridData;"; + void setNativePointer(std::unique_ptr new_value); + BaseHybridClass* getNativePointer(); + static local_ref create(); +}; + +template +struct HybridTraits { + // This static assert should actually always fail if we don't use one of the + // specializations below. + static_assert( + std::is_base_of::value || + std::is_base_of::value, + "The base of a HybridClass must be either another HybridClass or derived from JObject."); +}; + +template <> +struct HybridTraits { + using CxxBase = BaseHybridClass; + using JavaBase = JObject; +}; + +template +struct HybridTraits< + Base, + typename std::enable_if::value>::type> { + using CxxBase = Base; + using JavaBase = typename Base::JavaPart; +}; + +template +struct HybridTraits< + Base, + typename std::enable_if::value>::type> { + using CxxBase = BaseHybridClass; + using JavaBase = Base; +}; + +// convert to HybridClass* from jhybridobject +template +struct FBEXPORT Convert< + T, typename std::enable_if< + std::is_base_of::type>::value>::type> { + typedef typename std::remove_pointer::type::jhybridobject jniType; + static T fromJni(jniType t) { + if (t == nullptr) { + return nullptr; + } + return wrap_alias(t)->cthis(); + } + // There is no automatic return conversion for objects. +}; + +template +struct RefReprType::value, void>::type> { + static_assert(std::is_same::value, + "HybridFoo (where HybridFoo derives from HybridClass) is not supported in this context. " + "For an xxx_ref, you may want: xxx_ref or HybridFoo*."); + using Repr = T; +}; + + +} + +template +class FBEXPORT HybridClass : public detail::HybridTraits::CxxBase { +public: + struct JavaPart : JavaClass::JavaBase> { + // At this point, T is incomplete, and so we cannot access + // T::kJavaDescriptor directly. jtype_traits support this escape hatch for + // such a case. + static constexpr const char* kJavaDescriptor = nullptr; + static std::string get_instantiated_java_descriptor(); + static std::string get_instantiated_base_name(); + + using HybridType = T; + + // This will reach into the java object and extract the C++ instance from + // the mHybridData and return it. + T* cthis(); + + friend class HybridClass; + }; + + using jhybridobject = typename JavaPart::javaobject; + using javaobject = typename JavaPart::javaobject; + typedef detail::HybridData::javaobject jhybriddata; + + static alias_ref javaClassStatic() { + return JavaPart::javaClassStatic(); + } + + static local_ref javaClassLocal() { + std::string className(T::kJavaDescriptor + 1, strlen(T::kJavaDescriptor) - 2); + return findClassLocal(className.c_str()); + } + +protected: + typedef HybridClass HybridBase; + + // This ensures that a C++ hybrid part cannot be created on its own + // by default. If a hybrid wants to enable this, it can provide its + // own public ctor, or change the accessibility of this to public. + using detail::HybridTraits::CxxBase::CxxBase; + + static void registerHybrid(std::initializer_list methods) { + javaClassStatic()->registerNatives(methods); + } + + static local_ref makeHybridData(std::unique_ptr cxxPart) { + auto hybridData = detail::HybridData::create(); + hybridData->setNativePointer(std::move(cxxPart)); + return hybridData; + } + + template + static local_ref makeCxxInstance(Args&&... args) { + return makeHybridData(std::unique_ptr(new T(std::forward(args)...))); + } + +public: + // Factory method for creating a hybrid object where the arguments + // are used to initialize the C++ part directly without passing them + // through java. This method requires the Java part to have a ctor + // which takes a HybridData, and for the C++ part to have a ctor + // compatible with the arguments passed here. For safety, the ctor + // can be private, and the hybrid declared a friend of its base, so + // the hybrid can only be created from here. + // + // Exception behavior: This can throw an exception if creating the + // C++ object fails, or any JNI methods throw. + template + static local_ref newObjectCxxArgs(Args&&... args) { + auto hybridData = makeCxxInstance(std::forward(args)...); + return JavaPart::newInstance(hybridData); + } + + // TODO? Create reusable interface for Allocatable classes and use it to + // strengthen type-checking (and possibly provide a default + // implementation of allocate().) + template + static local_ref allocateWithCxxArgs(Args&&... args) { + auto hybridData = makeCxxInstance(std::forward(args)...); + static auto allocateMethod = + javaClassStatic()->template getStaticMethod("allocate"); + return allocateMethod(javaClassStatic(), hybridData.get()); + } + + // Factory method for creating a hybrid object where the arguments + // are passed to the java ctor. + template + static local_ref newObjectJavaArgs(Args&&... args) { + return JavaPart::newInstance(std::move(args)...); + } + + // If a hybrid class throws an exception which derives from + // std::exception, it will be passed to mapException on the hybrid + // class, or nearest ancestor. This allows boilerplate exception + // translation code (for example, calling throwNewJavaException on a + // particular java class) to be hoisted to a common function. If + // mapException returns, then the std::exception will be translated + // to Java. + static void mapException(const std::exception& ex) {} +}; + +template +inline T* HybridClass::JavaPart::cthis() { + static auto field = + HybridClass::JavaPart::javaClassStatic()->template getField("mHybridData"); + auto hybridData = this->getFieldValue(field); + if (!hybridData) { + throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); + } + // I'd like to use dynamic_cast here, but -fno-rtti is the default. + T* value = static_cast(hybridData->getNativePointer()); + // This would require some serious programmer error. + FBASSERTMSGF(value != 0, "Incorrect C++ type in hybrid field"); + return value; +}; + +template +/* static */ inline std::string HybridClass::JavaPart::get_instantiated_java_descriptor() { + return T::kJavaDescriptor; +} + +template +/* static */ inline std::string HybridClass::JavaPart::get_instantiated_base_name() { + auto name = get_instantiated_java_descriptor(); + return name.substr(1, name.size() - 2); +} + +// Given a *_ref object which refers to a hybrid class, this will reach inside +// of it, find the mHybridData, extract the C++ instance pointer, cast it to +// the appropriate type, and return it. +template +inline auto cthis(T jthis) -> decltype(jthis->cthis()) { + return jthis->cthis(); +} + +void HybridDataOnLoad(); + +} +} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Iterator-inl.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Iterator-inl.h new file mode 100644 index 000000000..507306de4 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Iterator-inl.h @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +namespace facebook { +namespace jni { + +namespace detail { + +template +struct IteratorHelper : public JavaClass> { + constexpr static auto kJavaDescriptor = "Lcom/facebook/jni/IteratorHelper;"; + + typedef local_ref value_type; + typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + typedef JavaClass> JavaBase_; + + bool hasNext() const { + static auto hasNextMethod = + JavaBase_::javaClassStatic()->template getMethod("hasNext"); + return hasNextMethod(JavaBase_::self()); + } + + value_type next() { + static auto elementField = + JavaBase_::javaClassStatic()->template getField("mElement"); + return dynamic_ref_cast(JavaBase_::getFieldValue(elementField)); + } + + static void reset(value_type& v) { + v.reset(); + } +}; + +template +struct MapIteratorHelper : public JavaClass> { + constexpr static auto kJavaDescriptor = "Lcom/facebook/jni/MapIteratorHelper;"; + + typedef std::pair, local_ref> value_type; + + typedef JavaClass> JavaBase_; + + bool hasNext() const { + static auto hasNextMethod = + JavaBase_::javaClassStatic()->template getMethod("hasNext"); + return hasNextMethod(JavaBase_::self()); + } + + value_type next() { + static auto keyField = JavaBase_::javaClassStatic()->template getField("mKey"); + static auto valueField = JavaBase_::javaClassStatic()->template getField("mValue"); + return std::make_pair(dynamic_ref_cast(JavaBase_::getFieldValue(keyField)), + dynamic_ref_cast(JavaBase_::getFieldValue(valueField))); + } + + static void reset(value_type& v) { + v.first.reset(); + v.second.reset(); + } +}; + +template +class Iterator { + public: + typedef typename T::value_type value_type; + typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::input_iterator_tag iterator_category; + + // begin ctor + Iterator(global_ref&& helper) + : helper_(std::move(helper)) + , i_(-1) { + ++(*this); + } + + // end ctor + Iterator() + : i_(-1) {} + + bool operator==(const Iterator& it) const { return i_ == it.i_; } + bool operator!=(const Iterator& it) const { return !(*this == it); } + const value_type& operator*() const { assert(i_ != -1); return entry_; } + const value_type* operator->() const { assert(i_ != -1); return &entry_; } + Iterator& operator++() { // preincrement + bool hasNext = helper_->hasNext(); + if (hasNext) { + ++i_; + entry_ = helper_->next(); + } else { + i_ = -1; + helper_->reset(entry_); + } + return *this; + } + Iterator operator++(int) { // postincrement + Iterator ret; + ret.i_ = i_; + ret.entry_ = std::move(entry_); + ++(*this); + return ret; + } + + global_ref helper_; + // set to -1 at end + std::ptrdiff_t i_; + value_type entry_; +}; + +} + +template +struct JIterator::Iterator : public detail::Iterator> { + using detail::Iterator>::Iterator; +}; + +template +typename JIterator::Iterator JIterator::begin() const { + static auto ctor = detail::IteratorHelper::javaClassStatic()-> + template getConstructor::javaobject( + typename JIterator::javaobject)>(); + return Iterator( + make_global( + detail::IteratorHelper::javaClassStatic()->newObject(ctor, this->self()))); +} + +template +typename JIterator::Iterator JIterator::end() const { + return Iterator(); +} + +template +struct JIterable::Iterator : public detail::Iterator> { + using detail::Iterator>::Iterator; +}; + +template +typename JIterable::Iterator JIterable::begin() const { + static auto ctor = detail::IteratorHelper::javaClassStatic()-> + template getConstructor::javaobject( + typename JIterable::javaobject)>(); + return Iterator( + make_global( + detail::IteratorHelper::javaClassStatic()->newObject(ctor, this->self()))); +} + +template +typename JIterable::Iterator JIterable::end() const { + return Iterator(); +} + +template +size_t JCollection::size() const { + static auto sizeMethod = + JCollection::javaClassStatic()->template getMethod("size"); + return sizeMethod(this->self()); +} + +template +struct JMap::Iterator : public detail::Iterator> { + using detail::Iterator>::Iterator; +}; + +template +size_t JMap::size() const { + static auto sizeMethod = + JMap::javaClassStatic()->template getMethod("size"); + return sizeMethod(this->self()); +} + +template +typename JMap::Iterator JMap::begin() const { + static auto ctor = detail::MapIteratorHelper::javaClassStatic()-> + template getConstructor::javaobject( + typename JMap::javaobject)>(); + return Iterator( + make_global( + detail::MapIteratorHelper::javaClassStatic()->newObject(ctor, this->self()))); +} + +template +typename JMap::Iterator JMap::end() const { + return Iterator(); +} + +} +} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Iterator.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Iterator.h new file mode 100644 index 000000000..efe8436f6 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Iterator.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include "CoreClasses.h" + +namespace facebook { +namespace jni { + +/** + * JavaClass which represents a reference to a java.util.Iterator instance. It + * provides begin()/end() methods to provide C++-style iteration over the + * underlying collection. The class has a template parameter for the element + * type, which defaults to jobject. For example: + * + * alias_ref::javaobject> my_iter = ...; + * + * In the simplest case, it can be used just as alias_ref::javaobject>, + * for example in a method declaration. + */ +template +struct JIterator : JavaClass> { + constexpr static auto kJavaDescriptor = "Ljava/util/Iterator;"; + + struct Iterator; + + /** + * To iterate: + * + * for (const auto& element : *jiter) { ... } + * + * The JIterator iterator value_type is local_ref, containing a reference + * to an element instance. + * + * If the Iterator returns objects whch are not convertible to the given + * element type, iteration will throw a java ClassCastException. + * + * For example, to convert an iterator over a collection of java strings to + * an std::vector of std::strings: + * + * std::vector vs; + * for (const auto& elem : *jiter) { + * vs.push_back(elem->toStdString()); + * } + * + * Or if you prefer using std algorithms: + * + * std::vector vs; + * std::transform(jiter->begin(), jiter->end(), std::back_inserter(vs), + * [](const local_ref& elem) { return elem->toStdString(); }); + * + * The iterator is a InputIterator. + */ + Iterator begin() const; + Iterator end() const; +}; + +/** + * Similar to JIterator, except this represents any object which implements the + * java.lang.Iterable interface. It will create the Java Iterator as a part of + * begin(). + */ +template +struct JIterable : JavaClass> { + constexpr static auto kJavaDescriptor = "Ljava/lang/Iterable;"; + + struct Iterator; + + Iterator begin() const; + Iterator end() const; +}; + +/** + * JavaClass types which represent Collection, List, and Set are also provided. + * These preserve the Java class heirarchy. + */ +template +struct JCollection : JavaClass, JIterable> { + constexpr static auto kJavaDescriptor = "Ljava/util/Collection;"; + + /** + * Returns the number of elements in the collection. + */ + size_t size() const; +}; + +template +struct JList : JavaClass, JCollection> { + constexpr static auto kJavaDescriptor = "Ljava/util/List;"; +}; + +template +struct JSet : JavaClass, JCollection> { + constexpr static auto kJavaDescriptor = "Ljava/util/Set;"; +}; + +/** + * JavaClass which represents a reference to a java.util.Map instance. It adds + * wrappers around Java methods, including begin()/end() methods to provide + * C++-style iteration over the Java Map. The class has template parameters + * for the key and value types, which default to jobject. For example: + * + * alias_ref::javaobject> my_map = ...; + * + * In the simplest case, it can be used just as alias_ref::javaobject>, + * for example in a method declaration. + */ +template +struct JMap : JavaClass> { + constexpr static auto kJavaDescriptor = "Ljava/util/Map;"; + + struct Iterator; + + /** + * Returns the number of pairs in the map. + */ + size_t size() const; + + /** + * To iterate over the Map: + * + * for (const auto& entry : *jmap) { ... } + * + * The JMap iterator value_type is std::pair, local_ref> + * containing references to key and value instances. + * + * If the Map contains objects whch are not convertible to the given key and + * value types, iteration will throw a java ClassCastException. + * + * The iterator is a InputIterator. + */ + Iterator begin() const; + Iterator end() const; +}; + +} +} + +#include "Iterator-inl.h" diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/JThread.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/JThread.h new file mode 100644 index 000000000..7dae9214b --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/JThread.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include "CoreClasses.h" +#include "NativeRunnable.h" + +namespace facebook { +namespace jni { + +class JThread : public JavaClass { + public: + static constexpr const char* kJavaDescriptor = "Ljava/lang/Thread;"; + + void start() { + static auto method = javaClassStatic()->getMethod("start"); + method(self()); + } + + void join() { + static auto method = javaClassStatic()->getMethod("join"); + method(self()); + } + + static local_ref create(std::function&& runnable) { + auto jrunnable = JNativeRunnable::newObjectCxxArgs(std::move(runnable)); + return newInstance(static_ref_cast(jrunnable)); + } +}; + +} +} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/JThrowable.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/JThrowable.h new file mode 100644 index 000000000..475e54d14 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/JThrowable.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once +#include "CoreClasses.h" + +struct JThrowable : public facebook::jni::JavaClass { + constexpr static auto kJavaDescriptor = "Ljava/lang/Throwable;"; + + std::string getStackTrace() const; +}; diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Meta-forward.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Meta-forward.h new file mode 100644 index 000000000..2736b3145 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Meta-forward.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +namespace facebook { +namespace jni { + +template +class JMethod; +template +class JStaticMethod; +template +class JNonvirtualMethod; +template +struct JConstructor; +template +class JField; +template +class JStaticField; + +/// Type traits for Java types (currently providing Java type descriptors) +template +struct jtype_traits; + +/// Type traits for Java methods (currently providing Java type descriptors) +template +struct jmethod_traits; + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Meta-inl.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Meta-inl.h new file mode 100644 index 000000000..e8f447698 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Meta-inl.h @@ -0,0 +1,430 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include + +#include "Common.h" +#include "Exceptions.h" +#include "MetaConvert.h" +#include "References.h" +#include "Boxed.h" + +#if defined(__ANDROID__) +#include +#endif + +namespace facebook { +namespace jni { + +// JMethod ///////////////////////////////////////////////////////////////////////////////////////// + +inline JMethodBase::JMethodBase(jmethodID method_id) noexcept + : method_id_{method_id} +{} + +inline JMethodBase::operator bool() const noexcept { + return method_id_ != nullptr; +} + +inline jmethodID JMethodBase::getId() const noexcept { + return method_id_; +} + +namespace { + +template +struct ArgsArraySetter; + +template +struct ArgsArraySetter { + static void set(alias_ref::javaobject> array, Arg arg0, Args... args) { + // TODO(xxxxxxxx): Use Convert... to do conversions like the fast path. + (*array)[idx] = autobox(arg0); + ArgsArraySetter::set(array, args...); + } +}; + +template +struct ArgsArraySetter { + static void set(alias_ref::javaobject> array) { + } +}; + +template +local_ref::javaobject> makeArgsArray(Args... args) { + auto arr = JArrayClass::newArray(sizeof...(args)); + ArgsArraySetter<0, Args...>::set(arr, args...); + return arr; +} + + +inline bool needsSlowPath(alias_ref obj) { +#if defined(__ANDROID__) + // On Android 6.0, art crashes when attempting to call a function on a Proxy. + // So, when we detect that case we must use the safe, slow workaround. That is, + // we resolve the method id to the corresponding java.lang.reflect.Method object + // and make the call via it's invoke() method. + static auto android_sdk = ([] { + char sdk_version_str[PROP_VALUE_MAX]; + __system_property_get("ro.build.version.sdk", sdk_version_str); + return atoi(sdk_version_str); + })(); + static auto is_bad_android = android_sdk == 23; + if (!is_bad_android) return false; + static auto proxy_class = findClassStatic("java/lang/reflect/Proxy"); + return obj->isInstanceOf(proxy_class); +#else + return false; +#endif +} + +} + +template +inline void JMethod::operator()(alias_ref self, Args... args) { + const auto env = Environment::current(); + env->CallVoidMethod( + self.get(), + getId(), + detail::callToJni(detail::Convert::type>::toCall(args))...); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); +} + +#pragma push_macro("DEFINE_PRIMITIVE_CALL") +#undef DEFINE_PRIMITIVE_CALL +#define DEFINE_PRIMITIVE_CALL(TYPE, METHOD, CLASS) \ +template \ +inline TYPE JMethod::operator()(alias_ref self, Args... args) { \ + const auto env = internal::getEnv(); \ + auto result = env->Call ## METHOD ## Method( \ + self.get(), \ + getId(), \ + detail::callToJni(detail::Convert::type>::toCall(args))...); \ + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); \ + return result; \ +} + +DEFINE_PRIMITIVE_CALL(jboolean, Boolean, JBoolean) +DEFINE_PRIMITIVE_CALL(jbyte, Byte, JByte) +DEFINE_PRIMITIVE_CALL(jchar, Char, JCharacter) +DEFINE_PRIMITIVE_CALL(jshort, Short, JShort) +DEFINE_PRIMITIVE_CALL(jint, Int, JInteger) +DEFINE_PRIMITIVE_CALL(jlong, Long, JLong) +DEFINE_PRIMITIVE_CALL(jfloat, Float, JFloat) +DEFINE_PRIMITIVE_CALL(jdouble, Double, JDouble) +#pragma pop_macro("DEFINE_PRIMITIVE_CALL") + +/// JMethod specialization for references that wraps the return value in a @ref local_ref +template +class JMethod : public JMethodBase { + public: + // TODO: static_assert is jobject-derived or local_ref jobject + using JniRet = typename detail::Convert::type>::jniType; + static_assert(IsPlainJniReference(), "JniRet must be a JNI reference"); + using JMethodBase::JMethodBase; + JMethod() noexcept {}; + JMethod(const JMethod& other) noexcept = default; + + /// Invoke a method and return a local reference wrapping the result + local_ref operator()(alias_ref self, Args... args); + + friend class JClass; +}; + +template +inline auto JMethod::operator()(alias_ref self, Args... args) -> local_ref { + const auto env = Environment::current(); + auto result = env->CallObjectMethod( + self.get(), + getId(), + detail::callToJni(detail::Convert::type>::toCall(args))...); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); + return adopt_local(static_cast(result)); +} + +template +inline void JStaticMethod::operator()(alias_ref cls, Args... args) { + const auto env = internal::getEnv(); + env->CallStaticVoidMethod( + cls.get(), + getId(), + detail::callToJni(detail::Convert::type>::toCall(args))...); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); +} + +#pragma push_macro("DEFINE_PRIMITIVE_STATIC_CALL") +#undef DEFINE_PRIMITIVE_STATIC_CALL +#define DEFINE_PRIMITIVE_STATIC_CALL(TYPE, METHOD) \ +template \ +inline TYPE JStaticMethod::operator()(alias_ref cls, Args... args) { \ + const auto env = internal::getEnv(); \ + auto result = env->CallStatic ## METHOD ## Method( \ + cls.get(), \ + getId(), \ + detail::callToJni(detail::Convert::type>::toCall(args))...); \ + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); \ + return result; \ +} + +DEFINE_PRIMITIVE_STATIC_CALL(jboolean, Boolean) +DEFINE_PRIMITIVE_STATIC_CALL(jbyte, Byte) +DEFINE_PRIMITIVE_STATIC_CALL(jchar, Char) +DEFINE_PRIMITIVE_STATIC_CALL(jshort, Short) +DEFINE_PRIMITIVE_STATIC_CALL(jint, Int) +DEFINE_PRIMITIVE_STATIC_CALL(jlong, Long) +DEFINE_PRIMITIVE_STATIC_CALL(jfloat, Float) +DEFINE_PRIMITIVE_STATIC_CALL(jdouble, Double) +#pragma pop_macro("DEFINE_PRIMITIVE_STATIC_CALL") + +/// JStaticMethod specialization for references that wraps the return value in a @ref local_ref +template +class JStaticMethod : public JMethodBase { + + public: + using JniRet = typename detail::Convert::type>::jniType; + static_assert(IsPlainJniReference(), "T* must be a JNI reference"); + using JMethodBase::JMethodBase; + JStaticMethod() noexcept {}; + JStaticMethod(const JStaticMethod& other) noexcept = default; + + /// Invoke a method and return a local reference wrapping the result + local_ref operator()(alias_ref cls, Args... args) { + const auto env = internal::getEnv(); + auto result = env->CallStaticObjectMethod( + cls.get(), + getId(), + detail::callToJni(detail::Convert::type>::toCall(args))...); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); + return adopt_local(static_cast(result)); + } + + friend class JClass; +}; + +template +inline void +JNonvirtualMethod::operator()(alias_ref self, alias_ref cls, Args... args) { + const auto env = internal::getEnv(); + env->CallNonvirtualVoidMethod( + self.get(), + cls.get(), + getId(), + detail::callToJni(detail::Convert::type>::toCall(args))...); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); +} + +#pragma push_macro("DEFINE_PRIMITIVE_NON_VIRTUAL_CALL") +#undef DEFINE_PRIMITIVE_NON_VIRTUAL_CALL +#define DEFINE_PRIMITIVE_NON_VIRTUAL_CALL(TYPE, METHOD) \ +template \ +inline TYPE \ +JNonvirtualMethod::operator()(alias_ref self, alias_ref cls, Args... args) { \ + const auto env = internal::getEnv(); \ + auto result = env->CallNonvirtual ## METHOD ## Method( \ + self.get(), \ + cls.get(), \ + getId(), \ + detail::callToJni(detail::Convert::type>::toCall(args))...); \ + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); \ + return result; \ +} + +DEFINE_PRIMITIVE_NON_VIRTUAL_CALL(jboolean, Boolean) +DEFINE_PRIMITIVE_NON_VIRTUAL_CALL(jbyte, Byte) +DEFINE_PRIMITIVE_NON_VIRTUAL_CALL(jchar, Char) +DEFINE_PRIMITIVE_NON_VIRTUAL_CALL(jshort, Short) +DEFINE_PRIMITIVE_NON_VIRTUAL_CALL(jint, Int) +DEFINE_PRIMITIVE_NON_VIRTUAL_CALL(jlong, Long) +DEFINE_PRIMITIVE_NON_VIRTUAL_CALL(jfloat, Float) +DEFINE_PRIMITIVE_NON_VIRTUAL_CALL(jdouble, Double) +#pragma pop_macro("DEFINE_PRIMITIVE_NON_VIRTUAL_CALL") + +/// JNonvirtualMethod specialization for references that wraps the return value in a @ref local_ref +template +class JNonvirtualMethod : public JMethodBase { + public: + using JniRet = typename detail::Convert::type>::jniType; + static_assert(IsPlainJniReference(), "T* must be a JNI reference"); + using JMethodBase::JMethodBase; + JNonvirtualMethod() noexcept {}; + JNonvirtualMethod(const JNonvirtualMethod& other) noexcept = default; + + /// Invoke a method and return a local reference wrapping the result + local_ref operator()(alias_ref self, alias_ref cls, Args... args){ + const auto env = internal::getEnv(); + auto result = env->CallNonvirtualObjectMethod( + self.get(), + cls.get(), + getId(), + detail::callToJni(detail::Convert::type>::toCall(args))...); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); + return adopt_local(static_cast(result)); + } + + friend class JClass; +}; + +template +local_ref slowCall(jmethodID method_id, alias_ref self, Args... args) { + static auto invoke = findClassStatic("java/lang/reflect/Method") + ->getMethod::javaobject)>("invoke"); + // TODO(xxxxxxx): Provide fbjni interface to ToReflectedMethod. + auto reflected = adopt_local(Environment::current()->ToReflectedMethod(self->getClass().get(), method_id, JNI_FALSE)); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); + if (!reflected) throw std::runtime_error("Unable to get reflected java.lang.reflect.Method"); + auto argsArray = makeArgsArray(args...); + // No need to check for exceptions since invoke is itself a JMethod that will do that for us. + return invoke(reflected, self.get(), argsArray.get()); +} + + +// JField /////////////////////////////////////////////////////////////////////////////////////// + +template +inline JField::JField(jfieldID field) noexcept + : field_id_{field} +{} + +template +inline JField::operator bool() const noexcept { + return field_id_ != nullptr; +} + +template +inline jfieldID JField::getId() const noexcept { + return field_id_; +} + +#pragma push_macro("DEFINE_FIELD_PRIMITIVE_GET_SET") +#undef DEFINE_FIELD_PRIMITIVE_GET_SET +#define DEFINE_FIELD_PRIMITIVE_GET_SET(TYPE, METHOD) \ +template<> \ +inline TYPE JField::get(jobject object) const noexcept { \ + const auto env = internal::getEnv(); \ + return env->Get ## METHOD ## Field(object, field_id_); \ +} \ + \ +template<> \ +inline void JField::set(jobject object, TYPE value) noexcept { \ + const auto env = internal::getEnv(); \ + env->Set ## METHOD ## Field(object, field_id_, value); \ +} + +DEFINE_FIELD_PRIMITIVE_GET_SET(jboolean, Boolean) +DEFINE_FIELD_PRIMITIVE_GET_SET(jbyte, Byte) +DEFINE_FIELD_PRIMITIVE_GET_SET(jchar, Char) +DEFINE_FIELD_PRIMITIVE_GET_SET(jshort, Short) +DEFINE_FIELD_PRIMITIVE_GET_SET(jint, Int) +DEFINE_FIELD_PRIMITIVE_GET_SET(jlong, Long) +DEFINE_FIELD_PRIMITIVE_GET_SET(jfloat, Float) +DEFINE_FIELD_PRIMITIVE_GET_SET(jdouble, Double) +#pragma pop_macro("DEFINE_FIELD_PRIMITIVE_GET_SET") + +template +inline T JField::get(jobject object) const noexcept { + return static_cast(internal::getEnv()->GetObjectField(object, field_id_)); +} + +template +inline void JField::set(jobject object, T value) noexcept { + internal::getEnv()->SetObjectField(object, field_id_, static_cast(value)); +} + +// JStaticField ///////////////////////////////////////////////////////////////////////////////// + +template +inline JStaticField::JStaticField(jfieldID field) noexcept + : field_id_{field} +{} + +template +inline JStaticField::operator bool() const noexcept { + return field_id_ != nullptr; +} + +template +inline jfieldID JStaticField::getId() const noexcept { + return field_id_; +} + +#pragma push_macro("DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET") +#undef DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET +#define DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET(TYPE, METHOD) \ +template<> \ +inline TYPE JStaticField::get(jclass jcls) const noexcept { \ + const auto env = internal::getEnv(); \ + return env->GetStatic ## METHOD ## Field(jcls, field_id_); \ +} \ + \ +template<> \ +inline void JStaticField::set(jclass jcls, TYPE value) noexcept { \ + const auto env = internal::getEnv(); \ + env->SetStatic ## METHOD ## Field(jcls, field_id_, value); \ +} + +DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET(jboolean, Boolean) +DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET(jbyte, Byte) +DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET(jchar, Char) +DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET(jshort, Short) +DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET(jint, Int) +DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET(jlong, Long) +DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET(jfloat, Float) +DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET(jdouble, Double) +#pragma pop_macro("DEFINE_STATIC_FIELD_PRIMITIVE_GET_SET") + +template +inline T JStaticField::get(jclass jcls) const noexcept { + const auto env = internal::getEnv(); + return static_cast(env->GetStaticObjectField(jcls, field_id_)); +} + +template +inline void JStaticField::set(jclass jcls, T value) noexcept { + internal::getEnv()->SetStaticObjectField(jcls, field_id_, value); +} + + +// jmethod_traits ////////////////////////////////////////////////////////////////////////////////// + +// TODO(T6608405) Adapt this to implement a register natives method that requires no descriptor +namespace internal { + +template +inline std::string JavaDescriptor() { + return jtype_traits::descriptor(); +} + +template +inline std::string JavaDescriptor() { + return JavaDescriptor() + JavaDescriptor(); +} + +template +inline std::string JMethodDescriptor() { + return "(" + JavaDescriptor() + ")" + JavaDescriptor(); +} + +template +inline std::string JMethodDescriptor() { + return "()" + JavaDescriptor(); +} + +} // internal + +template +inline std::string jmethod_traits::descriptor() { + return internal::JMethodDescriptor(); +} + +template +inline std::string jmethod_traits::constructor_descriptor() { + return internal::JMethodDescriptor(); +} + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Meta.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Meta.h new file mode 100644 index 000000000..a859367fa --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Meta.h @@ -0,0 +1,338 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +/** @file meta.h + * + * Provides wrappers for meta data such as methods and fields. + */ + +#pragma once + +#include +#include + +#include + +#include "References-forward.h" + +#ifdef __ANDROID__ +# include +# define XLOG_TAG "fb-jni" +# define XLOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, XLOG_TAG, __VA_ARGS__) +# define XLOGD(...) __android_log_print(ANDROID_LOG_DEBUG, XLOG_TAG, __VA_ARGS__) +# define XLOGI(...) __android_log_print(ANDROID_LOG_INFO, XLOG_TAG, __VA_ARGS__) +# define XLOGW(...) __android_log_print(ANDROID_LOG_WARN, XLOG_TAG, __VA_ARGS__) +# define XLOGE(...) __android_log_print(ANDROID_LOG_ERROR, XLOG_TAG, __VA_ARGS__) +# define XLOGWTF(...) __android_log_print(ANDROID_LOG_FATAL, XLOG_TAG, __VA_ARGS__) +#endif + +namespace facebook { +namespace jni { + +// This will get the reflected Java Method from the method_id, get it's invoke +// method, and call the method via that. This shouldn't ever be needed, but +// Android 6.0 crashes when calling a method on a java.lang.Proxy via jni. +template +local_ref slowCall(jmethodID method_id, alias_ref self, Args... args); + +class JObject; + + +/// Wrapper of a jmethodID. Provides a common base for JMethod specializations +class JMethodBase { + public: + /// Verify that the method is valid + explicit operator bool() const noexcept; + + /// Access the wrapped id + jmethodID getId() const noexcept; + + protected: + /// Create a wrapper of a method id + explicit JMethodBase(jmethodID method_id = nullptr) noexcept; + + private: + jmethodID method_id_; +}; + + +/// Representation of a jmethodID +template +class JMethod; + +/// @cond INTERNAL +#pragma push_macro("DEFINE_PRIMITIVE_METHOD_CLASS") + +#undef DEFINE_PRIMITIVE_METHOD_CLASS + +// Defining JMethod specializations based on return value +#define DEFINE_PRIMITIVE_METHOD_CLASS(TYPE) \ +template \ +class JMethod : public JMethodBase { \ + public: \ + static_assert(std::is_void::value || IsJniPrimitive(), \ + "TYPE must be primitive or void"); \ + \ + using JMethodBase::JMethodBase; \ + JMethod() noexcept {}; \ + JMethod(const JMethod& other) noexcept = default; \ + \ + TYPE operator()(alias_ref self, Args... args); \ + \ + friend class JClass; \ +} + +DEFINE_PRIMITIVE_METHOD_CLASS(void); +DEFINE_PRIMITIVE_METHOD_CLASS(jboolean); +DEFINE_PRIMITIVE_METHOD_CLASS(jbyte); +DEFINE_PRIMITIVE_METHOD_CLASS(jchar); +DEFINE_PRIMITIVE_METHOD_CLASS(jshort); +DEFINE_PRIMITIVE_METHOD_CLASS(jint); +DEFINE_PRIMITIVE_METHOD_CLASS(jlong); +DEFINE_PRIMITIVE_METHOD_CLASS(jfloat); +DEFINE_PRIMITIVE_METHOD_CLASS(jdouble); + +#pragma pop_macro("DEFINE_PRIMITIVE_METHOD_CLASS") +/// @endcond + + +/// Convenience type representing constructors +/// These should only be used with JClass::getConstructor and JClass::newObject. +template +struct JConstructor : private JMethod { + using JMethod::JMethod; + private: + JConstructor(const JMethod& other) : JMethod(other.getId()) {} + friend class JClass; +}; + +/// Representation of a jStaticMethodID +template +class JStaticMethod; + +/// @cond INTERNAL +#pragma push_macro("DEFINE_PRIMITIVE_STATIC_METHOD_CLASS") + +#undef DEFINE_PRIMITIVE_STATIC_METHOD_CLASS + +// Defining JStaticMethod specializations based on return value +#define DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(TYPE) \ +template \ +class JStaticMethod : public JMethodBase { \ + static_assert(std::is_void::value || IsJniPrimitive(), \ + "T must be a JNI primitive or void"); \ + \ + public: \ + using JMethodBase::JMethodBase; \ + JStaticMethod() noexcept {}; \ + JStaticMethod(const JStaticMethod& other) noexcept = default; \ + \ + TYPE operator()(alias_ref cls, Args... args); \ + \ + friend class JClass; \ +} + +DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(void); +DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(jboolean); +DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(jbyte); +DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(jchar); +DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(jshort); +DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(jint); +DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(jlong); +DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(jfloat); +DEFINE_PRIMITIVE_STATIC_METHOD_CLASS(jdouble); + +#pragma pop_macro("DEFINE_PRIMITIVE_STATIC_METHOD_CLASS") +/// @endcond + + +/// Representation of a jNonvirtualMethodID +template +class JNonvirtualMethod; + +/// @cond INTERNAL +#pragma push_macro("DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS") + +#undef DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS + +// Defining JNonvirtualMethod specializations based on return value +#define DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(TYPE) \ +template \ +class JNonvirtualMethod : public JMethodBase { \ + static_assert(std::is_void::value || IsJniPrimitive(), \ + "T must be a JNI primitive or void"); \ + \ + public: \ + using JMethodBase::JMethodBase; \ + JNonvirtualMethod() noexcept {}; \ + JNonvirtualMethod(const JNonvirtualMethod& other) noexcept = default; \ + \ + TYPE operator()(alias_ref self, alias_ref cls, Args... args); \ + \ + friend class JClass; \ +} + +DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(void); +DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(jboolean); +DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(jbyte); +DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(jchar); +DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(jshort); +DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(jint); +DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(jlong); +DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(jfloat); +DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS(jdouble); + +#pragma pop_macro("DEFINE_PRIMITIVE_NON_VIRTUAL_METHOD_CLASS") +/// @endcond + + +/** + * JField represents typed fields and simplifies their access. Note that object types return + * raw pointers which generally should promptly get a wrap_local treatment. + */ +template +class JField { + static_assert(IsJniScalar(), "T must be a JNI scalar"); + + public: + /// Wraps an existing field id + explicit JField(jfieldID field = nullptr) noexcept; + + /// Verify that the id is valid + explicit operator bool() const noexcept; + + /// Access the wrapped id + jfieldID getId() const noexcept; + + private: + jfieldID field_id_; + + /// Get field value + /// @pre object != nullptr + T get(jobject object) const noexcept; + + /// Set field value + /// @pre object != nullptr + void set(jobject object, T value) noexcept; + + friend class JObject; +}; + + +/** + * JStaticField represents typed fields and simplifies their access. Note that object types + * return raw pointers which generally should promptly get a wrap_local treatment. + */ +template +class JStaticField { + static_assert(IsJniScalar(), "T must be a JNI scalar"); + + public: + /// Wraps an existing field id + explicit JStaticField(jfieldID field = nullptr) noexcept; + + /// Verify that the id is valid + explicit operator bool() const noexcept; + + /// Access the wrapped id + jfieldID getId() const noexcept; + + private: + jfieldID field_id_; + + /// Get field value + /// @pre object != nullptr + T get(jclass jcls) const noexcept; + + /// Set field value + /// @pre object != nullptr + void set(jclass jcls, T value) noexcept; + + friend class JClass; + friend class JObject; +}; + + +/// Template magic to provide @ref jmethod_traits +template +struct jmethod_traits { + static std::string descriptor(); + static std::string constructor_descriptor(); +}; + + +// jtype_traits //////////////////////////////////////////////////////////////////////////////////// + +template +struct jtype_traits { +private: + using Repr = ReprType; +public: + // The jni type signature (described at + // http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/types.html). + static std::string descriptor() { + std::string descriptor; + if (Repr::kJavaDescriptor == nullptr) { + descriptor = Repr::get_instantiated_java_descriptor(); + } else { + descriptor = Repr::kJavaDescriptor; + } + return descriptor; + } + + // The signature used for class lookups. See + // http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#getName(). + static std::string base_name() { + if (Repr::kJavaDescriptor != nullptr) { + std::string base_name = Repr::kJavaDescriptor; + return base_name.substr(1, base_name.size() - 2); + } + return Repr::get_instantiated_base_name(); + } +}; + +#pragma push_macro("DEFINE_FIELD_AND_ARRAY_TRAIT") +#undef DEFINE_FIELD_AND_ARRAY_TRAIT + +#define DEFINE_FIELD_AND_ARRAY_TRAIT(TYPE, DSC) \ +template<> \ +struct jtype_traits { \ + static std::string descriptor() { return std::string{#DSC}; } \ + static std::string base_name() { return descriptor(); } \ + using array_type = TYPE ## Array; \ +}; \ +template<> \ +struct jtype_traits { \ + static std::string descriptor() { return std::string{"[" #DSC}; } \ + static std::string base_name() { return descriptor(); } \ + using entry_type = TYPE; \ +}; + +// There is no voidArray, handle that without the macro. +template<> +struct jtype_traits { + static std::string descriptor() { return std::string{"V"}; }; +}; + +DEFINE_FIELD_AND_ARRAY_TRAIT(jboolean, Z) +DEFINE_FIELD_AND_ARRAY_TRAIT(jbyte, B) +DEFINE_FIELD_AND_ARRAY_TRAIT(jchar, C) +DEFINE_FIELD_AND_ARRAY_TRAIT(jshort, S) +DEFINE_FIELD_AND_ARRAY_TRAIT(jint, I) +DEFINE_FIELD_AND_ARRAY_TRAIT(jlong, J) +DEFINE_FIELD_AND_ARRAY_TRAIT(jfloat, F) +DEFINE_FIELD_AND_ARRAY_TRAIT(jdouble, D) + +#pragma pop_macro("DEFINE_FIELD_AND_ARRAY_TRAIT") + + +template +struct jmethod_traits_from_cxx; + +}} + +#include "Meta-inl.h" diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/MetaConvert.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/MetaConvert.h new file mode 100644 index 000000000..479316197 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/MetaConvert.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2004-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include + +#include "Common.h" +#include "References.h" + +namespace facebook { +namespace jni { + +namespace detail { + +// In order to avoid potentially filling the jni locals table, +// temporary objects (right now, this is just jstrings) need to be +// released. This is done by returning a holder which autoconverts to +// jstring. +template +inline T callToJni(T&& t) { + return t; +} + +template +inline JniType callToJni(local_ref&& sref) { + return sref.get(); +} + +// Normally, pass through types unmolested. +template +struct Convert { + typedef T jniType; + static jniType fromJni(jniType t) { + return t; + } + static jniType toJniRet(jniType t) { + return t; + } + static jniType toCall(jniType t) { + return t; + } +}; + +// This is needed for return conversion +template <> +struct Convert { + typedef void jniType; +}; + +// jboolean is an unsigned char, not a bool. Allow it to work either way. +template<> +struct Convert { + typedef jboolean jniType; + static bool fromJni(jniType t) { + return t; + } + static jniType toJniRet(bool t) { + return t; + } + static jniType toCall(bool t) { + return t; + } +}; + +// convert to alias_ref from T +template +struct Convert> { + typedef JniType jniType; + static alias_ref fromJni(jniType t) { + return wrap_alias(t); + } + static jniType toJniRet(alias_ref t) { + return t.get(); + } + static jniType toCall(alias_ref t) { + return t.get(); + } +}; + +// convert return from local_ref +template +struct Convert> { + typedef JniType jniType; + // No automatic synthesis of local_ref + static jniType toJniRet(local_ref t) { + return t.release(); + } + static jniType toCall(local_ref t) { + return t.get(); + } +}; + +// convert return from global_ref +template +struct Convert> { + typedef JniType jniType; + // No automatic synthesis of global_ref + static jniType toJniRet(global_ref t) { + return t.get(); + } + static jniType toCall(global_ref t) { + return t.get(); + } +}; + +template struct jni_sig_from_cxx_t; +template +struct jni_sig_from_cxx_t { + using JniRet = typename Convert::type>::jniType; + using JniSig = JniRet(typename Convert::type>::jniType...); +}; + +template +using jni_sig_from_cxx = typename jni_sig_from_cxx_t::JniSig; + +} // namespace detail + +template +struct jmethod_traits_from_cxx : jmethod_traits> { +}; + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/NativeRunnable.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/NativeRunnable.h new file mode 100644 index 000000000..57182214b --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/NativeRunnable.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include "CoreClasses.h" +#include "Hybrid.h" +#include "Registration.h" + +#include + +namespace facebook { +namespace jni { + +struct JRunnable : public JavaClass { + static auto constexpr kJavaDescriptor = "Ljava/lang/Runnable;"; +}; + +struct JNativeRunnable : public HybridClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/NativeRunnable;"; + + JNativeRunnable(std::function&& runnable) : runnable_(std::move(runnable)) {} + + static void OnLoad() { + registerHybrid({ + makeNativeMethod("run", JNativeRunnable::run), + }); + } + + void run() { + runnable_(); + } + + private: + std::function runnable_; +}; + + +} // namespace jni +} // namespace facebook diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/ReferenceAllocators-inl.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/ReferenceAllocators-inl.h new file mode 100644 index 000000000..2b3cf3dee --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/ReferenceAllocators-inl.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace jni { + +/// @cond INTERNAL +namespace internal { + +// Statistics mostly provided for test (only updated if FBJNI_DEBUG_REFS is defined) +struct ReferenceStats { + std::atomic_uint locals_deleted, globals_deleted, weaks_deleted; + + void reset() noexcept; +}; + +extern ReferenceStats g_reference_stats; +} +/// @endcond + + +// LocalReferenceAllocator ///////////////////////////////////////////////////////////////////////// + +inline jobject LocalReferenceAllocator::newReference(jobject original) const { + internal::dbglog("Local new: %p", original); + auto ref = internal::getEnv()->NewLocalRef(original); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); + return ref; +} + +inline void LocalReferenceAllocator::deleteReference(jobject reference) const noexcept { + internal::dbglog("Local release: %p", reference); + + if (reference) { + #ifdef FBJNI_DEBUG_REFS + ++internal::g_reference_stats.locals_deleted; + #endif + assert(verifyReference(reference)); + internal::getEnv()->DeleteLocalRef(reference); + } +} + +inline bool LocalReferenceAllocator::verifyReference(jobject reference) const noexcept { + if (!reference || !internal::doesGetObjectRefTypeWork()) { + return true; + } + return internal::getEnv()->GetObjectRefType(reference) == JNILocalRefType; +} + + +// GlobalReferenceAllocator //////////////////////////////////////////////////////////////////////// + +inline jobject GlobalReferenceAllocator::newReference(jobject original) const { + internal::dbglog("Global new: %p", original); + auto ref = internal::getEnv()->NewGlobalRef(original); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); + return ref; +} + +inline void GlobalReferenceAllocator::deleteReference(jobject reference) const noexcept { + internal::dbglog("Global release: %p", reference); + + if (reference) { + #ifdef FBJNI_DEBUG_REFS + ++internal::g_reference_stats.globals_deleted; + #endif + assert(verifyReference(reference)); + internal::getEnv()->DeleteGlobalRef(reference); + } +} + +inline bool GlobalReferenceAllocator::verifyReference(jobject reference) const noexcept { + if (!reference || !internal::doesGetObjectRefTypeWork()) { + return true; + } + return internal::getEnv()->GetObjectRefType(reference) == JNIGlobalRefType; +} + + +// WeakGlobalReferenceAllocator //////////////////////////////////////////////////////////////////// + +inline jobject WeakGlobalReferenceAllocator::newReference(jobject original) const { + internal::dbglog("Weak global new: %p", original); + auto ref = internal::getEnv()->NewWeakGlobalRef(original); + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); + return ref; +} + +inline void WeakGlobalReferenceAllocator::deleteReference(jobject reference) const noexcept { + internal::dbglog("Weak Global release: %p", reference); + + if (reference) { + #ifdef FBJNI_DEBUG_REFS + ++internal::g_reference_stats.weaks_deleted; + #endif + assert(verifyReference(reference)); + internal::getEnv()->DeleteWeakGlobalRef(reference); + } +} + +inline bool WeakGlobalReferenceAllocator::verifyReference(jobject reference) const noexcept { + if (!reference || !internal::doesGetObjectRefTypeWork()) { + return true; + } + return internal::getEnv()->GetObjectRefType(reference) == JNIWeakGlobalRefType; +} + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/ReferenceAllocators.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/ReferenceAllocators.h new file mode 100644 index 000000000..214f6b2c2 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/ReferenceAllocators.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +/** + * @file ReferenceAllocators.h + * + * Reference allocators are used to create and delete various classes of JNI references (local, + * global, and weak global). + */ + +#pragma once + +#include + +#include "Common.h" + +namespace facebook { namespace jni { + +/// Allocator that handles local references +class FBEXPORT LocalReferenceAllocator { + public: + jobject newReference(jobject original) const; + void deleteReference(jobject reference) const noexcept; + bool verifyReference(jobject reference) const noexcept; +}; + +/// Allocator that handles global references +class FBEXPORT GlobalReferenceAllocator { + public: + jobject newReference(jobject original) const; + void deleteReference(jobject reference) const noexcept; + bool verifyReference(jobject reference) const noexcept; +}; + +/// Allocator that handles weak global references +class FBEXPORT WeakGlobalReferenceAllocator { + public: + jobject newReference(jobject original) const; + void deleteReference(jobject reference) const noexcept; + bool verifyReference(jobject reference) const noexcept; +}; + +/// @cond INTERNAL +namespace internal { + +/** + * @return true iff env->GetObjectRefType is expected to work properly. + */ +FBEXPORT bool doesGetObjectRefTypeWork(); + +} +/// @endcond + +}} + +#include "ReferenceAllocators-inl.h" diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/References-forward.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/References-forward.h new file mode 100644 index 000000000..13b92877a --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/References-forward.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include "ReferenceAllocators.h" + +namespace facebook { +namespace jni { + +template +class JObjectWrapper; + +namespace detail { +struct JObjectBase { + jobject get() const noexcept; + void set(jobject reference) noexcept; + jobject this_; +}; + +// RefReprType maps a type to the representation used by fbjni smart references. +template +struct RefReprType; + +template +struct JavaObjectType; + +template +struct ReprAccess; +} + +// Given T, either a jobject-like type or a JavaClass-derived type, ReprType +// is the corresponding JavaClass-derived type and JniType is the +// jobject-like type. +template +using ReprType = typename detail::RefReprType::type; + +template +using JniType = typename detail::JavaObjectType::type; + +template +class base_owned_ref; + +template +class basic_strong_ref; + +template +class weak_ref; + +template +class alias_ref; + +/// A smart unique reference owning a local JNI reference +template +using local_ref = basic_strong_ref; + +/// A smart unique reference owning a global JNI reference +template +using global_ref = basic_strong_ref; + +}} // namespace facebook::jni diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/References-inl.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/References-inl.h new file mode 100644 index 000000000..58c158515 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/References-inl.h @@ -0,0 +1,508 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include +#include "CoreClasses.h" + +namespace facebook { +namespace jni { + +template +inline enable_if_t(), T> getPlainJniReference(T ref) { + return ref; +} + +template +inline JniType getPlainJniReference(alias_ref ref) { + return ref.get(); +} + +template +inline JniType getPlainJniReference(const base_owned_ref& ref) { + return ref.get(); +} + + +namespace detail { +template +struct ReprAccess { + using javaobject = JniType; + static void set(Repr& repr, javaobject obj) noexcept { + repr.JObjectBase::set(obj); + } + static javaobject get(const Repr& repr) { + return static_cast(repr.JObject::get()); + } +}; + +namespace { +template +void StaticAssertValidRepr() noexcept { + static_assert(std::is_base_of::value, + "A smart ref representation must be derived from JObject."); + static_assert(IsPlainJniReference>(), "T must be a JNI reference"); + static_assert(sizeof(Repr) == sizeof(JObjectBase), ""); + static_assert(alignof(Repr) == alignof(JObjectBase), ""); +} +} + +template +ReprStorage::ReprStorage(JniType obj) noexcept { + StaticAssertValidRepr(); + set(obj); +} + +template +void ReprStorage::set(JniType obj) noexcept { + new (&storage_) Repr; + ReprAccess::set(get(), obj); +} + +template +Repr& ReprStorage::get() noexcept { + return *reinterpret_cast(&storage_); +} + +template +const Repr& ReprStorage::get() const noexcept { + return *reinterpret_cast(&storage_); +} + +template +JniType ReprStorage::jobj() const noexcept { + ReprAccess::get(get()); + return ReprAccess::get(get()); +} + +template +void ReprStorage::swap(ReprStorage& other) noexcept { + StaticAssertValidRepr(); + using std::swap; + swap(get(), other.get()); +} + +inline void JObjectBase::set(jobject reference) noexcept { + this_ = reference; +} + +inline jobject JObjectBase::get() const noexcept { + return this_; +} + +template +enable_if_t(), plain_jni_reference_t> make_ref(const T& reference) { + auto old_reference = getPlainJniReference(reference); + if (!old_reference) { + return nullptr; + } + + auto ref = Alloc{}.newReference(old_reference); + if (!ref) { + // Note that we end up here if we pass a weak ref that refers to a collected object. + // Thus, it's hard to come up with a reason why this function should be used with + // weak references. + throw std::bad_alloc{}; + } + + return static_cast>(ref); +} + +} // namespace detail + +template +inline local_ref adopt_local(T ref) noexcept { + static_assert(IsPlainJniReference(), "T must be a plain jni reference"); + return local_ref{ref}; +} + +template +inline global_ref adopt_global(T ref) noexcept { + static_assert(IsPlainJniReference(), "T must be a plain jni reference"); + return global_ref{ref}; +} + +template +inline weak_ref adopt_weak_global(T ref) noexcept { + static_assert(IsPlainJniReference(), "T must be a plain jni reference"); + return weak_ref{ref}; +} + + +template +inline enable_if_t(), alias_ref> wrap_alias(T ref) noexcept { + return alias_ref(ref); +} + + +template +enable_if_t(), alias_ref> wrap_alias(T ref) noexcept; + + +template +enable_if_t(), local_ref>> +make_local(const T& ref) { + return adopt_local(detail::make_ref(ref)); +} + +template +enable_if_t(), global_ref>> +make_global(const T& ref) { + return adopt_global(detail::make_ref(ref)); +} + +template +enable_if_t(), weak_ref>> +make_weak(const T& ref) { + return adopt_weak_global(detail::make_ref(ref)); +} + +template +inline enable_if_t() && IsNonWeakReference(), bool> +operator==(const T1& a, const T2& b) { + return isSameObject(getPlainJniReference(a), getPlainJniReference(b)); +} + +template +inline enable_if_t() && IsNonWeakReference(), bool> +operator!=(const T1& a, const T2& b) { + return !(a == b); +} + + +// base_owned_ref /////////////////////////////////////////////////////////////////////// + +template +inline base_owned_ref::base_owned_ref() noexcept + : base_owned_ref(nullptr) +{} + +template +inline base_owned_ref::base_owned_ref(std::nullptr_t t) noexcept + : base_owned_ref(static_cast(nullptr)) +{} + +template +inline base_owned_ref::base_owned_ref(const base_owned_ref& other) + : storage_{static_cast(Alloc{}.newReference(other.get()))} +{} + +template +template +inline base_owned_ref::base_owned_ref(const base_owned_ref& other) + : storage_{static_cast(Alloc{}.newReference(other.get()))} +{ + static_assert(std::is_convertible, javaobject>::value, ""); +} + +template +inline facebook::jni::base_owned_ref::base_owned_ref( + javaobject reference) noexcept + : storage_(reference) { + assert(Alloc{}.verifyReference(reference)); + internal::dbglog("New wrapped ref=%p this=%p", get(), this); +} + +template +inline base_owned_ref::base_owned_ref( + base_owned_ref&& other) noexcept + : storage_(other.get()) { + internal::dbglog("New move from ref=%p other=%p", other.get(), &other); + internal::dbglog("New move to ref=%p this=%p", get(), this); + // JObject is a simple type and does not support move semantics so we explicitly + // clear other + other.set(nullptr); +} + +template +template +base_owned_ref::base_owned_ref(base_owned_ref&& other) noexcept + : storage_(other.get()) { + internal::dbglog("New move from ref=%p other=%p", other.get(), &other); + internal::dbglog("New move to ref=%p this=%p", get(), this); + // JObject is a simple type and does not support move semantics so we explicitly + // clear other + other.set(nullptr); +} + +template +inline base_owned_ref::~base_owned_ref() noexcept { + reset(); + internal::dbglog("Ref destruct ref=%p this=%p", get(), this); +} + +template +inline auto base_owned_ref::release() noexcept -> javaobject { + auto value = get(); + internal::dbglog("Ref release ref=%p this=%p", value, this); + set(nullptr); + return value; +} + +template +inline void base_owned_ref::reset() noexcept { + reset(nullptr); +} + +template +inline void base_owned_ref::reset(javaobject reference) noexcept { + if (get()) { + assert(Alloc{}.verifyReference(reference)); + Alloc{}.deleteReference(get()); + } + set(reference); +} + +template +inline auto base_owned_ref::get() const noexcept -> javaobject { + return storage_.jobj(); +} + +template +inline void base_owned_ref::set(javaobject ref) noexcept { + storage_.set(ref); +} + + +// weak_ref /////////////////////////////////////////////////////////////////////// + +template +inline weak_ref& weak_ref::operator=( + const weak_ref& other) { + auto otherCopy = other; + swap(*this, otherCopy); + return *this; +} + +template +inline weak_ref& weak_ref::operator=( + weak_ref&& other) noexcept { + internal::dbglog("Op= move ref=%p this=%p oref=%p other=%p", + get(), this, other.get(), &other); + reset(other.release()); + return *this; +} + +template +local_ref weak_ref::lockLocal() const { + return adopt_local( + static_cast(LocalReferenceAllocator{}.newReference(get()))); +} + +template +global_ref weak_ref::lockGlobal() const { + return adopt_global( + static_cast(GlobalReferenceAllocator{}.newReference(get()))); +} + +template +inline void swap( + weak_ref& a, + weak_ref& b) noexcept { + internal::dbglog("Ref swap a.ref=%p a=%p b.ref=%p b=%p", + a.get(), &a, b.get(), &b); + a.storage_.swap(b.storage_); +} + + +// basic_strong_ref //////////////////////////////////////////////////////////////////////////// + +template +inline basic_strong_ref& basic_strong_ref::operator=( + const basic_strong_ref& other) { + auto otherCopy = other; + swap(*this, otherCopy); + return *this; +} + +template +inline basic_strong_ref& basic_strong_ref::operator=( + basic_strong_ref&& other) noexcept { + internal::dbglog("Op= move ref=%p this=%p oref=%p other=%p", + get(), this, other.get(), &other); + reset(other.release()); + return *this; +} + +template +inline alias_ref basic_strong_ref::releaseAlias() noexcept { + return wrap_alias(release()); +} + +template +inline basic_strong_ref::operator bool() const noexcept { + return get() != nullptr; +} + +template +inline auto basic_strong_ref::operator->() noexcept -> Repr* { + return &storage_.get(); +} + +template +inline auto basic_strong_ref::operator->() const noexcept -> const Repr* { + return &storage_.get(); +} + +template +inline auto basic_strong_ref::operator*() noexcept -> Repr& { + return storage_.get(); +} + +template +inline auto basic_strong_ref::operator*() const noexcept -> const Repr& { + return storage_.get(); +} + +template +inline void swap( + basic_strong_ref& a, + basic_strong_ref& b) noexcept { + internal::dbglog("Ref swap a.ref=%p a=%p b.ref=%p b=%p", + a.get(), &a, b.get(), &b); + using std::swap; + a.storage_.swap(b.storage_); +} + + +// alias_ref ////////////////////////////////////////////////////////////////////////////// + +template +inline alias_ref::alias_ref() noexcept + : storage_{nullptr} +{} + +template +inline alias_ref::alias_ref(std::nullptr_t) noexcept + : storage_{nullptr} +{} + +template +inline alias_ref::alias_ref(const alias_ref& other) noexcept + : storage_{other.get()} +{} + +template +inline alias_ref::alias_ref(javaobject ref) noexcept + : storage_(ref) { + assert( + LocalReferenceAllocator{}.verifyReference(ref) || + GlobalReferenceAllocator{}.verifyReference(ref)); +} + +template +template +inline alias_ref::alias_ref(alias_ref other) noexcept + : storage_{other.get()} +{} + +template +template +inline alias_ref::alias_ref(const basic_strong_ref& other) noexcept + : storage_{other.get()} +{} + +template +inline alias_ref& alias_ref::operator=(alias_ref other) noexcept { + swap(*this, other); + return *this; +} + +template +inline alias_ref::operator bool() const noexcept { + return get() != nullptr; +} + +template +inline auto facebook::jni::alias_ref::get() const noexcept -> javaobject { + return storage_.jobj(); +} + +template +inline auto alias_ref::operator->() noexcept -> Repr* { + return &(**this); +} + +template +inline auto alias_ref::operator->() const noexcept -> const Repr* { + return &(**this); +} + +template +inline auto alias_ref::operator*() noexcept -> Repr& { + return storage_.get(); +} + +template +inline auto alias_ref::operator*() const noexcept -> const Repr& { + return storage_.get(); +} + +template +inline void alias_ref::set(javaobject ref) noexcept { + storage_.set(ref); +} + +template +inline void swap(alias_ref& a, alias_ref& b) noexcept { + a.storage_.swap(b.storage_); +} + +// Could reduce code duplication by using a pointer-to-function +// template argument. I'm not sure whether that would make the code +// more maintainable (DRY), or less (too clever/confusing.). +template +enable_if_t(), local_ref> +static_ref_cast(const local_ref& ref) noexcept +{ + T p = static_cast(ref.get()); + return make_local(p); +} + +template +enable_if_t(), global_ref> +static_ref_cast(const global_ref& ref) noexcept +{ + T p = static_cast(ref.get()); + return make_global(p); +} + +template +enable_if_t(), alias_ref> +static_ref_cast(const alias_ref& ref) noexcept +{ + T p = static_cast(ref.get()); + return wrap_alias(p); +} + +template +auto dynamic_ref_cast(const RefType& ref) -> +enable_if_t(), decltype(static_ref_cast(ref))> +{ + if (! ref) { + return decltype(static_ref_cast(ref))(); + } + + std::string target_class_name{jtype_traits::base_name()}; + + // If not found, will throw an exception. + alias_ref target_class = findClassStatic(target_class_name.c_str()); + + local_ref source_class = ref->getClass(); + + if ( ! source_class->isAssignableFrom(target_class)) { + throwNewJavaException("java/lang/ClassCastException", + "Tried to cast from %s to %s.", + source_class->toString().c_str(), + target_class_name.c_str()); + } + + return static_ref_cast(ref); +} + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/References.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/References.h new file mode 100644 index 000000000..981acb6c6 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/References.h @@ -0,0 +1,585 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +/** @file References.h + * + * Functionality similar to smart pointers, but for references into the VM. Four main reference + * types are provided: local_ref, global_ref, weak_ref, and alias_ref. All are generic + * templates that and refer to objects in the jobject hierarchy. The type of the referred objects + * are specified using the template parameter. All reference types except alias_ref own their + * underlying reference, just as a std smart pointer owns the underlying raw pointer. In the context + * of std smart pointers, these references behave like unique_ptr, and have basically the same + * interface. Thus, when the reference is destructed, the plain JNI reference, i.e. the underlying + * JNI reference (like the parameters passed directly to JNI functions), is released. The alias + * references provides no ownership and is a simple wrapper for plain JNI references. + * + * All but the weak references provides access to the underlying object using dereferencing, and a + * get() method. It is also possible to convert these references to booleans to test for nullity. + * To access the underlying object of a weak reference, the reference must either be released, or + * the weak reference can be used to create a local or global reference. + * + * An owning reference is created either by moving the reference from an existing owned reference, + * by copying an existing owned reference (which creates a new underlying reference), by using the + * default constructor which initialize the reference to nullptr, or by using a helper function. The + * helper function exist in two flavors: make_XXX or adopt_XXX. + * + * Adopting takes a plain JNI reference and wrap it in an owned reference. It takes ownership of the + * plain JNI reference so be sure that no one else owns the reference when you adopt it, and make + * sure that you know what kind of reference it is. + * + * New owned references can be created from existing plain JNI references, alias references, local + * references, and global references (i.e. non-weak references) using the make_local, make_global, + * and make_weak functions. + * + * Alias references can be implicitly initialized using global, local and plain JNI references using + * the wrap_alias function. Here, we don't assume ownership of the passed-in reference, but rather + * create a separate reference that we do own, leaving the passed-in reference to its fate. + * + * Similar rules apply for assignment. An owned reference can be copy or move assigned using a smart + * reference of the same type. In the case of copy assignment a new reference is created. Alias + * reference can also be assigned new values, but since they are simple wrappers of plain JNI + * references there is no move semantics involved. + * + * Alias references are special in that they do not own the object and can therefore safely be + * converted to and from its corresponding plain JNI reference. They are useful as parameters of + * functions that do not affect the lifetime of a reference. Usage can be compared with using plain + * JNI pointers as parameters where a function does not take ownership of the underlying object. + * + * The local, global, and alias references makes it possible to access methods in the underlying + * objects. A core set of classes are implemented in CoreClasses.h, and user defined wrappers are + * supported (see example below). The wrappers also supports inheritance so a wrapper can inherit + * from another wrapper to gain access to its functionality. As an example the jstring wrapper + * inherits from the jobject wrapper, so does the jclass wrapper. That means that you can for + * example call the toString() method using the jclass wrapper, or any other class that inherits + * from the jobject wrapper. + * + * Note that the wrappers are parameterized on the static type of your (jobject) pointer, thus if + * you have a jobject that refers to a Java String you will need to cast it to jstring to get the + * jstring wrapper. This also mean that if you make a down cast that is invalid there will be no one + * stopping you and the wrappers currently does not detect this which can cause crashes. Thus, cast + * wisely. + * + * @include WrapperSample.cpp + */ + +#pragma once + +#include +#include +#include + +#include + +#include + +#include "ReferenceAllocators.h" +#include "TypeTraits.h" +#include "References-forward.h" + +namespace facebook { +namespace jni { + +/// Convenience function to wrap an existing local reference +template +local_ref adopt_local(T ref) noexcept; + +/// Convenience function to wrap an existing global reference +template +global_ref adopt_global(T ref) noexcept; + +/// Convenience function to wrap an existing weak reference +template +weak_ref adopt_weak_global(T ref) noexcept; + + +/// Swaps two owning references of the same type +template +void swap(weak_ref& a, weak_ref& b) noexcept; + +/// Swaps two owning references of the same type +template +void swap(basic_strong_ref& a, basic_strong_ref& b) noexcept; + +/** + * Retrieve the plain reference from a plain reference. + */ +template +enable_if_t(), T> getPlainJniReference(T ref); + +/** + * Retrieve the plain reference from an alias reference. + */ +template +JniType getPlainJniReference(alias_ref ref); + +/** + * Retrieve the plain JNI reference from any reference owned reference. + */ +template +JniType getPlainJniReference(const base_owned_ref& ref); + +class JObject; +class JClass; + +namespace detail { + +template +struct HasJniRefRepr : std::false_type {}; + +template +struct HasJniRefRepr::value, void>::type> : std::true_type { + using type = typename T::JniRefRepr; +}; + +template +struct RefReprType { + using type = typename std::conditional::value, typename HasJniRefRepr::type, JObjectWrapper>::type; + static_assert(std::is_base_of::value, + "Repr type missing JObject base."); + static_assert(std::is_same::type>::value, + "RefReprType not idempotent"); +}; + +template +struct RefReprType::value, void>::type> { + using type = T; + static_assert(std::is_base_of::value, + "Repr type missing JObject base."); + static_assert(std::is_same::type>::value, + "RefReprType not idempotent"); +}; + +template +struct JavaObjectType { + using type = typename RefReprType::type::javaobject; + static_assert(IsPlainJniReference(), + "JavaObjectType not a plain jni reference"); + static_assert(std::is_same::type>::value, + "JavaObjectType not idempotent"); +}; + +template +struct JavaObjectType> { + using type = T; + static_assert(IsPlainJniReference(), + "JavaObjectType not a plain jni reference"); + static_assert(std::is_same::type>::value, + "JavaObjectType not idempotent"); +}; + +template +struct JavaObjectType { + using type = T*; + static_assert(IsPlainJniReference(), + "JavaObjectType not a plain jni reference"); + static_assert(std::is_same::type>::value, + "JavaObjectType not idempotent"); +}; + +template +struct ReprStorage { + explicit ReprStorage(JniType obj) noexcept; + + void set(JniType obj) noexcept; + + Repr& get() noexcept; + const Repr& get() const noexcept; + JniType jobj() const noexcept; + + void swap(ReprStorage& other) noexcept; + private: + ReprStorage() = delete; + ReprStorage(const ReprStorage&) = delete; + ReprStorage(ReprStorage&&) = delete; + ReprStorage& operator=(const ReprStorage&) = delete; + ReprStorage& operator=(ReprStorage&&) = delete; + + using Storage = typename std::aligned_storage::type; + Storage storage_; +}; + +} // namespace detail + +/** + * Create a new local reference from an existing reference + * + * @param ref a plain JNI, alias, or strong reference + * @return an owned local reference (referring to null if the input does) + * @throws std::bad_alloc if the JNI reference could not be created + */ +template +enable_if_t(), local_ref>> +make_local(const T& r); + +/** + * Create a new global reference from an existing reference + * + * @param ref a plain JNI, alias, or strong reference + * @return an owned global reference (referring to null if the input does) + * @throws std::bad_alloc if the JNI reference could not be created + */ +template +enable_if_t(), global_ref>> +make_global(const T& r); + +/** + * Create a new weak global reference from an existing reference + * + * @param ref a plain JNI, alias, or strong reference + * @return an owned weak global reference (referring to null if the input does) + * @throws std::bad_alloc if the returned reference is null + */ +template +enable_if_t(), weak_ref>> +make_weak(const T& r); + +/** + * Compare two references to see if they refer to the same object + */ +template +enable_if_t() && IsNonWeakReference(), bool> +operator==(const T1& a, const T2& b); + +/** + * Compare two references to see if they don't refer to the same object + */ +template +enable_if_t() && IsNonWeakReference(), bool> +operator!=(const T1& a, const T2& b); + +template +class base_owned_ref { + public: + using javaobject = JniType; + + /** + * Release the ownership and set the reference to null. Thus no deleter is invoked. + * @return Returns the reference + */ + javaobject release() noexcept; + + /** + * Reset the reference to refer to nullptr. + */ + void reset() noexcept; + + protected: + using Repr = ReprType; + detail::ReprStorage storage_; + + javaobject get() const noexcept; + void set(javaobject ref) noexcept; + + /* + * Wrap an existing reference and transfers its ownership to the newly created unique reference. + * NB! Does not create a new reference + */ + explicit base_owned_ref(javaobject reference) noexcept; + + /// Create a null reference + base_owned_ref() noexcept; + + /// Create a null reference + explicit base_owned_ref(std::nullptr_t) noexcept; + + /// Copy constructor (note creates a new reference) + base_owned_ref(const base_owned_ref& other); + template + base_owned_ref(const base_owned_ref& other); + + /// Transfers ownership of an underlying reference from one unique reference to another + base_owned_ref(base_owned_ref&& other) noexcept; + template + base_owned_ref(base_owned_ref&& other) noexcept; + + /// The delete the underlying reference if applicable + ~base_owned_ref() noexcept; + + + /// Assignment operator (note creates a new reference) + base_owned_ref& operator=(const base_owned_ref& other); + + /// Assignment by moving a reference thus not creating a new reference + base_owned_ref& operator=(base_owned_ref&& rhs) noexcept; + + void reset(javaobject reference) noexcept; + + friend javaobject jni::getPlainJniReference<>(const base_owned_ref& ref); + + template + friend class base_owned_ref; +}; + + +/** + * A smart reference that owns its underlying JNI reference. The class provides basic + * functionality to handle a reference but gives no access to it unless the reference is + * released, thus no longer owned. The API is stolen with pride from unique_ptr and the + * semantics should be basically the same. This class should not be used directly, instead use + * @ref weak_ref + */ +template +class weak_ref : public base_owned_ref { + public: + using javaobject = JniType; + + using Allocator = WeakGlobalReferenceAllocator; + + // This inherits non-default, non-copy, non-move ctors. + using base_owned_ref::base_owned_ref; + + /// Create a null reference + weak_ref() noexcept + : base_owned_ref{} {} + + /// Create a null reference + explicit weak_ref(std::nullptr_t) noexcept + : base_owned_ref{nullptr} {} + + /// Copy constructor (note creates a new reference) + weak_ref(const weak_ref& other) + : base_owned_ref{other} {} + + // This needs to be explicit to change its visibility. + template + weak_ref(const weak_ref& other) + : base_owned_ref{other} {} + + /// Transfers ownership of an underlying reference from one unique reference to another + weak_ref(weak_ref&& other) noexcept + : base_owned_ref{std::move(other)} {} + + + /// Assignment operator (note creates a new reference) + weak_ref& operator=(const weak_ref& other); + + /// Assignment by moving a reference thus not creating a new reference + weak_ref& operator=(weak_ref&& rhs) noexcept; + + // Creates an owned local reference to the referred object or to null if the object is reclaimed + local_ref lockLocal() const; + + // Creates an owned global reference to the referred object or to null if the object is reclaimed + global_ref lockGlobal() const; + + private: + // get/release/reset on weak_ref are not exposed to users. + using base_owned_ref::get; + using base_owned_ref::release; + using base_owned_ref::reset; + /* + * Wrap an existing reference and transfers its ownership to the newly created unique reference. + * NB! Does not create a new reference + */ + explicit weak_ref(javaobject reference) noexcept + : base_owned_ref{reference} {} + + template friend class weak_ref; + friend weak_ref adopt_weak_global(javaobject ref) noexcept; + friend void swap(weak_ref& a, weak_ref& b) noexcept; +}; + + +/** + * A class representing owned strong references to Java objects. This class + * should not be used directly, instead use @ref local_ref, or @ref global_ref. + */ +template +class basic_strong_ref : public base_owned_ref { + using typename base_owned_ref::Repr; + public: + using javaobject = JniType; + + using Allocator = Alloc; + + // This inherits non-default, non-copy, non-move ctors. + using base_owned_ref::base_owned_ref; + using base_owned_ref::release; + using base_owned_ref::reset; + + /// Create a null reference + basic_strong_ref() noexcept + : base_owned_ref{} {} + + /// Create a null reference + explicit basic_strong_ref(std::nullptr_t) noexcept + : base_owned_ref{nullptr} {} + + /// Copy constructor (note creates a new reference) + basic_strong_ref(const basic_strong_ref& other) + : base_owned_ref{other} {} + + // This needs to be explicit to change its visibility. + template + basic_strong_ref(const basic_strong_ref& other) + : base_owned_ref{other} {} + + /// Transfers ownership of an underlying reference from one unique reference to another + basic_strong_ref(basic_strong_ref&& other) noexcept + : base_owned_ref{std::move(other)} {} + + /// Assignment operator (note creates a new reference) + basic_strong_ref& operator=(const basic_strong_ref& other); + + /// Assignment by moving a reference thus not creating a new reference + basic_strong_ref& operator=(basic_strong_ref&& rhs) noexcept; + + /// Get the plain JNI reference + using base_owned_ref::get; + + /// Release the ownership of the reference and return the wrapped reference in an alias + alias_ref releaseAlias() noexcept; + + /// Checks if the reference points to a non-null object + explicit operator bool() const noexcept; + + /// Access the functionality provided by the object wrappers + Repr* operator->() noexcept; + + /// Access the functionality provided by the object wrappers + const Repr* operator->() const noexcept; + + /// Provide a reference to the underlying wrapper (be sure that it is non-null before invoking) + Repr& operator*() noexcept; + + /// Provide a const reference to the underlying wrapper (be sure that it is non-null + /// before invoking) + const Repr& operator*() const noexcept; + + private: + + using base_owned_ref::storage_; + + /* + * Wrap an existing reference and transfers its ownership to the newly created unique reference. + * NB! Does not create a new reference + */ + explicit basic_strong_ref(javaobject reference) noexcept + : base_owned_ref{reference} {} + + + friend local_ref adopt_local(T ref) noexcept; + friend global_ref adopt_global(T ref) noexcept; + friend void swap(basic_strong_ref& a, basic_strong_ref& b) noexcept; +}; + + +template +enable_if_t(), alias_ref> wrap_alias(T ref) noexcept; + +/// Swaps to alias reference of the same type +template +void swap(alias_ref& a, alias_ref& b) noexcept; + +/** + * A non-owning variant of the smart references (a dumb reference). These references still provide + * access to the functionality of the @ref JObjectWrapper specializations including exception + * handling and ease of use. Use this representation when you don't want to claim ownership of the + * underlying reference (compare to using raw pointers instead of smart pointers.) For symmetry use + * @ref alias_ref instead of this class. + */ +template +class alias_ref { + using Repr = ReprType; + + public: + using javaobject = JniType; + + /// Create a null reference + alias_ref() noexcept; + + /// Create a null reference + alias_ref(std::nullptr_t) noexcept; + + /// Copy constructor + alias_ref(const alias_ref& other) noexcept; + + /// Wrap an existing plain JNI reference + /* implicit */ alias_ref(javaobject ref) noexcept; + + /// Wrap an existing smart reference of any type convertible to T + template< + typename TOther, + typename = enable_if_t< + IsConvertible, javaobject>(), T> + > + alias_ref(alias_ref other) noexcept; + + /// Wrap an existing alias reference of a type convertible to T + template< + typename TOther, + typename AOther, + typename = enable_if_t< + IsConvertible, javaobject>(), T> + > + alias_ref(const basic_strong_ref& other) noexcept; + + /// Assignment operator + alias_ref& operator=(alias_ref other) noexcept; + + /// Checks if the reference points to a non-null object + explicit operator bool() const noexcept; + + /// Converts back to a plain JNI reference + javaobject get() const noexcept; + + /// Access the functionality provided by the object wrappers + Repr* operator->() noexcept; + + /// Access the functionality provided by the object wrappers + const Repr* operator->() const noexcept; + + /// Provide a guaranteed non-null reference (be sure that it is non-null before invoking) + Repr& operator*() noexcept; + + /// Provide a guaranteed non-null reference (be sure that it is non-null before invoking) + const Repr& operator*() const noexcept; + + private: + void set(javaobject ref) noexcept; + + detail::ReprStorage storage_; + + friend void swap(alias_ref& a, alias_ref& b) noexcept; +}; + + +/** + * RAII object to create a local JNI frame, using PushLocalFrame/PopLocalFrame. + * + * This is useful when you have a call which is initiated from C++-land, and therefore + * doesn't automatically get a local JNI frame managed for you by the JNI framework. + */ +class FBEXPORT JniLocalScope { +public: + JniLocalScope(JNIEnv* p_env, jint capacity); + ~JniLocalScope(); + +private: + JNIEnv* env_; + bool hasFrame_; +}; + +template +enable_if_t(), local_ref> +static_ref_cast(const local_ref& ref) noexcept; + +template +enable_if_t(), global_ref> +static_ref_cast(const global_ref& ref) noexcept; + +template +enable_if_t(), alias_ref> +static_ref_cast(const alias_ref& ref) noexcept; + +template +auto dynamic_ref_cast(const RefType& ref) -> +enable_if_t(), decltype(static_ref_cast(ref))> ; + +}} + +#include "References-inl.h" diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Registration-inl.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Registration-inl.h new file mode 100644 index 000000000..a25a88906 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Registration-inl.h @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include "Exceptions.h" +#include "Hybrid.h" + +namespace facebook { +namespace jni { + +namespace detail { + +#ifdef __i386__ +// X86 ABI forces 16 byte stack allignment on calls. Unfortunately +// sometimes Dalvik chooses not to obey the ABI: +// - https://code.google.com/p/android/issues/detail?id=61012 +// - https://android.googlesource.com/platform/ndk/+/81696d2%5E!/ +// Therefore, we tell the compiler to re-align the stack on entry +// to our JNI functions. +#define JNI_ENTRY_POINT __attribute__((force_align_arg_pointer)) +#else +#define JNI_ENTRY_POINT +#endif + +// registration wrapper for legacy JNI-style functions + +template +inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { + struct funcWrapper { + JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { + // Note that if func was declared noexcept, then both gcc and clang are smart + // enough to elide the try/catch. + try { + (*func)(env, static_cast(obj), args...); + } catch (...) { + translatePendingCppExceptionToJavaException(); + } + } + }; + + // This intentionally erases the real type; JNI will do it anyway + return reinterpret_cast(&(funcWrapper::call)); +} + +template +inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { + struct funcWrapper { + JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { + try { + return (*func)(env, static_cast>(obj), args...); + } catch (...) { + translatePendingCppExceptionToJavaException(); + return R{}; + } + } + }; + + // This intentionally erases the real type; JNI will do it anyway + return reinterpret_cast(&(funcWrapper::call)); +} + +// registration wrappers for functions, with autoconversion of arguments. + +template +inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref, Args... args)) { + struct funcWrapper { + JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, + typename Convert::type>::jniType... args) { + try { + (*func)(static_cast>(obj), Convert::type>::fromJni(args)...); + } catch (...) { + translatePendingCppExceptionToJavaException(); + } + } + }; + + // This intentionally erases the real type; JNI will do it anyway + return reinterpret_cast(&(funcWrapper::call)); +} + +template +inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref, Args... args)) { + struct funcWrapper { + + JNI_ENTRY_POINT static typename Convert::type>::jniType call(JNIEnv*, jobject obj, + typename Convert::type>::jniType... args) { + try { + return Convert::type>::toJniRet( + (*func)(static_cast>(obj), Convert::type>::fromJni(args)...)); + } catch (...) { + using jniRet = typename Convert::type>::jniType; + translatePendingCppExceptionToJavaException(); + return jniRet{}; + } + } + }; + + // This intentionally erases the real type; JNI will do it anyway + return reinterpret_cast(&(funcWrapper::call)); +} + +// registration wrappers for non-static methods, with autoconvertion of arguments. + +template +inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { + struct funcWrapper { + JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, + typename Convert::type>::jniType... args) { + try { + try { + auto aref = wrap_alias(static_cast(obj)); + // This is usually a noop, but if the hybrid object is a + // base class of other classes which register JNI methods, + // this will get the right type for the registered method. + auto cobj = static_cast(facebook::jni::cthis(aref)); + (cobj->*method)(Convert::type>::fromJni(args)...); + } catch (const std::exception& ex) { + C::mapException(ex); + throw; + } + } catch (...) { + translatePendingCppExceptionToJavaException(); + } + } + }; + + // This intentionally erases the real type; JNI will do it anyway + return reinterpret_cast(&(funcWrapper::call)); +} + +template +inline NativeMethodWrapper* exceptionWrapJNIMethod(R (C::*method0)(Args... args)) { + struct funcWrapper { + + JNI_ENTRY_POINT static typename Convert::type>::jniType call(JNIEnv* env, jobject obj, + typename Convert::type>::jniType... args) { + try { + try { + auto aref = wrap_alias(static_cast(obj)); + // This is usually a noop, but if the hybrid object is a + // base class of other classes which register JNI methods, + // this will get the right type for the registered method. + auto cobj = static_cast(facebook::jni::cthis(aref)); + return Convert::type>::toJniRet( + (cobj->*method)(Convert::type>::fromJni(args)...)); + } catch (const std::exception& ex) { + C::mapException(ex); + throw; + } + } catch (...) { + using jniRet = typename Convert::type>::jniType; + translatePendingCppExceptionToJavaException(); + return jniRet{}; + } + } + }; + + // This intentionally erases the real type; JNI will do it anyway + return reinterpret_cast(&(funcWrapper::call)); +} + +template +inline std::string makeDescriptor(R (*)(JNIEnv*, C, Args... args)) { + return jmethod_traits::descriptor(); +} + +template +inline std::string makeDescriptor(R (*)(alias_ref, Args... args)) { + return jmethod_traits_from_cxx::descriptor(); +} + +template +inline std::string makeDescriptor(R (C::*)(Args... args)) { + return jmethod_traits_from_cxx::descriptor(); +} + +} + +}} diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/Registration.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/Registration.h new file mode 100644 index 000000000..4cf65fac6 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/Registration.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include +#include "References.h" + +namespace facebook { +namespace jni { + +namespace detail { + +// This uses the real JNI function as a non-type template parameter to +// cause a (static member) function to exist with the same signature, +// but with try/catch exception translation. +template +NativeMethodWrapper* exceptionWrapJNIMethod(void (*func0)(JNIEnv*, jobject, Args... args)); + +// Same as above, but for non-void return types. +template +NativeMethodWrapper* exceptionWrapJNIMethod(R (*func0)(JNIEnv*, jobject, Args... args)); + +// Automatically wrap object argument, and don't take env explicitly. +template +NativeMethodWrapper* exceptionWrapJNIMethod(void (*func0)(alias_ref, Args... args)); + +// Automatically wrap object argument, and don't take env explicitly, +// non-void return type. +template +NativeMethodWrapper* exceptionWrapJNIMethod(R (*func0)(alias_ref, Args... args)); + +// Extract C++ instance from object, and invoke given method on it. +template +NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)); + +// Extract C++ instance from object, and invoke given method on it, +// non-void return type +template +NativeMethodWrapper* exceptionWrapJNIMethod(R (C::*method0)(Args... args)); + +// This uses deduction to figure out the descriptor name if the types +// are primitive or have JObjectWrapper specializations. +template +std::string makeDescriptor(R (*func)(JNIEnv*, C, Args... args)); + +// This uses deduction to figure out the descriptor name if the types +// are primitive or have JObjectWrapper specializations. +template +std::string makeDescriptor(R (*func)(alias_ref, Args... args)); + +// This uses deduction to figure out the descriptor name if the types +// are primitive or have JObjectWrapper specializations. +template +std::string makeDescriptor(R (C::*method0)(Args... args)); + +} + +// We have to use macros here, because the func needs to be used +// as both a decltype expression argument and as a non-type template +// parameter, since C++ provides no way for translateException +// to deduce the type of its non-type template parameter. +// The empty string in the macros below ensures that name +// is always a string literal (because that syntax is only +// valid when name is a string literal). +#define makeNativeMethod2(name, func) \ + { name "", ::facebook::jni::detail::makeDescriptor(&func), \ + ::facebook::jni::detail::exceptionWrapJNIMethod(&func) } + +#define makeNativeMethod3(name, desc, func) \ + { name "", desc, \ + ::facebook::jni::detail::exceptionWrapJNIMethod(&func) } + +// Variadic template hacks to get macros with different numbers of +// arguments. Usage instructions are in CoreClasses.h. +#define makeNativeMethodN(a, b, c, count, ...) makeNativeMethod ## count +#define makeNativeMethod(...) makeNativeMethodN(__VA_ARGS__, 3, 2)(__VA_ARGS__) + +}} + +#include "Registration-inl.h" diff --git a/libs/fbjni/src/main/cpp/include/fb/fbjni/TypeTraits.h b/libs/fbjni/src/main/cpp/include/fb/fbjni/TypeTraits.h new file mode 100644 index 000000000..80cb382b0 --- /dev/null +++ b/libs/fbjni/src/main/cpp/include/fb/fbjni/TypeTraits.h @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +#pragma once + +#include + +#include "References-forward.h" + +namespace facebook { +namespace jni { + +/// Generic std::enable_if helper +template +using enable_if_t = typename std::enable_if::type; + +/// Generic std::is_convertible helper +template +constexpr bool IsConvertible() { + return std::is_convertible::value; +} + +template class TT, typename T> +struct is_instantiation_of : std::false_type {}; + +template class TT, typename... Ts> +struct is_instantiation_of> : std::true_type {}; + +template class TT, typename... Ts> +constexpr bool IsInstantiationOf() { + return is_instantiation_of::value; +} + +/// Metafunction to determine whether a type is a JNI reference or not +template +struct is_plain_jni_reference : + std::integral_constant::value && + std::is_base_of< + typename std::remove_pointer::type, + typename std::remove_pointer::type>::value> {}; + +/// Helper to simplify use of is_plain_jni_reference +template +constexpr bool IsPlainJniReference() { + return is_plain_jni_reference::value; +} + +/// Metafunction to determine whether a type is a primitive JNI type or not +template +struct is_jni_primitive : + std::integral_constant::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value> {}; + +/// Helper to simplify use of is_jni_primitive +template +constexpr bool IsJniPrimitive() { + return is_jni_primitive::value; +} + +/// Metafunction to determine whether a type is a JNI array of primitives or not +template +struct is_jni_primitive_array : + std::integral_constant::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value> {}; + +/// Helper to simplify use of is_jni_primitive_array +template +constexpr bool IsJniPrimitiveArray() { + return is_jni_primitive_array::value; +} + +/// Metafunction to determine if a type is a scalar (primitive or reference) JNI type +template +struct is_jni_scalar : + std::integral_constant::value || + is_jni_primitive::value> {}; + +/// Helper to simplify use of is_jni_scalar +template +constexpr bool IsJniScalar() { + return is_jni_scalar::value; +} + +// Metafunction to determine if a type is a JNI type +template +struct is_jni_type : + std::integral_constant::value || + std::is_void::value> {}; + +/// Helper to simplify use of is_jni_type +template +constexpr bool IsJniType() { + return is_jni_type::value; +} + +template +struct is_non_weak_reference : + std::integral_constant() || + IsInstantiationOf() || + IsInstantiationOf()> {}; + +template +constexpr bool IsNonWeakReference() { + return is_non_weak_reference::value; +} + +template +struct is_any_reference : + std::integral_constant() || + IsInstantiationOf() || + IsInstantiationOf() || + IsInstantiationOf()> {}; + +template +constexpr bool IsAnyReference() { + return is_any_reference::value; +} + +template +struct reference_traits { + using plain_jni_reference_t = JniType; + static_assert(IsPlainJniReference(), "Need a plain JNI reference"); +}; + +template