Compare commits

...

1 Commits

Author SHA1 Message Date
Diego Mello 21a1a20258 Update RN to 0.63.0-rc.1 2020-07-07 13:19:58 -03:00
620 changed files with 40046 additions and 35070 deletions

View File

@ -171,12 +171,12 @@ android {
}
}
packagingOptions {
pickFirst '**/armeabi-v7a/libc++_shared.so'
pickFirst '**/x86/libc++_shared.so'
pickFirst '**/arm64-v8a/libc++_shared.so'
pickFirst '**/x86_64/libc++_shared.so'
}
// packagingOptions {
// pickFirst '**/armeabi-v7a/libc++_shared.so'
// pickFirst '**/x86/libc++_shared.so'
// pickFirst '**/arm64-v8a/libc++_shared.so'
// pickFirst '**/x86_64/libc++_shared.so'
// }
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->

View File

@ -1,10 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
buildToolsVersion = "29.0.2"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
compileSdkVersion = 29
targetSdkVersion = 29
glideVersion = "4.9.0"
kotlin_version = "1.3.50"
supportLibVersion = "28.0.0"
@ -18,7 +18,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.28.1'
classpath 'com.google.firebase:perf-plugin:1.2.1'

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

29
android/gradlew vendored
View File

@ -154,19 +154,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@ -175,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

5
android/gradlew.bat vendored
View File

@ -5,7 +5,7 @@
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

View File

@ -1,143 +1,23 @@
platform :ios, '11.0'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
def add_flipper_pods!(versions = {})
versions['Flipper'] ||= '~> 0.33.1'
versions['DoubleConversion'] ||= '1.1.7'
versions['Flipper-Folly'] ||= '~> 2.1'
versions['Flipper-Glog'] ||= '0.3.6'
versions['Flipper-PeerTalk'] ||= '~> 0.0.4'
versions['Flipper-RSocket'] ||= '~> 1.0'
pod 'FlipperKit', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FlipperKitReactPlugin', versions['Flipper'], :configuration => 'Debug'
# List all transitive dependencies for FlipperKit pods
# to avoid them being linked in Release builds
pod 'Flipper', versions['Flipper'], :configuration => 'Debug'
pod 'Flipper-DoubleConversion', versions['DoubleConversion'], :configuration => 'Debug'
pod 'Flipper-Folly', versions['Flipper-Folly'], :configuration => 'Debug'
pod 'Flipper-Glog', versions['Flipper-Glog'], :configuration => 'Debug'
pod 'Flipper-PeerTalk', versions['Flipper-PeerTalk'], :configuration => 'Debug'
pod 'Flipper-RSocket', versions['Flipper-RSocket'], :configuration => 'Debug'
pod 'FlipperKit/Core', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/CppBridge', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FBCxxFollyDynamicConvert', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FBDefines', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FKPortForwarding', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
end
# Post Install processing for Flipper
def flipper_post_install(installer)
installer.pods_project.targets.each do |target|
if target.name == 'YogaKit'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
file_name = Dir.glob("*.xcodeproj")[0]
app_project = Xcodeproj::Project.open(file_name)
app_project.native_targets.each do |target|
target.build_configurations.each do |config|
cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
cflags << '-DFB_SONARKIT_ENABLED=1'
end
config.build_settings['OTHER_CFLAGS'] = cflags
end
app_project.save
end
installer.pods_project.save
def all_pods
config = use_native_modules!
use_unimodules!
use_react_native!(:path => config["reactNativePath"])
use_flipper!
end
target 'RocketChatRN' do
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
use_native_modules!
use_unimodules!
all_pods
end
target 'ShareRocketChatRN' do
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
pod 'JitsiMeetSDK', :git => 'https://github.com/RocketChat/jitsi-meet-ios-sdk-releases.git'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
use_native_modules!
use_unimodules!
all_pods
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
add_flipper_pods!
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
@ -145,4 +25,4 @@ post_install do |installer|
end
end
flipper_post_install(installer)
end
end

View File

@ -40,42 +40,39 @@ PODS:
- EXWebBrowser (8.2.1):
- UMCore
- Fabric (1.10.2)
- FBLazyVector (0.62.2)
- FBReactNativeSpec (0.62.2):
- Folly (= 2018.10.22.00)
- RCTRequired (= 0.62.2)
- RCTTypeSafety (= 0.62.2)
- React-Core (= 0.62.2)
- React-jsi (= 0.62.2)
- ReactCommon/turbomodule/core (= 0.62.2)
- Firebase/Core (6.24.0):
- FBLazyVector (0.63.0-rc.1)
- FBReactNativeSpec (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- RCTRequired (= 0.63.0-rc.1)
- RCTTypeSafety (= 0.63.0-rc.1)
- React-Core (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (= 0.63.0-rc.1)
- Firebase/Core (6.27.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 6.5.0)
- Firebase/CoreOnly (6.24.0):
- FirebaseCore (= 6.7.0)
- FirebaseAnalytics (6.5.0):
- FirebaseCore (~> 6.7)
- FirebaseInstallations (~> 1.2)
- GoogleAppMeasurement (= 6.5.0)
- FirebaseAnalytics (= 6.6.1)
- Firebase/CoreOnly (6.27.0):
- FirebaseCore (= 6.8.0)
- FirebaseAnalytics (6.6.1):
- FirebaseCore (~> 6.8)
- FirebaseInstallations (~> 1.4)
- GoogleAppMeasurement (= 6.6.1)
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
- GoogleUtilities/MethodSwizzler (~> 6.0)
- GoogleUtilities/Network (~> 6.0)
- "GoogleUtilities/NSData+zlib (~> 6.0)"
- nanopb (~> 1.30905.0)
- FirebaseCore (6.7.0):
- FirebaseCore (6.8.0):
- FirebaseCoreDiagnostics (~> 1.3)
- FirebaseCoreDiagnosticsInterop (~> 1.2)
- GoogleUtilities/Environment (~> 6.5)
- GoogleUtilities/Logger (~> 6.5)
- FirebaseCoreDiagnostics (1.3.0):
- FirebaseCoreDiagnosticsInterop (~> 1.2)
- FirebaseCoreDiagnostics (1.4.0):
- GoogleDataTransportCCTSupport (~> 3.1)
- GoogleUtilities/Environment (~> 6.5)
- GoogleUtilities/Logger (~> 6.5)
- nanopb (~> 1.30905.0)
- FirebaseCoreDiagnosticsInterop (1.2.0)
- FirebaseInstallations (1.2.0):
- FirebaseCore (~> 6.6)
- FirebaseInstallations (1.4.0):
- FirebaseCore (~> 6.8)
- GoogleUtilities/Environment (~> 6.6)
- GoogleUtilities/UserDefaults (~> 6.6)
- PromisesObjC (~> 1.2)
@ -125,24 +122,24 @@ PODS:
- FlipperKit/SKIOSNetworkPlugin (0.33.1):
- FlipperKit/Core
- FlipperKit/FlipperKitNetworkPlugin
- Folly (2018.10.22.00):
- Folly (2020.01.13.00):
- boost-for-react-native
- DoubleConversion
- Folly/Default (= 2018.10.22.00)
- Folly/Default (= 2020.01.13.00)
- glog
- Folly/Default (2018.10.22.00):
- Folly/Default (2020.01.13.00):
- boost-for-react-native
- DoubleConversion
- glog
- glog (0.3.5)
- GoogleAppMeasurement (6.5.0):
- GoogleAppMeasurement (6.6.1):
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
- GoogleUtilities/MethodSwizzler (~> 6.0)
- GoogleUtilities/Network (~> 6.0)
- "GoogleUtilities/NSData+zlib (~> 6.0)"
- nanopb (~> 1.30905.0)
- GoogleDataTransport (6.1.0)
- GoogleDataTransportCCTSupport (3.1.0):
- GoogleDataTransport (6.2.1)
- GoogleDataTransportCCTSupport (3.2.0):
- GoogleDataTransport (~> 6.1)
- nanopb (~> 1.30905.0)
- GoogleUtilities/AppDelegateSwizzler (6.6.0):
@ -184,170 +181,173 @@ PODS:
- OpenSSL-Universal (1.0.2.19):
- OpenSSL-Universal/Static (= 1.0.2.19)
- OpenSSL-Universal/Static (1.0.2.19)
- PromisesObjC (1.2.8)
- RCTRequired (0.62.2)
- RCTTypeSafety (0.62.2):
- FBLazyVector (= 0.62.2)
- Folly (= 2018.10.22.00)
- RCTRequired (= 0.62.2)
- React-Core (= 0.62.2)
- React (0.62.2):
- React-Core (= 0.62.2)
- React-Core/DevSupport (= 0.62.2)
- React-Core/RCTWebSocket (= 0.62.2)
- React-RCTActionSheet (= 0.62.2)
- React-RCTAnimation (= 0.62.2)
- React-RCTBlob (= 0.62.2)
- React-RCTImage (= 0.62.2)
- React-RCTLinking (= 0.62.2)
- React-RCTNetwork (= 0.62.2)
- React-RCTSettings (= 0.62.2)
- React-RCTText (= 0.62.2)
- React-RCTVibration (= 0.62.2)
- React-Core (0.62.2):
- Folly (= 2018.10.22.00)
- PromisesObjC (1.2.9)
- RCTRequired (0.63.0-rc.1)
- RCTTypeSafety (0.63.0-rc.1):
- FBLazyVector (= 0.63.0-rc.1)
- Folly (= 2020.01.13.00)
- RCTRequired (= 0.63.0-rc.1)
- React-Core (= 0.63.0-rc.1)
- React (0.63.0-rc.1):
- React-Core (= 0.63.0-rc.1)
- React-Core/DevSupport (= 0.63.0-rc.1)
- React-Core/RCTWebSocket (= 0.63.0-rc.1)
- React-RCTActionSheet (= 0.63.0-rc.1)
- React-RCTAnimation (= 0.63.0-rc.1)
- React-RCTBlob (= 0.63.0-rc.1)
- React-RCTImage (= 0.63.0-rc.1)
- React-RCTLinking (= 0.63.0-rc.1)
- React-RCTNetwork (= 0.63.0-rc.1)
- React-RCTSettings (= 0.63.0-rc.1)
- React-RCTText (= 0.63.0-rc.1)
- React-RCTVibration (= 0.63.0-rc.1)
- React-callinvoker (0.63.0-rc.1)
- React-Core (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default (= 0.62.2)
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-Core/Default (= 0.63.0-rc.1)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/CoreModulesHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/CoreModulesHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/Default (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/Default (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/DevSupport (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/DevSupport (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default (= 0.62.2)
- React-Core/RCTWebSocket (= 0.62.2)
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-jsinspector (= 0.62.2)
- React-Core/Default (= 0.63.0-rc.1)
- React-Core/RCTWebSocket (= 0.63.0-rc.1)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- React-jsinspector (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTActionSheetHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTActionSheetHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTAnimationHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTAnimationHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTBlobHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTBlobHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTImageHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTImageHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTLinkingHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTLinkingHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTNetworkHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTNetworkHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTSettingsHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTSettingsHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTTextHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTTextHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTVibrationHeaders (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTVibrationHeaders (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-Core/RCTWebSocket (0.62.2):
- Folly (= 2018.10.22.00)
- React-Core/RCTWebSocket (0.63.0-rc.1):
- Folly (= 2020.01.13.00)
- glog
- React-Core/Default (= 0.62.2)
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsiexecutor (= 0.62.2)
- React-Core/Default (= 0.63.0-rc.1)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsiexecutor (= 0.63.0-rc.1)
- Yoga
- React-CoreModules (0.62.2):
- FBReactNativeSpec (= 0.62.2)
- Folly (= 2018.10.22.00)
- RCTTypeSafety (= 0.62.2)
- React-Core/CoreModulesHeaders (= 0.62.2)
- React-RCTImage (= 0.62.2)
- ReactCommon/turbomodule/core (= 0.62.2)
- React-cxxreact (0.62.2):
- React-CoreModules (0.63.0-rc.1):
- FBReactNativeSpec (= 0.63.0-rc.1)
- Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.0-rc.1)
- React-Core/CoreModulesHeaders (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-RCTImage (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (= 0.63.0-rc.1)
- React-cxxreact (0.63.0-rc.1):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- Folly (= 2018.10.22.00)
- Folly (= 2020.01.13.00)
- glog
- React-jsinspector (= 0.62.2)
- React-jsi (0.62.2):
- React-callinvoker (= 0.63.0-rc.1)
- React-jsinspector (= 0.63.0-rc.1)
- React-jsi (0.63.0-rc.1):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- Folly (= 2018.10.22.00)
- Folly (= 2020.01.13.00)
- glog
- React-jsi/Default (= 0.62.2)
- React-jsi/Default (0.62.2):
- React-jsi/Default (= 0.63.0-rc.1)
- React-jsi/Default (0.63.0-rc.1):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- Folly (= 2018.10.22.00)
- Folly (= 2020.01.13.00)
- glog
- React-jsiexecutor (0.62.2):
- React-jsiexecutor (0.63.0-rc.1):
- DoubleConversion
- Folly (= 2018.10.22.00)
- Folly (= 2020.01.13.00)
- glog
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsinspector (0.62.2)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-jsinspector (0.63.0-rc.1)
- react-native-appearance (0.3.4):
- React
- react-native-background-timer (2.2.0):
@ -369,65 +369,66 @@ PODS:
- React
- react-native-webview (9.4.0):
- React
- React-RCTActionSheet (0.62.2):
- React-Core/RCTActionSheetHeaders (= 0.62.2)
- React-RCTAnimation (0.62.2):
- FBReactNativeSpec (= 0.62.2)
- Folly (= 2018.10.22.00)
- RCTTypeSafety (= 0.62.2)
- React-Core/RCTAnimationHeaders (= 0.62.2)
- ReactCommon/turbomodule/core (= 0.62.2)
- React-RCTBlob (0.62.2):
- FBReactNativeSpec (= 0.62.2)
- Folly (= 2018.10.22.00)
- React-Core/RCTBlobHeaders (= 0.62.2)
- React-Core/RCTWebSocket (= 0.62.2)
- React-jsi (= 0.62.2)
- React-RCTNetwork (= 0.62.2)
- ReactCommon/turbomodule/core (= 0.62.2)
- React-RCTImage (0.62.2):
- FBReactNativeSpec (= 0.62.2)
- Folly (= 2018.10.22.00)
- RCTTypeSafety (= 0.62.2)
- React-Core/RCTImageHeaders (= 0.62.2)
- React-RCTNetwork (= 0.62.2)
- ReactCommon/turbomodule/core (= 0.62.2)
- React-RCTLinking (0.62.2):
- FBReactNativeSpec (= 0.62.2)
- React-Core/RCTLinkingHeaders (= 0.62.2)
- ReactCommon/turbomodule/core (= 0.62.2)
- React-RCTNetwork (0.62.2):
- FBReactNativeSpec (= 0.62.2)
- Folly (= 2018.10.22.00)
- RCTTypeSafety (= 0.62.2)
- React-Core/RCTNetworkHeaders (= 0.62.2)
- ReactCommon/turbomodule/core (= 0.62.2)
- React-RCTSettings (0.62.2):
- FBReactNativeSpec (= 0.62.2)
- Folly (= 2018.10.22.00)
- RCTTypeSafety (= 0.62.2)
- React-Core/RCTSettingsHeaders (= 0.62.2)
- ReactCommon/turbomodule/core (= 0.62.2)
- React-RCTText (0.62.2):
- React-Core/RCTTextHeaders (= 0.62.2)
- React-RCTVibration (0.62.2):
- FBReactNativeSpec (= 0.62.2)
- Folly (= 2018.10.22.00)
- React-Core/RCTVibrationHeaders (= 0.62.2)
- ReactCommon/turbomodule/core (= 0.62.2)
- ReactCommon/callinvoker (0.62.2):
- React-RCTActionSheet (0.63.0-rc.1):
- React-Core/RCTActionSheetHeaders (= 0.63.0-rc.1)
- React-RCTAnimation (0.63.0-rc.1):
- FBReactNativeSpec (= 0.63.0-rc.1)
- Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.0-rc.1)
- React-Core/RCTAnimationHeaders (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (= 0.63.0-rc.1)
- React-RCTBlob (0.63.0-rc.1):
- FBReactNativeSpec (= 0.63.0-rc.1)
- Folly (= 2020.01.13.00)
- React-Core/RCTBlobHeaders (= 0.63.0-rc.1)
- React-Core/RCTWebSocket (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-RCTNetwork (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (= 0.63.0-rc.1)
- React-RCTImage (0.63.0-rc.1):
- FBReactNativeSpec (= 0.63.0-rc.1)
- Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.0-rc.1)
- React-Core/RCTImageHeaders (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- React-RCTNetwork (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (= 0.63.0-rc.1)
- React-RCTLinking (0.63.0-rc.1):
- FBReactNativeSpec (= 0.63.0-rc.1)
- React-Core/RCTLinkingHeaders (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (= 0.63.0-rc.1)
- React-RCTNetwork (0.63.0-rc.1):
- FBReactNativeSpec (= 0.63.0-rc.1)
- Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.0-rc.1)
- React-Core/RCTNetworkHeaders (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (= 0.63.0-rc.1)
- React-RCTSettings (0.63.0-rc.1):
- FBReactNativeSpec (= 0.63.0-rc.1)
- Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.0-rc.1)
- React-Core/RCTSettingsHeaders (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (= 0.63.0-rc.1)
- React-RCTText (0.63.0-rc.1):
- React-Core/RCTTextHeaders (= 0.63.0-rc.1)
- React-RCTVibration (0.63.0-rc.1):
- FBReactNativeSpec (= 0.63.0-rc.1)
- Folly (= 2020.01.13.00)
- React-Core/RCTVibrationHeaders (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (= 0.63.0-rc.1)
- ReactCommon/turbomodule/core (0.63.0-rc.1):
- DoubleConversion
- Folly (= 2018.10.22.00)
- Folly (= 2020.01.13.00)
- glog
- React-cxxreact (= 0.62.2)
- ReactCommon/turbomodule/core (0.62.2):
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-Core (= 0.62.2)
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- ReactCommon/callinvoker (= 0.62.2)
- React-callinvoker (= 0.63.0-rc.1)
- React-Core (= 0.63.0-rc.1)
- React-cxxreact (= 0.63.0-rc.1)
- React-jsi (= 0.63.0-rc.1)
- ReactNativeART (1.2.0):
- React
- ReactNativeKeyboardInput (6.0.0):
@ -484,13 +485,13 @@ PODS:
- React
- RNVectorIcons (6.6.0):
- React
- SDWebImage (5.7.4):
- SDWebImage/Core (= 5.7.4)
- SDWebImage/Core (5.7.4)
- SDWebImage (5.8.3):
- SDWebImage/Core (= 5.8.3)
- SDWebImage/Core (5.8.3)
- SDWebImageWebPCoder (0.4.1):
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.5)
- TOCropViewController (2.5.2)
- TOCropViewController (2.5.3)
- UMAppLoader (1.0.2)
- UMBarCodeScannerInterface (5.1.0)
- UMCameraInterface (5.1.0)
@ -548,11 +549,11 @@ DEPENDENCIES:
- FlipperKit/SKIOSNetworkPlugin (~> 0.33.1)
- Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- JitsiMeetSDK (from `https://github.com/RocketChat/jitsi-meet-ios-sdk-releases.git`)
- KeyCommands (from `../node_modules/react-native-keycommands`)
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
- React (from `../node_modules/react-native/`)
- React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`)
- React-Core (from `../node_modules/react-native/`)
- React-Core/DevSupport (from `../node_modules/react-native/`)
- React-Core/RCTWebSocket (from `../node_modules/react-native/`)
@ -580,7 +581,6 @@ DEPENDENCIES:
- React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`)
- React-RCTText (from `../node_modules/react-native/Libraries/Text`)
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- ReactCommon/callinvoker (from `../node_modules/react-native/ReactCommon`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- "ReactNativeART (from `../node_modules/@react-native-community/art`)"
- ReactNativeKeyboardInput (from `../node_modules/react-native-keyboard-input`)
@ -628,7 +628,6 @@ SPEC REPOS:
- FirebaseAnalytics
- FirebaseCore
- FirebaseCoreDiagnostics
- FirebaseCoreDiagnosticsInterop
- FirebaseInstallations
- Flipper
- Flipper-DoubleConversion
@ -641,6 +640,7 @@ SPEC REPOS:
- GoogleDataTransport
- GoogleDataTransportCCTSupport
- GoogleUtilities
- JitsiMeetSDK
- libwebp
- nanopb
- OpenSSL-Universal
@ -683,8 +683,6 @@ EXTERNAL SOURCES:
:podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec"
glog:
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
JitsiMeetSDK:
:git: https://github.com/RocketChat/jitsi-meet-ios-sdk-releases.git
KeyCommands:
:path: "../node_modules/react-native-keycommands"
RCTRequired:
@ -693,6 +691,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/Libraries/TypeSafety"
React:
:path: "../node_modules/react-native/"
React-callinvoker:
:path: "../node_modules/react-native/ReactCommon/callinvoker"
React-Core:
:path: "../node_modules/react-native/"
React-CoreModules:
@ -814,18 +814,13 @@ EXTERNAL SOURCES:
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"
CHECKOUT OPTIONS:
JitsiMeetSDK:
:commit: 9177aaa3afb379e17cc687887485e91e5cd24a49
:git: https://github.com/RocketChat/jitsi-meet-ios-sdk-releases.git
SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
BugsnagReactNative: 14c1b59cfbf34fd5591b734bfec65a277b677ef8
CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845
CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f
Crashlytics: 540b7e5f5da5a042647227a5e3ac51d85eed06df
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
DoubleConversion: cde416483dac037923206447da6e1454df403714
EXAV: 2edd9cd30fe98d04b55325303c7ff01db02d1d0f
EXConstants: 5304709b1bea70a4828f48ba4c7fc3ec3b2d9b17
EXFileSystem: cf4232ba7c62dc49b78c2d36005f97b6fddf0b01
@ -837,14 +832,13 @@ SPEC CHECKSUMS:
EXVideoThumbnails: be6984a3cda1e44c45b5c6278244e99855f99a0a
EXWebBrowser: 5902f99ac5ac551e5c82ff46f13a337b323aa9ea
Fabric: 706c8b8098fff96c33c0db69cbf81f9c551d0d74
FBLazyVector: 4aab18c93cd9546e4bfed752b4084585eca8b245
FBReactNativeSpec: 5465d51ccfeecb7faa12f9ae0024f2044ce4044e
Firebase: b28e55c60efd98963cd9011fe2fac5a10c2ba124
FirebaseAnalytics: 7386fc2176e3f93ad8ef34b5b1f2b33a891e4962
FirebaseCore: e610482f64097b0e9f056cd97bc6b33dfabcbb6a
FirebaseCoreDiagnostics: 4a773a47bd83bbd5a9b1ccf1ce7caa8b2d535e67
FirebaseCoreDiagnosticsInterop: 296e2c5f5314500a850ad0b83e9e7c10b011a850
FirebaseInstallations: 2119fb3e46b0a88bfdbf12562f855ee3252462fa
FBLazyVector: 80d80617d51e24046a0bcc817cd9209027ecfaa9
FBReactNativeSpec: b0fff079b3d224bd19ddd66857a9ebd879248c22
Firebase: fc4cbf6f1592636431821ef9a3c557e4dfd9f268
FirebaseAnalytics: 0ea640473474f036cabbc2576e20c2d63671c92f
FirebaseCore: feda061cb1ee6d8ad4824f4a4a8ffbcfe284f595
FirebaseCoreDiagnostics: 4505e4d4009b1d93f605088ee7d7764d5f0d1c84
FirebaseInstallations: 293f567159b6d66d1c990f13bb868066096c94ec
Flipper: 6c1f484f9a88d30ab3e272800d53688439e50f69
Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
Flipper-Folly: c12092ea368353b58e992843a990a3225d4533c3
@ -852,27 +846,28 @@ SPEC CHECKSUMS:
Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
Flipper-RSocket: 64e7431a55835eb953b0bf984ef3b90ae9fdddd7
FlipperKit: 6dc9b8f4ef60d9e5ded7f0264db299c91f18832e
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
GoogleAppMeasurement: 4c644d86835d827bab30ab6aabb9ecaf1f500735
GoogleDataTransport: f6f8eba931df03ebd2232ff4645aa85f8f47b5ab
GoogleDataTransportCCTSupport: d70a561f7d236af529fee598835caad5e25f6d3d
Folly: b73c3869541e86821df3c387eb0af5f65addfab4
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
GoogleAppMeasurement: 2fd5c5a56c069db635c8e7b92d4809a9591d0a69
GoogleDataTransport: 9a8a16f79feffc7f42096743de2a7c4815e84020
GoogleDataTransportCCTSupport: 489c1265d2c85b68187a83a911913d190012158d
GoogleUtilities: 39530bc0ad980530298e9c4af8549e991fd033b1
JitsiMeetSDK: 2984eac1343690bf1c0c72bde75b48b0148d0f79
KeyCommands: f66c535f698ed14b3d3a4e58859d79a827ea907e
libwebp: 946cb3063cea9236285f7e9a8505d806d30e07f3
nanopb: c43f40fadfe79e8b8db116583945847910cbabc9
OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355
PromisesObjC: c119f3cd559f50b7ae681fa59dc1acd19173b7e6
RCTRequired: cec6a34b3ac8a9915c37e7e4ad3aa74726ce4035
RCTTypeSafety: 93006131180074cffa227a1075802c89a49dd4ce
React: 29a8b1a02bd764fb7644ef04019270849b9a7ac3
React-Core: b12bffb3f567fdf99510acb716ef1abd426e0e05
React-CoreModules: 4a9b87bbe669d6c3173c0132c3328e3b000783d0
React-cxxreact: e65f9c2ba0ac5be946f53548c1aaaee5873a8103
React-jsi: b6dc94a6a12ff98e8877287a0b7620d365201161
React-jsiexecutor: 1540d1c01bb493ae3124ed83351b1b6a155db7da
React-jsinspector: 512e560d0e985d0e8c479a54a4e5c147a9c83493
PromisesObjC: b48e0338dbbac2207e611750777895f7a5811b75
RCTRequired: 6d452db9ed41ed479dded8b25cefaea171af100a
RCTTypeSafety: 9f116cdf6450aae848567f03de76a519ce8b5ffa
React: ae32f1a326e384e477a4130efaf35785cf66c482
React-callinvoker: b1222d51ffbc55017208d26e168d76035ade9d53
React-Core: b328df15e9952f937d4497d08821f908ddf63510
React-CoreModules: ddbd7c6b62241597e467cedfa4acd89f1504f613
React-cxxreact: 2e594ee40fb8666e2e48428a1767257a60873877
React-jsi: a968acc454a107677da6027d2111221f57765de9
React-jsiexecutor: c40a9c0e687bd7a44cc0a616ff4592a823732a0d
React-jsinspector: 655f32d922ffb180714c0bec652e7e0923b5a5dd
react-native-appearance: 0f0e5fc2fcef70e03d48c8fe6b00b9158c2ba8aa
react-native-background-timer: 1f7d560647b40e6a60b01c452ba29c54bf581fc4
react-native-cameraroll: 02e60e9af9273a3cc3b641632bf651189830aaf8
@ -883,16 +878,16 @@ SPEC CHECKSUMS:
react-native-safe-area-context: b11a34881faac509cad5578726c98161ad4d275c
react-native-slider: e51492f1264d882a8815b71c5870f8978e52887d
react-native-webview: cf5527893252b3b036eea024a1da6996f7344c74
React-RCTActionSheet: f41ea8a811aac770e0cc6e0ad6b270c644ea8b7c
React-RCTAnimation: 49ab98b1c1ff4445148b72a3d61554138565bad0
React-RCTBlob: a332773f0ebc413a0ce85942a55b064471587a71
React-RCTImage: e70be9b9c74fe4e42d0005f42cace7981c994ac3
React-RCTLinking: c1b9739a88d56ecbec23b7f63650e44672ab2ad2
React-RCTNetwork: 73138b6f45e5a2768ad93f3d57873c2a18d14b44
React-RCTSettings: 6e3738a87e21b39a8cb08d627e68c44acf1e325a
React-RCTText: fae545b10cfdb3d247c36c56f61a94cfd6dba41d
React-RCTVibration: 4356114dbcba4ce66991096e51a66e61eda51256
ReactCommon: ed4e11d27609d571e7eee8b65548efc191116eb3
React-RCTActionSheet: ead415a8470cd3552f8cadce3b9b32e0d52e46a7
React-RCTAnimation: 627dc8ad905b206c9bf10e9527079ef754b6a5dc
React-RCTBlob: e70ce946cee9d400c5bfb0e8668dd11db852fa5a
React-RCTImage: 9b8566568c0191e460baf4bee5a48a26efc2649c
React-RCTLinking: 9a72da67543456af38b7fe01d851c247edb91e59
React-RCTNetwork: 9939c3f1c757b03abd3bfda89a41b0989254e2a8
React-RCTSettings: bb29c478fd69f557f939cf9e3a9f6f431df432bb
React-RCTText: 1aa0fd4251b108777dd6218eb92d3613514b150f
React-RCTVibration: b630e8fd023809796d47917d27caa343ade0678d
ReactCommon: 6d0c6086911f7bf87b8406a92bb2ec66aeefd2e1
ReactNativeART: 78edc68dd4a1e675338cd0cd113319cf3a65f2ab
ReactNativeKeyboardInput: c37e26821519869993b3b61844350feb9177ff37
ReactNativeKeyboardTrackingView: 02137fac3b2ebd330d74fa54ead48b14750a2306
@ -913,9 +908,9 @@ SPEC CHECKSUMS:
RNScreens: cf198f915f8a2bf163de94ca9f5bfc8d326c3706
RNUserDefaults: c421fd97ad06b35c16608c5d0fe675db353f632d
RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4
SDWebImage: 48b88379b798fd1e4298f95bb25d2cdabbf4deb3
SDWebImage: 112503ec94a5a2a41869503844a15e8d8f1ead5c
SDWebImageWebPCoder: 36f8f47bd9879a8aea6044765c1351120fd8e3a8
TOCropViewController: e9da34f484aedd4e5d5a8ab230ba217cfe16c729
TOCropViewController: 20a14b6a7a098308bf369e7c8d700dc983a974e6
UMAppLoader: ee77a072f9e15128f777ccd6d2d00f52ab4387e6
UMBarCodeScannerInterface: 9dc692b87e5f20fe277fa57aa47f45d418c3cc6c
UMCameraInterface: 625878bbf2ba188a8548675e1d1d2e438a653e6d
@ -929,9 +924,9 @@ SPEC CHECKSUMS:
UMReactNativeAdapter: 126da3486c1a1f11945b649d557d6c2ebb9407b2
UMSensorsInterface: 48941f70175e2975af1a9386c6d6cb16d8126805
UMTaskManagerInterface: cb890c79c63885504ddc0efd7a7d01481760aca2
Yoga: 3ebccbdd559724312790e7742142d062476b698e
Yoga: 5d62aa8f4e862e282e19a25865ef8124c70f2711
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
PODFILE CHECKSUM: 35d9478dd32cf502959b8efc14411ecf09c66c95
PODFILE CHECKSUM: 55c04243097892160d63f79f3a23157165b7ac68
COCOAPODS: 1.8.4

View File

@ -2,14 +2,20 @@
[![License](https://img.shields.io/cocoapods/l/Firebase.svg?style=flat)](https://cocoapods.org/pods/Firebase)
[![Platform](https://img.shields.io/cocoapods/p/Firebase.svg?style=flat)](https://cocoapods.org/pods/Firebase)
[![Actions Status][gh-abtesting-badge]][gh-actions]
[![Actions Status][gh-auth-badge]][gh-actions]
[![Actions Status][gh-core-badge]][gh-actions]
[![Actions Status][gh-crashlytics-badge]][gh-actions]
[![Actions Status][gh-database-badge]][gh-actions]
[![Actions Status][gh-datatransport-badge]][gh-actions]
[![Actions Status][gh-dynamiclinks-badge]][gh-actions]
[![Actions Status][gh-firebasepod-badge]][gh-actions]
[![Actions Status][gh-firestore-badge]][gh-actions]
[![Actions Status][gh-functions-badge]][gh-actions]
[![Actions Status][gh-inappmessaging-badge]][gh-actions]
[![Actions Status][gh-interop-badge]][gh-actions]
[![Actions Status][gh-messaging-badge]][gh-actions]
[![Actions Status][gh-remoteconfig-badge]][gh-actions]
[![Actions Status][gh-storage-badge]][gh-actions]
[![Actions Status][gh-symbolcollision-badge]][gh-actions]
[![Actions Status][gh-zip-badge]][gh-actions]
@ -92,7 +98,7 @@ Instructions for installing binary frameworks via
To develop Firebase software in this repository, ensure that you have at least
the following software:
* Xcode 10.1 (or later)
* Xcode 10.3 (or later)
* CocoaPods 1.7.2 (or later)
* [CocoaPods generate](https://github.com/square/cocoapods-generate)
@ -123,6 +129,10 @@ Firestore has a self contained Xcode project. See
See [AddNewPod.md](AddNewPod.md).
### Managing Headers and Imports
See [HeadersImports.md](HeadersImports.md).
### Code Formatting
To ensure that the code is formatted consistently, run the script
@ -185,8 +195,16 @@ building and running the FirebaseAuth pod along with various samples and tests.
### Firebase Database
To run the Database Integration tests, make your database authentication rules
[public](https://firebase.google.com/docs/database/security/quickstart).
The Firebase Database Integration tests can be run against a locally running Database Emulator
or against a production instance.
To run against a local emulator instance, invoke `./scripts/run_database_emulator.sh start` before
running the integration test.
To run against a production instance, provide a valid GoogleServices-Info.plist and copy it to
`Example/Database/App/GoogleService-Info.plist`. Your Security Rule must be set to
[public](https://firebase.google.com/docs/database/security/quickstart) while your tests are
running.
### Firebase Storage
@ -274,14 +292,20 @@ Your use of Firebase is governed by the
[Terms of Service for Firebase Services](https://firebase.google.com/terms/).
[gh-actions]: https://github.com/firebase/firebase-ios-sdk/actions
[gh-abtesting-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/abtesting/badge.svg
[gh-auth-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/auth/badge.svg
[gh-core-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/core/badge.svg
[gh-crashlytics-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/crashlytics/badge.svg
[gh-database-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/database/badge.svg
[gh-datatransport-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/datatransport/badge.svg
[gh-dynamiclinks-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/dynamiclinks/badge.svg
[gh-firebasepod-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/firebasepod/badge.svg
[gh-firestore-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/firestore/badge.svg
[gh-functions-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/functions/badge.svg
[gh-inappmessaging-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/inappmessaging/badge.svg
[gh-interop-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/interop/badge.svg
[gh-messaging-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/messaging/badge.svg
[gh-remoteconfig-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/remoteconfig/badge.svg
[gh-storage-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/storage/badge.svg
[gh-symbolcollision-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/symbolcollision/badge.svg
[gh-zip-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/zip/badge.svg

View File

@ -366,7 +366,6 @@ static NSString *const kFIREventViewItemList NS_SWIFT_NAME(AnalyticsEventViewIte
/// <ul>
/// <li>@c kFIRParameterSearchTerm (NSString)</li>
/// </ul>
/// <b>This constant has been deprecated.</b>
static NSString *const kFIREventViewSearchResults NS_SWIFT_NAME(AnalyticsEventViewSearchResults) =
@"view_search_results";

View File

@ -14,7 +14,7 @@
#import <Foundation/Foundation.h>
#import "FirebaseCore/Sources/Private/FIRAnalyticsConfiguration.h"
#import "FirebaseCore/Sources/FIRAnalyticsConfiguration.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"

View File

@ -22,14 +22,14 @@
#import <AppKit/AppKit.h>
#endif
#import <FirebaseCore/FIRApp.h>
#import "FirebaseCore/Sources/Public/FIRApp.h"
#import "FirebaseCore/Sources/FIRAnalyticsConfiguration.h"
#import "FirebaseCore/Sources/FIRBundleUtil.h"
#import "FirebaseCore/Sources/FIRComponentContainerInternal.h"
#import "FirebaseCore/Sources/FIRConfigurationInternal.h"
#import "FirebaseCore/Sources/FIRVersion.h"
#import "FirebaseCore/Sources/Private/FIRAnalyticsConfiguration.h"
#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
#import "FirebaseCore/Sources/Private/FIRComponentContainerInternal.h"
#import "FirebaseCore/Sources/Private/FIRConfigurationInternal.h"
#import "FirebaseCore/Sources/Private/FIRCoreDiagnosticsConnector.h"
#import "FirebaseCore/Sources/Private/FIRLibrary.h"
#import "FirebaseCore/Sources/Private/FIRLogger.h"
@ -166,7 +166,7 @@ static dispatch_once_t sFirebaseUserAgentOnceToken;
if ([name isEqualToString:kFIRDefaultAppName]) {
if (sDefaultApp) {
// The default app already exixts. Handle duplicate `configure` calls and return.
// The default app already exists. Handle duplicate `configure` calls and return.
[self appWasConfiguredTwice:sDefaultApp usingOptions:options];
return;
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#import "FirebaseCore/Sources/Private/FIRAppAssociationRegistration.h"
#import "FirebaseCore/Sources/FIRAppAssociationRegistration.h"
#import <objc/runtime.h>

View File

@ -49,15 +49,19 @@
+ (BOOL)hasBundleIdentifierPrefix:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles {
for (NSBundle *bundle in bundles) {
// This allows app extensions that have the app's bundle as their prefix to pass this test.
NSString *applicationBundleIdentifier =
[GULAppEnvironmentUtil isAppExtension]
? [self bundleIdentifierByRemovingLastPartFrom:bundle.bundleIdentifier]
: bundle.bundleIdentifier;
if ([applicationBundleIdentifier isEqualToString:bundleIdentifier]) {
if ([bundle.bundleIdentifier isEqualToString:bundleIdentifier]) {
return YES;
}
if ([GULAppEnvironmentUtil isAppExtension]) {
// A developer could be using the same `FIROptions` for both their app and extension. Since
// extensions have a suffix added to the bundleID, we consider a matching prefix as valid.
NSString *appBundleIDFromExtension =
[self bundleIdentifierByRemovingLastPartFrom:bundle.bundleIdentifier];
if ([appBundleIDFromExtension isEqualToString:bundleIdentifier]) {
return YES;
}
}
}
return NO;
}

View File

@ -15,8 +15,8 @@
*/
#import <Foundation/Foundation.h>
#import <FirebaseCore/FIRComponent.h>
#import <FirebaseCore/FIRComponentContainer.h>
#import "FirebaseCore/Sources/Private/FIRComponent.h"
#import "FirebaseCore/Sources/Private/FIRComponentContainer.h"
@class FIRApp;

View File

@ -16,7 +16,7 @@
#import "FirebaseCore/Sources/Private/FIRComponentType.h"
#import "FirebaseCore/Sources/Private/FIRComponentContainerInternal.h"
#import "FirebaseCore/Sources/FIRComponentContainerInternal.h"
@implementation FIRComponentType

View File

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#import "FirebaseCore/Sources/Private/FIRConfigurationInternal.h"
#import "FirebaseCore/Sources/FIRConfigurationInternal.h"
#import "FirebaseCore/Sources/Private/FIRAnalyticsConfiguration.h"
#import "FirebaseCore/Sources/FIRAnalyticsConfiguration.h"
extern void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel);

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
#import <FirebaseCore/FIRConfiguration.h>
#import "FIRConfiguration.h"
@class FIRAnalyticsConfiguration;

View File

@ -16,12 +16,12 @@
#import "FirebaseCore/Sources/Private/FIRCoreDiagnosticsConnector.h"
#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsInterop.h>
#import "Interop/CoreDiagnostics/Public/FIRCoreDiagnosticsInterop.h"
#import <FirebaseCore/FIROptions.h>
#import "FirebaseCore/Sources/Public/FIROptions.h"
#import "FirebaseCore/Sources/FIRDiagnosticsData.h"
#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
#import "FirebaseCore/Sources/Private/FIRDiagnosticsData.h"
#import "FirebaseCore/Sources/Private/FIROptionsInternal.h"
// Define the interop class symbol declared as an extern in FIRCoreDiagnosticsInterop.

View File

@ -16,7 +16,7 @@
#import <Foundation/Foundation.h>
#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsData.h>
#import "Interop/CoreDiagnostics/Public/FIRCoreDiagnosticsData.h"
NS_ASSUME_NONNULL_BEGIN

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
#import "FirebaseCore/Sources/Private/FIRDiagnosticsData.h"
#import "FirebaseCore/Sources/FIRDiagnosticsData.h"
#import <FirebaseCore/FIRApp.h>
#import "FirebaseCore/Sources/Public/FIRApp.h"
#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
#import "FirebaseCore/Sources/Private/FIROptionsInternal.h"

View File

@ -14,9 +14,9 @@
#import "FirebaseCore/Sources/Private/FIRLogger.h"
#import <FirebaseCore/FIRLoggerLevel.h>
#import <GoogleUtilities/GULAppEnvironmentUtil.h>
#import <GoogleUtilities/GULLogger.h>
#import "FirebaseCore/Sources/Public/FIRLoggerLevel.h"
#import "FirebaseCore/Sources/FIRVersion.h"

View File

@ -14,8 +14,19 @@
* limitations under the License.
*/
#if SWIFT_PACKAGE
// TODO(paulb777): Investigate if there's a common strategy for both Cocoapods and Swift PM.
#import "FIRApp.h"
#else
#import <FirebaseCore/FIRApp.h>
#endif
// The has_include is a workaround so the old IID needed for the FIS tests can find FIRErrors.h
#if __has_include("FirebaseCore/Sources/Private/FIRErrors.h")
#import "FirebaseCore/Sources/Private/FIRErrors.h"
#else
#import <FirebaseCore/FIRErrors.h>
#endif
@class FIRComponentContainer;
@protocol FIRLibrary;

View File

@ -15,8 +15,14 @@
*/
#import <Foundation/Foundation.h>
// The has_include is a workaround so the old IID needed for the FIS tests can find the headers.
#if __has_include("FirebaseCore/Sources/Private/FIRComponentType.h")
#import "FirebaseCore/Sources/Private/FIRComponentType.h"
#import "FirebaseCore/Sources/Private/FIRLibrary.h"
#else
#import <FirebaseCore/FIRComponentType.h>
#import <FirebaseCore/FIRLibrary.h>
#endif
NS_ASSUME_NONNULL_BEGIN

View File

@ -32,7 +32,8 @@ typedef NS_ENUM(NSInteger, FIRErrorCode) {
FIRErrorCodeInvalidAppID = -101,
/**
* Error code for failing to configure a specific service.
* Error code for failing to configure a specific service. It's deprecated, but
* still used after copybara.
*/
FIRErrorCodeConfigFailed = -114,
};

View File

@ -19,7 +19,12 @@
#import <Foundation/Foundation.h>
// The has_include is a workaround so the old IID needed for the FIS tests can find the headers.
#if __has_include("FirebaseCore/Sources/Private/FIRComponent.h")
#import "FirebaseCore/Sources/Private/FIRComponent.h"
#else
#import <FirebaseCore/FIRComponent.h>
#endif
@class FIRApp;

View File

@ -16,7 +16,12 @@
#import <Foundation/Foundation.h>
#if SWIFT_PACKAGE
// TODO(paulb777): Investigate if there's a common strategy for both Cocoapods and Swift PM.
#import "FIRLoggerLevel.h"
#else
#import <FirebaseCore/FIRLoggerLevel.h>
#endif
NS_ASSUME_NONNULL_BEGIN

View File

@ -14,7 +14,12 @@
* limitations under the License.
*/
#if SWIFT_PACKAGE
// TODO(paulb777): Investigate if there's a common strategy for both Cocoapods and Swift PM.
#import "FIROptions.h"
#else
#import <FirebaseCore/FIROptions.h>
#endif
/**
* Keys for the strings in the plist file.

View File

@ -0,0 +1,31 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// An umbrella header, for any other libraries in this repo to access Firebase Public and Private
// headers. Any package manager complexity should be handled here.
#if SWIFT_PACKAGE
@import FirebaseCore;
#else
#import <FirebaseCore/FirebaseCore.h>
#endif
#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
#import "FirebaseCore/Sources/Private/FIRComponent.h"
#import "FirebaseCore/Sources/Private/FIRComponentContainer.h"
#import "FirebaseCore/Sources/Private/FIRDependency.h"
#import "FirebaseCore/Sources/Private/FIRHeartbeatInfo.h"
#import "FirebaseCore/Sources/Private/FIRLibrary.h"
#import "FirebaseCore/Sources/Private/FIRLogger.h"
#import "FirebaseCore/Sources/Private/FIROptionsInternal.h"

View File

@ -16,7 +16,7 @@
#import <Foundation/Foundation.h>
#import <FirebaseCore/FIRLoggerLevel.h>
#import "FIRLoggerLevel.h"
NS_ASSUME_NONNULL_BEGIN

View File

@ -2,14 +2,20 @@
[![License](https://img.shields.io/cocoapods/l/Firebase.svg?style=flat)](https://cocoapods.org/pods/Firebase)
[![Platform](https://img.shields.io/cocoapods/p/Firebase.svg?style=flat)](https://cocoapods.org/pods/Firebase)
[![Actions Status][gh-abtesting-badge]][gh-actions]
[![Actions Status][gh-auth-badge]][gh-actions]
[![Actions Status][gh-core-badge]][gh-actions]
[![Actions Status][gh-crashlytics-badge]][gh-actions]
[![Actions Status][gh-database-badge]][gh-actions]
[![Actions Status][gh-datatransport-badge]][gh-actions]
[![Actions Status][gh-dynamiclinks-badge]][gh-actions]
[![Actions Status][gh-firebasepod-badge]][gh-actions]
[![Actions Status][gh-firestore-badge]][gh-actions]
[![Actions Status][gh-functions-badge]][gh-actions]
[![Actions Status][gh-inappmessaging-badge]][gh-actions]
[![Actions Status][gh-interop-badge]][gh-actions]
[![Actions Status][gh-messaging-badge]][gh-actions]
[![Actions Status][gh-remoteconfig-badge]][gh-actions]
[![Actions Status][gh-storage-badge]][gh-actions]
[![Actions Status][gh-symbolcollision-badge]][gh-actions]
[![Actions Status][gh-zip-badge]][gh-actions]
@ -92,7 +98,7 @@ Instructions for installing binary frameworks via
To develop Firebase software in this repository, ensure that you have at least
the following software:
* Xcode 10.1 (or later)
* Xcode 10.3 (or later)
* CocoaPods 1.7.2 (or later)
* [CocoaPods generate](https://github.com/square/cocoapods-generate)
@ -123,6 +129,10 @@ Firestore has a self contained Xcode project. See
See [AddNewPod.md](AddNewPod.md).
### Managing Headers and Imports
See [HeadersImports.md](HeadersImports.md).
### Code Formatting
To ensure that the code is formatted consistently, run the script
@ -185,8 +195,16 @@ building and running the FirebaseAuth pod along with various samples and tests.
### Firebase Database
To run the Database Integration tests, make your database authentication rules
[public](https://firebase.google.com/docs/database/security/quickstart).
The Firebase Database Integration tests can be run against a locally running Database Emulator
or against a production instance.
To run against a local emulator instance, invoke `./scripts/run_database_emulator.sh start` before
running the integration test.
To run against a production instance, provide a valid GoogleServices-Info.plist and copy it to
`Example/Database/App/GoogleService-Info.plist`. Your Security Rule must be set to
[public](https://firebase.google.com/docs/database/security/quickstart) while your tests are
running.
### Firebase Storage
@ -274,14 +292,20 @@ Your use of Firebase is governed by the
[Terms of Service for Firebase Services](https://firebase.google.com/terms/).
[gh-actions]: https://github.com/firebase/firebase-ios-sdk/actions
[gh-abtesting-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/abtesting/badge.svg
[gh-auth-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/auth/badge.svg
[gh-core-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/core/badge.svg
[gh-crashlytics-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/crashlytics/badge.svg
[gh-database-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/database/badge.svg
[gh-datatransport-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/datatransport/badge.svg
[gh-dynamiclinks-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/dynamiclinks/badge.svg
[gh-firebasepod-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/firebasepod/badge.svg
[gh-firestore-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/firestore/badge.svg
[gh-functions-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/functions/badge.svg
[gh-inappmessaging-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/inappmessaging/badge.svg
[gh-interop-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/interop/badge.svg
[gh-messaging-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/messaging/badge.svg
[gh-remoteconfig-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/remoteconfig/badge.svg
[gh-storage-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/storage/badge.svg
[gh-symbolcollision-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/symbolcollision/badge.svg
[gh-zip-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/zip/badge.svg

View File

@ -26,8 +26,8 @@
#import <GoogleUtilities/GULHeartbeatDateStorage.h>
#import <GoogleUtilities/GULLogger.h>
#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsData.h>
#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsInterop.h>
#import "Interop/CoreDiagnostics/Public/FIRCoreDiagnosticsData.h"
#import "Interop/CoreDiagnostics/Public/FIRCoreDiagnosticsInterop.h"
#import <nanopb/pb.h>
#import <nanopb/pb_decode.h>

View File

@ -0,0 +1,61 @@
/*
* Copyright 2019 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/** If present, is a BOOL wrapped in an NSNumber. */
#define kFIRCDIsDataCollectionDefaultEnabledKey @"FIRCDIsDataCollectionDefaultEnabledKey"
/** If present, is an int32_t wrapped in an NSNumber. */
#define kFIRCDConfigurationTypeKey @"FIRCDConfigurationTypeKey"
/** If present, is an NSString. */
#define kFIRCDSdkNameKey @"FIRCDSdkNameKey"
/** If present, is an NSString. */
#define kFIRCDSdkVersionKey @"FIRCDSdkVersionKey"
/** If present, is an int32_t wrapped in an NSNumber. */
#define kFIRCDllAppsCountKey @"FIRCDllAppsCountKey"
/** If present, is an NSString. */
#define kFIRCDGoogleAppIDKey @"FIRCDGoogleAppIDKey"
/** If present, is an NSString. */
#define kFIRCDBundleIDKey @"FIRCDBundleID"
/** If present, is a BOOL wrapped in an NSNumber. */
#define kFIRCDUsingOptionsFromDefaultPlistKey @"FIRCDUsingOptionsFromDefaultPlistKey"
/** If present, is an NSString. */
#define kFIRCDLibraryVersionIDKey @"FIRCDLibraryVersionIDKey"
/** If present, is an NSString. */
#define kFIRCDFirebaseUserAgentKey @"FIRCDFirebaseUserAgentKey"
/** Defines the interface of a data object needed to log diagnostics data. */
@protocol FIRCoreDiagnosticsData <NSObject>
@required
/** A dictionary containing data (non-exhaustive) to be logged in diagnostics. */
@property(nonatomic) NSDictionary<NSString *, id> *diagnosticObjects;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,34 @@
/*
* Copyright 2019 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
#import "FIRCoreDiagnosticsData.h"
NS_ASSUME_NONNULL_BEGIN
/** Allows the interoperation of FirebaseCore and FirebaseCoreDiagnostics. */
@protocol FIRCoreDiagnosticsInterop <NSObject>
/** Sends the given diagnostics data.
*
* @param diagnosticsData The diagnostics data object to send.
*/
+ (void)sendDiagnosticsData:(id<FIRCoreDiagnosticsData>)diagnosticsData;
@end
NS_ASSUME_NONNULL_END

View File

@ -2,14 +2,20 @@
[![License](https://img.shields.io/cocoapods/l/Firebase.svg?style=flat)](https://cocoapods.org/pods/Firebase)
[![Platform](https://img.shields.io/cocoapods/p/Firebase.svg?style=flat)](https://cocoapods.org/pods/Firebase)
[![Actions Status][gh-abtesting-badge]][gh-actions]
[![Actions Status][gh-auth-badge]][gh-actions]
[![Actions Status][gh-core-badge]][gh-actions]
[![Actions Status][gh-crashlytics-badge]][gh-actions]
[![Actions Status][gh-database-badge]][gh-actions]
[![Actions Status][gh-datatransport-badge]][gh-actions]
[![Actions Status][gh-dynamiclinks-badge]][gh-actions]
[![Actions Status][gh-firebasepod-badge]][gh-actions]
[![Actions Status][gh-firestore-badge]][gh-actions]
[![Actions Status][gh-functions-badge]][gh-actions]
[![Actions Status][gh-inappmessaging-badge]][gh-actions]
[![Actions Status][gh-interop-badge]][gh-actions]
[![Actions Status][gh-messaging-badge]][gh-actions]
[![Actions Status][gh-remoteconfig-badge]][gh-actions]
[![Actions Status][gh-storage-badge]][gh-actions]
[![Actions Status][gh-symbolcollision-badge]][gh-actions]
[![Actions Status][gh-zip-badge]][gh-actions]
@ -92,7 +98,7 @@ Instructions for installing binary frameworks via
To develop Firebase software in this repository, ensure that you have at least
the following software:
* Xcode 10.1 (or later)
* Xcode 10.3 (or later)
* CocoaPods 1.7.2 (or later)
* [CocoaPods generate](https://github.com/square/cocoapods-generate)
@ -123,6 +129,10 @@ Firestore has a self contained Xcode project. See
See [AddNewPod.md](AddNewPod.md).
### Managing Headers and Imports
See [HeadersImports.md](HeadersImports.md).
### Code Formatting
To ensure that the code is formatted consistently, run the script
@ -185,8 +195,16 @@ building and running the FirebaseAuth pod along with various samples and tests.
### Firebase Database
To run the Database Integration tests, make your database authentication rules
[public](https://firebase.google.com/docs/database/security/quickstart).
The Firebase Database Integration tests can be run against a locally running Database Emulator
or against a production instance.
To run against a local emulator instance, invoke `./scripts/run_database_emulator.sh start` before
running the integration test.
To run against a production instance, provide a valid GoogleServices-Info.plist and copy it to
`Example/Database/App/GoogleService-Info.plist`. Your Security Rule must be set to
[public](https://firebase.google.com/docs/database/security/quickstart) while your tests are
running.
### Firebase Storage
@ -274,14 +292,20 @@ Your use of Firebase is governed by the
[Terms of Service for Firebase Services](https://firebase.google.com/terms/).
[gh-actions]: https://github.com/firebase/firebase-ios-sdk/actions
[gh-abtesting-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/abtesting/badge.svg
[gh-auth-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/auth/badge.svg
[gh-core-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/core/badge.svg
[gh-crashlytics-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/crashlytics/badge.svg
[gh-database-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/database/badge.svg
[gh-datatransport-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/datatransport/badge.svg
[gh-dynamiclinks-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/dynamiclinks/badge.svg
[gh-firebasepod-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/firebasepod/badge.svg
[gh-firestore-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/firestore/badge.svg
[gh-functions-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/functions/badge.svg
[gh-inappmessaging-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/inappmessaging/badge.svg
[gh-interop-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/interop/badge.svg
[gh-messaging-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/messaging/badge.svg
[gh-remoteconfig-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/remoteconfig/badge.svg
[gh-storage-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/storage/badge.svg
[gh-symbolcollision-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/symbolcollision/badge.svg
[gh-zip-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/zip/badge.svg

View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,251 +0,0 @@
# Firebase iOS Open Source Development [![Build Status](https://travis-ci.org/firebase/firebase-ios-sdk.svg?branch=master)](https://travis-ci.org/firebase/firebase-ios-sdk)
This repository contains a subset of the Firebase iOS SDK source. It currently
includes FirebaseCore, FirebaseABTesting, FirebaseAuth, FirebaseDatabase,
FirebaseFirestore, FirebaseFunctions, FirebaseInstanceID, FirebaseInAppMessaging,
FirebaseInAppMessagingDisplay, FirebaseMessaging, FirebaseRemoteConfig, and
FirebaseStorage.
The repository also includes GoogleUtilities source. The
[GoogleUtilities](GoogleUtilities/README.md) pod is
a set of utilities used by Firebase and other Google products.
Firebase is an app development platform with tools to help you build, grow and
monetize your app. More information about Firebase can be found at
[https://firebase.google.com](https://firebase.google.com).
## Installation
See the three subsections for details about three different installation methods.
1. [Standard pod install](README.md#standard-pod-install)
1. [Installing from the GitHub repo](README.md#installing-from-github)
1. [Experimental Carthage](README.md#carthage-ios-only)
### Standard pod install
Go to
[https://firebase.google.com/docs/ios/setup](https://firebase.google.com/docs/ios/setup).
### Installing from GitHub
For releases starting with 5.0.0, the source for each release is also deployed
to CocoaPods master and available via standard
[CocoaPods Podfile syntax](https://guides.cocoapods.org/syntax/podfile.html#pod).
These instructions can be used to access the Firebase repo at other branches,
tags, or commits.
#### Background
See
[the Podfile Syntax Reference](https://guides.cocoapods.org/syntax/podfile.html#pod)
for instructions and options about overriding pod source locations.
#### Accessing Firebase Source Snapshots
All of the official releases are tagged in this repo and available via CocoaPods. To access a local
source snapshot or unreleased branch, use Podfile directives like the following:
To access FirebaseFirestore via a branch:
```
pod 'FirebaseCore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
pod 'FirebaseFirestore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
```
To access FirebaseMessaging via a checked out version of the firebase-ios-sdk repo do:
```
pod 'FirebaseCore', :path => '/path/to/firebase-ios-sdk'
pod 'FirebaseMessaging', :path => '/path/to/firebase-ios-sdk'
```
### Carthage (iOS only)
Instructions for the experimental Carthage distribution are at
[Carthage](Carthage.md).
### Rome
Instructions for installing binary frameworks via
[Rome](https://github.com/CocoaPods/Rome) are at [Rome](Rome.md).
## Development
To develop Firebase software in this repository, ensure that you have at least
the following software:
* Xcode 10.1 (or later)
* CocoaPods 1.7.2 (or later)
* [CocoaPods generate](https://github.com/square/cocoapods-generate)
For the pod that you want to develop:
`pod gen Firebase{name here}.podspec --local-sources=./ --auto-open --platforms=ios`
Note: If the CocoaPods cache is out of date, you may need to run
`pod repo update` before the `pod gen` command.
Note: Set the `--platforms` option to `macos` or `tvos` to develop/test for
those platforms. Since 10.2, Xcode does not properly handle multi-platform
CocoaPods workspaces.
Firestore has a self contained Xcode project. See
[Firestore/README.md](Firestore/README.md).
### Development for Catalyst
* `pod gen {name here}.podspec --local-sources=./ --auto-open --platforms=ios`
* Check the Mac box in the App-iOS Build Settings
* Sign the App in the Settings Signing & Capabilities tab
* Click Pods in the Project Manager
* Add Signing to the iOS host app and unit test targets
* Select the Unit-unit scheme
* Run it to build and test
### Adding a New Firebase Pod
See [AddNewPod.md](AddNewPod.md).
### Code Formatting
To ensure that the code is formatted consistently, run the script
[./scripts/style.sh](https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/style.sh)
before creating a PR.
Travis will verify that any code changes are done in a style compliant way. Install
`clang-format` and `swiftformat`.
These commands will get the right versions:
```
brew upgrade https://raw.githubusercontent.com/Homebrew/homebrew-core/e3496d9/Formula/clang-format.rb
brew upgrade https://raw.githubusercontent.com/Homebrew/homebrew-core/7963c3d/Formula/swiftformat.rb
```
Note: if you already have a newer version of these installed you may need to
`brew switch` to this version.
To update this section, find the versions of clang-format and swiftformat.rb to
match the versions in the CI failure logs
[here](https://github.com/Homebrew/homebrew-core/tree/master/Formula).
### Running Unit Tests
Select a scheme and press Command-u to build a component and run its unit tests.
#### Viewing Code Coverage
First, make sure that [xcov](https://github.com/nakiostudio/xcov) is installed with `gem install xcov`.
After running the `AllUnitTests_iOS` scheme in Xcode, execute
`xcov --workspace Firebase.xcworkspace --scheme AllUnitTests_iOS --output_directory xcov_output`
at Example/ in the terminal. This will aggregate the coverage, and you can run `open xcov_output/index.html` to see the results.
### Running Sample Apps
In order to run the sample apps and integration tests, you'll need valid
`GoogleService-Info.plist` files for those samples. The Firebase Xcode project contains dummy plist
files without real values, but can be replaced with real plist files. To get your own
`GoogleService-Info.plist` files:
1. Go to the [Firebase Console](https://console.firebase.google.com/)
2. Create a new Firebase project, if you don't already have one
3. For each sample app you want to test, create a new Firebase app with the sample app's bundle
identifier (e.g. `com.google.Database-Example`)
4. Download the resulting `GoogleService-Info.plist` and replace the appropriate dummy plist file
(e.g. in [Example/Database/App/](Example/Database/App/));
Some sample apps like Firebase Messaging ([Example/Messaging/App](Example/Messaging/App)) require
special Apple capabilities, and you will have to change the sample app to use a unique bundle
identifier that you can control in your own Apple Developer account.
## Specific Component Instructions
See the sections below for any special instructions for those components.
### Firebase Auth
If you're doing specific Firebase Auth development, see
[the Auth Sample README](Example/Auth/README.md) for instructions about
building and running the FirebaseAuth pod along with various samples and tests.
### Firebase Database
To run the Database Integration tests, make your database authentication rules
[public](https://firebase.google.com/docs/database/security/quickstart).
### Firebase Storage
To run the Storage Integration tests, follow the instructions in
[FIRStorageIntegrationTests.m](Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m).
#### Push Notifications
Push notifications can only be delivered to specially provisioned App IDs in the developer portal.
In order to actually test receiving push notifications, you will need to:
1. Change the bundle identifier of the sample app to something you own in your Apple Developer
account, and enable that App ID for push notifications.
2. You'll also need to
[upload your APNs Provider Authentication Key or certificate to the Firebase Console](https://firebase.google.com/docs/cloud-messaging/ios/certs)
at **Project Settings > Cloud Messaging > [Your Firebase App]**.
3. Ensure your iOS device is added to your Apple Developer portal as a test device.
#### iOS Simulator
The iOS Simulator cannot register for remote notifications, and will not receive push notifications.
In order to receive push notifications, you'll have to follow the steps above and run the app on a
physical device.
## Community Supported Efforts
We've seen an amazing amount of interest and contributions to improve the Firebase SDKs, and we are
very grateful! We'd like to empower as many developers as we can to be able to use Firebase and
participate in the Firebase community.
### tvOS, macOS, and Catalyst
Thanks to contributions from the community, FirebaseABTesting, FirebaseAuth, FirebaseCore,
FirebaseDatabase, FirebaseMessaging, FirebaseFirestore,
FirebaseFunctions, FirebaseRemoteConfig, and FirebaseStorage now compile, run unit tests, and work on
tvOS, macOS, and Catalyst.
For tvOS, checkout the [Sample](Example/tvOSSample).
Keep in mind that macOS, Catalyst and tvOS are not officially supported by Firebase, and this
repository is actively developed primarily for iOS. While we can catch basic unit test issues with
Travis, there may be some changes where the SDK no longer works as expected on macOS or tvOS. If you
encounter this, please [file an issue](https://github.com/firebase/firebase-ios-sdk/issues).
To install, add a subset of the following to the Podfile:
```
pod 'Firebase/ABTesting'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Firestore'
pod 'Firebase/Functions'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
```
#### Additional Catalyst Notes
* FirebaseAuth and FirebaseMessaging require adding `Keychain Sharing Capability`
to Build Settings.
* FirebaseFirestore requires signing the
[gRPC Resource target](https://github.com/firebase/firebase-ios-sdk/issues/3500#issuecomment-518741681).
## Roadmap
See [Roadmap](ROADMAP.md) for more about the Firebase iOS SDK Open Source
plans and directions.
## Contributing
See [Contributing](CONTRIBUTING.md) for more information on contributing to the Firebase
iOS SDK.
## License
The contents of this repository is licensed under the
[Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
Your use of Firebase is governed by the
[Terms of Service for Firebase Services](https://firebase.google.com/terms/).

View File

@ -0,0 +1,173 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if SWIFT_PACKAGE
// TODO(paulb777): Investigate if there's a common strategy for both Cocoapods and Swift PM.
#import "FIRApp.h"
#else
#import <FirebaseCore/FIRApp.h>
#endif
// The has_include is a workaround so the old IID needed for the FIS tests can find FIRErrors.h
#if __has_include("FirebaseCore/Sources/Private/FIRErrors.h")
#import "FirebaseCore/Sources/Private/FIRErrors.h"
#else
#import <FirebaseCore/FIRErrors.h>
#endif
@class FIRComponentContainer;
@protocol FIRLibrary;
/**
* The internal interface to FIRApp. This is meant for first-party integrators, who need to receive
* FIRApp notifications, log info about the success or failure of their configuration, and access
* other internal functionality of FIRApp.
*
* TODO(b/28296561): Restructure this header.
*/
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, FIRConfigType) {
FIRConfigTypeCore = 1,
FIRConfigTypeSDK = 2,
};
extern NSString *const kFIRDefaultAppName;
extern NSString *const kFIRAppReadyToConfigureSDKNotification;
extern NSString *const kFIRAppDeleteNotification;
extern NSString *const kFIRAppIsDefaultAppKey;
extern NSString *const kFIRAppNameKey;
extern NSString *const kFIRGoogleAppIDKey;
/**
* The format string for the User Defaults key used for storing the data collection enabled flag.
* This includes formatting to append the Firebase App's name.
*/
extern NSString *const kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat;
/**
* The plist key used for storing the data collection enabled flag.
*/
extern NSString *const kFIRGlobalAppDataCollectionEnabledPlistKey;
/**
* A notification fired containing diagnostic information when SDK errors occur.
*/
extern NSString *const kFIRAppDiagnosticsNotification;
/** @var FIRAuthStateDidChangeInternalNotification
@brief The name of the @c NSNotificationCenter notification which is posted when the auth state
changes (e.g. a new token has been produced, a user logs in or out). The object parameter of
the notification is a dictionary possibly containing the key:
@c FIRAuthStateDidChangeInternalNotificationTokenKey (the new access token.) If it does not
contain this key it indicates a sign-out event took place.
*/
extern NSString *const FIRAuthStateDidChangeInternalNotification;
/** @var FIRAuthStateDidChangeInternalNotificationTokenKey
@brief A key present in the dictionary object parameter of the
@c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
key will contain the new access token.
*/
extern NSString *const FIRAuthStateDidChangeInternalNotificationTokenKey;
/** @var FIRAuthStateDidChangeInternalNotificationAppKey
@brief A key present in the dictionary object parameter of the
@c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
key will contain the FIRApp associated with the auth instance.
*/
extern NSString *const FIRAuthStateDidChangeInternalNotificationAppKey;
/** @var FIRAuthStateDidChangeInternalNotificationUIDKey
@brief A key present in the dictionary object parameter of the
@c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
key will contain the new user's UID (or nil if there is no longer a user signed in).
*/
extern NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey;
@interface FIRApp ()
/**
* A flag indicating if this is the default app (has the default app name).
*/
@property(nonatomic, readonly) BOOL isDefaultApp;
/*
* The container of interop SDKs for this app.
*/
@property(nonatomic) FIRComponentContainer *container;
/**
* Creates an error for failing to configure a subspec service. This method is called by each
* FIRApp notification listener.
*/
+ (NSError *)errorForSubspecConfigurationFailureWithDomain:(NSString *)domain
errorCode:(FIRErrorCode)code
service:(NSString *)service
reason:(NSString *)reason;
/**
* Checks if the default app is configured without trying to configure it.
*/
+ (BOOL)isDefaultAppConfigured;
/**
* Registers a given third-party library with the given version number to be reported for
* analytics.
*
* @param name Name of the library.
* @param version Version of the library.
*/
+ (void)registerLibrary:(nonnull NSString *)name withVersion:(nonnull NSString *)version;
/**
* Registers a given internal library with the given version number to be reported for
* analytics.
*
* @param library Optional parameter for component registration.
* @param name Name of the library.
* @param version Version of the library.
*/
+ (void)registerInternalLibrary:(nonnull Class<FIRLibrary>)library
withName:(nonnull NSString *)name
withVersion:(nonnull NSString *)version;
/**
* A concatenated string representing all the third-party libraries and version numbers.
*/
+ (NSString *)firebaseUserAgent;
/**
* Used by each SDK to send logs about SDK configuration status to Clearcut.
*
* @note This API is a no-op, please remove calls to it.
*/
- (void)sendLogsWithServiceName:(NSString *)serviceName
version:(NSString *)version
error:(NSError *)error;
/**
* Can be used by the unit tests in eack SDK to reset FIRApp. This method is thread unsafe.
*/
+ (void)resetApps;
/**
* Can be used by the unit tests in each SDK to set customized options.
*/
- (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)options;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,91 @@
/*
* Copyright 2018 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
@class FIRApp;
@class FIRComponentContainer;
NS_ASSUME_NONNULL_BEGIN
/// Provides a system to clean up cached instances returned from the component system.
NS_SWIFT_NAME(ComponentLifecycleMaintainer)
@protocol FIRComponentLifecycleMaintainer
/// The associated app will be deleted, clean up any resources as they are about to be deallocated.
- (void)appWillBeDeleted:(FIRApp *)app;
@end
typedef _Nullable id (^FIRComponentCreationBlock)(FIRComponentContainer *container,
BOOL *isCacheable)
NS_SWIFT_NAME(ComponentCreationBlock);
@class FIRDependency;
/// Describes the timing of instantiation. Note: new components should default to lazy unless there
/// is a strong reason to be eager.
typedef NS_ENUM(NSInteger, FIRInstantiationTiming) {
FIRInstantiationTimingLazy,
FIRInstantiationTimingAlwaysEager,
FIRInstantiationTimingEagerInDefaultApp
} NS_SWIFT_NAME(InstantiationTiming);
/// A component that can be used from other Firebase SDKs.
NS_SWIFT_NAME(Component)
@interface FIRComponent : NSObject
/// The protocol describing functionality provided from the Component.
@property(nonatomic, strong, readonly) Protocol *protocol;
/// The timing of instantiation.
@property(nonatomic, readonly) FIRInstantiationTiming instantiationTiming;
/// An array of dependencies for the component.
@property(nonatomic, copy, readonly) NSArray<FIRDependency *> *dependencies;
/// A block to instantiate an instance of the component with the appropriate dependencies.
@property(nonatomic, copy, readonly) FIRComponentCreationBlock creationBlock;
// There's an issue with long NS_SWIFT_NAMES that causes compilation to fail, disable clang-format
// for the next two methods.
// clang-format off
/// Creates a component with no dependencies that will be lazily initialized.
+ (instancetype)componentWithProtocol:(Protocol *)protocol
creationBlock:(FIRComponentCreationBlock)creationBlock
NS_SWIFT_NAME(init(_:creationBlock:));
/// Creates a component to be registered with the component container.
///
/// @param protocol - The protocol describing functionality provided by the component.
/// @param instantiationTiming - When the component should be initialized. Use .lazy unless there's
/// a good reason to be instantiated earlier.
/// @param dependencies - Any dependencies the `implementingClass` has, optional or required.
/// @param creationBlock - A block to instantiate the component with a container, and if
/// @return A component that can be registered with the component container.
+ (instancetype)componentWithProtocol:(Protocol *)protocol
instantiationTiming:(FIRInstantiationTiming)instantiationTiming
dependencies:(NSArray<FIRDependency *> *)dependencies
creationBlock:(FIRComponentCreationBlock)creationBlock
NS_SWIFT_NAME(init(_:instantiationTiming:dependencies:creationBlock:));
// clang-format on
/// Unavailable.
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,50 @@
/*
* Copyright 2018 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
// The has_include is a workaround so the old IID needed for the FIS tests can find the headers.
#if __has_include("FirebaseCore/Sources/Private/FIRComponentType.h")
#import "FirebaseCore/Sources/Private/FIRComponentType.h"
#import "FirebaseCore/Sources/Private/FIRLibrary.h"
#else
#import <FirebaseCore/FIRComponentType.h>
#import <FirebaseCore/FIRLibrary.h>
#endif
NS_ASSUME_NONNULL_BEGIN
/// A type-safe macro to retrieve a component from a container. This should be used to retrieve
/// components instead of using the container directly.
#define FIR_COMPONENT(type, container) \
[FIRComponentType<id<type>> instanceForProtocol:@protocol(type) inContainer:container]
@class FIRApp;
/// A container that holds different components that are registered via the
/// `registerAsComponentRegistrant:` call. These classes should conform to `FIRComponentRegistrant`
/// in order to properly register components for Core.
NS_SWIFT_NAME(FirebaseComponentContainer)
@interface FIRComponentContainer : NSObject
/// A weak reference to the app that an instance of the container belongs to.
@property(nonatomic, weak, readonly) FIRApp *app;
/// Unavailable. Use the `container` property on `FIRApp`.
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,34 @@
/*
* Copyright 2018 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
@class FIRComponentContainer;
NS_ASSUME_NONNULL_BEGIN
/// Do not use directly. A placeholder type in order to provide a macro that will warn users of
/// mis-matched protocols.
NS_SWIFT_NAME(ComponentType)
@interface FIRComponentType<__covariant T> : NSObject
/// Do not use directly. A factory method to retrieve an instance that provides a specific
/// functionality.
+ (T)instanceForProtocol:(Protocol *)protocol inContainer:(FIRComponentContainer *)container;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,35 @@
/*
* Copyright 2019 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
@class FIRDiagnosticsData;
@class FIROptions;
NS_ASSUME_NONNULL_BEGIN
/** Connects FIRCore with the CoreDiagnostics library. */
@interface FIRCoreDiagnosticsConnector : NSObject
/** Logs FirebaseCore related data.
*
* @param options The options object containing data to log.
*/
+ (void)logCoreTelemetryWithOptions:(FIROptions *)options;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,45 @@
/*
* Copyright 2018 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// A dependency on a specific protocol's functionality.
NS_SWIFT_NAME(Dependency)
@interface FIRDependency : NSObject
/// The protocol describing functionality being depended on.
@property(nonatomic, strong, readonly) Protocol *protocol;
/// A flag to specify if the dependency is required or not.
@property(nonatomic, readonly) BOOL isRequired;
/// Initializes a dependency that is required. Calls `initWithProtocol:isRequired` with `YES` for
/// the required parameter.
/// Creates a required dependency on the specified protocol's functionality.
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol;
/// Creates a dependency on the specified protocol's functionality and specify if it's required for
/// the class's functionality.
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol isRequired:(BOOL)required;
/// Use `dependencyWithProtocol:isRequired:` instead.
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,39 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Error codes in Firebase error domain. */
typedef NS_ENUM(NSInteger, FIRErrorCode) {
/**
* Unknown error.
*/
FIRErrorCodeUnknown = 0,
/**
* Loading data from the GoogleService-Info.plist file failed. This is a fatal error and should
* not be ignored. Further calls to the API will fail and/or possibly cause crashes.
*/
FIRErrorCodeInvalidPlistFile = -100,
/**
* Validating the Google App ID format failed.
*/
FIRErrorCodeInvalidAppID = -101,
/**
* Error code for failing to configure a specific service. It's deprecated, but
* still used after copybara.
*/
FIRErrorCodeConfigFailed = -114,
};

View File

@ -0,0 +1,24 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
#include "FIRErrorCode.h"
extern NSString *const kFirebaseErrorDomain;
extern NSString *const kFirebaseConfigErrorDomain;
extern NSString *const kFirebaseCoreErrorDomain;
extern NSString *const kFirebasePerfErrorDomain;

View File

@ -0,0 +1,39 @@
// Copyright 2019 Google
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FIRHeartbeatInfo : NSObject
// Enum representing the different heartbeat codes.
typedef NS_ENUM(NSInteger, FIRHeartbeatInfoCode) {
FIRHeartbeatInfoCodeNone = 0,
FIRHeartbeatInfoCodeSDK = 1,
FIRHeartbeatInfoCodeGlobal = 2,
FIRHeartbeatInfoCodeCombined = 3,
};
/**
* Get heartbeat code requred for the sdk.
* @param heartbeatTag String representing the sdk heartbeat tag.
* @return Heartbeat code indicating whether or not an sdk/global heartbeat
* needs to be sent
*/
+ (FIRHeartbeatInfoCode)heartbeatCodeForTag:(NSString *)heartbeatTag;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,50 @@
/*
* Copyright 2018 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FIRLibrary_h
#define FIRLibrary_h
#import <Foundation/Foundation.h>
// The has_include is a workaround so the old IID needed for the FIS tests can find the headers.
#if __has_include("FirebaseCore/Sources/Private/FIRComponent.h")
#import "FirebaseCore/Sources/Private/FIRComponent.h"
#else
#import <FirebaseCore/FIRComponent.h>
#endif
@class FIRApp;
NS_ASSUME_NONNULL_BEGIN
/// Provide an interface to register a library for userAgent logging and availability to others.
NS_SWIFT_NAME(Library)
@protocol FIRLibrary
/// Returns one or more FIRComponents that will be registered in
/// FIRApp and participate in dependency resolution and injection.
+ (NSArray<FIRComponent *> *)componentsToRegister;
@optional
/// Implement this method if the library needs notifications for lifecycle events. This method is
/// called when the developer calls `FirebaseApp.configure()`.
+ (void)configureWithApp:(FIRApp *)app;
@end
NS_ASSUME_NONNULL_END
#endif /* FIRLibrary_h */

View File

@ -0,0 +1,156 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
#if SWIFT_PACKAGE
// TODO(paulb777): Investigate if there's a common strategy for both Cocoapods and Swift PM.
#import "FIRLoggerLevel.h"
#else
#import <FirebaseCore/FIRLoggerLevel.h>
#endif
NS_ASSUME_NONNULL_BEGIN
/**
* The Firebase services used in Firebase logger.
*/
typedef NSString *const FIRLoggerService;
extern FIRLoggerService kFIRLoggerABTesting;
extern FIRLoggerService kFIRLoggerAdMob;
extern FIRLoggerService kFIRLoggerAnalytics;
extern FIRLoggerService kFIRLoggerAuth;
extern FIRLoggerService kFIRLoggerCrash;
extern FIRLoggerService kFIRLoggerCore;
extern FIRLoggerService kFIRLoggerMLKit;
extern FIRLoggerService kFIRLoggerPerf;
extern FIRLoggerService kFIRLoggerRemoteConfig;
/**
* The key used to store the logger's error count.
*/
extern NSString *const kFIRLoggerErrorCountKey;
/**
* The key used to store the logger's warning count.
*/
extern NSString *const kFIRLoggerWarningCountKey;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/**
* Enables or disables Analytics debug mode.
* If set to YES, the logging level for Analytics will be set to FIRLoggerLevelDebug.
* Enabling the debug mode has no effect if the app is running from App Store.
* (required) analytics debug mode flag.
*/
void FIRSetAnalyticsDebugMode(BOOL analyticsDebugMode);
/**
* Changes the default logging level of FIRLoggerLevelNotice to a user-specified level.
* The default level cannot be set above FIRLoggerLevelNotice if the app is running from App Store.
* (required) log level (one of the FIRLoggerLevel enum values).
*/
void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel);
/**
* Checks if the specified logger level is loggable given the current settings.
* (required) log level (one of the FIRLoggerLevel enum values).
* (required) whether or not this function is called from the Analytics component.
*/
BOOL FIRIsLoggableLevel(FIRLoggerLevel loggerLevel, BOOL analyticsComponent);
/**
* Logs a message to the Xcode console and the device log. If running from AppStore, will
* not log any messages with a level higher than FIRLoggerLevelNotice to avoid log spamming.
* (required) log level (one of the FIRLoggerLevel enum values).
* (required) service name of type FIRLoggerService.
* (required) message code starting with "I-" which means iOS, followed by a capitalized
* three-character service identifier and a six digit integer message ID that is unique
* within the service.
* An example of the message code is @"I-COR000001".
* (required) message string which can be a format string.
* (optional) variable arguments list obtained from calling va_start, used when message is a format
* string.
*/
extern void FIRLogBasic(FIRLoggerLevel level,
FIRLoggerService service,
NSString *messageCode,
NSString *message,
// On 64-bit simulators, va_list is not a pointer, so cannot be marked nullable
// See: http://stackoverflow.com/q/29095469
#if __LP64__ && TARGET_OS_SIMULATOR || TARGET_OS_OSX
va_list args_ptr
#else
va_list _Nullable args_ptr
#endif
);
/**
* The following functions accept the following parameters in order:
* (required) service name of type FIRLoggerService.
* (required) message code starting from "I-" which means iOS, followed by a capitalized
* three-character service identifier and a six digit integer message ID that is unique
* within the service.
* An example of the message code is @"I-COR000001".
* See go/firebase-log-proposal for details.
* (required) message string which can be a format string.
* (optional) the list of arguments to substitute into the format string.
* Example usage:
* FIRLogError(kFIRLoggerCore, @"I-COR000001", @"Configuration of %@ failed.", app.name);
*/
extern void FIRLogError(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
extern void FIRLogWarning(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
extern void FIRLogNotice(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
extern void FIRLogInfo(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
extern void FIRLogDebug(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
@interface FIRLoggerWrapper : NSObject
/**
* Objective-C wrapper for FIRLogBasic to allow weak linking to FIRLogger
* (required) log level (one of the FIRLoggerLevel enum values).
* (required) service name of type FIRLoggerService.
* (required) message code starting with "I-" which means iOS, followed by a capitalized
* three-character service identifier and a six digit integer message ID that is unique
* within the service.
* An example of the message code is @"I-COR000001".
* (required) message string which can be a format string.
* (optional) variable arguments list obtained from calling va_start, used when message is a format
* string.
*/
+ (void)logWithLevel:(FIRLoggerLevel)level
withService:(FIRLoggerService)service
withCode:(NSString *)messageCode
withMessage:(NSString *)message
withArgs:(va_list)args;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,119 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if SWIFT_PACKAGE
// TODO(paulb777): Investigate if there's a common strategy for both Cocoapods and Swift PM.
#import "FIROptions.h"
#else
#import <FirebaseCore/FIROptions.h>
#endif
/**
* Keys for the strings in the plist file.
*/
extern NSString *const kFIRAPIKey;
extern NSString *const kFIRTrackingID;
extern NSString *const kFIRGoogleAppID;
extern NSString *const kFIRClientID;
extern NSString *const kFIRGCMSenderID;
extern NSString *const kFIRAndroidClientID;
extern NSString *const kFIRDatabaseURL;
extern NSString *const kFIRStorageBucket;
extern NSString *const kFIRBundleID;
extern NSString *const kFIRProjectID;
/**
* Keys for the plist file name
*/
extern NSString *const kServiceInfoFileName;
extern NSString *const kServiceInfoFileType;
/**
* This header file exposes the initialization of FIROptions to internal use.
*/
@interface FIROptions ()
/**
* resetDefaultOptions and initInternalWithOptionsDictionary: are exposed only for unit tests.
*/
+ (void)resetDefaultOptions;
/**
* Initializes the options with dictionary. The above strings are the keys of the dictionary.
* This is the designated initializer.
*/
- (instancetype)initInternalWithOptionsDictionary:(NSDictionary *)serviceInfoDictionary;
/**
* defaultOptions and defaultOptionsDictionary are exposed in order to be used in FIRApp and
* other first party services.
*/
+ (FIROptions *)defaultOptions;
+ (NSDictionary *)defaultOptionsDictionary;
/**
* Indicates whether or not Analytics collection was explicitly enabled via a plist flag or at
* runtime.
*/
@property(nonatomic, readonly) BOOL isAnalyticsCollectionExplicitlySet;
/**
* Whether or not Analytics Collection was enabled. Analytics Collection is enabled unless
* explicitly disabled in GoogleService-Info.plist.
*/
@property(nonatomic, readonly) BOOL isAnalyticsCollectionEnabled;
/**
* Whether or not Analytics Collection was completely disabled. If YES, then
* isAnalyticsCollectionEnabled will be NO.
*/
@property(nonatomic, readonly) BOOL isAnalyticsCollectionDeactivated;
/**
* The version ID of the client library, e.g. @"1100000".
*/
@property(nonatomic, readonly, copy) NSString *libraryVersionID;
/**
* The flag indicating whether this object was constructed with the values in the default plist
* file.
*/
@property(nonatomic) BOOL usingOptionsFromDefaultPlist;
/**
* Whether or not Measurement was enabled. Measurement is enabled unless explicitly disabled in
* GoogleService-Info.plist.
*/
@property(nonatomic, readonly) BOOL isMeasurementEnabled;
/**
* Whether or not Analytics was enabled in the developer console.
*/
@property(nonatomic, readonly) BOOL isAnalyticsEnabled;
/**
* Whether or not SignIn was enabled in the developer console.
*/
@property(nonatomic, readonly) BOOL isSignInEnabled;
/**
* Whether or not editing is locked. This should occur after FIROptions has been set on a FIRApp.
*/
@property(nonatomic, getter=isEditingLocked) BOOL editingLocked;
@end

View File

@ -0,0 +1,31 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// An umbrella header, for any other libraries in this repo to access Firebase Public and Private
// headers. Any package manager complexity should be handled here.
#if SWIFT_PACKAGE
@import FirebaseCore;
#else
#import <FirebaseCore/FirebaseCore.h>
#endif
#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
#import "FirebaseCore/Sources/Private/FIRComponent.h"
#import "FirebaseCore/Sources/Private/FIRComponentContainer.h"
#import "FirebaseCore/Sources/Private/FIRDependency.h"
#import "FirebaseCore/Sources/Private/FIRHeartbeatInfo.h"
#import "FirebaseCore/Sources/Private/FIRLibrary.h"
#import "FirebaseCore/Sources/Private/FIRLogger.h"
#import "FirebaseCore/Sources/Private/FIROptionsInternal.h"

View File

@ -41,9 +41,10 @@
+ (NSDictionary *)userInfoWithHTTPResponse:(NSHTTPURLResponse *)HTTPResponse
data:(nullable NSData *)data {
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *failureReason = [NSString
stringWithFormat:@"The server responded with an error. HTTP response: %@\nResponse body: %@",
HTTPResponse, responseString];
NSString *failureReason =
[NSString stringWithFormat:@"The server responded with an error: \n - URL: %@ \n - HTTP "
@"status code: %ld \n - Response body: %@",
HTTPResponse.URL, (long)HTTPResponse.statusCode, responseString];
return @{NSLocalizedFailureReasonErrorKey : failureReason};
}

View File

@ -22,12 +22,7 @@
#import "FBLPromises.h"
#endif
#import <FirebaseCore/FIRAppInternal.h>
#import <FirebaseCore/FIRComponent.h>
#import <FirebaseCore/FIRComponentContainer.h>
#import <FirebaseCore/FIRLibrary.h>
#import <FirebaseCore/FIRLogger.h>
#import <FirebaseCore/FIROptions.h>
#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
#import "FIRInstallationsAuthTokenResultInternal.h"
@ -89,10 +84,12 @@ NS_ASSUME_NONNULL_BEGIN
projectID:appOptions.projectID
GCMSenderID:appOptions.GCMSenderID
accessGroup:appOptions.appGroupID];
// `prefetchAuthToken` is disabled due to b/156746574.
return [self initWithAppOptions:appOptions
appName:appName
installationsIDController:IDController
prefetchAuthToken:YES];
prefetchAuthToken:NO];
}
/// The initializer is supposed to be used by tests to inject `installationsStore`.

View File

@ -16,7 +16,7 @@
#import <Foundation/Foundation.h>
#import <FirebaseCore/FIRLogger.h>
#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
extern FIRLoggerService kFIRLoggerInstallations;

View File

@ -24,11 +24,10 @@
#import "FBLPromises.h"
#endif
#import <FirebaseCore/FIRAppInternal.h>
#import <FirebaseCore/FIRHeartbeatInfo.h>
#import "FIRInstallationsErrorUtil.h"
#import "FIRInstallationsItem+RegisterInstallationAPI.h"
#import "FIRInstallationsLogger.h"
#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
NSString *const kFIRInstallationsAPIBaseURL = @"https://firebaseinstallations.googleapis.com";
NSString *const kFIRInstallationsAPIKey = @"X-Goog-Api-Key";

View File

@ -22,8 +22,8 @@
#import "FBLPromises.h"
#endif
#import <FirebaseCore/FIRAppInternal.h>
#import <GoogleUtilities/GULKeychainStorage.h>
#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
#import "FIRInstallationsAPIService.h"
#import "FIRInstallationsErrorUtil.h"
@ -44,6 +44,8 @@ NSString *const kFIRInstallationIDDidChangeNotificationAppNameKey =
NSTimeInterval const kFIRInstallationsTokenExpirationThreshold = 60 * 60; // 1 hour.
static NSString *const kKeychainService = @"com.firebase.FIRInstallations.installations";
@interface FIRInstallationsIDController ()
@property(nonatomic, readonly) NSString *appID;
@property(nonatomic, readonly) NSString *appName;
@ -71,9 +73,9 @@ NSTimeInterval const kFIRInstallationsTokenExpirationThreshold = 60 * 60; // 1
APIKey:(NSString *)APIKey
projectID:(NSString *)projectID
GCMSenderID:(NSString *)GCMSenderID
accessGroup:(NSString *)accessGroup {
GULKeychainStorage *secureStorage =
[[GULKeychainStorage alloc] initWithService:@"com.firebase.FIRInstallations.installations"];
accessGroup:(nullable NSString *)accessGroup {
NSString *serviceName = [FIRInstallationsIDController keychainServiceWithAppID:appID];
GULKeychainStorage *secureStorage = [[GULKeychainStorage alloc] initWithService:serviceName];
FIRInstallationsStore *installationsStore =
[[FIRInstallationsStore alloc] initWithSecureStorage:secureStorage accessGroup:accessGroup];
@ -256,9 +258,9 @@ NSTimeInterval const kFIRInstallationsTokenExpirationThreshold = 60 * 60; // 1
if ([self doesRegistrationErrorRequireConfigChange:error]) {
FIRLogError(kFIRLoggerInstallations,
kFIRInstallationsMessageCodeInvalidFirebaseConfiguration,
@"Firebase Installation registration failed for app with name: %@, error: "
@"Firebase Installation registration failed for app with name: %@, error:\n"
@"%@\nPlease make sure you use valid GoogleService-Info.plist",
self.appName, error);
self.appName, error.userInfo[NSLocalizedFailureReasonErrorKey]);
}
})
.then(^id(FIRInstallationsItem *registeredInstallation) {
@ -456,4 +458,23 @@ NSTimeInterval const kFIRInstallationsTokenExpirationThreshold = 60 * 60; // 1
return [self.appName isEqualToString:kFIRDefaultAppName];
}
#pragma mark - Keychain
+ (NSString *)keychainServiceWithAppID:(NSString *)appID {
#if TARGET_OS_MACCATALYST || TARGET_OS_OSX
// We need to keep service name unique per application on macOS.
// Applications on macOS may request access to Keychain items stored by other applications. It
// means that when the app looks up for a relevant Keychain item in the service scope it will
// request user password to grant access to the Keychain if there are other Keychain items from
// other applications stored under the same Keychain Service.
return [kKeychainService stringByAppendingFormat:@".%@", appID];
#else
// Use a constant Keychain service for non-macOS because:
// 1. Keychain items cannot be shared between apps until configured specifically so the service
// name collisions are not a concern
// 2. We don't want to change the service name to avoid doing a migration.
return kKeychainService;
#endif
}
@end

View File

@ -1,18 +1,29 @@
# Firebase iOS Open Source Development
[![Actions Status][gh-auth-badge]][gh-actions]
[![Actions Status][gh-core-badge]][gh-actions]
[![Actions Status][gh-datatransport-badge]][gh-actions]
[![Actions Status][gh-dynamiclinks-badge]][gh-actions]
[![Actions Status][gh-firebasepod-badge]][gh-actions]
[![Actions Status][gh-firestore-badge]][gh-actions]
[![Actions Status][gh-interop-badge]][gh-actions]
[![Actions Status][gh-messaging-badge]][gh-actions]
[![Actions Status][gh-storage-badge]][gh-actions]
[![Actions Status][gh-symbolcollision-badge]][gh-actions]
[![Actions Status][gh-zip-badge]][gh-actions]
[![Travis](https://travis-ci.org/firebase/firebase-ios-sdk.svg?branch=master)](https://travis-ci.org/firebase/firebase-ios-sdk)
[![Version](https://img.shields.io/cocoapods/v/Firebase.svg?style=flat)](https://cocoapods.org/pods/Firebase)
[![License](https://img.shields.io/cocoapods/l/Firebase.svg?style=flat)](https://cocoapods.org/pods/Firebase)
[![Platform](https://img.shields.io/cocoapods/p/Firebase.svg?style=flat)](https://cocoapods.org/pods/Firebase)
This repository contains all Firebase iOS SDK source except FirebaseAnalytics,
[![Actions Status][gh-abtesting-badge]][gh-actions]
[![Actions Status][gh-auth-badge]][gh-actions]
[![Actions Status][gh-core-badge]][gh-actions]
[![Actions Status][gh-crashlytics-badge]][gh-actions]
[![Actions Status][gh-database-badge]][gh-actions]
[![Actions Status][gh-datatransport-badge]][gh-actions]
[![Actions Status][gh-dynamiclinks-badge]][gh-actions]
[![Actions Status][gh-firebasepod-badge]][gh-actions]
[![Actions Status][gh-firestore-badge]][gh-actions]
[![Actions Status][gh-functions-badge]][gh-actions]
[![Actions Status][gh-inappmessaging-badge]][gh-actions]
[![Actions Status][gh-interop-badge]][gh-actions]
[![Actions Status][gh-messaging-badge]][gh-actions]
[![Actions Status][gh-remoteconfig-badge]][gh-actions]
[![Actions Status][gh-storage-badge]][gh-actions]
[![Actions Status][gh-symbolcollision-badge]][gh-actions]
[![Actions Status][gh-zip-badge]][gh-actions]
[![Travis](https://travis-ci.org/firebase/firebase-ios-sdk.svg?branch=master)](https://travis-ci.org/firebase/firebase-ios-sdk)
# Firebase Apple Open Source Development
This repository contains all Apple platform Firebase SDK source except FirebaseAnalytics,
FirebasePerformance, and FirebaseML.
The repository also includes GoogleUtilities source. The
@ -87,7 +98,7 @@ Instructions for installing binary frameworks via
To develop Firebase software in this repository, ensure that you have at least
the following software:
* Xcode 10.1 (or later)
* Xcode 10.3 (or later)
* CocoaPods 1.7.2 (or later)
* [CocoaPods generate](https://github.com/square/cocoapods-generate)
@ -118,6 +129,10 @@ Firestore has a self contained Xcode project. See
See [AddNewPod.md](AddNewPod.md).
### Managing Headers and Imports
See [HeadersImports.md](HeadersImports.md).
### Code Formatting
To ensure that the code is formatted consistently, run the script
@ -180,8 +195,16 @@ building and running the FirebaseAuth pod along with various samples and tests.
### Firebase Database
To run the Database Integration tests, make your database authentication rules
[public](https://firebase.google.com/docs/database/security/quickstart).
The Firebase Database Integration tests can be run against a locally running Database Emulator
or against a production instance.
To run against a local emulator instance, invoke `./scripts/run_database_emulator.sh start` before
running the integration test.
To run against a production instance, provide a valid GoogleServices-Info.plist and copy it to
`Example/Database/App/GoogleService-Info.plist`. Your Security Rule must be set to
[public](https://firebase.google.com/docs/database/security/quickstart) while your tests are
running.
### Firebase Storage
@ -269,14 +292,20 @@ Your use of Firebase is governed by the
[Terms of Service for Firebase Services](https://firebase.google.com/terms/).
[gh-actions]: https://github.com/firebase/firebase-ios-sdk/actions
[gh-abtesting-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/abtesting/badge.svg
[gh-auth-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/auth/badge.svg
[gh-core-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/core/badge.svg
[gh-crashlytics-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/crashlytics/badge.svg
[gh-database-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/database/badge.svg
[gh-datatransport-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/datatransport/badge.svg
[gh-dynamiclinks-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/dynamiclinks/badge.svg
[gh-firebasepod-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/firebasepod/badge.svg
[gh-firestore-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/firestore/badge.svg
[gh-functions-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/functions/badge.svg
[gh-inappmessaging-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/inappmessaging/badge.svg
[gh-interop-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/interop/badge.svg
[gh-messaging-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/messaging/badge.svg
[gh-remoteconfig-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/remoteconfig/badge.svg
[gh-storage-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/storage/badge.svg
[gh-symbolcollision-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/symbolcollision/badge.svg
[gh-zip-badge]: https://github.com/firebase/firebase-ios-sdk/workflows/zip/badge.svg

23
ios/Pods/Folly/LICENSE generated
View File

@ -175,3 +175,26 @@
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Files in folly/external/farmhash licensed as follows
Copyright (c) 2014 Google, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -66,13 +66,13 @@ is to look at the headers in [top level `folly/` directory](https://github.com/f
check the [`docs` folder](folly/docs) for documentation, starting with the
[overview](folly/docs/Overview.md).
Folly is published on Github at https://github.com/facebook/folly
Folly is published on GitHub at https://github.com/facebook/folly
### Build Notes
#### Dependencies
folly requires gcc 4.9+ and a version of boost compiled with C++14 support.
folly requires gcc 5.1+ and a version of boost compiled with C++14 support.
googletest is required to build and run folly's tests. You can download
it from https://github.com/google/googletest/archive/release-1.8.0.tar.gz
@ -104,6 +104,11 @@ cmake \
-DCMAKE_LIBRARY_PATH=/alt/lib/path1:/alt/lib/path2 ...
```
#### Building tests
By default, building the tests is disabled as part of the CMake `all` target.
To build the tests, specify `-DBUILD_TESTS=ON` to CMake at configure time.
#### Ubuntu 16.04 LTS
The following packages are required (feel free to cut and paste the apt-get
@ -127,7 +132,21 @@ sudo apt-get install \
binutils-dev \
libjemalloc-dev \
libssl-dev \
pkg-config
pkg-config \
libunwind-dev
```
Folly relies on [fmt](https://github.com/fmtlib/fmt) which needs to be installed from source.
The following commands will download, compile, and install fmt.
```
git clone https://github.com/fmtlib/fmt.git && cd fmt
mkdir _build && cd _build
cmake ..
make -j$(nproc)
sudo make install
```
If advanced debugging functionality is required, use:
@ -139,12 +158,12 @@ sudo apt-get install \
libdwarf-dev
```
In the folly directory, run:
In the folly directory (e.g. the checkout root or the archive unpack root), run:
```
mkdir _build && cd _build
cmake ..
make -j $(nproc)
make install
make install # with either sudo or DESTDIR as necessary
```
#### OS X (Homebrew)
@ -154,19 +173,19 @@ folly is available as a Formula and releases may be built via `brew install foll
You may also use `folly/build/bootstrap-osx-homebrew.sh` to build against `master`:
```
cd folly
./build/bootstrap-osx-homebrew.sh
./folly/build/bootstrap-osx-homebrew.sh
```
This will create a build directory `_build` in the top-level.
#### OS X (MacPorts)
Install the required packages from MacPorts:
```
sudo port install \
autoconf \
automake \
boost \
cmake \
gflags \
git \
google-glog \
@ -174,8 +193,9 @@ Install the required packages from MacPorts:
libtool \
lz4 \
lzma \
scons \
openssl \
snappy \
xz \
zlib
```
@ -193,9 +213,10 @@ Download and install folly with the parameters listed below:
```
git clone https://github.com/facebook/folly.git
cd folly/folly
autoreconf -ivf
./configure CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib"
cd folly
mkdir _build
cd _build
cmake ..
make
sudo make install
```

View File

@ -1,11 +1,11 @@
/*
* Copyright 2012-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -21,7 +21,9 @@
#include <type_traits>
#include <folly/detail/AtomicHashUtils.h>
#include <folly/detail/Iterators.h>
#include <folly/lang/Bits.h>
#include <folly/lang/Exception.h>
namespace folly {
@ -58,7 +60,11 @@ AtomicHashArray<
numEntries_(0, cacheSize),
numPendingEntries_(0, cacheSize),
isFull_(0),
numErases_(0) {}
numErases_(0) {
if (capacity == 0) {
throw_exception<std::invalid_argument>("capacity");
}
}
/*
* findInternal --
@ -480,10 +486,10 @@ struct AtomicHashArray<
Allocator,
ProbeFcn,
KeyConvertFcn>::aha_iterator
: boost::iterator_facade<
: detail::IteratorFacade<
aha_iterator<ContT, IterVal>,
IterVal,
boost::forward_traversal_tag> {
std::forward_iterator_tag> {
explicit aha_iterator() : aha_(nullptr) {}
// Conversion ctor for interoperability between const_iterator and
@ -514,7 +520,8 @@ struct AtomicHashArray<
private:
friend class AtomicHashArray;
friend class boost::iterator_core_access;
friend class detail::
IteratorFacade<aha_iterator, IterVal, std::forward_iterator_tag>;
void increment() {
++offset_;

View File

@ -1,11 +1,11 @@
/*
* Copyright 2012-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -34,9 +34,6 @@
#include <atomic>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/noncopyable.hpp>
#include <folly/ThreadCachedInt.h>
#include <folly/Utility.h>
#include <folly/hash/Hash.h>
@ -102,7 +99,7 @@ template <
class Allocator = std::allocator<char>,
class ProbeFcn = AtomicHashArrayLinearProbeFcn,
class KeyConvertFcn = Identity>
class AtomicHashArray : boost::noncopyable {
class AtomicHashArray {
static_assert(
(std::is_convertible<KeyT, int32_t>::value ||
std::is_convertible<KeyT, int64_t>::value ||
@ -422,6 +419,9 @@ class AtomicHashArray : boost::noncopyable {
double maxLoadFactor,
uint32_t cacheSize);
AtomicHashArray(const AtomicHashArray&) = delete;
AtomicHashArray& operator=(const AtomicHashArray&) = delete;
~AtomicHashArray() = default;
inline void unlockCell(value_type* const cell, KeyT newKey) {

View File

@ -1,11 +1,11 @@
/*
* Copyright 2012-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -19,6 +19,9 @@
#endif
#include <folly/detail/AtomicHashUtils.h>
#include <folly/detail/Iterators.h>
#include <type_traits>
namespace folly {
@ -566,10 +569,10 @@ struct AtomicHashMap<
Allocator,
ProbeFcn,
KeyConvertFcn>::ahm_iterator
: boost::iterator_facade<
: detail::IteratorFacade<
ahm_iterator<ContT, IterVal, SubIt>,
IterVal,
boost::forward_traversal_tag> {
std::forward_iterator_tag> {
explicit ahm_iterator() : ahm_(nullptr) {}
// Conversion ctor for interoperability between const_iterator and
@ -596,7 +599,8 @@ struct AtomicHashMap<
explicit ahm_iterator(ContT* ahm, uint32_t subMap, const SubIt& subIt)
: ahm_(ahm), subMap_(subMap), subIt_(subIt) {}
friend class boost::iterator_core_access;
friend class detail::
IteratorFacade<ahm_iterator, IterVal, std::forward_iterator_tag>;
void increment() {
CHECK(!isEnd());

View File

@ -1,11 +1,11 @@
/*
* Copyright 2012-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* AtomicHashMap --
*
@ -81,10 +82,6 @@
#pragma once
#define FOLLY_ATOMICHASHMAP_H_
#include <boost/iterator/iterator_facade.hpp>
#include <boost/noncopyable.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <atomic>
#include <functional>
#include <stdexcept>
@ -162,7 +159,7 @@ template <
class Allocator,
class ProbeFcn,
class KeyConvertFcn>
class AtomicHashMap : boost::noncopyable {
class AtomicHashMap {
typedef AtomicHashArray<
KeyT,
ValueT,
@ -206,6 +203,9 @@ class AtomicHashMap : boost::noncopyable {
// and a Config object to specify more advanced options.
explicit AtomicHashMap(size_t finalSizeEst, const Config& c = Config());
AtomicHashMap(const AtomicHashMap&) = delete;
AtomicHashMap& operator=(const AtomicHashMap&) = delete;
~AtomicHashMap() {
const unsigned int numMaps =
numMapsAllocated_.load(std::memory_order_relaxed);

View File

@ -1,11 +1,11 @@
/*
* Copyright 2014-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,11 +1,11 @@
/*
* Copyright 2014-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,11 +1,11 @@
/*
* Copyright 2013-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -24,11 +24,10 @@
#include <system_error>
#include <type_traits>
#include <boost/type_traits/has_trivial_destructor.hpp>
#include <folly/Conv.h>
#include <folly/Likely.h>
#include <folly/Random.h>
#include <folly/Traits.h>
#include <folly/detail/AtomicUnorderedMapUtils.h>
#include <folly/lang/Bits.h>
#include <folly/portability/SysMman.h>
@ -135,8 +134,8 @@ template <
typename Hash = std::hash<Key>,
typename KeyEqual = std::equal_to<Key>,
bool SkipKeyValueDeletion =
(boost::has_trivial_destructor<Key>::value &&
boost::has_trivial_destructor<Value>::value),
(std::is_trivially_destructible<Key>::value &&
std::is_trivially_destructible<Value>::value),
template <typename> class Atom = std::atomic,
typename IndexType = uint32_t,
typename Allocator = folly::detail::MMapAlloc>
@ -362,8 +361,7 @@ struct AtomicUnorderedInsertMap {
IndexType next_;
/// Key and Value
typename std::aligned_storage<sizeof(value_type), alignof(value_type)>::type
raw_;
aligned_storage_for_t<value_type> raw_;
~Slot() {
auto s = state();
@ -463,7 +461,7 @@ struct AtomicUnorderedInsertMap {
void zeroFillSlots() {
using folly::detail::GivesZeroFilledMemory;
if (!GivesZeroFilledMemory<Allocator>::value) {
memset(slots_, 0, mmapRequested_);
memset(static_cast<void*>(slots_), 0, mmapRequested_);
}
}
};
@ -478,8 +476,8 @@ template <
typename Hash = std::hash<Key>,
typename KeyEqual = std::equal_to<Key>,
bool SkipKeyValueDeletion =
(boost::has_trivial_destructor<Key>::value &&
boost::has_trivial_destructor<Value>::value),
(std::is_trivially_destructible<Key>::value &&
std::is_trivially_destructible<Value>::value),
template <typename> class Atom = std::atomic,
typename Allocator = folly::detail::MMapAlloc>
using AtomicUnorderedInsertMap64 = AtomicUnorderedInsertMap<

View File

@ -1,11 +1,11 @@
/*
* Copyright 2012-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -28,6 +28,7 @@
#include <functional>
#include <limits>
#include <type_traits>
#include <unordered_map>
#include <boost/function_types/function_arity.hpp>
#include <glog/logging.h>
@ -52,22 +53,41 @@ inline bool runBenchmarksOnFlag() {
return FLAGS_benchmark;
}
namespace detail {
class UserMetric {
public:
enum class Type { CUSTOM, TIME, METRIC };
using TimeIterPair =
std::pair<std::chrono::high_resolution_clock::duration, unsigned int>;
using BenchmarkFun = std::function<detail::TimeIterPair(unsigned int)>;
int64_t value{};
Type type{Type::CUSTOM};
UserMetric() = default;
/* implicit */ UserMetric(int64_t val, Type typ = Type::CUSTOM)
: value(val), type(typ) {}
};
using UserCounters = std::unordered_map<std::string, UserMetric>;
namespace detail {
struct TimeIterData {
std::chrono::high_resolution_clock::duration duration;
unsigned int niter;
UserCounters userCounters;
};
using BenchmarkFun = std::function<TimeIterData(unsigned int)>;
struct BenchmarkRegistration {
std::string file;
std::string name;
BenchmarkFun func;
bool useCounter = false;
};
struct BenchmarkResult {
std::string file;
std::string name;
double timeInNs;
UserCounters counters;
};
/**
@ -77,7 +97,8 @@ struct BenchmarkResult {
void addBenchmarkImpl(
const char* file,
const char* name,
std::function<TimeIterPair(unsigned int)>);
BenchmarkFun,
bool useCounter);
} // namespace detail
@ -166,9 +187,7 @@ struct BenchmarkSuspender {
* function).
*/
template <typename Lambda>
typename std::enable_if<
boost::function_types::function_arity<
decltype(&Lambda::operator())>::value == 2>::type
typename std::enable_if<folly::is_invocable<Lambda, unsigned>::value>::type
addBenchmark(const char* file, const char* name, Lambda&& lambda) {
auto execute = [=](unsigned int times) {
BenchmarkSuspender::timeSpent = {};
@ -179,13 +198,11 @@ addBenchmark(const char* file, const char* name, Lambda&& lambda) {
niter = lambda(times);
auto end = std::chrono::high_resolution_clock::now();
// CORE MEASUREMENT ENDS
return detail::TimeIterPair(
(end - start) - BenchmarkSuspender::timeSpent, niter);
return detail::TimeIterData{
(end - start) - BenchmarkSuspender::timeSpent, niter, UserCounters{}};
};
detail::addBenchmarkImpl(
file, name, std::function<detail::TimeIterPair(unsigned int)>(execute));
detail::addBenchmarkImpl(file, name, detail::BenchmarkFun(execute), false);
}
/**
@ -195,9 +212,7 @@ addBenchmark(const char* file, const char* name, Lambda&& lambda) {
* (iteration occurs outside the function).
*/
template <typename Lambda>
typename std::enable_if<
boost::function_types::function_arity<
decltype(&Lambda::operator())>::value == 1>::type
typename std::enable_if<folly::is_invocable<Lambda>::value>::type
addBenchmark(const char* file, const char* name, Lambda&& lambda) {
addBenchmark(file, name, [=](unsigned int times) {
unsigned int niter = 0;
@ -208,6 +223,47 @@ addBenchmark(const char* file, const char* name, Lambda&& lambda) {
});
}
/**
* similar as previous two template specialization, but lambda will also take
* customized counters in the following two cases
*/
template <typename Lambda>
typename std::enable_if<
folly::is_invocable<Lambda, UserCounters&, unsigned>::value>::type
addBenchmark(const char* file, const char* name, Lambda&& lambda) {
auto execute = [=](unsigned int times) {
BenchmarkSuspender::timeSpent = {};
unsigned int niter;
// CORE MEASUREMENT STARTS
auto start = std::chrono::high_resolution_clock::now();
UserCounters counters;
niter = lambda(counters, times);
auto end = std::chrono::high_resolution_clock::now();
// CORE MEASUREMENT ENDS
return detail::TimeIterData{
(end - start) - BenchmarkSuspender::timeSpent, niter, counters};
};
detail::addBenchmarkImpl(
file,
name,
std::function<detail::TimeIterData(unsigned int)>(execute),
true);
}
template <typename Lambda>
typename std::enable_if<folly::is_invocable<Lambda, UserCounters&>::value>::type
addBenchmark(const char* file, const char* name, Lambda&& lambda) {
addBenchmark(file, name, [=](UserCounters& counters, unsigned int times) {
unsigned int niter = 0;
while (times-- > 0) {
niter += lambda(counters);
}
return niter;
});
}
/**
* Call doNotOptimizeAway(var) to ensure that var will be computed even
* post-optimization. Use it for variables that are computed during
@ -315,32 +371,50 @@ void printResultComparison(
* Introduces a benchmark function. Used internally, see BENCHMARK and
* friends below.
*/
#define BENCHMARK_IMPL(funName, stringName, rv, paramType, paramName) \
static void funName(paramType); \
static bool FB_ANONYMOUS_VARIABLE(follyBenchmarkUnused) = \
(::folly::addBenchmark( \
__FILE__, \
stringName, \
[](paramType paramName) -> unsigned { \
funName(paramName); \
return rv; \
}), \
true); \
#define BENCHMARK_IMPL(funName, stringName, rv, paramType, paramName) \
static void funName(paramType); \
FOLLY_MAYBE_UNUSED static bool FB_ANONYMOUS_VARIABLE(follyBenchmarkUnused) = \
(::folly::addBenchmark( \
__FILE__, \
stringName, \
[](paramType paramName) -> unsigned { \
funName(paramName); \
return rv; \
}), \
true); \
static void funName(paramType paramName)
#define BENCHMARK_IMPL_COUNTERS( \
funName, stringName, counters, rv, paramType, paramName) \
static void funName( \
::folly::UserCounters& FOLLY_PP_DETAIL_APPEND_VA_ARG(paramType)); \
FOLLY_MAYBE_UNUSED static bool FB_ANONYMOUS_VARIABLE(follyBenchmarkUnused) = \
(::folly::addBenchmark( \
__FILE__, \
stringName, \
[](::folly::UserCounters& counters FOLLY_PP_DETAIL_APPEND_VA_ARG( \
paramType paramName)) -> unsigned { \
funName(counters FOLLY_PP_DETAIL_APPEND_VA_ARG(paramName)); \
return rv; \
}), \
true); \
static void funName(::folly::UserCounters& counters \
FOLLY_PP_DETAIL_APPEND_VA_ARG(paramType paramName))
/**
* Introduces a benchmark function with support for returning the actual
* number of iterations. Used internally, see BENCHMARK_MULTI and friends
* below.
*/
#define BENCHMARK_MULTI_IMPL(funName, stringName, paramType, paramName) \
static unsigned funName(paramType); \
static bool FB_ANONYMOUS_VARIABLE(follyBenchmarkUnused) = \
(::folly::addBenchmark( \
__FILE__, \
stringName, \
[](paramType paramName) { return funName(paramName); }), \
true); \
#define BENCHMARK_MULTI_IMPL(funName, stringName, paramType, paramName) \
static unsigned funName(paramType); \
FOLLY_MAYBE_UNUSED static bool FB_ANONYMOUS_VARIABLE(follyBenchmarkUnused) = \
(::folly::addBenchmark( \
__FILE__, \
stringName, \
[](paramType paramName) { return funName(paramName); }), \
true); \
static unsigned funName(paramType paramName)
/**
@ -355,9 +429,9 @@ void printResultComparison(
* v.push_back(42);
* }
*
* BENCHMARK(insertVectorBegin, n) {
* BENCHMARK(insertVectorBegin, iters) {
* vector<int> v;
* FOR_EACH_RANGE (i, 0, n) {
* FOR_EACH_RANGE (i, 0, iters) {
* v.insert(v.begin(), 42);
* }
* }
@ -365,11 +439,33 @@ void printResultComparison(
#define BENCHMARK(name, ...) \
BENCHMARK_IMPL( \
name, \
FB_STRINGIZE(name), \
FOLLY_PP_STRINGIZE(name), \
FB_ARG_2_OR_1(1, ##__VA_ARGS__), \
FB_ONE_OR_NONE(unsigned, ##__VA_ARGS__), \
__VA_ARGS__)
/**
* Allow users to record customized counter during benchmarking,
* there will be one extra column showing in the output result for each counter
*
* BENCHMARK_COUNTERS(insertVectorBegin, couters, iters) {
* vector<int> v;
* FOR_EACH_RANGE (i, 0, iters) {
* v.insert(v.begin(), 42);
* }
* BENCHMARK_SUSPEND {
* counters["foo"] = 10;
* }
* }
*/
#define BENCHMARK_COUNTERS(name, counters, ...) \
BENCHMARK_IMPL_COUNTERS( \
name, \
FOLLY_PP_STRINGIZE(name), \
counters, \
FB_ARG_2_OR_1(1, ##__VA_ARGS__), \
FB_ONE_OR_NONE(unsigned, ##__VA_ARGS__), \
__VA_ARGS__)
/**
* Like BENCHMARK above, but allows the user to return the actual
* number of iterations executed in the function body. This can be
@ -388,7 +484,7 @@ void printResultComparison(
#define BENCHMARK_MULTI(name, ...) \
BENCHMARK_MULTI_IMPL( \
name, \
FB_STRINGIZE(name), \
FOLLY_PP_STRINGIZE(name), \
FB_ONE_OR_NONE(unsigned, ##__VA_ARGS__), \
__VA_ARGS__)
@ -446,27 +542,27 @@ void printResultComparison(
* BENCHMARK_NAMED_PARAM(addValue, 0_to_1000, 10, 0, 1000)
* BENCHMARK_NAMED_PARAM(addValue, 5k_to_20k, 250, 5000, 20000)
*/
#define BENCHMARK_NAMED_PARAM(name, param_name, ...) \
BENCHMARK_IMPL( \
FB_CONCATENATE(name, FB_CONCATENATE(_, param_name)), \
FB_STRINGIZE(name) "(" FB_STRINGIZE(param_name) ")", \
iters, \
unsigned, \
iters) { \
name(iters, ##__VA_ARGS__); \
#define BENCHMARK_NAMED_PARAM(name, param_name, ...) \
BENCHMARK_IMPL( \
FB_CONCATENATE(name, FB_CONCATENATE(_, param_name)), \
FOLLY_PP_STRINGIZE(name) "(" FOLLY_PP_STRINGIZE(param_name) ")", \
iters, \
unsigned, \
iters) { \
name(iters, ##__VA_ARGS__); \
}
/**
* Same as BENCHMARK_NAMED_PARAM, but allows one to return the actual number
* of iterations that have been run.
*/
#define BENCHMARK_NAMED_PARAM_MULTI(name, param_name, ...) \
BENCHMARK_MULTI_IMPL( \
FB_CONCATENATE(name, FB_CONCATENATE(_, param_name)), \
FB_STRINGIZE(name) "(" FB_STRINGIZE(param_name) ")", \
unsigned, \
iters) { \
return name(iters, ##__VA_ARGS__); \
#define BENCHMARK_NAMED_PARAM_MULTI(name, param_name, ...) \
BENCHMARK_MULTI_IMPL( \
FB_CONCATENATE(name, FB_CONCATENATE(_, param_name)), \
FOLLY_PP_STRINGIZE(name) "(" FOLLY_PP_STRINGIZE(param_name) ")", \
unsigned, \
iters) { \
return name(iters, ##__VA_ARGS__); \
}
/**
@ -496,11 +592,19 @@ void printResultComparison(
#define BENCHMARK_RELATIVE(name, ...) \
BENCHMARK_IMPL( \
name, \
"%" FB_STRINGIZE(name), \
"%" FOLLY_PP_STRINGIZE(name), \
FB_ARG_2_OR_1(1, ##__VA_ARGS__), \
FB_ONE_OR_NONE(unsigned, ##__VA_ARGS__), \
__VA_ARGS__)
#define BENCHMARK_COUNTERS_RELATIVE(name, counters, ...) \
BENCHMARK_IMPL_COUNTERS( \
name, \
"%" FOLLY_PP_STRINGIZE(name), \
counters, \
FB_ARG_2_OR_1(1, ##__VA_ARGS__), \
FB_ONE_OR_NONE(unsigned, ##__VA_ARGS__), \
__VA_ARGS__)
/**
* Same as BENCHMARK_RELATIVE, but allows one to return the actual number
* of iterations that have been run.
@ -508,7 +612,7 @@ void printResultComparison(
#define BENCHMARK_RELATIVE_MULTI(name, ...) \
BENCHMARK_MULTI_IMPL( \
name, \
"%" FB_STRINGIZE(name), \
"%" FOLLY_PP_STRINGIZE(name), \
FB_ONE_OR_NONE(unsigned, ##__VA_ARGS__), \
__VA_ARGS__)
@ -528,35 +632,35 @@ void printResultComparison(
/**
* A combination of BENCHMARK_RELATIVE and BENCHMARK_NAMED_PARAM.
*/
#define BENCHMARK_RELATIVE_NAMED_PARAM(name, param_name, ...) \
BENCHMARK_IMPL( \
FB_CONCATENATE(name, FB_CONCATENATE(_, param_name)), \
"%" FB_STRINGIZE(name) "(" FB_STRINGIZE(param_name) ")", \
iters, \
unsigned, \
iters) { \
name(iters, ##__VA_ARGS__); \
#define BENCHMARK_RELATIVE_NAMED_PARAM(name, param_name, ...) \
BENCHMARK_IMPL( \
FB_CONCATENATE(name, FB_CONCATENATE(_, param_name)), \
"%" FOLLY_PP_STRINGIZE(name) "(" FOLLY_PP_STRINGIZE(param_name) ")", \
iters, \
unsigned, \
iters) { \
name(iters, ##__VA_ARGS__); \
}
/**
* Same as BENCHMARK_RELATIVE_NAMED_PARAM, but allows one to return the
* actual number of iterations that have been run.
*/
#define BENCHMARK_RELATIVE_NAMED_PARAM_MULTI(name, param_name, ...) \
BENCHMARK_MULTI_IMPL( \
FB_CONCATENATE(name, FB_CONCATENATE(_, param_name)), \
"%" FB_STRINGIZE(name) "(" FB_STRINGIZE(param_name) ")", \
unsigned, \
iters) { \
return name(iters, ##__VA_ARGS__); \
#define BENCHMARK_RELATIVE_NAMED_PARAM_MULTI(name, param_name, ...) \
BENCHMARK_MULTI_IMPL( \
FB_CONCATENATE(name, FB_CONCATENATE(_, param_name)), \
"%" FOLLY_PP_STRINGIZE(name) "(" FOLLY_PP_STRINGIZE(param_name) ")", \
unsigned, \
iters) { \
return name(iters, ##__VA_ARGS__); \
}
/**
* Draws a line of dashes.
*/
#define BENCHMARK_DRAW_LINE() \
static bool FB_ANONYMOUS_VARIABLE(follyBenchmarkUnused) = \
(::folly::addBenchmark(__FILE__, "-", []() -> unsigned { return 0; }), \
#define BENCHMARK_DRAW_LINE() \
FOLLY_MAYBE_UNUSED static bool FB_ANONYMOUS_VARIABLE(follyBenchmarkUnused) = \
(::folly::addBenchmark(__FILE__, "-", []() -> unsigned { return 0; }), \
true)
/**

View File

@ -1,11 +1,11 @@
/*
* Copyright 2011-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,11 +1,11 @@
/*
* Copyright 2013-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -68,12 +68,14 @@
* itself was compiled without ASAN but a downstream project that uses folly is
* compiling with ASAN enabled.
*
* Use FOLLY_ASAN_ENABLED (defined in folly-config.h) to check if folly itself
* was compiled with ASAN enabled.
* Use FOLLY_LIBRARY_SANITIZE_ADDRESS (defined in folly-config.h) to check if
* folly itself was compiled with ASAN enabled.
*/
#ifndef FOLLY_SANITIZE_ADDRESS
#if FOLLY_HAS_FEATURE(address_sanitizer) || __SANITIZE_ADDRESS__
#define FOLLY_SANITIZE_ADDRESS 1
#endif
#endif
/* Define attribute wrapper for function attribute used to disable
* address sanitizer instrumentation. Unfortunately, this attribute
@ -101,17 +103,46 @@
/* Define a convenience macro to test when thread sanitizer is being used
* across the different compilers (e.g. clang, gcc) */
#ifndef FOLLY_SANITIZE_THREAD
#if FOLLY_HAS_FEATURE(thread_sanitizer) || __SANITIZE_THREAD__
#define FOLLY_SANITIZE_THREAD 1
#endif
#endif
#if FOLLY_SANITIZE_THREAD
#define FOLLY_DISABLE_THREAD_SANITIZER \
__attribute__((no_sanitize_thread, noinline))
#else
#define FOLLY_DISABLE_THREAD_SANITIZER
#endif
/**
* Define a convenience macro to test when ASAN, UBSAN or TSAN sanitizer are
* being used
* Define a convenience macro to test when memory sanitizer is being used
* across the different compilers (e.g. clang, gcc)
*/
#if defined(FOLLY_SANITIZE_ADDRESS) || defined(FOLLY_SANITIZE_THREAD)
#ifndef FOLLY_SANITIZE_MEMORY
#if FOLLY_HAS_FEATURE(memory_sanitizer) || __SANITIZE_MEMORY__
#define FOLLY_SANITIZE_MEMORY 1
#endif
#endif
#if FOLLY_SANITIZE_MEMORY
#define FOLLY_DISABLE_MEMORY_SANITIZER \
__attribute__((no_sanitize_memory, noinline))
#else
#define FOLLY_DISABLE_MEMORY_SANITIZER
#endif
/**
* Define a convenience macro to test when ASAN, UBSAN, TSAN or MSAN sanitizer
* are being used
*/
#ifndef FOLLY_SANITIZE
#if defined(FOLLY_SANITIZE_ADDRESS) || defined(FOLLY_SANITIZE_THREAD) || \
defined(FOLLY_SANITIZE_MEMORY)
#define FOLLY_SANITIZE 1
#endif
#endif
#if FOLLY_SANITIZE
#define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(...) \
@ -120,15 +151,15 @@
#define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(...)
#endif // FOLLY_SANITIZE
#define FOLLY_DISABLE_SANITIZERS \
FOLLY_DISABLE_ADDRESS_SANITIZER FOLLY_DISABLE_THREAD_SANITIZER \
FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("undefined")
/**
* Macro for marking functions as having public visibility.
*/
#if defined(__GNUC__)
#if __GNUC_PREREQ(4, 9)
#define FOLLY_EXPORT [[gnu::visibility("default")]]
#else
#define FOLLY_EXPORT __attribute__((__visibility__("default")))
#endif
#else
#define FOLLY_EXPORT
#endif
@ -136,7 +167,7 @@
// noinline
#ifdef _MSC_VER
#define FOLLY_NOINLINE __declspec(noinline)
#elif defined(__clang__) || defined(__GNUC__)
#elif defined(__GNUC__)
#define FOLLY_NOINLINE __attribute__((__noinline__))
#else
#define FOLLY_NOINLINE
@ -145,16 +176,16 @@
// always inline
#ifdef _MSC_VER
#define FOLLY_ALWAYS_INLINE __forceinline
#elif defined(__clang__) || defined(__GNUC__)
#elif defined(__GNUC__)
#define FOLLY_ALWAYS_INLINE inline __attribute__((__always_inline__))
#else
#define FOLLY_ALWAYS_INLINE inline
#endif
// attribute hidden
#if _MSC_VER
#if defined(_MSC_VER)
#define FOLLY_ATTR_VISIBILITY_HIDDEN
#elif defined(__clang__) || defined(__GNUC__)
#elif defined(__GNUC__)
#define FOLLY_ATTR_VISIBILITY_HIDDEN __attribute__((__visibility__("hidden")))
#else
#define FOLLY_ATTR_VISIBILITY_HIDDEN
@ -174,21 +205,38 @@
#endif
#endif
// These functions are defined by the TSAN runtime library and enable
// annotating mutexes for TSAN.
extern "C" FOLLY_ATTR_WEAK void
AnnotateRWLockCreate(const char* f, int l, const volatile void* addr);
extern "C" FOLLY_ATTR_WEAK void
AnnotateRWLockCreateStatic(const char* f, int l, const volatile void* addr);
extern "C" FOLLY_ATTR_WEAK void
AnnotateRWLockDestroy(const char* f, int l, const volatile void* addr);
extern "C" FOLLY_ATTR_WEAK void
AnnotateRWLockAcquired(const char* f, int l, const volatile void* addr, long w);
extern "C" FOLLY_ATTR_WEAK void
AnnotateRWLockReleased(const char* f, int l, const volatile void* addr, long w);
extern "C" FOLLY_ATTR_WEAK void AnnotateBenignRaceSized(
const char* f,
int l,
const volatile void* addr,
long size,
const char* desc);
// FOLLY_ERASE
//
// A conceptual attribute/syntax combo for erasing a function from the build
// artifacts and forcing all call-sites to inline the callee, at least as far
// as each compiler supports.
//
// Semantically includes the inline specifier.
#define FOLLY_ERASE FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN
// FOLLY_ERASE_HACK_GCC
//
// Equivalent to FOLLY_ERASE, but without hiding under gcc. Useful when applied
// to a function which may sometimes be hidden separately, for example by being
// declared in an anonymous namespace, since in such cases with -Wattributes
// enabled, gcc would emit: 'visibility' attribute ignored.
//
// Semantically includes the inline specifier.
#if defined(__GNUC__) && !defined(__clang__)
#define FOLLY_ERASE_HACK_GCC FOLLY_ALWAYS_INLINE
#else
#define FOLLY_ERASE_HACK_GCC FOLLY_ERASE
#endif
// FOLLY_ERASE_TRYCATCH
//
// Equivalent to FOLLY_ERASE, but for code which might contain explicit
// exception handling. Has the effect of FOLLY_ERASE, except under MSVC which
// warns about __forceinline when functions contain exception handling.
//
// Semantically includes the inline specifier.
#ifdef _MSC_VER
#define FOLLY_ERASE_TRYCATCH inline
#else
#define FOLLY_ERASE_TRYCATCH FOLLY_ERASE
#endif

View File

@ -1,11 +1,11 @@
/*
* Copyright 2016-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -17,9 +17,11 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <utility>
#include <folly/lang/Align.h>
#include <folly/lang/SafeAssert.h>
namespace folly {
@ -29,17 +31,20 @@ namespace folly {
*
* If `sizeof(T) <= alignof(T)` then the inner `T` will be entirely within one
* false sharing range (AKA cache line).
*
* CachelinePadded may add padding both before and after the value. Consider
* whether alignas(folly::hardware_destructive_interference_size) suffices.
*/
template <typename T>
class CachelinePadded {
static_assert(
alignof(T) <= max_align_v,
"CachelinePadded does not support over-aligned types.");
public:
template <typename... Args>
explicit CachelinePadded(Args&&... args)
: inner_(std::forward<Args>(args)...) {}
: inner_(std::forward<Args>(args)...) {
FOLLY_SAFE_DCHECK(
(reinterpret_cast<uintptr_t>(&inner_) % alignof(T)) == 0,
"CachelinePadded requires types aligned to their ABI requirement");
}
T* get() {
return &inner_;

View File

@ -0,0 +1,351 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <algorithm>
#include <cstdint>
#include <limits>
#include <utility>
#include <glog/logging.h>
namespace folly {
namespace detail {
// Internal cancellation state object.
class CancellationState {
public:
FOLLY_NODISCARD static CancellationStateSourcePtr create();
private:
// Constructed initially with a CancellationSource reference count of 1.
CancellationState() noexcept;
~CancellationState();
friend struct CancellationStateTokenDeleter;
friend struct CancellationStateSourceDeleter;
void removeTokenReference() noexcept;
void removeSourceReference() noexcept;
public:
FOLLY_NODISCARD CancellationStateTokenPtr addTokenReference() noexcept;
FOLLY_NODISCARD CancellationStateSourcePtr addSourceReference() noexcept;
bool tryAddCallback(
CancellationCallback* callback,
bool incrementRefCountIfSuccessful) noexcept;
void removeCallback(CancellationCallback* callback) noexcept;
bool isCancellationRequested() const noexcept;
bool canBeCancelled() const noexcept;
// Request cancellation.
// Return 'true' if cancellation had already been requested.
// Return 'false' if this was the first thread to request
// cancellation.
bool requestCancellation() noexcept;
private:
void lock() noexcept;
void unlock() noexcept;
void unlockAndIncrementTokenCount() noexcept;
void unlockAndDecrementTokenCount() noexcept;
bool tryLockAndCancelUnlessCancelled() noexcept;
template <typename Predicate>
bool tryLock(Predicate predicate) noexcept;
static bool canBeCancelled(std::uint64_t state) noexcept;
static bool isCancellationRequested(std::uint64_t state) noexcept;
static bool isLocked(std::uint64_t state) noexcept;
static constexpr std::uint64_t kCancellationRequestedFlag = 1;
static constexpr std::uint64_t kLockedFlag = 2;
static constexpr std::uint64_t kTokenReferenceCountIncrement = 4;
static constexpr std::uint64_t kSourceReferenceCountIncrement =
std::uint64_t(1) << 33u;
static constexpr std::uint64_t kTokenReferenceCountMask =
(kSourceReferenceCountIncrement - 1u) -
(kTokenReferenceCountIncrement - 1u);
static constexpr std::uint64_t kSourceReferenceCountMask =
std::numeric_limits<std::uint64_t>::max() -
(kSourceReferenceCountIncrement - 1u);
// Bit 0 - Cancellation Requested
// Bit 1 - Locked Flag
// Bits 2-32 - Token reference count (max ~2 billion)
// Bits 33-63 - Source reference count (max ~2 billion)
std::atomic<std::uint64_t> state_;
CancellationCallback* head_;
std::thread::id signallingThreadId_;
};
inline void CancellationStateTokenDeleter::operator()(
CancellationState* state) noexcept {
state->removeTokenReference();
}
inline void CancellationStateSourceDeleter::operator()(
CancellationState* state) noexcept {
state->removeSourceReference();
}
} // namespace detail
inline CancellationToken::CancellationToken(
const CancellationToken& other) noexcept
: state_() {
if (other.state_) {
state_ = other.state_->addTokenReference();
}
}
inline CancellationToken::CancellationToken(CancellationToken&& other) noexcept
: state_(std::move(other.state_)) {}
inline CancellationToken& CancellationToken::operator=(
const CancellationToken& other) noexcept {
if (state_ != other.state_) {
CancellationToken temp{other};
swap(temp);
}
return *this;
}
inline CancellationToken& CancellationToken::operator=(
CancellationToken&& other) noexcept {
state_ = std::move(other.state_);
return *this;
}
inline bool CancellationToken::isCancellationRequested() const noexcept {
return state_ != nullptr && state_->isCancellationRequested();
}
inline bool CancellationToken::canBeCancelled() const noexcept {
return state_ != nullptr && state_->canBeCancelled();
}
inline void CancellationToken::swap(CancellationToken& other) noexcept {
std::swap(state_, other.state_);
}
inline CancellationToken::CancellationToken(
detail::CancellationStateTokenPtr state) noexcept
: state_(std::move(state)) {}
inline bool operator==(
const CancellationToken& a,
const CancellationToken& b) noexcept {
return a.state_ == b.state_;
}
inline bool operator!=(
const CancellationToken& a,
const CancellationToken& b) noexcept {
return !(a == b);
}
inline CancellationSource::CancellationSource()
: state_(detail::CancellationState::create()) {}
inline CancellationSource::CancellationSource(
const CancellationSource& other) noexcept
: state_() {
if (other.state_) {
state_ = other.state_->addSourceReference();
}
}
inline CancellationSource::CancellationSource(
CancellationSource&& other) noexcept
: state_(std::move(other.state_)) {}
inline CancellationSource& CancellationSource::operator=(
const CancellationSource& other) noexcept {
if (state_ != other.state_) {
CancellationSource temp{other};
swap(temp);
}
return *this;
}
inline CancellationSource& CancellationSource::operator=(
CancellationSource&& other) noexcept {
state_ = std::move(other.state_);
return *this;
}
inline CancellationSource CancellationSource::invalid() noexcept {
return CancellationSource{detail::CancellationStateSourcePtr{}};
}
inline bool CancellationSource::isCancellationRequested() const noexcept {
return state_ != nullptr && state_->isCancellationRequested();
}
inline bool CancellationSource::canBeCancelled() const noexcept {
return state_ != nullptr;
}
inline CancellationToken CancellationSource::getToken() const noexcept {
if (state_ != nullptr) {
return CancellationToken{state_->addTokenReference()};
}
return CancellationToken{};
}
inline bool CancellationSource::requestCancellation() const noexcept {
if (state_ != nullptr) {
return state_->requestCancellation();
}
return false;
}
inline void CancellationSource::swap(CancellationSource& other) noexcept {
std::swap(state_, other.state_);
}
inline CancellationSource::CancellationSource(
detail::CancellationStateSourcePtr&& state) noexcept
: state_(std::move(state)) {}
template <
typename Callable,
std::enable_if_t<
std::is_constructible<CancellationCallback::VoidFunction, Callable>::
value,
int>>
inline CancellationCallback::CancellationCallback(
CancellationToken&& ct,
Callable&& callable)
: next_(nullptr),
prevNext_(nullptr),
state_(nullptr),
callback_(static_cast<Callable&&>(callable)),
destructorHasRunInsideCallback_(nullptr),
callbackCompleted_(false) {
if (ct.state_ != nullptr && ct.state_->tryAddCallback(this, false)) {
state_ = ct.state_.release();
}
}
template <
typename Callable,
std::enable_if_t<
std::is_constructible<CancellationCallback::VoidFunction, Callable>::
value,
int>>
inline CancellationCallback::CancellationCallback(
const CancellationToken& ct,
Callable&& callable)
: next_(nullptr),
prevNext_(nullptr),
state_(nullptr),
callback_(static_cast<Callable&&>(callable)),
destructorHasRunInsideCallback_(nullptr),
callbackCompleted_(false) {
if (ct.state_ != nullptr && ct.state_->tryAddCallback(this, true)) {
state_ = ct.state_.get();
}
}
inline CancellationCallback::~CancellationCallback() {
if (state_ != nullptr) {
state_->removeCallback(this);
}
}
inline void CancellationCallback::invokeCallback() noexcept {
// Invoke within a noexcept context so that we std::terminate() if it throws.
callback_();
}
namespace detail {
inline CancellationStateSourcePtr CancellationState::create() {
return CancellationStateSourcePtr{new CancellationState()};
}
inline CancellationState::CancellationState() noexcept
: state_(kSourceReferenceCountIncrement),
head_(nullptr),
signallingThreadId_() {}
inline CancellationStateTokenPtr
CancellationState::addTokenReference() noexcept {
state_.fetch_add(kTokenReferenceCountIncrement, std::memory_order_relaxed);
return CancellationStateTokenPtr{this};
}
inline void CancellationState::removeTokenReference() noexcept {
const auto oldState = state_.fetch_sub(
kTokenReferenceCountIncrement, std::memory_order_acq_rel);
DCHECK(
(oldState & kTokenReferenceCountMask) >= kTokenReferenceCountIncrement);
if (oldState < (2 * kTokenReferenceCountIncrement)) {
delete this;
}
}
inline CancellationStateSourcePtr
CancellationState::addSourceReference() noexcept {
state_.fetch_add(kSourceReferenceCountIncrement, std::memory_order_relaxed);
return CancellationStateSourcePtr{this};
}
inline void CancellationState::removeSourceReference() noexcept {
const auto oldState = state_.fetch_sub(
kSourceReferenceCountIncrement, std::memory_order_acq_rel);
DCHECK(
(oldState & kSourceReferenceCountMask) >= kSourceReferenceCountIncrement);
if (oldState <
(kSourceReferenceCountIncrement + kTokenReferenceCountIncrement)) {
delete this;
}
}
inline bool CancellationState::isCancellationRequested() const noexcept {
return isCancellationRequested(state_.load(std::memory_order_acquire));
}
inline bool CancellationState::canBeCancelled() const noexcept {
return canBeCancelled(state_.load(std::memory_order_acquire));
}
inline bool CancellationState::canBeCancelled(std::uint64_t state) noexcept {
// Can be cancelled if there is at least one CancellationSource ref-count
// or if cancellation has been requested.
return (state >= kSourceReferenceCountIncrement) ||
isCancellationRequested(state);
}
inline bool CancellationState::isCancellationRequested(
std::uint64_t state) noexcept {
return (state & kCancellationRequestedFlag) != 0;
}
inline bool CancellationState::isLocked(std::uint64_t state) noexcept {
return (state & kLockedFlag) != 0;
}
} // namespace detail
} // namespace folly

298
ios/Pods/Folly/folly/CancellationToken.h generated Normal file
View File

@ -0,0 +1,298 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <folly/CppAttributes.h>
#include <folly/Function.h>
#include <atomic>
#include <memory>
#include <thread>
#include <type_traits>
namespace folly {
class CancellationCallback;
class CancellationSource;
struct OperationCancelled : public std::exception {
const char* what() const noexcept override {
return "coroutine operation cancelled";
}
};
namespace detail {
class CancellationState;
struct CancellationStateTokenDeleter {
void operator()(CancellationState*) noexcept;
};
struct CancellationStateSourceDeleter {
void operator()(CancellationState*) noexcept;
};
using CancellationStateTokenPtr =
std::unique_ptr<CancellationState, CancellationStateTokenDeleter>;
using CancellationStateSourcePtr =
std::unique_ptr<CancellationState, CancellationStateSourceDeleter>;
} // namespace detail
// A CancellationToken is an object that can be passed into an function or
// operation that allows the caller to later request that the operation be
// cancelled.
//
// A CancellationToken object can be obtained by calling the .getToken()
// method on a CancellationSource or by copying another CancellationToken
// object. All CancellationToken objects obtained from the same original
// CancellationSource object all reference the same underlying cancellation
// state and will all be cancelled together.
//
// If your function needs to be cancellable but does not need to request
// cancellation then you should take a CancellationToken as a parameter.
// If your function needs to be able to request cancellation then you
// should instead take a CancellationSource as a parameter.
class CancellationToken {
public:
// Constructs to a token that can never be cancelled.
//
// Pass a default-constructed CancellationToken into an operation that
// you never intend to cancel. These objects are very cheap to create.
CancellationToken() noexcept = default;
// Construct a copy of the token that shares the same underlying state.
CancellationToken(const CancellationToken& other) noexcept;
CancellationToken(CancellationToken&& other) noexcept;
CancellationToken& operator=(const CancellationToken& other) noexcept;
CancellationToken& operator=(CancellationToken&& other) noexcept;
// Query whether someone has called .requestCancellation() on an instance
// of CancellationSource object associated with this CancellationToken.
bool isCancellationRequested() const noexcept;
// Query whether this CancellationToken can ever have cancellation requested
// on it.
//
// This will return false if the CancellationToken is not associated with a
// CancellationSource object. eg. because the CancellationToken was
// default-constructed, has been moved-from or because the last
// CancellationSource object associated with the underlying cancellation state
// has been destroyed and the operation has not yet been cancelled and so
// never will be.
//
// Implementations of operations may be able to take more efficient code-paths
// if they know they can never be cancelled.
bool canBeCancelled() const noexcept;
void swap(CancellationToken& other) noexcept;
friend bool operator==(
const CancellationToken& a,
const CancellationToken& b) noexcept;
private:
friend class CancellationCallback;
friend class CancellationSource;
explicit CancellationToken(detail::CancellationStateTokenPtr state) noexcept;
detail::CancellationStateTokenPtr state_;
};
bool operator==(
const CancellationToken& a,
const CancellationToken& b) noexcept;
bool operator!=(
const CancellationToken& a,
const CancellationToken& b) noexcept;
// A CancellationSource object provides the ability to request cancellation of
// operations that an associated CancellationToken was passed to.
//
// Example usage:
// CancellationSource cs;
// Future<void> f = startSomeOperation(cs.getToken());
//
// // Later...
// cs.requestCancellation();
class CancellationSource {
public:
// Construct to a new, independent cancellation source.
CancellationSource();
// Construct a new reference to the same underlying cancellation state.
//
// Either the original or the new copy can be used to request cancellation
// of associated work.
CancellationSource(const CancellationSource& other) noexcept;
// This leaves 'other' in an empty state where 'requestCancellation()' is a
// no-op and 'canBeCancelled()' returns false.
CancellationSource(CancellationSource&& other) noexcept;
CancellationSource& operator=(const CancellationSource& other) noexcept;
CancellationSource& operator=(CancellationSource&& other) noexcept;
// Construct a CancellationSource that cannot be cancelled.
//
// This factory function can be used to obtain a CancellationSource that
// is equivalent to a moved-from CancellationSource object without needing
// to allocate any shared-state.
static CancellationSource invalid() noexcept;
// Query if cancellation has already been requested on this CancellationSource
// or any other CancellationSource object copied from the same original
// CancellationSource object.
bool isCancellationRequested() const noexcept;
// Query if cancellation can be requested through this CancellationSource
// object. This will only return false if the CancellationSource object has
// been moved-from.
bool canBeCancelled() const noexcept;
// Obtain a CancellationToken linked to this CancellationSource.
//
// This token can be passed into cancellable operations to allow the caller
// to later request cancellation of that operation.
CancellationToken getToken() const noexcept;
// Request cancellation of work associated with this CancellationSource.
//
// This will ensure subsequent calls to isCancellationRequested() on any
// CancellationSource or CancellationToken object associated with the same
// underlying cancellation state to return true.
//
// If this is the first call to requestCancellation() on any
// CancellationSource object with the same underlying state then this call
// will also execute the callbacks associated with any CancellationCallback
// objects that were constructed with an associated CancellationToken.
//
// Note that it is possible that another thread may be concurrently
// registering a callback with CancellationCallback. This method guarantees
// that either this thread will see the callback registration and will
// ensure that the callback is called, or the CancellationCallback constructor
// will see the cancellation-requested signal and will execute the callback
// inline inside the constructor.
//
// Returns the previous state of 'isCancellationRequested()'. i.e.
// - 'true' if cancellation had previously been requested.
// - 'false' if this was the first call to request cancellation.
bool requestCancellation() const noexcept;
void swap(CancellationSource& other) noexcept;
friend bool operator==(
const CancellationSource& a,
const CancellationSource& b) noexcept;
private:
explicit CancellationSource(
detail::CancellationStateSourcePtr&& state) noexcept;
detail::CancellationStateSourcePtr state_;
};
bool operator==(
const CancellationSource& a,
const CancellationSource& b) noexcept;
bool operator!=(
const CancellationSource& a,
const CancellationSource& b) noexcept;
class CancellationCallback {
using VoidFunction = folly::Function<void()>;
public:
// Constructing a CancellationCallback object registers the callback
// with the specified CancellationToken such that the callback will be
// executed if the corresponding CancellationSource object has the
// requestCancellation() method called on it.
//
// If the CancellationToken object already had cancellation requested
// then the callback will be executed inline on the current thread before
// the constructor returns. Otherwise, the callback will be executed on
// in the execution context of the first thread to call requestCancellation()
// on a corresponding CancellationSource.
//
// The callback object must not throw any unhandled exceptions. Doing so
// will result in the program terminating via std::terminate().
template <
typename Callable,
std::enable_if_t<
std::is_constructible<VoidFunction, Callable>::value,
int> = 0>
CancellationCallback(CancellationToken&& ct, Callable&& callable);
template <
typename Callable,
std::enable_if_t<
std::is_constructible<VoidFunction, Callable>::value,
int> = 0>
CancellationCallback(const CancellationToken& ct, Callable&& callable);
// Deregisters the callback from the CancellationToken.
//
// If cancellation has been requested concurrently on another thread and the
// callback is currently executing then the destructor will block until after
// the callback has returned (otherwise it might be left with a dangling
// reference).
//
// You should generally try to implement your callback functions to be lock
// free to avoid deadlocks between the callback executing and the
// CancellationCallback destructor trying to deregister the callback.
//
// If the callback has not started executing yet then the callback will be
// deregistered from the CancellationToken before the destructor completes.
//
// Once the destructor returns you can be guaranteed that the callback will
// not be called by a subsequent call to 'requestCancellation()' on a
// CancellationSource associated with the CancellationToken passed to the
// constructor.
~CancellationCallback();
// Not copyable/movable
CancellationCallback(const CancellationCallback&) = delete;
CancellationCallback(CancellationCallback&&) = delete;
CancellationCallback& operator=(const CancellationCallback&) = delete;
CancellationCallback& operator=(CancellationCallback&&) = delete;
private:
friend class detail::CancellationState;
void invokeCallback() noexcept;
CancellationCallback* next_;
// Pointer to the pointer that points to this node in the linked list.
// This could be the 'next_' of a previous CancellationCallback or could
// be the 'head_' pointer of the CancellationState.
// If this node is inserted in the list then this will be non-null.
CancellationCallback** prevNext_;
detail::CancellationState* state_;
VoidFunction callback_;
// Pointer to a flag stored on the stack of the caller to invokeCallback()
// that is used to indicate to the caller of invokeCallback() that the
// destructor has run and it is no longer valid to access the callback
// object.
bool* destructorHasRunInsideCallback_;
// Flag used to signal that the callback has completed executing on another
// thread and it is now safe to exit the destructor.
std::atomic<bool> callbackCompleted_;
};
} // namespace folly
#include <folly/CancellationToken-inl.h>

View File

@ -1,11 +1,11 @@
/*
* Copyright 2017-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -31,11 +31,12 @@
* * std::chrono::round
*/
#if __cpp_lib_chrono >= 201510 || _MSC_VER
#if __cpp_lib_chrono >= 201510 || _LIBCPP_STD_VER > 14 || _MSC_VER
namespace folly {
namespace chrono {
/* using override */ using std::chrono::abs;
/* using override */ using std::chrono::ceil;
/* using override */ using std::chrono::floor;
/* using override */ using std::chrono::round;
@ -81,6 +82,18 @@ constexpr To round_impl(Duration const& d, To const& t0) {
}
} // namespace detail
// mimic: std::chrono::abs, C++17
template <
typename Rep,
typename Period,
typename = typename std::enable_if<
std::chrono::duration<Rep, Period>::min() <
std::chrono::duration<Rep, Period>::zero()>::type>
constexpr std::chrono::duration<Rep, Period> abs(
std::chrono::duration<Rep, Period> const& d) {
return d < std::chrono::duration<Rep, Period>::zero() ? -d : d;
}
// mimic: std::chrono::ceil, C++17
// from: http://en.cppreference.com/w/cpp/chrono/duration/ceil, CC-BY-SA
template <
@ -168,17 +181,18 @@ struct coarse_steady_clock {
using time_point = std::chrono::time_point<coarse_steady_clock, duration>;
constexpr static bool is_steady = true;
static time_point now() {
static time_point now() noexcept {
#ifndef CLOCK_MONOTONIC_COARSE
return time_point(std::chrono::duration_cast<duration>(
std::chrono::steady_clock::now().time_since_epoch()));
#else
timespec ts;
auto ret = clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
if (ret != 0) {
if (kIsDebug && (ret != 0)) {
throw_exception<std::runtime_error>(
"Error using CLOCK_MONOTONIC_COARSE.");
}
return time_point(std::chrono::duration_cast<duration>(
std::chrono::seconds(ts.tv_sec) +
std::chrono::nanoseconds(ts.tv_nsec)));

View File

@ -1,11 +1,11 @@
/*
* Copyright 2016-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,11 +1,11 @@
/*
* Copyright 2013-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -22,22 +22,26 @@
#include <cstddef>
#include <limits>
#include <boost/noncopyable.hpp>
#include <folly/Portability.h>
namespace folly {
/**
* An atomic bitset of fixed size (specified at compile time).
*
* Formerly known as AtomicBitSet. It was renamed while fixing a bug
* to avoid any silent breakages during run time.
*/
template <size_t N>
class AtomicBitSet : private boost::noncopyable {
class ConcurrentBitSet {
public:
/**
* Construct an AtomicBitSet; all bits are initially false.
* Construct a ConcurrentBitSet; all bits are initially false.
*/
AtomicBitSet();
ConcurrentBitSet();
ConcurrentBitSet(const ConcurrentBitSet&) = delete;
ConcurrentBitSet& operator=(const ConcurrentBitSet&) = delete;
/**
* Set bit idx to true, using the given memory order. Returns the
@ -115,43 +119,44 @@ class AtomicBitSet : private boost::noncopyable {
// avoid casts
static constexpr BlockType kOne = 1;
std::array<AtomicBlockType, N> data_;
static constexpr size_t kNumBlocks = (N + kBitsPerBlock - 1) / kBitsPerBlock;
std::array<AtomicBlockType, kNumBlocks> data_;
};
// value-initialize to zero
template <size_t N>
inline AtomicBitSet<N>::AtomicBitSet() : data_() {}
inline ConcurrentBitSet<N>::ConcurrentBitSet() : data_() {}
template <size_t N>
inline bool AtomicBitSet<N>::set(size_t idx, std::memory_order order) {
assert(idx < N * kBitsPerBlock);
inline bool ConcurrentBitSet<N>::set(size_t idx, std::memory_order order) {
assert(idx < N);
BlockType mask = kOne << bitOffset(idx);
return data_[blockIndex(idx)].fetch_or(mask, order) & mask;
}
template <size_t N>
inline bool AtomicBitSet<N>::reset(size_t idx, std::memory_order order) {
assert(idx < N * kBitsPerBlock);
inline bool ConcurrentBitSet<N>::reset(size_t idx, std::memory_order order) {
assert(idx < N);
BlockType mask = kOne << bitOffset(idx);
return data_[blockIndex(idx)].fetch_and(~mask, order) & mask;
}
template <size_t N>
inline bool
AtomicBitSet<N>::set(size_t idx, bool value, std::memory_order order) {
ConcurrentBitSet<N>::set(size_t idx, bool value, std::memory_order order) {
return value ? set(idx, order) : reset(idx, order);
}
template <size_t N>
inline bool AtomicBitSet<N>::test(size_t idx, std::memory_order order) const {
assert(idx < N * kBitsPerBlock);
inline bool ConcurrentBitSet<N>::test(size_t idx, std::memory_order order)
const {
assert(idx < N);
BlockType mask = kOne << bitOffset(idx);
return data_[blockIndex(idx)].load(order) & mask;
}
template <size_t N>
inline bool AtomicBitSet<N>::operator[](size_t idx) const {
inline bool ConcurrentBitSet<N>::operator[](size_t idx) const {
return test(idx);
}

View File

@ -1,11 +1,11 @@
/*
* Copyright 2011-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -27,9 +27,7 @@
#include <type_traits>
#include <vector>
#include <boost/noncopyable.hpp>
#include <boost/random.hpp>
#include <boost/type_traits.hpp>
#include <glog/logging.h>
#include <folly/Memory.h>
@ -43,7 +41,7 @@ template <typename ValT, typename NodeT>
class csl_iterator;
template <typename T>
class SkipListNode : private boost::noncopyable {
class SkipListNode {
enum : uint16_t {
IS_HEAD_NODE = 1,
MARKED_FOR_REMOVAL = (1 << 1),
@ -53,6 +51,9 @@ class SkipListNode : private boost::noncopyable {
public:
typedef T value_type;
SkipListNode(const SkipListNode&) = delete;
SkipListNode& operator=(const SkipListNode&) = delete;
template <
typename NodeAlloc,
typename U,
@ -81,7 +82,7 @@ class SkipListNode : private boost::noncopyable {
template <typename NodeAlloc>
struct DestroyIsNoOp : StrictConjunction<
AllocatorHasTrivialDeallocate<NodeAlloc>,
boost::has_trivial_destructor<SkipListNode>> {};
std::is_trivially_destructible<SkipListNode>> {};
// copy the head node to a new head node assuming lock acquired
SkipListNode* copyHead(SkipListNode* node) {

View File

@ -1,11 +1,11 @@
/*
* Copyright 2011-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -125,12 +125,12 @@ Sample usage:
#include <memory>
#include <type_traits>
#include <boost/iterator/iterator_facade.hpp>
#include <glog/logging.h>
#include <folly/ConcurrentSkipList-inl.h>
#include <folly/Likely.h>
#include <folly/Memory.h>
#include <folly/detail/Iterators.h>
#include <folly/synchronization/MicroSpinLock.h>
namespace folly {
@ -158,7 +158,7 @@ class ConcurrentSkipList {
typedef T key_type;
typedef detail::csl_iterator<value_type, NodeType> iterator;
typedef detail::csl_iterator<const value_type, const NodeType> const_iterator;
typedef detail::csl_iterator<const value_type, NodeType> const_iterator;
class Accessor;
class Skipper;
@ -709,10 +709,10 @@ class ConcurrentSkipList<T, Comp, NodeAlloc, MAX_HEIGHT>::Accessor {
// implements forward iterator concept.
template <typename ValT, typename NodeT>
class detail::csl_iterator : public boost::iterator_facade<
class detail::csl_iterator : public detail::IteratorFacade<
csl_iterator<ValT, NodeT>,
ValT,
boost::forward_traversal_tag> {
std::forward_iterator_tag> {
public:
typedef ValT value_type;
typedef value_type& reference;
@ -738,9 +738,10 @@ class detail::csl_iterator : public boost::iterator_facade<
}
private:
friend class boost::iterator_core_access;
template <class, class>
friend class csl_iterator;
friend class detail::
IteratorFacade<csl_iterator, ValT, std::forward_iterator_tag>;
void increment() {
node_ = node_->next();

View File

@ -1,11 +1,11 @@
/*
* Copyright 2017-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -17,49 +17,11 @@
#pragma once
#include <cstdint>
#include <functional>
#include <limits>
#include <type_traits>
namespace folly {
// TODO: Replace with std::equal_to, etc., after upgrading to C++14.
template <typename T>
struct constexpr_equal_to {
constexpr bool operator()(T const& a, T const& b) const {
return a == b;
}
};
template <typename T>
struct constexpr_not_equal_to {
constexpr bool operator()(T const& a, T const& b) const {
return a != b;
}
};
template <typename T>
struct constexpr_less {
constexpr bool operator()(T const& a, T const& b) const {
return a < b;
}
};
template <typename T>
struct constexpr_less_equal {
constexpr bool operator()(T const& a, T const& b) const {
return a <= b;
}
};
template <typename T>
struct constexpr_greater {
constexpr bool operator()(T const& a, T const& b) const {
return a > b;
}
};
template <typename T>
struct constexpr_greater_equal {
constexpr bool operator()(T const& a, T const& b) const {
return a >= b;
}
};
// TLDR: Prefer using operator< for ordering. And when
// a and b are equivalent objects, we return b to make
// sorting stable.
@ -91,7 +53,7 @@ constexpr_clamp(T const& v, T const& lo, T const& hi, Less less) {
}
template <typename T>
constexpr T const& constexpr_clamp(T const& v, T const& lo, T const& hi) {
return constexpr_clamp(v, lo, hi, constexpr_less<T>{});
return constexpr_clamp(v, lo, hi, std::less<T>{});
}
namespace detail {

View File

@ -1,11 +1,11 @@
/*
* Copyright 2011-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/Conv.h>
#include <array>
@ -275,7 +276,7 @@ Expected<bool, ConversionCode> str_to_bool(StringPiece* src) noexcept {
}
bool result;
size_t len = size_t(e - b);
auto len = size_t(e - b);
switch (*b) {
case '0':
case '1': {
@ -399,7 +400,7 @@ Expected<Tgt, ConversionCode> str_to_floating(StringPiece* src) noexcept {
// There must be non-whitespace, otherwise we would have caught this above
assert(b < e);
size_t size = size_t(e - b);
auto size = size_t(e - b);
bool negative = false;
if (*b == '-') {
@ -543,7 +544,7 @@ inline Expected<Tgt, ConversionCode> digits_to(
return makeUnexpected(err);
}
size_t size = size_t(e - b);
auto size = size_t(e - b);
/* Although the string is entirely made of digits, we still need to
* check for overflow.
@ -777,7 +778,7 @@ ConversionError makeConversionError(ConversionCode code, StringPiece input) {
if (err.quote) {
tmp.append(1, '"');
}
if (input.size() > 0) {
if (!input.empty()) {
tmp.append(input.data(), input.size());
}
if (err.quote) {

View File

@ -1,11 +1,11 @@
/*
* Copyright 2011-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -15,15 +15,92 @@
*/
/**
* Converts anything to anything, with an emphasis on performance and
* safety.
*
* @author Andrei Alexandrescu (andrei.alexandrescu@fb.com)
* This file provides a generic interface for converting objects to and from
* string-like types (std::string, fbstring, StringPiece), as well as
* range-checked conversions between numeric and enum types. The mechanisms are
* extensible, so that user-specified types can add folly::to support.
*
*******************************************************************************
* TYPE -> STRING CONVERSIONS
*******************************************************************************
* You can call the to<std::string> or to<fbstring>. These are variadic
* functions that convert their arguments to strings, and concatenate them to
* form a result. So, for example,
*
* auto str = to<std::string>(123, "456", 789);
*
* Sets str to "123456789".
*
* In addition to just concatenating the arguments, related functions can
* delimit them with some string: toDelim<std::string>(",", "123", 456, "789")
* will return the string "123,456,789".
*
* toAppend does not return a string; instead, it takes a pointer to a string as
* its last argument, and appends the result of the concatenation into it:
* std::string str = "123";
* toAppend(456, "789", &str); // Now str is "123456789".
*
* The toAppendFit function acts like toAppend, but it precalculates the size
* required to perform the append operation, and reserves that space in the
* output string before actually inserting its arguments. This can sometimes
* save on string expansion, but beware: appending to the same string many times
* with toAppendFit is likely a pessimization, since it will resize the string
* once per append.
*
* The combination of the append and delim variants also exist: toAppendDelim
* and toAppendDelimFit are defined, with the obvious semantics.
*
*******************************************************************************
* STRING -> TYPE CONVERSIONS
*******************************************************************************
* Going in the other direction, and parsing a string into a C++ type, is also
* supported:
* to<int>("123"); // Returns 123.
*
* Out of range (e.g. to<std::uint8_t>("1000")), or invalidly formatted (e.g.
* to<int>("four")) inputs will throw. If throw-on-error is undesirable (for
* instance: you're dealing with untrusted input, and want to protect yourself
* from users sending you down a very slow exception-throwing path), you can use
* tryTo<T>, which will return an Expected<T, ConversionCode>.
*
* There are overloads of to() and tryTo() that take a StringPiece*. These parse
* out a type from the beginning of a string, and modify the passed-in
* StringPiece to indicate the portion of the string not consumed.
*
*******************************************************************************
* NUMERIC / ENUM CONVERSIONS
*******************************************************************************
* Conv also supports a to<T>(S) overload, where T and S are numeric or enum
* types, that checks to see that the target type can represent its argument,
* and will throw if it cannot. This includes cases where a floating point ->
* integral conversion is attempted on a value with a non-zero fractional
* component, and integral -> floating point conversions that would lose
* precision. Enum conversions are range-checked for the underlying type of the
* enum, but there is no check that the input value is a valid choice of enum
* value.
*
*******************************************************************************
* CUSTOM TYPE CONVERSIONS
*******************************************************************************
* Users may customize the string conversion functionality for their own data
* types, . The key functions you should implement are:
* // Two functions to allow conversion to your type from a string.
* Expected<StringPiece, ConversionCode> parseTo(folly::StringPiece in,
* YourType& out);
* YourErrorType makeConversionError(YourErrorType in, StringPiece in);
* // Two functions to allow conversion from your type to a string.
* template <class String>
* void toAppend(const YourType& in, String* out);
* size_t estimateSpaceNeeded(const YourType& in);
*
* These are documented below, inline.
*/
#pragma once
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cstddef>
@ -32,7 +109,6 @@
#include <string>
#include <tuple>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include <double-conversion/double-conversion.h> // V8 JavaScript implementation
@ -44,7 +120,9 @@
#include <folly/Range.h>
#include <folly/Traits.h>
#include <folly/Unit.h>
#include <folly/Utility.h>
#include <folly/lang/Exception.h>
#include <folly/lang/Pretty.h>
#include <folly/portability/Math.h>
namespace folly {
@ -109,7 +187,7 @@ class ConversionError : public ConversionErrorBase {
* return YourConversionError(messageString);
* }
******************************************************************************/
ConversionError makeConversionError(ConversionCode code, StringPiece sp);
ConversionError makeConversionError(ConversionCode code, StringPiece input);
namespace detail {
/**
@ -648,15 +726,13 @@ template <class Tgt, class Src>
typename std::enable_if<
std::is_enum<Src>::value && IsSomeString<Tgt>::value>::type
toAppend(Src value, Tgt* result) {
toAppend(
static_cast<typename std::underlying_type<Src>::type>(value), result);
toAppend(to_underlying(value), result);
}
template <class Src>
typename std::enable_if<std::is_enum<Src>::value, size_t>::type
estimateSpaceNeeded(Src value) {
return estimateSpaceNeeded(
static_cast<typename std::underlying_type<Src>::type>(value));
return estimateSpaceNeeded(to_underlying(value));
}
/*******************************************************************************
@ -699,8 +775,9 @@ toAppend(
case DoubleToStringConverter::FIXED:
conv.ToFixed(value, int(numDigits), &builder);
break;
case DoubleToStringConverter::PRECISION:
default:
CHECK(mode == DoubleToStringConverter::PRECISION);
assert(mode == DoubleToStringConverter::PRECISION);
conv.ToPrecision(value, int(numDigits), &builder);
break;
}
@ -1216,8 +1293,8 @@ typename std::enable_if<
Expected<Tgt, ConversionCode>>::type
convertTo(const Src& value) noexcept {
if /* constexpr */ (
folly::_t<std::make_unsigned<Tgt>>(std::numeric_limits<Tgt>::max()) <
folly::_t<std::make_unsigned<Src>>(std::numeric_limits<Src>::max())) {
std::make_unsigned_t<Tgt>(std::numeric_limits<Tgt>::max()) <
std::make_unsigned_t<Src>(std::numeric_limits<Src>::max())) {
if (greater_than<Tgt, std::numeric_limits<Tgt>::max()>(value)) {
return makeUnexpected(ConversionCode::ARITH_POSITIVE_OVERFLOW);
}
@ -1335,11 +1412,7 @@ convertTo(const Src& value) noexcept {
template <typename Tgt, typename Src>
inline std::string errorValue(const Src& value) {
#ifdef FOLLY_HAS_RTTI
return to<std::string>("(", demangle(typeid(Tgt)), ") ", value);
#else
return to<std::string>(value);
#endif
return to<std::string>("(", pretty_name<Tgt>(), ") ", value);
}
template <typename Tgt, typename Src>
@ -1551,8 +1624,7 @@ typename std::enable_if<
!std::is_convertible<Tgt, StringPiece>::value,
Expected<Tgt, ConversionCode>>::type
tryTo(const Src& value) {
using I = typename std::underlying_type<Src>::type;
return tryTo<Tgt>(static_cast<I>(value));
return tryTo<Tgt>(to_underlying(value));
}
template <class Tgt, class Src>
@ -1571,7 +1643,7 @@ typename std::enable_if<
!std::is_convertible<Tgt, StringPiece>::value,
Tgt>::type
to(const Src& value) {
return to<Tgt>(static_cast<typename std::underlying_type<Src>::type>(value));
return to<Tgt>(to_underlying(value));
}
template <class Tgt, class Src>

View File

@ -1,11 +1,11 @@
/*
* Copyright 2015-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,11 +1,11 @@
/*
* Copyright 2012-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -105,108 +105,108 @@ class CpuId {
#endif
}
#define X(name, r, bit) \
FOLLY_ALWAYS_INLINE bool name() const { \
return ((r) & (1U << bit)) != 0; \
#define FOLLY_DETAIL_CPUID_X(name, r, bit) \
FOLLY_ALWAYS_INLINE bool name() const { \
return ((r) & (1U << bit)) != 0; \
}
// cpuid(1): Processor Info and Feature Bits.
#define C(name, bit) X(name, f1c_, bit)
C(sse3, 0)
C(pclmuldq, 1)
C(dtes64, 2)
C(monitor, 3)
C(dscpl, 4)
C(vmx, 5)
C(smx, 6)
C(eist, 7)
C(tm2, 8)
C(ssse3, 9)
C(cnxtid, 10)
C(fma, 12)
C(cx16, 13)
C(xtpr, 14)
C(pdcm, 15)
C(pcid, 17)
C(dca, 18)
C(sse41, 19)
C(sse42, 20)
C(x2apic, 21)
C(movbe, 22)
C(popcnt, 23)
C(tscdeadline, 24)
C(aes, 25)
C(xsave, 26)
C(osxsave, 27)
C(avx, 28)
C(f16c, 29)
C(rdrand, 30)
#undef C
#define D(name, bit) X(name, f1d_, bit)
D(fpu, 0)
D(vme, 1)
D(de, 2)
D(pse, 3)
D(tsc, 4)
D(msr, 5)
D(pae, 6)
D(mce, 7)
D(cx8, 8)
D(apic, 9)
D(sep, 11)
D(mtrr, 12)
D(pge, 13)
D(mca, 14)
D(cmov, 15)
D(pat, 16)
D(pse36, 17)
D(psn, 18)
D(clfsh, 19)
D(ds, 21)
D(acpi, 22)
D(mmx, 23)
D(fxsr, 24)
D(sse, 25)
D(sse2, 26)
D(ss, 27)
D(htt, 28)
D(tm, 29)
D(pbe, 31)
#undef D
#define FOLLY_DETAIL_CPUID_C(name, bit) FOLLY_DETAIL_CPUID_X(name, f1c_, bit)
FOLLY_DETAIL_CPUID_C(sse3, 0)
FOLLY_DETAIL_CPUID_C(pclmuldq, 1)
FOLLY_DETAIL_CPUID_C(dtes64, 2)
FOLLY_DETAIL_CPUID_C(monitor, 3)
FOLLY_DETAIL_CPUID_C(dscpl, 4)
FOLLY_DETAIL_CPUID_C(vmx, 5)
FOLLY_DETAIL_CPUID_C(smx, 6)
FOLLY_DETAIL_CPUID_C(eist, 7)
FOLLY_DETAIL_CPUID_C(tm2, 8)
FOLLY_DETAIL_CPUID_C(ssse3, 9)
FOLLY_DETAIL_CPUID_C(cnxtid, 10)
FOLLY_DETAIL_CPUID_C(fma, 12)
FOLLY_DETAIL_CPUID_C(cx16, 13)
FOLLY_DETAIL_CPUID_C(xtpr, 14)
FOLLY_DETAIL_CPUID_C(pdcm, 15)
FOLLY_DETAIL_CPUID_C(pcid, 17)
FOLLY_DETAIL_CPUID_C(dca, 18)
FOLLY_DETAIL_CPUID_C(sse41, 19)
FOLLY_DETAIL_CPUID_C(sse42, 20)
FOLLY_DETAIL_CPUID_C(x2apic, 21)
FOLLY_DETAIL_CPUID_C(movbe, 22)
FOLLY_DETAIL_CPUID_C(popcnt, 23)
FOLLY_DETAIL_CPUID_C(tscdeadline, 24)
FOLLY_DETAIL_CPUID_C(aes, 25)
FOLLY_DETAIL_CPUID_C(xsave, 26)
FOLLY_DETAIL_CPUID_C(osxsave, 27)
FOLLY_DETAIL_CPUID_C(avx, 28)
FOLLY_DETAIL_CPUID_C(f16c, 29)
FOLLY_DETAIL_CPUID_C(rdrand, 30)
#undef FOLLY_DETAIL_CPUID_C
#define FOLLY_DETAIL_CPUID_D(name, bit) FOLLY_DETAIL_CPUID_X(name, f1d_, bit)
FOLLY_DETAIL_CPUID_D(fpu, 0)
FOLLY_DETAIL_CPUID_D(vme, 1)
FOLLY_DETAIL_CPUID_D(de, 2)
FOLLY_DETAIL_CPUID_D(pse, 3)
FOLLY_DETAIL_CPUID_D(tsc, 4)
FOLLY_DETAIL_CPUID_D(msr, 5)
FOLLY_DETAIL_CPUID_D(pae, 6)
FOLLY_DETAIL_CPUID_D(mce, 7)
FOLLY_DETAIL_CPUID_D(cx8, 8)
FOLLY_DETAIL_CPUID_D(apic, 9)
FOLLY_DETAIL_CPUID_D(sep, 11)
FOLLY_DETAIL_CPUID_D(mtrr, 12)
FOLLY_DETAIL_CPUID_D(pge, 13)
FOLLY_DETAIL_CPUID_D(mca, 14)
FOLLY_DETAIL_CPUID_D(cmov, 15)
FOLLY_DETAIL_CPUID_D(pat, 16)
FOLLY_DETAIL_CPUID_D(pse36, 17)
FOLLY_DETAIL_CPUID_D(psn, 18)
FOLLY_DETAIL_CPUID_D(clfsh, 19)
FOLLY_DETAIL_CPUID_D(ds, 21)
FOLLY_DETAIL_CPUID_D(acpi, 22)
FOLLY_DETAIL_CPUID_D(mmx, 23)
FOLLY_DETAIL_CPUID_D(fxsr, 24)
FOLLY_DETAIL_CPUID_D(sse, 25)
FOLLY_DETAIL_CPUID_D(sse2, 26)
FOLLY_DETAIL_CPUID_D(ss, 27)
FOLLY_DETAIL_CPUID_D(htt, 28)
FOLLY_DETAIL_CPUID_D(tm, 29)
FOLLY_DETAIL_CPUID_D(pbe, 31)
#undef FOLLY_DETAIL_CPUID_D
// cpuid(7): Extended Features.
#define B(name, bit) X(name, f7b_, bit)
B(bmi1, 3)
B(hle, 4)
B(avx2, 5)
B(smep, 7)
B(bmi2, 8)
B(erms, 9)
B(invpcid, 10)
B(rtm, 11)
B(mpx, 14)
B(avx512f, 16)
B(avx512dq, 17)
B(rdseed, 18)
B(adx, 19)
B(smap, 20)
B(avx512ifma, 21)
B(pcommit, 22)
B(clflushopt, 23)
B(clwb, 24)
B(avx512pf, 26)
B(avx512er, 27)
B(avx512cd, 28)
B(sha, 29)
B(avx512bw, 30)
B(avx512vl, 31)
#undef B
#define C(name, bit) X(name, f7c_, bit)
C(prefetchwt1, 0)
C(avx512vbmi, 1)
#undef C
#define FOLLY_DETAIL_CPUID_B(name, bit) FOLLY_DETAIL_CPUID_X(name, f7b_, bit)
FOLLY_DETAIL_CPUID_B(bmi1, 3)
FOLLY_DETAIL_CPUID_B(hle, 4)
FOLLY_DETAIL_CPUID_B(avx2, 5)
FOLLY_DETAIL_CPUID_B(smep, 7)
FOLLY_DETAIL_CPUID_B(bmi2, 8)
FOLLY_DETAIL_CPUID_B(erms, 9)
FOLLY_DETAIL_CPUID_B(invpcid, 10)
FOLLY_DETAIL_CPUID_B(rtm, 11)
FOLLY_DETAIL_CPUID_B(mpx, 14)
FOLLY_DETAIL_CPUID_B(avx512f, 16)
FOLLY_DETAIL_CPUID_B(avx512dq, 17)
FOLLY_DETAIL_CPUID_B(rdseed, 18)
FOLLY_DETAIL_CPUID_B(adx, 19)
FOLLY_DETAIL_CPUID_B(smap, 20)
FOLLY_DETAIL_CPUID_B(avx512ifma, 21)
FOLLY_DETAIL_CPUID_B(pcommit, 22)
FOLLY_DETAIL_CPUID_B(clflushopt, 23)
FOLLY_DETAIL_CPUID_B(clwb, 24)
FOLLY_DETAIL_CPUID_B(avx512pf, 26)
FOLLY_DETAIL_CPUID_B(avx512er, 27)
FOLLY_DETAIL_CPUID_B(avx512cd, 28)
FOLLY_DETAIL_CPUID_B(sha, 29)
FOLLY_DETAIL_CPUID_B(avx512bw, 30)
FOLLY_DETAIL_CPUID_B(avx512vl, 31)
#undef FOLLY_DETAIL_CPUID_B
#define FOLLY_DETAIL_CPUID_C(name, bit) FOLLY_DETAIL_CPUID_X(name, f7c_, bit)
FOLLY_DETAIL_CPUID_C(prefetchwt1, 0)
FOLLY_DETAIL_CPUID_C(avx512vbmi, 1)
#undef FOLLY_DETAIL_CPUID_C
#undef X
#undef FOLLY_DETAIL_CPUID_X
private:
uint32_t f1c_ = 0;

View File

@ -1,11 +1,11 @@
/*
* Copyright 2018-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -46,6 +46,15 @@ class DefaultKeepAliveExecutor : public virtual Executor {
keepAliveReleaseBaton_.wait();
}
void joinAndResetKeepAlive() {
joinKeepAlive();
auto keepAliveCount =
controlBlock_->keepAliveCount_.exchange(1, std::memory_order_relaxed);
DCHECK_EQ(keepAliveCount, 0);
keepAliveReleaseBaton_.reset();
keepAlive_ = makeKeepAlive(this);
}
private:
struct ControlBlock {
std::atomic<ssize_t> keepAliveCount_{1};
@ -143,8 +152,7 @@ class DefaultKeepAliveExecutor : public virtual Executor {
std::shared_ptr<ControlBlock> controlBlock_{std::make_shared<ControlBlock>()};
Baton<> keepAliveReleaseBaton_;
KeepAlive<DefaultKeepAliveExecutor> keepAlive_{
makeKeepAlive<DefaultKeepAliveExecutor>(this)};
KeepAlive<DefaultKeepAliveExecutor> keepAlive_{makeKeepAlive(this)};
};
} // namespace folly

View File

@ -1,11 +1,11 @@
/*
* Copyright 2014-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -20,6 +20,7 @@
#include <cstring>
#include <folly/detail/Demangle.h>
#include <folly/lang/CString.h>
#include <folly/portability/Config.h>
#if FOLLY_DETAIL_HAVE_DEMANGLE_H
@ -33,6 +34,9 @@ namespace folly {
#if FOLLY_DETAIL_HAVE_DEMANGLE_H
fbstring demangle(const char* name) {
if (!name) {
return fbstring();
}
#ifdef FOLLY_DEMANGLE_MAX_SYMBOL_SIZE
// GCC's __cxa_demangle() uses on-stack data structures for the
// parser state which are linear in the number of components of the
@ -118,14 +122,4 @@ size_t demangle(const char* name, char* out, size_t outSize) {
#endif
size_t strlcpy(char* dest, const char* const src, size_t size) {
size_t len = strlen(src);
if (size != 0) {
size_t n = std::min(len, size - 1); // always null terminate!
memcpy(dest, src, n);
dest[n] = '\0';
}
return len;
}
} // namespace folly

View File

@ -1,11 +1,11 @@
/*
* Copyright 2014-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -54,12 +54,9 @@ inline fbstring demangle(const std::type_info& type) {
* libiberty), so it is possible for the fbstring version to work, while this
* version returns the original, mangled name.
*/
size_t demangle(const char* name, char* buf, size_t bufSize);
size_t demangle(const char* name, char* out, size_t outSize);
inline size_t demangle(const std::type_info& type, char* buf, size_t bufSize) {
return demangle(type.name(), buf, bufSize);
}
// glibc doesn't have strlcpy
size_t strlcpy(char* dest, const char* const src, size_t size);
} // namespace folly

View File

@ -1,11 +1,11 @@
/*
* Copyright 2011-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,11 +1,11 @@
/*
* Copyright 2012-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -27,7 +27,9 @@
#include <folly/Likely.h>
#include <folly/Optional.h>
#include <folly/Traits.h>
#include <folly/Utility.h>
#include <folly/dynamic.h>
#include <folly/lang/Exception.h>
namespace folly {
template <typename T>
@ -110,7 +112,7 @@ struct Dereferencer {
static inline void derefToCache(
Optional<T>* /* mem */,
const dynamic::const_item_iterator& /* it */) {
throw TypeError("array", dynamic::Type::OBJECT);
throw_exception<TypeError>("array", dynamic::Type::OBJECT);
}
static inline void derefToCache(
@ -249,7 +251,7 @@ struct DynamicConverter<std::pair<F, S>> {
auto it = d.items().begin();
return std::make_pair(convertTo<F>(it->first), convertTo<S>(it->second));
} else {
throw TypeError("array (size 2) or object (size 1)", d.type());
throw_exception<TypeError>("array (size 2) or object (size 1)", d.type());
}
}
};
@ -271,7 +273,7 @@ struct DynamicConverter<
dynamicconverter_detail::conversionIterator<C>(d.items().begin()),
dynamicconverter_detail::conversionIterator<C>(d.items().end()));
} else {
throw TypeError("object or array", d.type());
throw_exception<TypeError>("object or array", d.type());
}
}
};
@ -295,7 +297,7 @@ struct DynamicConverter<
dynamicconverter_detail::conversionIterator<C>(d.items().begin()),
dynamicconverter_detail::conversionIterator<C>(d.items().end()));
} else {
throw TypeError("object or array", d.type());
throw_exception<TypeError>("object or array", d.type());
}
return ret;
}
@ -327,6 +329,16 @@ struct DynamicConstructor<
}
};
// enums
template <typename C>
struct DynamicConstructor<
C,
typename std::enable_if<std::is_enum<C>::value>::type> {
static dynamic construct(const C& x) {
return dynamic(to_underlying(x));
}
};
// maps
template <typename C>
struct DynamicConstructor<

View File

@ -1,11 +1,11 @@
/*
* Copyright 2013-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -63,12 +63,12 @@ std::system_error makeSystemError(Args&&... args) {
// Helper to throw std::system_error
[[noreturn]] inline void throwSystemErrorExplicit(int err, const char* msg) {
throw makeSystemErrorExplicit(err, msg);
throw_exception(makeSystemErrorExplicit(err, msg));
}
template <class... Args>
[[noreturn]] void throwSystemErrorExplicit(int err, Args&&... args) {
throw makeSystemErrorExplicit(err, std::forward<Args>(args)...);
throw_exception(makeSystemErrorExplicit(err, std::forward<Args>(args)...));
}
// Helper to throw std::system_error from errno and components of a string
@ -132,11 +132,11 @@ void checkFopenErrorExplicit(FILE* fp, int savedErrno, Args&&... args) {
* If cond is not true, raise an exception of type E. E must have a ctor that
* works with const char* (a description of the failure).
*/
#define CHECK_THROW(cond, E) \
do { \
if (!(cond)) { \
throw E("Check failed: " #cond); \
} \
#define CHECK_THROW(cond, E) \
do { \
if (!(cond)) { \
folly::throw_exception<E>("Check failed: " #cond); \
} \
} while (0)
} // namespace folly

View File

@ -1,11 +1,11 @@
/*
* Copyright 2016-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -31,7 +31,7 @@ namespace folly {
* defined.
*/
inline fbstring exceptionStr(const std::exception& e) {
#ifdef FOLLY_HAS_RTTI
#if FOLLY_HAS_RTTI
fbstring rv(demangle(typeid(e)));
rv += ": ";
#else
@ -41,29 +41,27 @@ inline fbstring exceptionStr(const std::exception& e) {
return rv;
}
// Empirically, this indicates if the runtime supports
// std::exception_ptr, as not all (arm, for instance) do.
#if defined(__GNUC__) && defined(__GCC_ATOMIC_INT_LOCK_FREE) && \
__GCC_ATOMIC_INT_LOCK_FREE > 1
inline fbstring exceptionStr(std::exception_ptr ep) {
try {
std::rethrow_exception(ep);
} catch (const std::exception& e) {
return exceptionStr(e);
} catch (...) {
return "<unknown exception>";
if (!kHasExceptions) {
return "Exception (catch unavailable)";
}
return catch_exception(
[&]() -> fbstring {
return catch_exception<std::exception const&>(
[&]() -> fbstring { std::rethrow_exception(ep); },
[](auto&& e) { return exceptionStr(e); });
},
[]() -> fbstring { return "<unknown exception>"; });
}
#endif
template <typename E>
auto exceptionStr(const E& e) -> typename std::
enable_if<!std::is_base_of<std::exception, E>::value, fbstring>::type {
#ifdef FOLLY_HAS_RTTI
#if FOLLY_HAS_RTTI
return demangle(typeid(e));
#else
(void)e;
return "Exception (no RTTI available) ";
return "Exception (no RTTI available)";
#endif
}

View File

@ -1,11 +1,11 @@
/*
* Copyright 2017-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
*
* Author: Eric Niebler <eniebler@fb.com>
@ -201,7 +202,7 @@ inline void exception_wrapper::InPlace<Ex>::delete_(exception_wrapper* that) {
template <class Ex>
[[noreturn]] inline void exception_wrapper::InPlace<Ex>::throw_(
exception_wrapper const* that) {
throw that->buff_.as<Ex>(); // @nolint
throw that->buff_.as<Ex>();
}
template <class Ex>
inline std::type_info const* exception_wrapper::InPlace<Ex>::type_(
@ -226,7 +227,7 @@ inline exception_wrapper exception_wrapper::InPlace<Ex>::get_exception_ptr_(
template <class Ex>
[[noreturn]] inline void exception_wrapper::SharedPtr::Impl<Ex>::throw_()
const {
throw ex_; // @nolint
throw ex_;
}
template <class Ex>
inline std::exception const*
@ -343,7 +344,7 @@ inline exception_wrapper::exception_wrapper(
namespace exception_wrapper_detail {
template <class Ex>
Ex&& dont_slice(Ex&& ex) {
assert(typeid(ex) == typeid(_t<std::decay<Ex>>) ||
assert(typeid(ex) == typeid(std::decay_t<Ex>) ||
!"Dynamic and static exception types don't match. Exception would "
"be sliced when storing in exception_wrapper.");
return std::forward<Ex>(ex);
@ -479,12 +480,12 @@ template <class Ex>
template <class CatchFn, bool IsConst>
struct exception_wrapper::ExceptionTypeOf {
using type = arg_type<_t<std::decay<CatchFn>>>;
using type = arg_type<std::decay_t<CatchFn>>;
static_assert(
std::is_reference<type>::value,
"Always catch exceptions by reference.");
static_assert(
!IsConst || std::is_const<_t<std::remove_reference<type>>>::value,
!IsConst || std::is_const<std::remove_reference_t<type>>::value,
"handle() or with_exception() called on a const exception_wrapper "
"and asked to catch a non-const exception. Handler will never fire. "
"Catch exception by const reference to fix this.");
@ -550,7 +551,7 @@ struct exception_wrapper::HandleStdExceptReduce {
return
[th = std::forward<ThrowFn>(th), &ca](auto&& continuation) -> StdEx* {
if (auto e = const_cast<StdEx*>(th(continuation))) {
if (auto e2 = dynamic_cast<_t<std::add_pointer<Ex>>>(e)) {
if (auto e2 = dynamic_cast<std::add_pointer_t<Ex>>(e)) {
ca(*e2);
} else {
return e;

View File

@ -1,11 +1,11 @@
/*
* Copyright 2014-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Author: Eric Niebler <eniebler@fb.com>
*/
@ -52,7 +53,7 @@ FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS
namespace folly {
#define FOLLY_REQUIRES_DEF(...) \
_t<std::enable_if<static_cast<bool>(__VA_ARGS__), long>>
std::enable_if_t<static_cast<bool>(__VA_ARGS__), long>
#define FOLLY_REQUIRES(...) FOLLY_REQUIRES_DEF(__VA_ARGS__) = __LINE__
@ -62,16 +63,15 @@ template <template <class> class T, class... As>
using AllOf = StrictConjunction<T<As>...>;
template <bool If, class T>
using AddConstIf = _t<std::conditional<If, const T, T>>;
using AddConstIf = std::conditional_t<If, const T, T>;
template <class Fn, class A>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN auto fold(Fn&&, A&& a) {
FOLLY_ERASE auto fold(Fn&&, A&& a) {
return static_cast<A&&>(a);
}
template <class Fn, class A, class B, class... Bs>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN auto
fold(Fn&& fn, A&& a, B&& b, Bs&&... bs) {
FOLLY_ERASE auto fold(Fn&& fn, A&& a, B&& b, Bs&&... bs) {
return fold(
// This looks like a use of fn after a move of fn, but in reality, this is
// just a cast and not a move. That's because regardless of which fold
@ -206,12 +206,12 @@ class exception_wrapper final {
static VTable const uninit_;
template <class Ex>
using IsStdException = std::is_base_of<std::exception, _t<std::decay<Ex>>>;
using IsStdException = std::is_base_of<std::exception, std::decay_t<Ex>>;
template <bool B, class T>
using AddConstIf = exception_wrapper_detail::AddConstIf<B, T>;
template <class CatchFn>
using IsCatchAll =
std::is_same<arg_type<_t<std::decay<CatchFn>>>, AnyException>;
std::is_same<arg_type<std::decay_t<CatchFn>>, AnyException>;
struct Unknown {};
@ -221,7 +221,7 @@ class exception_wrapper final {
// and runtime_error can be safely stored internally.
struct Buffer {
using Storage =
_t<std::aligned_storage<2 * sizeof(void*), alignof(std::exception)>>;
std::aligned_storage_t<2 * sizeof(void*), alignof(std::exception)>;
Storage buff_;
Buffer() : buff_{} {}
@ -239,16 +239,16 @@ class exception_wrapper final {
struct OnHeapTag {};
template <class T>
using PlacementOf = _t<std::conditional<
using PlacementOf = std::conditional_t<
!IsStdException<T>::value,
ThrownTag,
_t<std::conditional<
std::conditional_t<
sizeof(T) <= sizeof(Buffer::Storage) &&
alignof(T) <= alignof(Buffer::Storage) &&
noexcept(T(std::declval<T&&>())) &&
noexcept(T(std::declval<T const&>())),
InSituTag,
OnHeapTag>>>>;
OnHeapTag>>;
static std::exception const* as_exception_or_null_(std::exception const& ex);
static std::exception const* as_exception_or_null_(AnyException);
@ -429,7 +429,7 @@ class exception_wrapper final {
//! converted to an `exception_wrapper`.
template <
class Ex,
class Ex_ = _t<std::decay<Ex>>,
class Ex_ = std::decay_t<Ex>,
FOLLY_REQUIRES(
Conjunction<IsStdException<Ex_>, IsRegularExceptionType<Ex_>>::value)>
/* implicit */ exception_wrapper(Ex&& ex);
@ -443,7 +443,7 @@ class exception_wrapper final {
//! `folly::in_place` as the first parameter.
template <
class Ex,
class Ex_ = _t<std::decay<Ex>>,
class Ex_ = std::decay_t<Ex>,
FOLLY_REQUIRES(IsRegularExceptionType<Ex_>::value)>
exception_wrapper(in_place_t, Ex&& ex);

View File

@ -1,11 +1,11 @@
/*
* Copyright 2014-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -18,14 +18,38 @@
#include <cassert>
#include <climits>
#include <utility>
#include <folly/Function.h>
#include <folly/Utility.h>
namespace folly {
namespace pushmi {
// derive from this for types that need to find operator|() overloads by ADL
struct folly_pipeorigin {};
} // namespace pushmi
using Func = Function<void()>;
namespace detail {
class ExecutorKeepAliveBase {
public:
// A dummy keep-alive is a keep-alive to an executor which does not support
// the keep-alive mechanism.
static constexpr uintptr_t kDummyFlag = uintptr_t(1) << 0;
// An alias keep-alive is a keep-alive to an executor to which there is
// known to be another keep-alive whose lifetime surrounds the lifetime of
// the alias.
static constexpr uintptr_t kAliasFlag = uintptr_t(1) << 1;
static constexpr uintptr_t kFlagMask = kDummyFlag | kAliasFlag;
static constexpr uintptr_t kExecutorMask = ~kFlagMask;
};
} // namespace detail
/// An Executor accepts units of work with add(), which should be
/// threadsafe.
class Executor {
@ -49,9 +73,25 @@ class Executor {
static const int8_t MID_PRI = 0;
static const int8_t HI_PRI = SCHAR_MAX;
/**
* Executor::KeepAlive is a safe pointer to an Executor.
* For any Executor that supports KeepAlive functionality, Executor's
* destructor will block until all the KeepAlive objects associated with that
* Executor are destroyed.
* For Executors that don't support the KeepAlive funcionality, KeepAlive
* doesn't provide such protection.
*
* KeepAlive should *always* be used instead of Executor*. KeepAlive can be
* implicitly constructed from Executor*. getKeepAliveToken() helper method
* can be used to construct a KeepAlive in templated code if you need to
* preserve the original Executor type.
*/
template <typename ExecutorT = Executor>
class KeepAlive {
class KeepAlive : pushmi::folly_pipeorigin,
private detail::ExecutorKeepAliveBase {
public:
using KeepAliveFunc = Function<void(KeepAlive&&)>;
KeepAlive() = default;
~KeepAlive() {
@ -59,23 +99,41 @@ class Executor {
}
KeepAlive(KeepAlive&& other) noexcept
: executorAndDummyFlag_(exchange(other.executorAndDummyFlag_, 0)) {}
: storage_(std::exchange(other.storage_, 0)) {}
KeepAlive(const KeepAlive& other) noexcept
: KeepAlive(getKeepAliveToken(other.get())) {}
template <
typename OtherExecutor,
typename = typename std::enable_if<
std::is_convertible<OtherExecutor*, ExecutorT*>::value>::type>
/* implicit */ KeepAlive(KeepAlive<OtherExecutor>&& other) noexcept
: KeepAlive(other.get(), other.executorAndDummyFlag_ & kDummyFlag) {
other.executorAndDummyFlag_ = 0;
: KeepAlive(other.get(), other.storage_ & kFlagMask) {
other.storage_ = 0;
}
template <
typename OtherExecutor,
typename = typename std::enable_if<
std::is_convertible<OtherExecutor*, ExecutorT*>::value>::type>
/* implicit */ KeepAlive(const KeepAlive<OtherExecutor>& other) noexcept
: KeepAlive(getKeepAliveToken(other.get())) {}
/* implicit */ KeepAlive(ExecutorT* executor) {
*this = getKeepAliveToken(executor);
}
KeepAlive& operator=(KeepAlive&& other) {
reset();
executorAndDummyFlag_ = exchange(other.executorAndDummyFlag_, 0);
storage_ = std::exchange(other.storage_, 0);
return *this;
}
KeepAlive& operator=(KeepAlive const& other) {
return operator=(folly::copy(other));
}
template <
typename OtherExecutor,
typename = typename std::enable_if<
@ -84,22 +142,29 @@ class Executor {
return *this = KeepAlive(std::move(other));
}
template <
typename OtherExecutor,
typename = typename std::enable_if<
std::is_convertible<OtherExecutor*, ExecutorT*>::value>::type>
KeepAlive& operator=(const KeepAlive<OtherExecutor>& other) {
return *this = KeepAlive(other);
}
void reset() {
if (Executor* executor = get()) {
if (exchange(executorAndDummyFlag_, 0) & kDummyFlag) {
return;
auto const flags = std::exchange(storage_, 0) & kFlagMask;
if (!(flags & (kDummyFlag | kAliasFlag))) {
executor->keepAliveRelease();
}
executor->keepAliveRelease();
}
}
explicit operator bool() const {
return executorAndDummyFlag_;
return storage_;
}
ExecutorT* get() const {
return reinterpret_cast<ExecutorT*>(
executorAndDummyFlag_ & kExecutorMask);
return reinterpret_cast<ExecutorT*>(storage_ & kExecutorMask);
}
ExecutorT& operator*() const {
@ -111,27 +176,42 @@ class Executor {
}
KeepAlive copy() const {
return getKeepAliveToken(get());
return isKeepAliveDummy(*this) //
? makeKeepAliveDummy(get())
: getKeepAliveToken(get());
}
KeepAlive get_alias() const {
return KeepAlive(storage_ | kAliasFlag);
}
template <class KAF>
void add(KAF&& f) && {
static_assert(
is_invocable<KAF, KeepAlive&&>::value,
"Parameter to add must be void(KeepAlive&&)>");
auto ex = get();
ex->add([ka = std::move(*this), f = std::forward<KAF>(f)]() mutable {
f(std::move(ka));
});
}
private:
static constexpr intptr_t kDummyFlag = 1;
static constexpr intptr_t kExecutorMask = ~kDummyFlag;
friend class Executor;
template <typename OtherExecutor>
friend class KeepAlive;
KeepAlive(ExecutorT* executor, bool dummy)
: executorAndDummyFlag_(
reinterpret_cast<intptr_t>(executor) | (dummy ? kDummyFlag : 0)) {
KeepAlive(ExecutorT* executor, uintptr_t flags) noexcept
: storage_(reinterpret_cast<uintptr_t>(executor) | flags) {
assert(executor);
assert(
(reinterpret_cast<intptr_t>(executor) & kExecutorMask) ==
reinterpret_cast<intptr_t>(executor));
assert(!(reinterpret_cast<uintptr_t>(executor) & ~kExecutorMask));
assert(!(flags & kExecutorMask));
}
intptr_t executorAndDummyFlag_{reinterpret_cast<intptr_t>(nullptr)};
explicit KeepAlive(uintptr_t storage) noexcept : storage_(storage) {}
// Combined storage for the executor pointer and for all flags.
uintptr_t storage_{reinterpret_cast<uintptr_t>(nullptr)};
};
template <typename ExecutorT>
@ -164,8 +244,7 @@ class Executor {
*/
template <typename ExecutorT>
static bool isKeepAliveDummy(const KeepAlive<ExecutorT>& keepAlive) {
return reinterpret_cast<intptr_t>(keepAlive.executorAndDummyFlag_) &
KeepAlive<ExecutorT>::kDummyFlag;
return keepAlive.storage_ & KeepAlive<ExecutorT>::kDummyFlag;
}
// Acquire a keep alive token. Should return false if keep-alive mechanism
@ -180,7 +259,7 @@ class Executor {
static_assert(
std::is_base_of<Executor, ExecutorT>::value,
"makeKeepAlive only works for folly::Executor implementations.");
return KeepAlive<ExecutorT>{executor, false};
return KeepAlive<ExecutorT>{executor, uintptr_t(0)};
}
private:
@ -189,7 +268,7 @@ class Executor {
static_assert(
std::is_base_of<Executor, ExecutorT>::value,
"makeKeepAliveDummy only works for folly::Executor implementations.");
return KeepAlive<ExecutorT>{executor, true};
return KeepAlive<ExecutorT>{executor, KeepAlive<ExecutorT>::kDummyFlag};
}
};
@ -212,4 +291,10 @@ Executor::KeepAlive<ExecutorT> getKeepAliveToken(ExecutorT& executor) {
return getKeepAliveToken(&executor);
}
template <typename ExecutorT>
Executor::KeepAlive<ExecutorT> getKeepAliveToken(
Executor::KeepAlive<ExecutorT>& ka) {
return ka.copy();
}
} // namespace folly

View File

@ -1,11 +1,11 @@
/*
* Copyright 2016-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Like folly::Optional, but can store a value *or* an error.
*
@ -37,7 +38,6 @@
#include <folly/Traits.h>
#include <folly/Unit.h>
#include <folly/Utility.h>
#include <folly/lang/ColdClass.h>
#include <folly/lang/Exception.h>
#define FOLLY_EXPECTED_ID(X) FB_CONCATENATE(FB_CONCATENATE(Folly, X), __LINE__)
@ -52,17 +52,6 @@
#define FOLLY_REQUIRES(...) template <FOLLY_REQUIRES_IMPL(__VA_ARGS__)>
/**
* gcc-4.7 warns about use of uninitialized memory around the use of storage_
* even though this is explicitly initialized at each point.
*/
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // __GNUC__
namespace folly {
/**
@ -101,15 +90,8 @@ namespace expected_detail {
template <typename Value, typename Error>
struct PromiseReturn;
#ifdef _MSC_VER
// MSVC 2015 can't handle the StrictConjunction, so we have
// to use std::conjunction instead.
template <template <class...> class Trait, class... Ts>
using StrictAllOf = std::conjunction<Trait<Ts>...>;
#else
template <template <class...> class Trait, class... Ts>
using StrictAllOf = StrictConjunction<Trait<Ts>...>;
#endif
template <class T>
using IsCopyable = StrictConjunction<
@ -230,6 +212,7 @@ struct ExpectedStorage {
case Which::eError:
this->assignError(static_cast<Other&&>(that).error());
break;
case Which::eEmpty:
default:
this->clear();
break;
@ -244,11 +227,6 @@ struct ExpectedStorage {
Value&& value() && {
return std::move(value_);
}
// TODO (t17322426): remove when VS2015 support is deprecated
// VS2015 static analyzer incorrectly flags these as unreachable in certain
// circumstances. VS2017 does not have this problem on the same code.
FOLLY_PUSH_WARNING
FOLLY_MSVC_DISABLE_WARNING(4702) // unreachable code
Error& error() & {
return error_;
}
@ -258,7 +236,6 @@ struct ExpectedStorage {
Error&& error() && {
return std::move(error_);
}
FOLLY_POP_WARNING
};
template <class Value, class Error>
@ -430,6 +407,7 @@ struct ExpectedStorage<Value, Error, StorageType::eUnion>
case Which::eError:
this->error().~Error();
break;
case Which::eEmpty:
default:
break;
}
@ -480,6 +458,7 @@ struct ExpectedStorage<Value, Error, StorageType::eUnion>
case Which::eError:
this->assignError(static_cast<Other&&>(that).error());
break;
case Which::eEmpty:
default:
this->clear();
break;
@ -531,6 +510,7 @@ struct ExpectedStorage<Value, Error, StorageType::ePODStruct> {
case Which::eError:
this->assignError(static_cast<Other&&>(that).error());
break;
case Which::eEmpty:
default:
this->clear();
break;
@ -545,11 +525,6 @@ struct ExpectedStorage<Value, Error, StorageType::ePODStruct> {
Value&& value() && {
return std::move(value_);
}
// TODO (t17322426): remove when VS2015 support is deprecated
// VS2015 static analyzer incorrectly flags these as unreachable in certain
// circumstances. VS2017 does not have this problem on the same code.
FOLLY_PUSH_WARNING
FOLLY_MSVC_DISABLE_WARNING(4702) // unreachable code
Error& error() & {
return error_;
}
@ -559,7 +534,6 @@ struct ExpectedStorage<Value, Error, StorageType::ePODStruct> {
Error&& error() && {
return std::move(error_);
}
FOLLY_POP_WARNING
};
namespace expected_detail_ExpectedHelper {
@ -675,7 +649,7 @@ namespace expected_detail {
* Expected objects in the error state.
*/
template <class Error>
class Unexpected final : ColdClass {
class Unexpected final {
template <class E>
friend class Unexpected;
template <class V, class E>
@ -712,8 +686,10 @@ class Unexpected final : ColdClass {
Unexpected(Unexpected&&) = default;
Unexpected& operator=(const Unexpected&) = default;
Unexpected& operator=(Unexpected&&) = default;
constexpr /* implicit */ Unexpected(const Error& err) : error_(err) {}
constexpr /* implicit */ Unexpected(Error&& err) : error_(std::move(err)) {}
FOLLY_COLD constexpr /* implicit */ Unexpected(const Error& err)
: error_(err) {}
FOLLY_COLD constexpr /* implicit */ Unexpected(Error&& err)
: error_(std::move(err)) {}
template <class Other FOLLY_REQUIRES_TRAILING(
std::is_constructible<Error, Other&&>::value)>
@ -931,7 +907,7 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
std::is_constructible<Value, V&&>::value &&
std::is_constructible<Error, E&&>::value)>
Expected(Expected<V, E> that) : Base{expected_detail::EmptyTag{}} {
*this = std::move(that);
this->assign(std::move(that));
}
FOLLY_REQUIRES(std::is_copy_constructible<Value>::value)
@ -1425,10 +1401,6 @@ bool operator>(const Value& other, const Expected<Value, Error>&) = delete;
} // namespace folly
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#undef FOLLY_REQUIRES
#undef FOLLY_REQUIRES_TRAILING

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
/*
* Copyright 2011-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -37,6 +37,7 @@
#include <folly/FormatTraits.h>
#include <folly/Likely.h>
#include <folly/ScopeGuard.h>
#include <folly/Traits.h>
#include <folly/lang/Exception.h>
#include <folly/memory/Malloc.h>
@ -117,7 +118,7 @@ class fbvector {
// allocation
// note that 'allocate' and 'deallocate' are inherited from Allocator
T* D_allocate(size_type n) {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
return static_cast<T*>(checkedMalloc(n * sizeof(T)));
} else {
return std::allocator_traits<Allocator>::allocate(*this, n);
@ -125,7 +126,7 @@ class fbvector {
}
void D_deallocate(T* p, size_type n) noexcept {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
free(p);
} else {
std::allocator_traits<Allocator>::deallocate(*this, p, n);
@ -145,7 +146,7 @@ class fbvector {
// THIS DISPATCH CODE IS DUPLICATED IN fbvector::D_destroy_range_a.
// It has been inlined here for speed. It calls the static fbvector
// methods to perform the actual destruction.
if (usingStdAllocator::value) {
if (usingStdAllocator) {
S_destroy_range(b_, e_);
} else {
S_destroy_range_a(*this, b_, e_);
@ -174,12 +175,9 @@ class fbvector {
void reset(size_type newCap) {
destroy();
try {
init(newCap);
} catch (...) {
init(0);
throw;
}
auto rollback = makeGuard([&] { init(0); });
init(newCap);
rollback.dismiss();
}
void reset() { // same as reset(0)
destroy();
@ -189,7 +187,7 @@ class fbvector {
static void swap(Impl& a, Impl& b) {
using std::swap;
if (!usingStdAllocator::value) {
if (!usingStdAllocator) {
swap(static_cast<Allocator&>(a), static_cast<Allocator&>(b));
}
a.swapData(b);
@ -213,22 +211,16 @@ class fbvector {
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
private:
typedef bool_constant<
static constexpr bool should_pass_by_value =
is_trivially_copyable<T>::value &&
sizeof(T) <= 16 // don't force large structures to be passed by value
>
should_pass_by_value;
typedef
typename std::conditional<should_pass_by_value::value, T, const T&>::type
VT;
typedef
typename std::conditional<should_pass_by_value::value, T, T&&>::type MT;
sizeof(T) <= 16; // don't force large structures to be passed by value
typedef typename std::conditional<should_pass_by_value, T, const T&>::type VT;
typedef typename std::conditional<should_pass_by_value, T, T&&>::type MT;
typedef bool_constant<std::is_same<Allocator, std::allocator<T>>::value>
usingStdAllocator;
static constexpr bool usingStdAllocator =
std::is_same<Allocator, std::allocator<T>>::value;
typedef bool_constant<
usingStdAllocator::value ||
A::propagate_on_container_move_assignment::value>
usingStdAllocator || A::propagate_on_container_move_assignment::value>
moveIsSwap;
//===========================================================================
@ -257,7 +249,7 @@ class fbvector {
template <typename U, typename... Args>
void M_construct(U* p, Args&&... args) {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
new (p) U(std::forward<Args>(args)...);
} else {
std::allocator_traits<Allocator>::construct(
@ -282,7 +274,7 @@ class fbvector {
typename U,
typename Enable = typename std::enable_if<std::is_scalar<U>::value>::type>
void M_construct(U* p, U arg) {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
*p = arg;
} else {
std::allocator_traits<Allocator>::construct(impl_, p, arg);
@ -309,7 +301,7 @@ class fbvector {
typename Enable =
typename std::enable_if<!std::is_scalar<U>::value>::type>
void M_construct(U* p, const U& value) {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
new (p) U(value);
} else {
std::allocator_traits<Allocator>::construct(impl_, p, value);
@ -336,7 +328,7 @@ class fbvector {
// destroy
void M_destroy(T* p) noexcept {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
if (!std::is_trivially_destructible<T>::value) {
p->~T();
}
@ -361,7 +353,7 @@ class fbvector {
// dispatch
// THIS DISPATCH CODE IS DUPLICATED IN IMPL. SEE IMPL FOR DETAILS.
void D_destroy_range_a(T* first, T* last) noexcept {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
S_destroy_range(first, last);
} else {
S_destroy_range_a(impl_, first, last);
@ -380,7 +372,7 @@ class fbvector {
if (!std::is_trivially_destructible<T>::value) {
#define FOLLY_FBV_OP(p) (p)->~T()
// EXPERIMENTAL DATA on fbvector<vector<int>> (where each vector<int> has
// size 0).
// size 0), were vector<int> to be relocatable.
// The unrolled version seems to work faster for small to medium sized
// fbvectors. It gets a 10% speedup on fbvectors of size 1024, 64, and
// 16.
@ -411,7 +403,7 @@ class fbvector {
// dispatch
void D_uninitialized_fill_n_a(T* dest, size_type sz) {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
S_uninitialized_fill_n(dest, sz);
} else {
S_uninitialized_fill_n_a(impl_, dest, sz);
@ -419,7 +411,7 @@ class fbvector {
}
void D_uninitialized_fill_n_a(T* dest, size_type sz, VT value) {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
S_uninitialized_fill_n(dest, sz, value);
} else {
S_uninitialized_fill_n_a(impl_, dest, sz, value);
@ -435,51 +427,44 @@ class fbvector {
Args&&... args) {
auto b = dest;
auto e = dest + sz;
try {
for (; b != e; ++b) {
std::allocator_traits<Allocator>::construct(
a, b, std::forward<Args>(args)...);
}
} catch (...) {
S_destroy_range_a(a, dest, b);
throw;
auto rollback = makeGuard([&] { S_destroy_range_a(a, dest, b); });
for (; b != e; ++b) {
std::allocator_traits<Allocator>::construct(
a, b, std::forward<Args>(args)...);
}
rollback.dismiss();
}
// optimized
static void S_uninitialized_fill_n(T* dest, size_type n) {
if (folly::IsZeroInitializable<T>::value) {
if (LIKELY(n != 0)) {
std::memset(dest, 0, sizeof(T) * n);
std::memset((void*)dest, 0, sizeof(T) * n);
}
} else {
auto b = dest;
auto e = dest + n;
try {
for (; b != e; ++b) {
S_construct(b);
}
} catch (...) {
auto rollback = makeGuard([&] {
--b;
for (; b >= dest; --b) {
b->~T();
}
throw;
});
for (; b != e; ++b) {
S_construct(b);
}
rollback.dismiss();
}
}
static void S_uninitialized_fill_n(T* dest, size_type n, const T& value) {
auto b = dest;
auto e = dest + n;
try {
for (; b != e; ++b) {
S_construct(b, value);
}
} catch (...) {
S_destroy_range(dest, b);
throw;
auto rollback = makeGuard([&] { S_destroy_range(dest, b); });
for (; b != e; ++b) {
S_construct(b, value);
}
rollback.dismiss();
}
//---------------------------------------------------------------------------
@ -504,7 +489,7 @@ class fbvector {
// dispatch
template <typename It>
void D_uninitialized_copy_a(T* dest, It first, It last) {
if (usingStdAllocator::value) {
if (usingStdAllocator) {
if (folly::is_trivially_copyable<T>::value) {
S_uninitialized_copy_bits(dest, first, last);
} else {
@ -525,28 +510,22 @@ class fbvector {
template <typename It>
static void S_uninitialized_copy_a(Allocator& a, T* dest, It first, It last) {
auto b = dest;
try {
for (; first != last; ++first, ++b) {
std::allocator_traits<Allocator>::construct(a, b, *first);
}
} catch (...) {
S_destroy_range_a(a, dest, b);
throw;
auto rollback = makeGuard([&] { S_destroy_range_a(a, dest, b); });
for (; first != last; ++first, ++b) {
std::allocator_traits<Allocator>::construct(a, b, *first);
}
rollback.dismiss();
}
// optimized
template <typename It>
static void S_uninitialized_copy(T* dest, It first, It last) {
auto b = dest;
try {
for (; first != last; ++first, ++b) {
S_construct(b, *first);
}
} catch (...) {
S_destroy_range(dest, b);
throw;
auto rollback = makeGuard([&] { S_destroy_range(dest, b); });
for (; first != last; ++first, ++b) {
S_construct(b, *first);
}
rollback.dismiss();
}
static void
@ -654,13 +633,11 @@ class fbvector {
}
// dispatch type trait
typedef bool_constant<
folly::IsRelocatable<T>::value && usingStdAllocator::value>
typedef bool_constant<folly::IsRelocatable<T>::value && usingStdAllocator>
relocate_use_memcpy;
typedef bool_constant<
(std::is_nothrow_move_constructible<T>::value &&
usingStdAllocator::value) ||
(std::is_nothrow_move_constructible<T>::value && usingStdAllocator) ||
!std::is_copy_constructible<T>::value>
relocate_use_move;
@ -689,7 +666,7 @@ class fbvector {
// done
void relocate_done(T* /*dest*/, T* first, T* last) noexcept {
if (folly::IsRelocatable<T>::value && usingStdAllocator::value) {
if (folly::IsRelocatable<T>::value && usingStdAllocator) {
// used memcpy; data has been relocated, do not call destructor
} else {
D_destroy_range_a(first, last);
@ -698,11 +675,10 @@ class fbvector {
// undo
void relocate_undo(T* dest, T* first, T* last) noexcept {
if (folly::IsRelocatable<T>::value && usingStdAllocator::value) {
if (folly::IsRelocatable<T>::value && usingStdAllocator) {
// used memcpy, old data is still valid, nothing to do
} else if (
std::is_nothrow_move_constructible<T>::value &&
usingStdAllocator::value) {
std::is_nothrow_move_constructible<T>::value && usingStdAllocator) {
// noexcept move everything back, aka relocate_move
relocate_move(first, dest, dest + (last - first));
} else if (!std::is_copy_constructible<T>::value) {
@ -769,7 +745,7 @@ class fbvector {
return *this;
}
if (!usingStdAllocator::value &&
if (!usingStdAllocator &&
A::propagate_on_container_copy_assignment::value) {
if (impl_ != other.impl_) {
// can't use other's different allocator to clean up self
@ -906,7 +882,7 @@ class fbvector {
// contract dispatch for aliasing under VT optimization
bool dataIsInternalAndNotVT(const T& t) {
if (should_pass_by_value::value) {
if (should_pass_by_value) {
return false;
}
return dataIsInternal(t);
@ -1011,11 +987,10 @@ class fbvector {
auto newCap = folly::goodMallocSize(n * sizeof(T)) / sizeof(T);
auto newB = M_allocate(newCap);
try {
{
auto rollback = makeGuard([&] { M_deallocate(newB, newCap); });
M_relocate(newB);
} catch (...) {
M_deallocate(newB, newCap);
throw;
rollback.dismiss();
}
if (impl_.b_) {
M_deallocate(impl_.b_, size_type(impl_.z_ - impl_.b_));
@ -1042,21 +1017,31 @@ class fbvector {
void* p = impl_.b_;
// xallocx() will shrink to precisely newCapacityBytes (which was generated
// by goodMallocSize()) if it successfully shrinks in place.
if ((usingJEMalloc() && usingStdAllocator::value) &&
if ((usingJEMalloc() && usingStdAllocator) &&
newCapacityBytes >= folly::jemallocMinInPlaceExpandable &&
xallocx(p, newCapacityBytes, 0, 0) == newCapacityBytes) {
impl_.z_ += newCap - oldCap;
} else {
T* newB; // intentionally uninitialized
try {
newB = M_allocate(newCap);
try {
M_relocate(newB);
} catch (...) {
M_deallocate(newB, newCap);
return; // swallow the error
}
} catch (...) {
if (!catch_exception(
[&] {
newB = M_allocate(newCap);
return true;
},
[&] { //
return false;
})) {
return;
}
if (!catch_exception(
[&] {
M_relocate(newB);
return true;
},
[&] {
M_deallocate(newB, newCap);
return false;
})) {
return;
}
if (impl_.b_) {
@ -1070,7 +1055,7 @@ class fbvector {
private:
bool reserve_in_place(size_type n) {
if (!usingStdAllocator::value || !usingJEMalloc()) {
if (!usingStdAllocator || !usingJEMalloc()) {
return false;
}
@ -1145,13 +1130,14 @@ class fbvector {
// modifiers (common)
public:
template <class... Args>
void emplace_back(Args&&... args) {
reference emplace_back(Args&&... args) {
if (impl_.e_ != impl_.z_) {
M_construct(impl_.e_, std::forward<Args>(args)...);
++impl_.e_;
} else {
emplace_back_aux(std::forward<Args>(args)...);
}
return back();
}
void push_back(const T& value) {
@ -1179,7 +1165,7 @@ class fbvector {
}
void swap(fbvector& other) noexcept {
if (!usingStdAllocator::value && A::propagate_on_container_swap::value) {
if (!usingStdAllocator && A::propagate_on_container_swap::value) {
swap(impl_, other.impl_);
} else {
impl_.swapData(other.impl_);
@ -1223,7 +1209,69 @@ class fbvector {
}
template <class... Args>
void emplace_back_aux(Args&&... args);
void emplace_back_aux(Args&&... args) {
size_type byte_sz =
folly::goodMallocSize(computePushBackCapacity() * sizeof(T));
if (usingStdAllocator && usingJEMalloc() &&
((impl_.z_ - impl_.b_) * sizeof(T) >=
folly::jemallocMinInPlaceExpandable)) {
// Try to reserve in place.
// Ask xallocx to allocate in place at least size()+1 and at most sz
// space.
// xallocx will allocate as much as possible within that range, which
// is the best possible outcome: if sz space is available, take it all,
// otherwise take as much as possible. If nothing is available, then
// fail.
// In this fashion, we never relocate if there is a possibility of
// expanding in place, and we never reallocate by less than the desired
// amount unless we cannot expand further. Hence we will not reallocate
// sub-optimally twice in a row (modulo the blocking memory being freed).
size_type lower = folly::goodMallocSize(sizeof(T) + size() * sizeof(T));
size_type upper = byte_sz;
size_type extra = upper - lower;
void* p = impl_.b_;
size_t actual;
if ((actual = xallocx(p, lower, extra, 0)) >= lower) {
impl_.z_ = impl_.b_ + actual / sizeof(T);
M_construct(impl_.e_, std::forward<Args>(args)...);
++impl_.e_;
return;
}
}
// Reallocation failed. Perform a manual relocation.
size_type sz = byte_sz / sizeof(T);
auto newB = M_allocate(sz);
auto newE = newB + size();
{
auto rollback1 = makeGuard([&] { M_deallocate(newB, sz); });
if (folly::IsRelocatable<T>::value && usingStdAllocator) {
// For linear memory access, relocate before construction.
// By the test condition, relocate is noexcept.
// Note that there is no cleanup to do if M_construct throws - that's
// one of the beauties of relocation.
// Benchmarks for this code have high variance, and seem to be close.
relocate_move(newB, impl_.b_, impl_.e_);
M_construct(newE, std::forward<Args>(args)...);
++newE;
} else {
M_construct(newE, std::forward<Args>(args)...);
++newE;
auto rollback2 = makeGuard([&] { M_destroy(newE - 1); });
M_relocate(newB);
rollback2.dismiss();
}
rollback1.dismiss();
}
if (impl_.b_) {
M_deallocate(impl_.b_, size());
}
impl_.b_ = newB;
impl_.e_ = newE;
impl_.z_ = newB + sz;
}
//===========================================================================
//---------------------------------------------------------------------------
@ -1240,12 +1288,13 @@ class fbvector {
if (last == end()) {
M_destroy_range_e((iterator)first);
} else {
if (folly::IsRelocatable<T>::value && usingStdAllocator::value) {
if (folly::IsRelocatable<T>::value && usingStdAllocator) {
D_destroy_range_a((iterator)first, (iterator)last);
if (last - first >= cend() - last) {
std::memcpy((void*)first, (void*)last, (cend() - last) * sizeof(T));
} else {
std::memmove((iterator)first, last, (cend() - last) * sizeof(T));
std::memmove(
(void*)first, (void*)last, (cend() - last) * sizeof(T));
}
impl_.e_ -= (last - first);
} else {
@ -1339,20 +1388,21 @@ class fbvector {
relocate_done(position + n, position, impl_.e_);
impl_.e_ += n;
} else {
if (folly::IsRelocatable<T>::value && usingStdAllocator::value) {
std::memmove(position + n, position, tail * sizeof(T));
if (folly::IsRelocatable<T>::value && usingStdAllocator) {
std::memmove((void*)(position + n), (void*)position, tail * sizeof(T));
impl_.e_ += n;
} else {
D_uninitialized_move_a(impl_.e_, impl_.e_ - n, impl_.e_);
try {
{
auto rollback = makeGuard([&] {
D_destroy_range_a(impl_.e_ - n, impl_.e_ + n);
impl_.e_ -= n;
});
std::copy_backward(
std::make_move_iterator(position),
std::make_move_iterator(impl_.e_ - n),
impl_.e_);
} catch (...) {
D_destroy_range_a(impl_.e_ - n, impl_.e_ + n);
impl_.e_ -= n;
throw;
rollback.dismiss();
}
impl_.e_ += n;
D_destroy_range_a(position, position + n);
@ -1373,11 +1423,12 @@ class fbvector {
assert(n != 0);
relocate_move(ledge, impl_.b_, impl_.b_ + idx);
try {
{
auto rollback = makeGuard([&] { //
relocate_undo(ledge, impl_.b_, impl_.b_ + idx);
});
relocate_move(ledge + idx + n, impl_.b_ + idx, impl_.e_);
} catch (...) {
relocate_undo(ledge, impl_.b_, impl_.b_ + idx);
throw;
rollback.dismiss();
}
relocate_done(ledge, impl_.b_, impl_.b_ + idx);
relocate_done(ledge + idx + n, impl_.b_ + idx, impl_.e_);
@ -1449,30 +1500,32 @@ class fbvector {
}
T* start = b + idx;
try {
{
auto rollback = makeGuard([&] {
if (fresh) {
M_deallocate(b, newCap);
} else {
if (!at_end) {
undo_window(position, n);
} else {
impl_.e_ -= n;
}
}
});
// construct the inserted elements
constructFunc(start);
} catch (...) {
if (fresh) {
M_deallocate(b, newCap);
} else {
if (!at_end) {
undo_window(position, n);
} else {
impl_.e_ -= n;
}
}
throw;
rollback.dismiss();
}
if (fresh) {
try {
{
auto rollback = makeGuard([&] {
// delete the inserted elements (exception has been thrown)
destroyFunc(start);
M_deallocate(b, newCap);
});
wrap_frame(b, idx, n);
} catch (...) {
// delete the inserted elements (exception has been thrown)
destroyFunc(start);
M_deallocate(b, newCap);
throw;
rollback.dismiss();
}
if (impl_.b_) {
M_deallocate(impl_.b_, capacity());
@ -1618,78 +1671,6 @@ class fbvector {
}; // class fbvector
//=============================================================================
//-----------------------------------------------------------------------------
// outlined functions (gcc, you finicky compiler you)
template <typename T, typename Allocator>
template <class... Args>
void fbvector<T, Allocator>::emplace_back_aux(Args&&... args) {
size_type byte_sz =
folly::goodMallocSize(computePushBackCapacity() * sizeof(T));
if (usingStdAllocator::value && usingJEMalloc() &&
((impl_.z_ - impl_.b_) * sizeof(T) >=
folly::jemallocMinInPlaceExpandable)) {
// Try to reserve in place.
// Ask xallocx to allocate in place at least size()+1 and at most sz space.
// xallocx will allocate as much as possible within that range, which
// is the best possible outcome: if sz space is available, take it all,
// otherwise take as much as possible. If nothing is available, then fail.
// In this fashion, we never relocate if there is a possibility of
// expanding in place, and we never reallocate by less than the desired
// amount unless we cannot expand further. Hence we will not reallocate
// sub-optimally twice in a row (modulo the blocking memory being freed).
size_type lower = folly::goodMallocSize(sizeof(T) + size() * sizeof(T));
size_type upper = byte_sz;
size_type extra = upper - lower;
void* p = impl_.b_;
size_t actual;
if ((actual = xallocx(p, lower, extra, 0)) >= lower) {
impl_.z_ = impl_.b_ + actual / sizeof(T);
M_construct(impl_.e_, std::forward<Args>(args)...);
++impl_.e_;
return;
}
}
// Reallocation failed. Perform a manual relocation.
size_type sz = byte_sz / sizeof(T);
auto newB = M_allocate(sz);
auto newE = newB + size();
try {
if (folly::IsRelocatable<T>::value && usingStdAllocator::value) {
// For linear memory access, relocate before construction.
// By the test condition, relocate is noexcept.
// Note that there is no cleanup to do if M_construct throws - that's
// one of the beauties of relocation.
// Benchmarks for this code have high variance, and seem to be close.
relocate_move(newB, impl_.b_, impl_.e_);
M_construct(newE, std::forward<Args>(args)...);
++newE;
} else {
M_construct(newE, std::forward<Args>(args)...);
++newE;
try {
M_relocate(newB);
} catch (...) {
M_destroy(newE - 1);
throw;
}
}
} catch (...) {
M_deallocate(newB, sz);
throw;
}
if (impl_.b_) {
M_deallocate(impl_.b_, size());
}
impl_.b_ = newB;
impl_.e_ = newE;
impl_.z_ = newB + sz;
}
//=============================================================================
//-----------------------------------------------------------------------------
// specialized functions
@ -1756,4 +1737,22 @@ void attach(fbvector<T, A>& v, T* data, size_t sz, size_t cap) {
v.impl_.z_ = data + cap;
}
#if __cpp_deduction_guides >= 201703
template <
class InputIt,
class Allocator =
std::allocator<typename std::iterator_traits<InputIt>::value_type>>
fbvector(InputIt, InputIt, Allocator = Allocator())
->fbvector<typename std::iterator_traits<InputIt>::value_type, Allocator>;
#endif
template <class T, class A, class U>
void erase(fbvector<T, A>& v, U value) {
v.erase(std::remove(v.begin(), v.end(), value), v.end());
}
template <class T, class A, class Predicate>
void erase_if(fbvector<T, A>& v, Predicate predicate) {
v.erase(std::remove_if(v.begin(), v.end(), predicate), v.end());
}
} // namespace folly

View File

@ -1,11 +1,11 @@
/*
* Copyright 2013-present Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,

Some files were not shown because too many files have changed in this diff Show More