Move to firebase for push notifications

This commit is contained in:
Michael Zanetti 2020-03-19 00:30:04 +01:00 committed by Michael Zanetti
parent 8436790fc2
commit 61a923253c
99 changed files with 30212 additions and 8 deletions

172
3rdParty/ios/Firebase/Firebase.h vendored Executable file
View File

@ -0,0 +1,172 @@
// 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 <FirebaseCore/FirebaseCore.h>
#if !defined(__has_include)
#error "Firebase.h won't import anything if your compiler doesn't support __has_include. Please \
import the headers individually."
#else
#if __has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
#import <FirebaseAnalytics/FirebaseAnalytics.h>
#endif
#if __has_include(<FirebaseAuth/FirebaseAuth.h>)
#import <FirebaseAuth/FirebaseAuth.h>
#endif
#if __has_include(<FirebaseCrashlytics/FirebaseCrashlytics.h>)
#import <FirebaseCrashlytics/FirebaseCrashlytics.h>
#endif
#if __has_include(<FirebaseDatabase/FirebaseDatabase.h>)
#import <FirebaseDatabase/FirebaseDatabase.h>
#endif
#if __has_include(<FirebaseDynamicLinks/FirebaseDynamicLinks.h>)
#import <FirebaseDynamicLinks/FirebaseDynamicLinks.h>
#if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
#ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#warning "FirebaseAnalytics.framework is not included in your target. Please add \
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure \
Firebase Dynamic Links works as intended."
#endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#endif
#endif
#if __has_include(<FirebaseFirestore/FirebaseFirestore.h>)
#import <FirebaseFirestore/FirebaseFirestore.h>
#endif
#if __has_include(<FirebaseFunctions/FirebaseFunctions.h>)
#import <FirebaseFunctions/FirebaseFunctions.h>
#endif
#if __has_include(<FirebaseInAppMessaging/FirebaseInAppMessaging.h>)
#import <FirebaseInAppMessaging/FirebaseInAppMessaging.h>
#if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
#ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#warning "FirebaseAnalytics.framework is not included in your target. Please add \
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure \
Firebase In App Messaging works as intended."
#endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#endif
#endif
#if __has_include(<FirebaseInstanceID/FirebaseInstanceID.h>)
#import <FirebaseInstanceID/FirebaseInstanceID.h>
#endif
#if __has_include(<FirebaseMessaging/FirebaseMessaging.h>)
#import <FirebaseMessaging/FirebaseMessaging.h>
#if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
#ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#warning "FirebaseAnalytics.framework is not included in your target. Please add \
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure \
Firebase Messaging works as intended."
#endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#endif
#endif
#if __has_include(<FirebaseMLCommon/FirebaseMLCommon.h>)
#import <FirebaseMLCommon/FirebaseMLCommon.h>
#endif
#if __has_include(<FirebaseMLModelInterpreter/FirebaseMLModelInterpreter.h>)
#import <FirebaseMLModelInterpreter/FirebaseMLModelInterpreter.h>
#endif
#if __has_include(<FirebaseMLNLLanguageID/FirebaseMLNLLanguageID.h>)
#import <FirebaseMLNLLanguageID/FirebaseMLNLLanguageID.h>
#endif
#if __has_include(<FirebaseMLNLSmartReply/FirebaseMLNLSmartReply.h>)
#import <FirebaseMLNLSmartReply/FirebaseMLNLSmartReply.h>
#endif
#if __has_include(<FirebaseMLNLTranslate/FirebaseMLNLTranslate.h>)
#import <FirebaseMLNLTranslate/FirebaseMLNLTranslate.h>
#endif
#if __has_include(<FirebaseMLNaturalLanguage/FirebaseMLNaturalLanguage.h>)
#import <FirebaseMLNaturalLanguage/FirebaseMLNaturalLanguage.h>
#endif
#if __has_include(<FirebaseMLVision/FirebaseMLVision.h>)
#import <FirebaseMLVision/FirebaseMLVision.h>
#endif
#if __has_include(<FirebaseMLVisionAutoML/FirebaseMLVisionAutoML.h>)
#import <FirebaseMLVisionAutoML/FirebaseMLVisionAutoML.h>
#endif
#if __has_include(<FirebaseMLVisionBarcodeModel/FirebaseMLVisionBarcodeModel.h>)
#import <FirebaseMLVisionBarcodeModel/FirebaseMLVisionBarcodeModel.h>
#endif
#if __has_include(<FirebaseMLVisionFaceModel/FirebaseMLVisionFaceModel.h>)
#import <FirebaseMLVisionFaceModel/FirebaseMLVisionFaceModel.h>
#endif
#if __has_include(<FirebaseMLVisionLabelModel/FirebaseMLVisionLabelModel.h>)
#import <FirebaseMLVisionLabelModel/FirebaseMLVisionLabelModel.h>
#endif
#if __has_include(<FirebaseMLVisionObjectDetection/FirebaseMLVisionObjectDetection.h>)
#import <FirebaseMLVisionObjectDetection/FirebaseMLVisionObjectDetection.h>
#endif
#if __has_include(<FirebaseMLVisionTextModel/FirebaseMLVisionTextModel.h>)
#import <FirebaseMLVisionTextModel/FirebaseMLVisionTextModel.h>
#endif
#if __has_include(<FirebasePerformance/FirebasePerformance.h>)
#import <FirebasePerformance/FirebasePerformance.h>
#if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
#ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#warning "FirebaseAnalytics.framework is not included in your target. Please add \
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure \
Firebase Performance works as intended."
#endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#endif
#endif
#if __has_include(<FirebaseRemoteConfig/FirebaseRemoteConfig.h>)
#import <FirebaseRemoteConfig/FirebaseRemoteConfig.h>
#if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
#ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#warning "FirebaseAnalytics.framework is not included in your target. Please add \
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure \
Firebase Remote Config works as intended."
#endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
#endif
#endif
#if __has_include(<FirebaseStorage/FirebaseStorage.h>)
#import <FirebaseStorage/FirebaseStorage.h>
#endif
#if __has_include(<GoogleMobileAds/GoogleMobileAds.h>)
#import <GoogleMobileAds/GoogleMobileAds.h>
#endif
#if __has_include(<Fabric/Fabric.h>)
#import <Fabric/Fabric.h>
#endif
#if __has_include(<Crashlytics/Crashlytics.h>)
#import <Crashlytics/Crashlytics.h>
#endif
#endif // defined(__has_include)

View File

@ -0,0 +1,127 @@
/*
* 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>
@class FIROptions;
NS_ASSUME_NONNULL_BEGIN
/** A block that takes a BOOL and has no return value. */
typedef void (^FIRAppVoidBoolCallback)(BOOL success) NS_SWIFT_NAME(FirebaseAppVoidBoolCallback);
/**
* The entry point of Firebase SDKs.
*
* Initialize and configure FIRApp using +[FIRApp configure]
* or other customized ways as shown below.
*
* The logging system has two modes: default mode and debug mode. In default mode, only logs with
* log level Notice, Warning and Error will be sent to device. In debug mode, all logs will be sent
* to device. The log levels that Firebase uses are consistent with the ASL log levels.
*
* Enable debug mode by passing the -FIRDebugEnabled argument to the application. You can add this
* argument in the application's Xcode scheme. When debug mode is enabled via -FIRDebugEnabled,
* further executions of the application will also be in debug mode. In order to return to default
* mode, you must explicitly disable the debug mode with the application argument -FIRDebugDisabled.
*
* It is also possible to change the default logging level in code by calling setLoggerLevel: on
* the FIRConfiguration interface.
*/
NS_SWIFT_NAME(FirebaseApp)
@interface FIRApp : NSObject
/**
* Configures a default Firebase app. Raises an exception if any configuration step fails. The
* default app is named "__FIRAPP_DEFAULT". This method should be called after the app is launched
* and before using Firebase services. This method is thread safe and contains synchronous file I/O
* (reading GoogleService-Info.plist from disk).
*/
+ (void)configure;
/**
* Configures the default Firebase app with the provided options. The default app is named
* "__FIRAPP_DEFAULT". Raises an exception if any configuration step fails. This method is thread
* safe.
*
* @param options The Firebase application options used to configure the service.
*/
+ (void)configureWithOptions:(FIROptions *)options NS_SWIFT_NAME(configure(options:));
/**
* Configures a Firebase app with the given name and options. Raises an exception if any
* configuration step fails. This method is thread safe.
*
* @param name The application's name given by the developer. The name should should only contain
Letters, Numbers and Underscore.
* @param options The Firebase application options used to configure the services.
*/
// clang-format off
+ (void)configureWithName:(NSString *)name
options:(FIROptions *)options NS_SWIFT_NAME(configure(name:options:));
// clang-format on
/**
* Returns the default app, or nil if the default app does not exist.
*/
+ (nullable FIRApp *)defaultApp NS_SWIFT_NAME(app());
/**
* Returns a previously created FIRApp instance with the given name, or nil if no such app exists.
* This method is thread safe.
*/
+ (nullable FIRApp *)appNamed:(NSString *)name NS_SWIFT_NAME(app(name:));
/**
* Returns the set of all extant FIRApp instances, or nil if there are no FIRApp instances. This
* method is thread safe.
*/
@property(class, readonly, nullable) NSDictionary<NSString *, FIRApp *> *allApps;
/**
* Cleans up the current FIRApp, freeing associated data and returning its name to the pool for
* future use. This method is thread safe.
*/
- (void)deleteApp:(FIRAppVoidBoolCallback)completion;
/**
* FIRApp instances should not be initialized directly. Call +[FIRApp configure],
* +[FIRApp configureWithOptions:], or +[FIRApp configureWithNames:options:] directly.
*/
- (instancetype)init NS_UNAVAILABLE;
/**
* Gets the name of this app.
*/
@property(nonatomic, copy, readonly) NSString *name;
/**
* Gets a copy of the options for this app. These are non-modifiable.
*/
@property(nonatomic, copy, readonly) FIROptions *options;
/**
* Gets or sets whether automatic data collection is enabled for all products. Defaults to `YES`
* unless `FirebaseDataCollectionDefaultEnabled` is set to `NO` in your app's Info.plist. This value
* is persisted across runs of the app so that it can be set once when users have consented to
* collection.
*/
@property(nonatomic, readwrite, getter=isDataCollectionDefaultEnabled)
BOOL dataCollectionDefaultEnabled;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,45 @@
/*
* 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>
#import <FirebaseCore/FIRLoggerLevel.h>
NS_ASSUME_NONNULL_BEGIN
/**
* This interface provides global level properties that the developer can tweak.
*/
NS_SWIFT_NAME(FirebaseConfiguration)
@interface FIRConfiguration : NSObject
/** Returns the shared configuration object. */
@property(class, nonatomic, readonly) FIRConfiguration *sharedInstance NS_SWIFT_NAME(shared);
/**
* Sets the logging level for internal Firebase logging. Firebase will only log messages
* that are logged at or below loggerLevel. The messages are logged both to the Xcode
* console and to the device's log. Note that if an app is running from AppStore, it will
* never log above FIRLoggerLevelNotice even if loggerLevel is set to a higher (more verbose)
* setting.
*
* @param loggerLevel The maximum logging level. The default level is set to FIRLoggerLevelNotice.
*/
- (void)setLoggerLevel:(FIRLoggerLevel)loggerLevel;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,38 @@
/*
* 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.
*/
// Note that importing GULLoggerLevel.h will lead to a non-modular header
// import error.
/**
* The log levels used by internal logging.
*/
typedef NS_ENUM(NSInteger, FIRLoggerLevel) {
/** Error level, matches ASL_LEVEL_ERR. */
FIRLoggerLevelError = 3,
/** Warning level, matches ASL_LEVEL_WARNING. */
FIRLoggerLevelWarning = 4,
/** Notice level, matches ASL_LEVEL_NOTICE. */
FIRLoggerLevelNotice = 5,
/** Info level, matches ASL_LEVEL_INFO. */
FIRLoggerLevelInfo = 6,
/** Debug level, matches ASL_LEVEL_DEBUG. */
FIRLoggerLevelDebug = 7,
/** Minimum log level. */
FIRLoggerLevelMin = FIRLoggerLevelError,
/** Maximum log level. */
FIRLoggerLevelMax = FIRLoggerLevelDebug
} NS_SWIFT_NAME(FirebaseLoggerLevel);

View File

@ -0,0 +1,123 @@
/*
* 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>
NS_ASSUME_NONNULL_BEGIN
/**
* This class provides constant fields of Google APIs.
*/
NS_SWIFT_NAME(FirebaseOptions)
@interface FIROptions : NSObject <NSCopying>
/**
* Returns the default options. The first time this is called it synchronously reads
* GoogleService-Info.plist from disk.
*/
+ (nullable FIROptions *)defaultOptions NS_SWIFT_NAME(defaultOptions());
/**
* An iOS API key used for authenticating requests from your app, e.g.
* @"AIzaSyDdVgKwhZl0sTTTLZ7iTmt1r3N2cJLnaDk", used to identify your app to Google servers.
*/
@property(nonatomic, copy, nullable) NSString *APIKey NS_SWIFT_NAME(apiKey);
/**
* The bundle ID for the application. Defaults to `[[NSBundle mainBundle] bundleID]` when not set
* manually or in a plist.
*/
@property(nonatomic, copy) NSString *bundleID;
/**
* The OAuth2 client ID for iOS application used to authenticate Google users, for example
* @"12345.apps.googleusercontent.com", used for signing in with Google.
*/
@property(nonatomic, copy, nullable) NSString *clientID;
/**
* The tracking ID for Google Analytics, e.g. @"UA-12345678-1", used to configure Google Analytics.
*/
@property(nonatomic, copy, nullable) NSString *trackingID;
/**
* The Project Number from the Google Developer's console, for example @"012345678901", used to
* configure Google Cloud Messaging.
*/
@property(nonatomic, copy) NSString *GCMSenderID NS_SWIFT_NAME(gcmSenderID);
/**
* The Project ID from the Firebase console, for example @"abc-xyz-123".
*/
@property(nonatomic, copy, nullable) NSString *projectID;
/**
* The Android client ID used in Google AppInvite when an iOS app has its Android version, for
* example @"12345.apps.googleusercontent.com".
*/
@property(nonatomic, copy, nullable) NSString *androidClientID;
/**
* The Google App ID that is used to uniquely identify an instance of an app.
*/
@property(nonatomic, copy) NSString *googleAppID;
/**
* The database root URL, e.g. @"http://abc-xyz-123.firebaseio.com".
*/
@property(nonatomic, copy, nullable) NSString *databaseURL;
/**
* The URL scheme used to set up Durable Deep Link service.
*/
@property(nonatomic, copy, nullable) NSString *deepLinkURLScheme;
/**
* The Google Cloud Storage bucket name, e.g. @"abc-xyz-123.storage.firebase.com".
*/
@property(nonatomic, copy, nullable) NSString *storageBucket;
/**
* The App Group identifier to share data between the application and the application extensions.
* The App Group must be configured in the application and on the Apple Developer Portal. Default
* value `nil`.
*/
@property(nonatomic, copy, nullable) NSString *appGroupID;
/**
* Initializes a customized instance of FIROptions from the file at the given plist file path. This
* will read the file synchronously from disk.
* For example,
* NSString *filePath =
* [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
* FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
* Returns nil if the plist file does not exist or is invalid.
*/
- (nullable instancetype)initWithContentsOfFile:(NSString *)plistPath;
/**
* Initializes a customized instance of FIROptions with required fields. Use the mutable properties
* to modify fields for configuring specific services.
*/
// clang-format off
- (instancetype)initWithGoogleAppID:(NSString *)googleAppID
GCMSenderID:(NSString *)GCMSenderID
NS_SWIFT_NAME(init(googleAppID:gcmSenderID:));
// clang-format on
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,20 @@
/*
* 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 "FIRApp.h"
#import "FIRConfiguration.h"
#import "FIRLoggerLevel.h"
#import "FIROptions.h"

View File

@ -0,0 +1,11 @@
framework module FirebaseCore {
umbrella header "FirebaseCore.h"
export *
module * { export * }
link framework "CoreTelephony"
link framework "Foundation"
link framework "Security"
link framework "SystemConfiguration"
link framework "UIKit"
link "z"
}

View File

@ -0,0 +1,120 @@
/*
* 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 FIRApp;
@class FIRInstallationsAuthTokenResult;
NS_ASSUME_NONNULL_BEGIN
/** A notification with this name is sent each time an installation is created or deleted. */
FOUNDATION_EXPORT const NSNotificationName FIRInstallationIDDidChangeNotification;
/** `userInfo` key for the `FirebaseApp.name` in `FIRInstallationIDDidChangeNotification`. */
FOUNDATION_EXPORT NSString *const kFIRInstallationIDDidChangeNotificationAppNameKey;
/**
* An installation ID handler block.
* @param identifier The installation ID string if exists or `nil` otherwise.
* @param error The error when `identifier == nil` or `nil` otherwise.
*/
typedef void (^FIRInstallationsIDHandler)(NSString *__nullable identifier,
NSError *__nullable error)
NS_SWIFT_NAME(InstallationsIDHandler);
/**
* An authorization token handler block.
* @param tokenResult An instance of `InstallationsAuthTokenResult` in case of success or `nil`
* otherwise.
* @param error The error when `tokenResult == nil` or `nil` otherwise.
*/
typedef void (^FIRInstallationsTokenHandler)(
FIRInstallationsAuthTokenResult *__nullable tokenResult, NSError *__nullable error)
NS_SWIFT_NAME(InstallationsTokenHandler);
/**
* The class provides API for Firebase Installations.
* Each configured `FirebaseApp` has a corresponding single instance of `Installations`.
* An instance of the class provides access to the installation info for the `FirebaseApp` as well
* as the ability to delete it. A Firebase Installation is unique by `FirebaseApp.name` and
* `FirebaseApp.options.googleAppID` .
*/
NS_SWIFT_NAME(Installations)
@interface FIRInstallations : NSObject
- (instancetype)init NS_UNAVAILABLE;
/**
* Returns a default instance of `Installations`.
* @returns An instance of `Installations` for `FirebaseApp.defaultApp().
* @throw Throws an exception if the default app is not configured yet or required `FirebaseApp`
* options are missing.
*/
+ (FIRInstallations *)installations NS_SWIFT_NAME(installations());
/**
* Returns an instance of `Installations` for an application.
* @param application A configured `FirebaseApp` instance.
* @returns An instance of `Installations` corresponding to the passed application.
* @throw Throws an exception if required `FirebaseApp` options are missing.
*/
+ (FIRInstallations *)installationsWithApp:(FIRApp *)application NS_SWIFT_NAME(installations(app:));
/**
* The method creates or retrieves an installation ID. The installation ID is a stable identifier
* that uniquely identifies the app instance. NOTE: If the application already has an existing
* FirebaseInstanceID then the InstanceID identifier will be used.
* @param completion A completion handler which is invoked when the operation completes. See
* `InstallationsIDHandler` for additional details.
*/
- (void)installationIDWithCompletion:(FIRInstallationsIDHandler)completion;
/**
* Retrieves (locally if it exists or from the server) a valid authorization token. An existing
* token may be invalidated or expired, so it is recommended to fetch the auth token before each
* server request. The method does the same as `Installations.authTokenForcingRefresh(:,
* completion:)` with forcing refresh `NO`.
* @param completion A completion handler which is invoked when the operation completes. See
* `InstallationsTokenHandler` for additional details.
*/
- (void)authTokenWithCompletion:(FIRInstallationsTokenHandler)completion;
/**
* Retrieves (locally or from the server depending on `forceRefresh` value) a valid authorization
* token. An existing token may be invalidated or expire, so it is recommended to fetch the auth
* token before each server request. This method should be used with `forceRefresh == YES` when e.g.
* a request with the previously fetched auth token failed with "Not Authorized" error.
* @param forceRefresh If `YES` then the locally cached auth token will be ignored and a new one
* will be requested from the server. If `NO`, then the locally cached auth token will be returned
* if exists and has not expired yet.
* @param completion A completion handler which is invoked when the operation completes. See
* `InstallationsTokenHandler` for additional details.
*/
- (void)authTokenForcingRefresh:(BOOL)forceRefresh
completion:(FIRInstallationsTokenHandler)completion;
/**
* Deletes all the installation data including the unique identifier, auth tokens and
* all related data on the server side. A network connection is required for the method to
* succeed. If fails, the existing installation data remains untouched.
* @param completion A completion handler which is invoked when the operation completes. `error ==
* nil` indicates success.
*/
- (void)deleteWithCompletion:(void (^)(NSError *__nullable error))completion;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,33 @@
/*
* 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
/** The class represents a result of the auth token request. */
NS_SWIFT_NAME(InstallationsAuthTokenResult)
@interface FIRInstallationsAuthTokenResult : NSObject
/** The authorization token string. */
@property(nonatomic, readonly) NSString *authToken;
/** The auth token expiration date. */
@property(nonatomic, readonly) NSDate *expirationDate;
@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>
extern NSString *const kFirebaseInstallationsErrorDomain;
typedef NS_ENUM(NSUInteger, FIRInstallationsErrorCode) {
/** Unknown error. See `userInfo` for details. */
FIRInstallationsErrorCodeUnknown = 0,
/** Keychain error. See `userInfo` for details. */
FIRInstallationsErrorCodeKeychain = 1,
/** Server unreachable. A network error or server is unavailable. See `userInfo` for details. */
FIRInstallationsErrorCodeServerUnreachable = 2,
/** FirebaseApp configuration issues e.g. invalid GMP-App-ID, etc. See `userInfo` for details. */
FIRInstallationsErrorCodeInvalidConfiguration = 3,
} NS_SWIFT_NAME(InstallationsErrorCode);

View File

@ -0,0 +1,19 @@
/*
* 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>
FOUNDATION_EXPORT const char *const FIRInstallationsVersionStr;

View File

@ -0,0 +1,20 @@
/*
* 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 "FIRInstallations.h"
#import "FIRInstallationsAuthTokenResult.h"
#import "FIRInstallationsErrors.h"
#import "FIRInstallationsVersion.h"

View File

@ -0,0 +1,11 @@
framework module FirebaseInstallations {
umbrella header "FirebaseInstallations.h"
export *
module * { export * }
link framework "CoreTelephony"
link framework "Foundation"
link framework "Security"
link framework "SystemConfiguration"
link framework "UIKit"
link "z"
}

View File

@ -0,0 +1,56 @@
/*
* Copyright 2018 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.
*/
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, GULSwizzlerMessageCode) {
// App Delegate Swizzling.
kGULSwizzlerMessageCodeAppDelegateSwizzling000 = 1000, // I-SWZ001000
kGULSwizzlerMessageCodeAppDelegateSwizzling001 = 1001, // I-SWZ001001
kGULSwizzlerMessageCodeAppDelegateSwizzling002 = 1002, // I-SWZ001002
kGULSwizzlerMessageCodeAppDelegateSwizzling003 = 1003, // I-SWZ001003
kGULSwizzlerMessageCodeAppDelegateSwizzling004 = 1004, // I-SWZ001004
kGULSwizzlerMessageCodeAppDelegateSwizzling005 = 1005, // I-SWZ001005
kGULSwizzlerMessageCodeAppDelegateSwizzling006 = 1006, // I-SWZ001006
kGULSwizzlerMessageCodeAppDelegateSwizzling007 = 1007, // I-SWZ001007
kGULSwizzlerMessageCodeAppDelegateSwizzling008 = 1008, // I-SWZ001008
kGULSwizzlerMessageCodeAppDelegateSwizzling009 = 1009, // I-SWZ001009
kGULSwizzlerMessageCodeAppDelegateSwizzling010 = 1010, // I-SWZ001010
kGULSwizzlerMessageCodeAppDelegateSwizzling011 = 1011, // I-SWZ001011
kGULSwizzlerMessageCodeAppDelegateSwizzling012 = 1012, // I-SWZ001012
kGULSwizzlerMessageCodeAppDelegateSwizzling013 = 1013, // I-SWZ001013
kGULSwizzlerMessageCodeAppDelegateSwizzlingInvalidAppDelegate = 1014, // I-SWZ001014
// Scene Delegate Swizzling.
kGULSwizzlerMessageCodeSceneDelegateSwizzling000 = 1100, // I-SWZ001100
kGULSwizzlerMessageCodeSceneDelegateSwizzling001 = 1101, // I-SWZ001101
kGULSwizzlerMessageCodeSceneDelegateSwizzling002 = 1102, // I-SWZ001102
kGULSwizzlerMessageCodeSceneDelegateSwizzling003 = 1103, // I-SWZ001103
kGULSwizzlerMessageCodeSceneDelegateSwizzling004 = 1104, // I-SWZ001104
kGULSwizzlerMessageCodeSceneDelegateSwizzling005 = 1105, // I-SWZ001105
kGULSwizzlerMessageCodeSceneDelegateSwizzling006 = 1106, // I-SWZ001106
kGULSwizzlerMessageCodeSceneDelegateSwizzling007 = 1107, // I-SWZ001107
kGULSwizzlerMessageCodeSceneDelegateSwizzling008 = 1108, // I-SWZ001108
kGULSwizzlerMessageCodeSceneDelegateSwizzling009 = 1109, // I-SWZ001109
kGULSwizzlerMessageCodeSceneDelegateSwizzling010 = 1110, // I-SWZ001110
kGULSwizzlerMessageCodeSceneDelegateSwizzling011 = 1111, // I-SWZ001111
kGULSwizzlerMessageCodeSceneDelegateSwizzling012 = 1112, // I-SWZ001112
kGULSwizzlerMessageCodeSceneDelegateSwizzling013 = 1113, // I-SWZ001113
kGULSwizzlerMessageCodeSceneDelegateSwizzlingInvalidSceneDelegate = 1114, // I-SWZ001114
// Method Swizzling.
kGULSwizzlerMessageCodeMethodSwizzling000 = 2000, // I-SWZ002000
};

View File

@ -0,0 +1,37 @@
/*
* 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 log levels used by internal logging.
*/
typedef NS_ENUM(NSInteger, GULLoggerLevel) {
/** Error level, matches ASL_LEVEL_ERR. */
GULLoggerLevelError = 3,
/** Warning level, matches ASL_LEVEL_WARNING. */
GULLoggerLevelWarning = 4,
/** Notice level, matches ASL_LEVEL_NOTICE. */
GULLoggerLevelNotice = 5,
/** Info level, matches ASL_LEVEL_INFO. */
GULLoggerLevelInfo = 6,
/** Debug level, matches ASL_LEVEL_DEBUG. */
GULLoggerLevelDebug = 7,
/** Minimum log level. */
GULLoggerLevelMin = GULLoggerLevelError,
/** Maximum log level. */
GULLoggerLevelMax = GULLoggerLevelDebug
} NS_SWIFT_NAME(GoogleLoggerLevel);

View File

@ -0,0 +1,49 @@
// 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>
/// This is a copy of Google Toolbox for Mac library to avoid creating an extra framework.
// NOTE: For 64bit, none of these apis handle input sizes >32bits, they will return nil when given
// such data. To handle data of that size you really should be streaming it rather then doing it all
// in memory.
@interface NSData (GULGzip)
/// Returns an data as the result of decompressing the payload of |data|.The data to decompress must
/// be a gzipped payloads.
+ (NSData *)gul_dataByInflatingGzippedData:(NSData *)data error:(NSError **)error;
/// Returns an compressed data with the result of gzipping the payload of |data|. Uses the default
/// compression level.
+ (NSData *)gul_dataByGzippingData:(NSData *)data error:(NSError **)error;
FOUNDATION_EXPORT NSString *const GULNSDataZlibErrorDomain;
FOUNDATION_EXPORT NSString *const GULNSDataZlibErrorKey; // NSNumber
FOUNDATION_EXPORT NSString *const GULNSDataZlibRemainingBytesKey; // NSNumber
typedef NS_ENUM(NSInteger, GULNSDataZlibError) {
GULNSDataZlibErrorGreaterThan32BitsToCompress = 1024,
// An internal zlib error.
// GULNSDataZlibErrorKey will contain the error value.
// NSLocalizedDescriptionKey may contain an error string from zlib.
// Look in zlib.h for list of errors.
GULNSDataZlibErrorInternal,
// There was left over data in the buffer that was not used.
// GULNSDataZlibRemainingBytesKey will contain number of remaining bytes.
GULNSDataZlibErrorDataRemaining
};
@end

View File

@ -0,0 +1,8 @@
framework module GoogleUtilities {
umbrella header "GoogleUtilities.h"
export *
module * { export * }
link framework "Security"
link framework "SystemConfiguration"
link "z"
}

View File

@ -0,0 +1,63 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(AllAdditions)
/**
Wait until all of the given promises are fulfilled.
If one of the given promises is rejected, then the returned promise is rejected with same error.
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
Promises resolved with `nil` become `NSNull` instances in the resulting array.
@param promises Promises to wait for.
@return Promise of an array containing the values of input promises in the same order.
*/
+ (FBLPromise<NSArray *> *)all:(NSArray *)promises NS_SWIFT_UNAVAILABLE("");
/**
Wait until all of the given promises are fulfilled.
If one of the given promises is rejected, then the returned promise is rejected with same error.
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
it's implicitly considered a pre-fulfilled or pre-rejected FBLPromise correspondingly.
Promises resolved with `nil` become `NSNull` instances in the resulting array.
@param queue A queue to dispatch on.
@param promises Promises to wait for.
@return Promise of an array containing the values of input promises in the same order.
*/
+ (FBLPromise<NSArray *> *)onQueue:(dispatch_queue_t)queue
all:(NSArray *)promises NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `all` operators.
Usage: FBLPromise.all(@[ ... ])
*/
@interface FBLPromise<Value>(DotSyntax_AllAdditions)
+ (FBLPromise<NSArray *> * (^)(NSArray *))all FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSArray *> * (^)(dispatch_queue_t, NSArray *))allOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,54 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(AlwaysAdditions)
typedef void (^FBLPromiseAlwaysWorkBlock)(void) NS_SWIFT_UNAVAILABLE("");
/**
@param work A block that always executes, no matter if the receiver is rejected or fulfilled.
@return A new pending promise to be resolved with same resolution as the receiver.
*/
- (FBLPromise *)always:(FBLPromiseAlwaysWorkBlock)work NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to dispatch on.
@param work A block that always executes, no matter if the receiver is rejected or fulfilled.
@return A new pending promise to be resolved with same resolution as the receiver.
*/
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
always:(FBLPromiseAlwaysWorkBlock)work NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `always` operators.
Usage: promise.always(^{...})
*/
@interface FBLPromise<Value>(DotSyntax_AlwaysAdditions)
- (FBLPromise* (^)(FBLPromiseAlwaysWorkBlock))always FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseAlwaysWorkBlock))alwaysOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,69 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(AnyAdditions)
/**
Waits until all of the given promises are either fulfilled or rejected.
If all promises are rejected, then the returned promise is rejected with same error
as the last one rejected.
If at least one of the promises is fulfilled, the resulting promise is fulfilled with an array of
values or `NSErrors`, matching the original order of fulfilled or rejected promises respectively.
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
Promises resolved with `nil` become `NSNull` instances in the resulting array.
@param promises Promises to wait for.
@return Promise of array containing the values or `NSError`s of input promises in the same order.
*/
+ (FBLPromise<NSArray *> *)any:(NSArray *)promises NS_SWIFT_UNAVAILABLE("");
/**
Waits until all of the given promises are either fulfilled or rejected.
If all promises are rejected, then the returned promise is rejected with same error
as the last one rejected.
If at least one of the promises is fulfilled, the resulting promise is fulfilled with an array of
values or `NSError`s, matching the original order of fulfilled or rejected promises respectively.
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
Promises resolved with `nil` become `NSNull` instances in the resulting array.
@param queue A queue to dispatch on.
@param promises Promises to wait for.
@return Promise of array containing the values or `NSError`s of input promises in the same order.
*/
+ (FBLPromise<NSArray *> *)onQueue:(dispatch_queue_t)queue
any:(NSArray *)promises NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `any` operators.
Usage: FBLPromise.any(@[ ... ])
*/
@interface FBLPromise<Value>(DotSyntax_AnyAdditions)
+ (FBLPromise<NSArray *> * (^)(NSArray *))any FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSArray *> * (^)(dispatch_queue_t, NSArray *))anyOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,60 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(AsyncAdditions)
typedef void (^FBLPromiseFulfillBlock)(Value __nullable value) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseRejectBlock)(NSError *error) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseAsyncWorkBlock)(FBLPromiseFulfillBlock fulfill,
FBLPromiseRejectBlock reject) NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise and executes `work` block asynchronously.
@param work A block to perform any operations needed to resolve the promise.
@return A new pending promise.
*/
+ (instancetype)async:(FBLPromiseAsyncWorkBlock)work NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise and executes `work` block asynchronously on the given queue.
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@return A new pending promise.
*/
+ (instancetype)onQueue:(dispatch_queue_t)queue
async:(FBLPromiseAsyncWorkBlock)work NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `async` operators.
Usage: FBLPromise.async(^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) { ... })
*/
@interface FBLPromise<Value>(DotSyntax_AsyncAdditions)
+ (FBLPromise* (^)(FBLPromiseAsyncWorkBlock))async FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(dispatch_queue_t, FBLPromiseAsyncWorkBlock))asyncOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,32 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
/**
Waits for promise resolution. The current thread blocks until the promise is resolved.
@param promise Promise to wait for.
@param error Error the promise was rejected with, or `nil` if the promise was fulfilled.
@return Value the promise was fulfilled with. If the promise was rejected, the return value
is always `nil`, but the error out arg is not.
*/
FOUNDATION_EXTERN id __nullable FBLPromiseAwait(FBLPromise *promise,
NSError **error) NS_REFINED_FOR_SWIFT;
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,59 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(CatchAdditions)
typedef void (^FBLPromiseCatchWorkBlock)(NSError *error) NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise which eventually gets resolved with same resolution as the receiver.
If receiver is rejected, then `reject` block is executed asynchronously.
@param reject A block to handle the error that receiver was rejected with.
@return A new pending promise.
*/
- (FBLPromise *)catch:(FBLPromiseCatchWorkBlock)reject NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise which eventually gets resolved with same resolution as the receiver.
If receiver is rejected, then `reject` block is executed asynchronously on the given queue.
@param queue A queue to invoke the `reject` block on.
@param reject A block to handle the error that receiver was rejected with.
@return A new pending promise.
*/
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
catch:(FBLPromiseCatchWorkBlock)reject NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `catch` operators.
Usage: promise.catch(^(NSError *error) { ... })
*/
@interface FBLPromise<Value>(DotSyntax_CatchAdditions)
- (FBLPromise* (^)(FBLPromiseCatchWorkBlock))catch FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseCatchWorkBlock))catchOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,59 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(DelayAdditions)
/**
Creates a new pending promise that fulfills with the same value as `self` after the `delay`, or
rejects with the same error immediately.
@param interval Time to wait in seconds.
@return A new pending promise that fulfills at least `delay` seconds later than `self`, or rejects
with the same error immediately.
*/
- (FBLPromise *)delay:(NSTimeInterval)interval NS_SWIFT_UNAVAILABLE("");
/**
Creates a new pending promise that fulfills with the same value as `self` after the `delay`, or
rejects with the same error immediately.
@param queue A queue to dispatch on.
@param interval Time to wait in seconds.
@return A new pending promise that fulfills at least `delay` seconds later than `self`, or rejects
with the same error immediately.
*/
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
delay:(NSTimeInterval)interval NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `delay` operators.
Usage: promise.delay(...)
*/
@interface FBLPromise<Value>(DotSyntax_DelayAdditions)
- (FBLPromise * (^)(NSTimeInterval))delay FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
- (FBLPromise * (^)(dispatch_queue_t, NSTimeInterval))delayOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,55 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(DoAdditions)
typedef id __nullable (^FBLPromiseDoWorkBlock)(void) NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise and executes `work` block asynchronously.
@param work A block that returns a value or an error used to resolve the promise.
@return A new pending promise.
*/
+ (instancetype)do:(FBLPromiseDoWorkBlock)work NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise and executes `work` block asynchronously on the given queue.
@param queue A queue to invoke the `work` block on.
@param work A block that returns a value or an error used to resolve the promise.
@return A new pending promise.
*/
+ (instancetype)onQueue:(dispatch_queue_t)queue do:(FBLPromiseDoWorkBlock)work NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `do` operators.
Usage: FBLPromise.doOn(queue, ^(NSError *error) { ... })
*/
@interface FBLPromise<Value>(DotSyntax_DoAdditions)
+ (FBLPromise * (^)(dispatch_queue_t, FBLPromiseDoWorkBlock))doOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,62 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(RaceAdditions)
/**
Wait until any of the given promises are fulfilled.
If one of the promises is rejected, then the returned promise is rejected with same error.
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
@param promises Promises to wait for.
@return A new pending promise to be resolved with the same resolution as the first promise, among
the given ones, which was resolved.
*/
+ (instancetype)race:(NSArray *)promises NS_SWIFT_UNAVAILABLE("");
/**
Wait until any of the given promises are fulfilled.
If one of the promises is rejected, then the returned promise is rejected with same error.
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
@param queue A queue to dispatch on.
@param promises Promises to wait for.
@return A new pending promise to be resolved with the same resolution as the first promise, among
the given ones, which was resolved.
*/
+ (instancetype)onQueue:(dispatch_queue_t)queue race:(NSArray *)promises NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `race` operators.
Usage: FBLPromise.race(@[ ... ])
*/
@interface FBLPromise<Value>(DotSyntax_RaceAdditions)
+ (FBLPromise * (^)(NSArray *))race FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise * (^)(dispatch_queue_t, NSArray *))raceOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,60 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(RecoverAdditions)
typedef id __nullable (^FBLPromiseRecoverWorkBlock)(NSError *error) NS_SWIFT_UNAVAILABLE("");
/**
Provides a new promise to recover in case the receiver gets rejected.
@param recovery A block to handle the error that the receiver was rejected with.
@return A new pending promise to use instead of the rejected one that gets resolved with resolution
returned from `recovery` block.
*/
- (FBLPromise *)recover:(FBLPromiseRecoverWorkBlock)recovery NS_SWIFT_UNAVAILABLE("");
/**
Provides a new promise to recover in case the receiver gets rejected.
@param queue A queue to dispatch on.
@param recovery A block to handle the error that the receiver was rejected with.
@return A new pending promise to use instead of the rejected one that gets resolved with resolution
returned from `recovery` block.
*/
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
recover:(FBLPromiseRecoverWorkBlock)recovery NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `recover` operators.
Usage: promise.recover(^id(NSError *error) {...})
*/
@interface FBLPromise<Value>(DotSyntax_RecoverAdditions)
- (FBLPromise * (^)(FBLPromiseRecoverWorkBlock))recover FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
- (FBLPromise * (^)(dispatch_queue_t, FBLPromiseRecoverWorkBlock))recoverOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,71 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(ReduceAdditions)
typedef id __nullable (^FBLPromiseReducerBlock)(Value __nullable partial, id next)
NS_SWIFT_UNAVAILABLE("");
/**
Sequentially reduces a collection of values to a single promise using a given combining block
and the value `self` resolves with as initial value.
@param items An array of values to process in order.
@param reducer A block to combine an accumulating value and an element of the sequence into
the new accumulating value or a promise resolved with it, to be used in the next
call of the `reducer` or returned to the caller.
@return A new pending promise returned from the last `reducer` invocation.
Or `self` if `items` is empty.
*/
- (FBLPromise *)reduce:(NSArray *)items
combine:(FBLPromiseReducerBlock)reducer NS_SWIFT_UNAVAILABLE("");
/**
Sequentially reduces a collection of values to a single promise using a given combining block
and the value `self` resolves with as initial value.
@param queue A queue to dispatch on.
@param items An array of values to process in order.
@param reducer A block to combine an accumulating value and an element of the sequence into
the new accumulating value or a promise resolved with it, to be used in the next
call of the `reducer` or returned to the caller.
@return A new pending promise returned from the last `reducer` invocation.
Or `self` if `items` is empty.
*/
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
reduce:(NSArray *)items
combine:(FBLPromiseReducerBlock)reducer NS_SWIFT_UNAVAILABLE("");
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `reduce` operators.
Usage: promise.reduce(values, ^id(id partial, id next) { ... })
*/
@interface FBLPromise<Value>(DotSyntax_ReduceAdditions)
- (FBLPromise * (^)(NSArray *, FBLPromiseReducerBlock))reduce FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
- (FBLPromise * (^)(dispatch_queue_t, NSArray *, FBLPromiseReducerBlock))reduceOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,165 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
/** The default number of retry attempts is 1. */
FOUNDATION_EXTERN NSInteger const FBLPromiseRetryDefaultAttemptsCount NS_REFINED_FOR_SWIFT;
/** The default delay interval before making a retry attempt is 1.0 second. */
FOUNDATION_EXTERN NSTimeInterval const FBLPromiseRetryDefaultDelayInterval NS_REFINED_FOR_SWIFT;
@interface FBLPromise<Value>(RetryAdditions)
typedef id __nullable (^FBLPromiseRetryWorkBlock)(void) NS_SWIFT_UNAVAILABLE("");
typedef BOOL (^FBLPromiseRetryPredicateBlock)(NSInteger, NSError *) NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise that fulfills with the same value as the promise returned from `work`
block, which executes asynchronously, or rejects with the same error after all retry attempts have
been exhausted. Defaults to `FBLPromiseRetryDefaultAttemptsCount` attempt(s) on rejection where the
`work` block is retried after a delay of `FBLPromiseRetryDefaultDelayInterval` second(s).
@param work A block that executes asynchronously on the default queue and returns a value or an
error used to resolve the promise.
@return A new pending promise that fulfills with the same value as the promise returned from `work`
block, or rejects with the same error after all retry attempts have been exhausted.
*/
+ (FBLPromise *)retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise that fulfills with the same value as the promise returned from `work`
block, which executes asynchronously on the given `queue`, or rejects with the same error after all
retry attempts have been exhausted. Defaults to `FBLPromiseRetryDefaultAttemptsCount` attempt(s) on
rejection where the `work` block is retried on the given `queue` after a delay of
`FBLPromiseRetryDefaultDelayInterval` second(s).
@param queue A queue to invoke the `work` block on.
@param work A block that executes asynchronously on the given `queue` and returns a value or an
error used to resolve the promise.
@return A new pending promise that fulfills with the same value as the promise returned from `work`
block, or rejects with the same error after all retry attempts have been exhausted.
*/
+ (FBLPromise *)onQueue:(dispatch_queue_t)queue
retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise that fulfills with the same value as the promise returned from `work`
block, which executes asynchronously, or rejects with the same error after all retry attempts have
been exhausted.
@param count Max number of retry attempts. The `work` block will be executed once if the specified
count is less than or equal to zero.
@param work A block that executes asynchronously on the default queue and returns a value or an
error used to resolve the promise.
@return A new pending promise that fulfills with the same value as the promise returned from `work`
block, or rejects with the same error after all retry attempts have been exhausted.
*/
+ (FBLPromise *)attempts:(NSInteger)count
retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise that fulfills with the same value as the promise returned from `work`
block, which executes asynchronously on the given `queue`, or rejects with the same error after all
retry attempts have been exhausted.
@param queue A queue to invoke the `work` block on.
@param count Max number of retry attempts. The `work` block will be executed once if the specified
count is less than or equal to zero.
@param work A block that executes asynchronously on the given `queue` and returns a value or an
error used to resolve the promise.
@return A new pending promise that fulfills with the same value as the promise returned from `work`
block, or rejects with the same error after all retry attempts have been exhausted.
*/
+ (FBLPromise *)onQueue:(dispatch_queue_t)queue
attempts:(NSInteger)count
retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise that fulfills with the same value as the promise returned from `work`
block, which executes asynchronously, or rejects with the same error after all retry attempts have
been exhausted. On rejection, the `work` block is retried after the given delay `interval` and will
continue to retry until the number of specified attempts have been exhausted or will bail early if
the given condition is not met.
@param count Max number of retry attempts. The `work` block will be executed once if the specified
count is less than or equal to zero.
@param interval Time to wait before the next retry attempt.
@param predicate Condition to check before the next retry attempt. The predicate block provides the
the number of remaining retry attempts and the error that the promise was rejected
with.
@param work A block that executes asynchronously on the default queue and returns a value or an
error used to resolve the promise.
@return A new pending promise that fulfills with the same value as the promise returned from `work`
block, or rejects with the same error after all retry attempts have been exhausted or if
the given condition is not met.
*/
+ (FBLPromise *)attempts:(NSInteger)count
delay:(NSTimeInterval)interval
condition:(nullable FBLPromiseRetryPredicateBlock)predicate
retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise that fulfills with the same value as the promise returned from `work`
block, which executes asynchronously on the given `queue`, or rejects with the same error after all
retry attempts have been exhausted. On rejection, the `work` block is retried after the given
delay `interval` and will continue to retry until the number of specified attempts have been
exhausted or will bail early if the given condition is not met.
@param queue A queue to invoke the `work` block on.
@param count Max number of retry attempts. The `work` block will be executed once if the specified
count is less than or equal to zero.
@param interval Time to wait before the next retry attempt.
@param predicate Condition to check before the next retry attempt. The predicate block provides the
the number of remaining retry attempts and the error that the promise was rejected
with.
@param work A block that executes asynchronously on the given `queue` and returns a value or an
error used to resolve the promise.
@return A new pending promise that fulfills with the same value as the promise returned from `work`
block, or rejects with the same error after all retry attempts have been exhausted or if
the given condition is not met.
*/
+ (FBLPromise *)onQueue:(dispatch_queue_t)queue
attempts:(NSInteger)count
delay:(NSTimeInterval)interval
condition:(nullable FBLPromiseRetryPredicateBlock)predicate
retry:(FBLPromiseRetryWorkBlock)work NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise+Retry` operators.
Usage: FBLPromise.retry(^id { ... })
*/
@interface FBLPromise<Value>(DotSyntax_RetryAdditions)
+ (FBLPromise * (^)(FBLPromiseRetryWorkBlock))retry FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise * (^)(dispatch_queue_t, FBLPromiseRetryWorkBlock))retryOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise * (^)(NSInteger, NSTimeInterval, FBLPromiseRetryPredicateBlock __nullable,
FBLPromiseRetryWorkBlock))retryAgain FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise * (^)(dispatch_queue_t, NSInteger, NSTimeInterval,
FBLPromiseRetryPredicateBlock __nullable,
FBLPromiseRetryWorkBlock))retryAgainOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,63 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
/**
Waits for all scheduled promises blocks.
@param timeout Maximum time to wait.
@return YES if all promises blocks have completed before the timeout and NO otherwise.
*/
FOUNDATION_EXTERN BOOL FBLWaitForPromisesWithTimeout(NSTimeInterval timeout) NS_REFINED_FOR_SWIFT;
@interface FBLPromise<Value>(TestingAdditions)
/**
Dispatch group for promises that is typically used to wait for all scheduled blocks.
*/
@property(class, nonatomic, readonly) dispatch_group_t dispatchGroup NS_REFINED_FOR_SWIFT;
/**
Properties to get the current state of the promise.
*/
@property(nonatomic, readonly) BOOL isPending NS_REFINED_FOR_SWIFT;
@property(nonatomic, readonly) BOOL isFulfilled NS_REFINED_FOR_SWIFT;
@property(nonatomic, readonly) BOOL isRejected NS_REFINED_FOR_SWIFT;
/**
Set of arbitrary objects to keep strongly while the promise is pending.
Becomes nil after the promise has been resolved.
*/
@property(nonatomic, readonly, nullable) NSMutableSet *pendingObjects NS_REFINED_FOR_SWIFT;
/**
Value the promise was fulfilled with.
Can be nil if the promise is still pending, was resolved with nil or after it has been rejected.
*/
@property(nonatomic, readonly, nullable) Value value NS_REFINED_FOR_SWIFT;
/**
Error the promise was rejected with.
Can be nil if the promise is still pending or after it has been fulfilled.
*/
@property(nonatomic, readonly, nullable) NSError *error NS_REFINED_FOR_SWIFT;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,63 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(ThenAdditions)
typedef id __nullable (^FBLPromiseThenWorkBlock)(Value __nullable value) NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise which eventually gets resolved with resolution returned from `work`
block: either value, error or another promise. The `work` block is executed asynchronously only
when the receiver is fulfilled. If receiver is rejected, the returned promise is also rejected with
the same error.
@param work A block to handle the value that receiver was fulfilled with.
@return A new pending promise to be resolved with resolution returned from the `work` block.
*/
- (FBLPromise *)then:(FBLPromiseThenWorkBlock)work NS_SWIFT_UNAVAILABLE("");
/**
Creates a pending promise which eventually gets resolved with resolution returned from `work`
block: either value, error or another promise. The `work` block is executed asynchronously when the
receiver is fulfilled. If receiver is rejected, the returned promise is also rejected with the same
error.
@param queue A queue to invoke the `work` block on.
@param work A block to handle the value that receiver was fulfilled with.
@return A new pending promise to be resolved with resolution returned from the `work` block.
*/
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
then:(FBLPromiseThenWorkBlock)work NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `then` operators.
Usage: promise.then(^id(id value) { ... })
*/
@interface FBLPromise<Value>(DotSyntax_ThenAdditions)
- (FBLPromise* (^)(FBLPromiseThenWorkBlock))then FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseThenWorkBlock))thenOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,57 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(TimeoutAdditions)
/**
Waits for a promise with the specified `timeout`.
@param interval Time to wait in seconds.
@return A new pending promise that gets either resolved with same resolution as the receiver or
rejected with `FBLPromiseErrorCodeTimedOut` error code in `FBLPromiseErrorDomain`.
*/
- (FBLPromise *)timeout:(NSTimeInterval)interval NS_SWIFT_UNAVAILABLE("");
/**
Waits for a promise with the specified `timeout`.
@param queue A queue to dispatch on.
@param interval Time to wait in seconds.
@return A new pending promise that gets either resolved with same resolution as the receiver or
rejected with `FBLPromiseErrorCodeTimedOut` error code in `FBLPromiseErrorDomain`.
*/
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
timeout:(NSTimeInterval)interval NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `timeout` operators.
Usage: promise.timeout(...)
*/
@interface FBLPromise<Value>(DotSyntax_TimeoutAdditions)
- (FBLPromise* (^)(NSTimeInterval))timeout FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
- (FBLPromise* (^)(dispatch_queue_t, NSTimeInterval))timeoutOn FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,60 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
@interface FBLPromise<Value>(ValidateAdditions)
typedef BOOL (^FBLPromiseValidateWorkBlock)(Value __nullable value) NS_SWIFT_UNAVAILABLE("");
/**
Validates a fulfilled value or rejects the value if it can not be validated.
@param predicate An expression to validate.
@return A new pending promise that gets either resolved with same resolution as the receiver or
rejected with `FBLPromiseErrorCodeValidationFailure` error code in `FBLPromiseErrorDomain`.
*/
- (FBLPromise *)validate:(FBLPromiseValidateWorkBlock)predicate NS_SWIFT_UNAVAILABLE("");
/**
Validates a fulfilled value or rejects the value if it can not be validated.
@param queue A queue to dispatch on.
@param predicate An expression to validate.
@return A new pending promise that gets either resolved with same resolution as the receiver or
rejected with `FBLPromiseErrorCodeValidationFailure` error code in `FBLPromiseErrorDomain`.
*/
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
validate:(FBLPromiseValidateWorkBlock)predicate NS_REFINED_FOR_SWIFT;
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `validate` operators.
Usage: promise.validate(^BOOL(id value) { ... })
*/
@interface FBLPromise<Value>(DotSyntax_ValidateAdditions)
- (FBLPromise * (^)(FBLPromiseValidateWorkBlock))validate FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
- (FBLPromise * (^)(dispatch_queue_t, FBLPromiseValidateWorkBlock))validateOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,316 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise.h"
NS_ASSUME_NONNULL_BEGIN
/**
Different types of completion handlers available to be wrapped with promise.
*/
typedef void (^FBLPromiseCompletion)(void) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseObjectCompletion)(id __nullable) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseErrorCompletion)(NSError* __nullable) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseObjectOrErrorCompletion)(id __nullable, NSError* __nullable)
NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseErrorOrObjectCompletion)(NSError* __nullable, id __nullable)
NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromise2ObjectsOrErrorCompletion)(id __nullable, id __nullable,
NSError* __nullable) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseBoolCompletion)(BOOL) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseBoolOrErrorCompletion)(BOOL, NSError* __nullable) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseIntegerCompletion)(NSInteger) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseIntegerOrErrorCompletion)(NSInteger, NSError* __nullable)
NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseDoubleCompletion)(double) NS_SWIFT_UNAVAILABLE("");
typedef void (^FBLPromiseDoubleOrErrorCompletion)(double, NSError* __nullable)
NS_SWIFT_UNAVAILABLE("");
/**
Provides an easy way to convert methods that use common callback patterns into promises.
*/
@interface FBLPromise<Value>(WrapAdditions)
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with `nil` when completion handler is invoked.
*/
+ (instancetype)wrapCompletion:(void (^)(FBLPromiseCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with `nil` when completion handler is invoked.
*/
+ (instancetype)onQueue:(dispatch_queue_t)queue
wrapCompletion:(void (^)(FBLPromiseCompletion handler))work NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an object provided by completion handler.
*/
+ (instancetype)wrapObjectCompletion:(void (^)(FBLPromiseObjectCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an object provided by completion handler.
*/
+ (instancetype)onQueue:(dispatch_queue_t)queue
wrapObjectCompletion:(void (^)(FBLPromiseObjectCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an error provided by completion handler.
If error is `nil`, fulfills with `nil`, otherwise rejects with the error.
*/
+ (instancetype)wrapErrorCompletion:(void (^)(FBLPromiseErrorCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an error provided by completion handler.
If error is `nil`, fulfills with `nil`, otherwise rejects with the error.
*/
+ (instancetype)onQueue:(dispatch_queue_t)queue
wrapErrorCompletion:(void (^)(FBLPromiseErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an object provided by completion handler if error is `nil`.
Otherwise, rejects with the error.
*/
+ (instancetype)wrapObjectOrErrorCompletion:
(void (^)(FBLPromiseObjectOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an object provided by completion handler if error is `nil`.
Otherwise, rejects with the error.
*/
+ (instancetype)onQueue:(dispatch_queue_t)queue
wrapObjectOrErrorCompletion:(void (^)(FBLPromiseObjectOrErrorCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an error or object provided by completion handler. If error
is not `nil`, rejects with the error.
*/
+ (instancetype)wrapErrorOrObjectCompletion:
(void (^)(FBLPromiseErrorOrObjectCompletion handler))work NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an error or object provided by completion handler. If error
is not `nil`, rejects with the error.
*/
+ (instancetype)onQueue:(dispatch_queue_t)queue
wrapErrorOrObjectCompletion:(void (^)(FBLPromiseErrorOrObjectCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an array of objects provided by completion handler in order
if error is `nil`. Otherwise, rejects with the error.
*/
+ (FBLPromise<NSArray*>*)wrap2ObjectsOrErrorCompletion:
(void (^)(FBLPromise2ObjectsOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an array of objects provided by completion handler in order
if error is `nil`. Otherwise, rejects with the error.
*/
+ (FBLPromise<NSArray*>*)onQueue:(dispatch_queue_t)queue
wrap2ObjectsOrErrorCompletion:(void (^)(FBLPromise2ObjectsOrErrorCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping YES/NO.
*/
+ (FBLPromise<NSNumber*>*)wrapBoolCompletion:(void (^)(FBLPromiseBoolCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping YES/NO.
*/
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
wrapBoolCompletion:(void (^)(FBLPromiseBoolCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping YES/NO when error is `nil`.
Otherwise rejects with the error.
*/
+ (FBLPromise<NSNumber*>*)wrapBoolOrErrorCompletion:
(void (^)(FBLPromiseBoolOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping YES/NO when error is `nil`.
Otherwise rejects with the error.
*/
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
wrapBoolOrErrorCompletion:(void (^)(FBLPromiseBoolOrErrorCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping an integer.
*/
+ (FBLPromise<NSNumber*>*)wrapIntegerCompletion:(void (^)(FBLPromiseIntegerCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping an integer.
*/
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
wrapIntegerCompletion:(void (^)(FBLPromiseIntegerCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping an integer when error is `nil`.
Otherwise rejects with the error.
*/
+ (FBLPromise<NSNumber*>*)wrapIntegerOrErrorCompletion:
(void (^)(FBLPromiseIntegerOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping an integer when error is `nil`.
Otherwise rejects with the error.
*/
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
wrapIntegerOrErrorCompletion:(void (^)(FBLPromiseIntegerOrErrorCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping a double.
*/
+ (FBLPromise<NSNumber*>*)wrapDoubleCompletion:(void (^)(FBLPromiseDoubleCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping a double.
*/
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
wrapDoubleCompletion:(void (^)(FBLPromiseDoubleCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
/**
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping a double when error is `nil`.
Otherwise rejects with the error.
*/
+ (FBLPromise<NSNumber*>*)wrapDoubleOrErrorCompletion:
(void (^)(FBLPromiseDoubleOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
/**
@param queue A queue to invoke the `work` block on.
@param work A block to perform any operations needed to resolve the promise.
@returns A promise that resolves with an `NSNumber` wrapping a double when error is `nil`.
Otherwise rejects with the error.
*/
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
wrapDoubleOrErrorCompletion:(void (^)(FBLPromiseDoubleOrErrorCompletion handler))work
NS_SWIFT_UNAVAILABLE("");
@end
/**
Convenience dot-syntax wrappers for `FBLPromise` `wrap` operators.
Usage: FBLPromise.wrapCompletion(^(FBLPromiseCompletion handler) {...})
*/
@interface FBLPromise<Value>(DotSyntax_WrapAdditions)
+ (FBLPromise* (^)(void (^)(FBLPromiseCompletion)))wrapCompletion FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(dispatch_queue_t, void (^)(FBLPromiseCompletion)))wrapCompletionOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(void (^)(FBLPromiseObjectCompletion)))wrapObjectCompletion
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(dispatch_queue_t, void (^)(FBLPromiseObjectCompletion)))wrapObjectCompletionOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(void (^)(FBLPromiseErrorCompletion)))wrapErrorCompletion FBL_PROMISES_DOT_SYNTAX
NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(dispatch_queue_t, void (^)(FBLPromiseErrorCompletion)))wrapErrorCompletionOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(void (^)(FBLPromiseObjectOrErrorCompletion)))wrapObjectOrErrorCompletion
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(dispatch_queue_t,
void (^)(FBLPromiseObjectOrErrorCompletion)))wrapObjectOrErrorCompletionOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(void (^)(FBLPromiseErrorOrObjectCompletion)))wrapErrorOrObjectCompletion
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise* (^)(dispatch_queue_t,
void (^)(FBLPromiseErrorOrObjectCompletion)))wrapErrorOrObjectCompletionOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSArray*>* (^)(void (^)(FBLPromise2ObjectsOrErrorCompletion)))
wrap2ObjectsOrErrorCompletion FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSArray*>* (^)(dispatch_queue_t, void (^)(FBLPromise2ObjectsOrErrorCompletion)))
wrap2ObjectsOrErrorCompletionOn FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseBoolCompletion)))wrapBoolCompletion
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t,
void (^)(FBLPromiseBoolCompletion)))wrapBoolCompletionOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseBoolOrErrorCompletion)))wrapBoolOrErrorCompletion
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t,
void (^)(FBLPromiseBoolOrErrorCompletion)))wrapBoolOrErrorCompletionOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseIntegerCompletion)))wrapIntegerCompletion
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t,
void (^)(FBLPromiseIntegerCompletion)))wrapIntegerCompletionOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseIntegerOrErrorCompletion)))
wrapIntegerOrErrorCompletion FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t, void (^)(FBLPromiseIntegerOrErrorCompletion)))
wrapIntegerOrErrorCompletionOn FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseDoubleCompletion)))wrapDoubleCompletion
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t,
void (^)(FBLPromiseDoubleCompletion)))wrapDoubleCompletionOn
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseDoubleOrErrorCompletion)))
wrapDoubleOrErrorCompletion FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t, void (^)(FBLPromiseDoubleOrErrorCompletion)))
wrapDoubleOrErrorCompletionOn FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,82 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromiseError.h"
NS_ASSUME_NONNULL_BEGIN
/**
Promises synchronization construct in Objective-C.
*/
@interface FBLPromise<__covariant Value> : NSObject
/**
Default dispatch queue used for `FBLPromise`, which is `main` if a queue is not specified.
*/
@property(class) dispatch_queue_t defaultDispatchQueue NS_REFINED_FOR_SWIFT;
/**
Creates a pending promise.
*/
+ (instancetype)pendingPromise NS_REFINED_FOR_SWIFT;
/**
Creates a resolved promise.
@param resolution An object to resolve the promise with: either a value or an error.
@return A new resolved promise.
*/
+ (instancetype)resolvedWith:(nullable id)resolution NS_REFINED_FOR_SWIFT;
/**
Synchronously fulfills the promise with a value.
@param value An arbitrary value to fulfill the promise with, including `nil`.
*/
- (void)fulfill:(nullable Value)value NS_REFINED_FOR_SWIFT;
/**
Synchronously rejects the promise with an error.
@param error An error to reject the promise with.
*/
- (void)reject:(NSError *)error NS_REFINED_FOR_SWIFT;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
@end
#ifdef FBL_PROMISES_DOT_SYNTAX_IS_DEPRECATED
#define FBL_PROMISES_DOT_SYNTAX __attribute__((deprecated))
#else
#define FBL_PROMISES_DOT_SYNTAX
#endif
@interface FBLPromise<Value>(DotSyntaxAdditions)
/**
Convenience dot-syntax wrappers for FBLPromise.
Usage: FBLPromise.pending()
FBLPromise.resolved(value)
*/
+ (instancetype (^)(void))pending FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
+ (instancetype (^)(id __nullable))resolved FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,43 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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
FOUNDATION_EXTERN NSErrorDomain const FBLPromiseErrorDomain NS_REFINED_FOR_SWIFT;
/**
Possible error codes in `FBLPromiseErrorDomain`.
*/
typedef NS_ENUM(NSInteger, FBLPromiseErrorCode) {
/** Promise failed to resolve in time. */
FBLPromiseErrorCodeTimedOut = 1,
/** Validation predicate returned false. */
FBLPromiseErrorCodeValidationFailure = 2,
} NS_REFINED_FOR_SWIFT;
NS_INLINE BOOL FBLPromiseErrorIsTimedOut(NSError *error) NS_SWIFT_UNAVAILABLE("") {
return error.domain == FBLPromiseErrorDomain &&
error.code == FBLPromiseErrorCodeTimedOut;
}
NS_INLINE BOOL FBLPromiseErrorIsValidationFailure(NSError *error) NS_SWIFT_UNAVAILABLE("") {
return error.domain == FBLPromiseErrorDomain &&
error.code == FBLPromiseErrorCodeValidationFailure;
}
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,32 @@
/**
Copyright 2018 Google Inc. All rights reserved.
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 "FBLPromise+All.h"
#import "FBLPromise+Always.h"
#import "FBLPromise+Any.h"
#import "FBLPromise+Async.h"
#import "FBLPromise+Await.h"
#import "FBLPromise+Catch.h"
#import "FBLPromise+Delay.h"
#import "FBLPromise+Do.h"
#import "FBLPromise+Race.h"
#import "FBLPromise+Recover.h"
#import "FBLPromise+Reduce.h"
#import "FBLPromise+Retry.h"
#import "FBLPromise+Then.h"
#import "FBLPromise+Timeout.h"
#import "FBLPromise+Validate.h"
#import "FBLPromise+Wrap.h"

View File

@ -0,0 +1,5 @@
framework module PromisesObjC {
umbrella header "PromisesObjC.h"
export *
module * { export * }
}

View File

@ -0,0 +1,312 @@
/*
* 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
@class FIRInstanceIDResult;
/**
* @memberof FIRInstanceID
*
* The scope to be used when fetching/deleting a token for Firebase Messaging.
*/
FOUNDATION_EXPORT NSString *const kFIRInstanceIDScopeFirebaseMessaging
NS_SWIFT_NAME(InstanceIDScopeFirebaseMessaging);
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
/**
* Called when the system determines that tokens need to be refreshed.
* This method is also called if Instance ID has been reset in which
* case, tokens and FCM topic subscriptions also need to be refreshed.
*
* Instance ID service will throttle the refresh event across all devices
* to control the rate of token updates on application servers.
*/
FOUNDATION_EXPORT const NSNotificationName kFIRInstanceIDTokenRefreshNotification
NS_SWIFT_NAME(InstanceIDTokenRefresh);
#else
/**
* Called when the system determines that tokens need to be refreshed.
* This method is also called if Instance ID has been reset in which
* case, tokens and FCM topic subscriptions also need to be refreshed.
*
* Instance ID service will throttle the refresh event across all devices
* to control the rate of token updates on application servers.
*/
FOUNDATION_EXPORT NSString *const kFIRInstanceIDTokenRefreshNotification
NS_SWIFT_NAME(InstanceIDTokenRefreshNotification);
#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
/**
* @related FIRInstanceID
*
* The completion handler invoked when the InstanceID token returns. If
* the call fails we return the appropriate `error code` as described below.
*
* @param token The valid token as returned by InstanceID backend.
*
* @param error The error describing why generating a new token
* failed. See the error codes below for a more detailed
* description.
*/
typedef void (^FIRInstanceIDTokenHandler)(NSString *__nullable token, NSError *__nullable error)
NS_SWIFT_NAME(InstanceIDTokenHandler);
/**
* @related FIRInstanceID
*
* The completion handler invoked when the InstanceID `deleteToken` returns. If
* the call fails we return the appropriate `error code` as described below
*
* @param error The error describing why deleting the token failed.
* See the error codes below for a more detailed description.
*/
typedef void (^FIRInstanceIDDeleteTokenHandler)(NSError *error)
NS_SWIFT_NAME(InstanceIDDeleteTokenHandler);
/**
* @related FIRInstanceID
*
* The completion handler invoked when the app identity is created. If the
* identity wasn't created for some reason we return the appropriate error code.
*
* @param identity A valid identity for the app instance, nil if there was an error
* while creating an identity.
* @param error The error if fetching the identity fails else nil.
*/
typedef void (^FIRInstanceIDHandler)(NSString *__nullable identity, NSError *__nullable error)
NS_SWIFT_NAME(InstanceIDHandler);
/**
* @related FIRInstanceID
*
* The completion handler invoked when the app identity and all the tokens associated
* with it are deleted. Returns a valid error object in case of failure else nil.
*
* @param error The error if deleting the identity and all the tokens associated with
* it fails else nil.
*/
typedef void (^FIRInstanceIDDeleteHandler)(NSError *__nullable error)
NS_SWIFT_NAME(InstanceIDDeleteHandler);
/**
* @related FIRInstanceID
*
* The completion handler invoked when the app identity and token are fetched. If the
* identity wasn't created for some reason we return the appropriate error code.
*
* @param result The result containing an identity for the app instance and a valid token,
* nil if there was an error while creating the result.
* @param error The error if fetching the identity or token fails else nil.
*/
typedef void (^FIRInstanceIDResultHandler)(FIRInstanceIDResult *__nullable result,
NSError *__nullable error)
NS_SWIFT_NAME(InstanceIDResultHandler);
/**
* Public errors produced by InstanceID.
*/
typedef NS_ENUM(NSUInteger, FIRInstanceIDError) {
// Http related errors.
/// Unknown error.
FIRInstanceIDErrorUnknown = 0,
/// Auth Error -- GCM couldn't validate request from this client.
FIRInstanceIDErrorAuthentication = 1,
/// NoAccess -- InstanceID service cannot be accessed.
FIRInstanceIDErrorNoAccess = 2,
/// Timeout -- Request to InstanceID backend timed out.
FIRInstanceIDErrorTimeout = 3,
/// Network -- No network available to reach the servers.
FIRInstanceIDErrorNetwork = 4,
/// OperationInProgress -- Another similar operation in progress,
/// bailing this one.
FIRInstanceIDErrorOperationInProgress = 5,
/// InvalidRequest -- Some parameters of the request were invalid.
FIRInstanceIDErrorInvalidRequest = 7,
} NS_SWIFT_NAME(InstanceIDError);
/**
* A class contains the results of InstanceID and token query.
*/
NS_SWIFT_NAME(InstanceIDResult)
@interface FIRInstanceIDResult : NSObject <NSCopying>
/**
* An instanceID uniquely identifies the app instance.
*/
@property(nonatomic, readonly, copy) NSString *instanceID;
/*
* Returns a Firebase Messaging scoped token for the firebase app.
*/
@property(nonatomic, readonly, copy) NSString *token;
@end
/**
* Instance ID provides a unique identifier for each app instance and a mechanism
* to authenticate and authorize actions (for example, sending an FCM message).
*
* Once an InstanceID is generated, the library periodically sends information about the
* application and the device where it's running to the Firebase backend. To stop this. see
* `[FIRInstanceID deleteIDWithHandler:]`.
*
* Instance ID is long lived but, may be reset if the device is not used for
* a long time or the Instance ID service detects a problem.
* If Instance ID is reset, the app will be notified via
* `kFIRInstanceIDTokenRefreshNotification`.
*
* If the Instance ID has become invalid, the app can request a new one and
* send it to the app server.
* To prove ownership of Instance ID and to allow servers to access data or
* services associated with the app, call
* `[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]`.
*/
NS_SWIFT_NAME(InstanceID)
@interface FIRInstanceID : NSObject
/**
* FIRInstanceID.
*
* @return A shared instance of FIRInstanceID.
*/
+ (instancetype)instanceID NS_SWIFT_NAME(instanceID());
/**
* Unavailable. Use +instanceID instead.
*/
- (instancetype)init __attribute__((unavailable("Use +instanceID instead.")));
#pragma mark - Tokens
/**
* Returns a result of app instance identifier InstanceID and a Firebase Messaging scoped token.
* param handler The callback handler invoked when an app instanceID and a default token
* are generated and returned. If instanceID and token fetching fail for some
* reason the callback is invoked with nil `result` and the appropriate error.
*/
- (void)instanceIDWithHandler:(FIRInstanceIDResultHandler)handler;
/**
* Returns a token that authorizes an Entity (example: cloud service) to perform
* an action on behalf of the application identified by Instance ID.
*
* This is similar to an OAuth2 token except, it applies to the
* application instance instead of a user.
*
* This is an asynchronous call. If the token fetching fails for some reason
* we invoke the completion callback with nil `token` and the appropriate
* error.
*
* This generates an Instance ID if it does not exist yet, which starts periodically sending
* information to the Firebase backend (see `[FIRInstanceID getIDWithHandler:]`).
*
* Note, you can only have one `token` or `deleteToken` call for a given
* authorizedEntity and scope at any point of time. Making another such call with the
* same authorizedEntity and scope before the last one finishes will result in an
* error with code `OperationInProgress`.
*
* @see FIRInstanceID deleteTokenWithAuthorizedEntity:scope:handler:
*
* @param authorizedEntity Entity authorized by the token.
* @param scope Action authorized for authorizedEntity.
* @param options The extra options to be sent with your token request. The
* value for the `apns_token` should be the NSData object
* passed to the UIApplicationDelegate's
* `didRegisterForRemoteNotificationsWithDeviceToken` method.
* The value for `apns_sandbox` should be a boolean (or an
* NSNumber representing a BOOL in Objective-C) set to true if
* your app is a debug build, which means that the APNs
* device token is for the sandbox environment. It should be
* set to false otherwise. If the `apns_sandbox` key is not
* provided, an automatically-detected value shall be used.
* @param handler The callback handler which is invoked when the token is
* successfully fetched. In case of success a valid `token` and
* `nil` error are returned. In case of any error the `token`
* is nil and a valid `error` is returned. The valid error
* codes have been documented above.
*/
- (void)tokenWithAuthorizedEntity:(NSString *)authorizedEntity
scope:(NSString *)scope
options:(nullable NSDictionary *)options
handler:(FIRInstanceIDTokenHandler)handler;
/**
* Revokes access to a scope (action) for an entity previously
* authorized by `[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]`.
*
* This is an asynchronous call. Call this on the main thread since InstanceID lib
* is not thread safe. In case token deletion fails for some reason we invoke the
* `handler` callback passed in with the appropriate error code.
*
* Note, you can only have one `token` or `deleteToken` call for a given
* authorizedEntity and scope at a point of time. Making another such call with the
* same authorizedEntity and scope before the last one finishes will result in an error
* with code `OperationInProgress`.
*
* @param authorizedEntity Entity that must no longer have access.
* @param scope Action that entity is no longer authorized to perform.
* @param handler The handler that is invoked once the unsubscribe call ends.
* In case of error an appropriate error object is returned
* else error is nil.
*/
- (void)deleteTokenWithAuthorizedEntity:(NSString *)authorizedEntity
scope:(NSString *)scope
handler:(FIRInstanceIDDeleteTokenHandler)handler;
#pragma mark - Identity
/**
* Asynchronously fetch a stable identifier that uniquely identifies the app
* instance. If the identifier has been revoked or has expired, this method will
* return a new identifier.
*
* Once an InstanceID is generated, the library periodically sends information about the
* application and the device where it's running to the Firebase backend. To stop this. see
* `[FIRInstanceID deleteIDWithHandler:]`.
*
* @param handler The handler to invoke once the identifier has been fetched.
* In case of error an appropriate error object is returned else
* a valid identifier is returned and a valid identifier for the
* application instance.
*/
- (void)getIDWithHandler:(FIRInstanceIDHandler)handler NS_SWIFT_NAME(getID(handler:));
/**
* Resets Instance ID and revokes all tokens.
*
* This method also triggers a request to fetch a new Instance ID and Firebase Messaging scope
* token. Please listen to kFIRInstanceIDTokenRefreshNotification when the new ID and token are
* ready.
*
* This stops the periodic sending of data to the Firebase backend that began when the Instance ID
* was generated. No more data is sent until another library calls Instance ID internally again
* (like FCM, RemoteConfig or Analytics) or user explicitly calls Instance ID APIs to get an
* Instance ID and token again.
*/
- (void)deleteIDWithHandler:(FIRInstanceIDDeleteHandler)handler NS_SWIFT_NAME(deleteID(handler:));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,17 @@
/*
* 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 "FIRInstanceID.h"

View File

@ -0,0 +1,11 @@
framework module FirebaseInstanceID {
umbrella header "FirebaseInstanceID.h"
export *
module * { export * }
link framework "CoreTelephony"
link framework "Foundation"
link framework "Security"
link framework "SystemConfiguration"
link framework "UIKit"
link "z"
}

View File

@ -0,0 +1,508 @@
/*
* 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>
NS_ASSUME_NONNULL_BEGIN
/**
* @related FIRMessaging
*
* The completion handler invoked when the registration token returns.
* If the call fails we return the appropriate `error code`, described by
* `FIRMessagingError`.
*
* @param FCMToken The valid registration token returned by FCM.
* @param error The error describing why a token request failed. The error code
* will match a value from the FIRMessagingError enumeration.
*/
typedef void (^FIRMessagingFCMTokenFetchCompletion)(NSString *_Nullable FCMToken,
NSError *_Nullable error)
NS_SWIFT_NAME(MessagingFCMTokenFetchCompletion);
/**
* @related FIRMessaging
*
* The completion handler invoked when the registration token deletion request is
* completed. If the call fails we return the appropriate `error code`, described
* by `FIRMessagingError`.
*
* @param error The error describing why a token deletion failed. The error code
* will match a value from the FIRMessagingError enumeration.
*/
typedef void (^FIRMessagingDeleteFCMTokenCompletion)(NSError *_Nullable error)
NS_SWIFT_NAME(MessagingDeleteFCMTokenCompletion);
/**
* Callback to invoke once the HTTP call to FIRMessaging backend for updating
* subscription finishes.
*
* @param error The error which occurred while updating the subscription topic
* on the FIRMessaging server. This will be nil in case the operation
* was successful, or if the operation was cancelled.
*/
typedef void (^FIRMessagingTopicOperationCompletion)(NSError *_Nullable error);
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
/**
* Notification sent when the upstream message has been delivered
* successfully to the server. The notification object will be the messageID
* of the successfully delivered message.
*/
FOUNDATION_EXPORT const NSNotificationName FIRMessagingSendSuccessNotification
NS_SWIFT_NAME(MessagingSendSuccess) DEPRECATED_ATTRIBUTE;
/**
* Notification sent when the upstream message was failed to be sent to the
* server. The notification object will be the messageID of the failed
* message. The userInfo dictionary will contain the relevant error
* information for the failure.
*/
FOUNDATION_EXPORT const NSNotificationName FIRMessagingSendErrorNotification
NS_SWIFT_NAME(MessagingSendError) DEPRECATED_ATTRIBUTE;
/**
* Notification sent when the Firebase messaging server deletes pending
* messages due to exceeded storage limits. This may occur, for example, when
* the device cannot be reached for an extended period of time.
*
* It is recommended to retrieve any missing messages directly from the
* server.
*/
FOUNDATION_EXPORT const NSNotificationName FIRMessagingMessagesDeletedNotification
NS_SWIFT_NAME(MessagingMessagesDeleted) DEPRECATED_ATTRIBUTE;
/**
* Notification sent when Firebase Messaging establishes or disconnects from
* an FCM socket connection. You can query the connection state in this
* notification by checking the `isDirectChannelEstablished` property of FIRMessaging.
*/
FOUNDATION_EXPORT const NSNotificationName FIRMessagingConnectionStateChangedNotification
NS_SWIFT_NAME(MessagingConnectionStateChanged) DEPRECATED_ATTRIBUTE;
/**
* Notification sent when the FCM registration token has been refreshed. Please use the
* FIRMessaging delegate method `messaging:didReceiveRegistrationToken:` to receive current and
* updated tokens.
*/
FOUNDATION_EXPORT const NSNotificationName FIRMessagingRegistrationTokenRefreshedNotification
NS_SWIFT_NAME(MessagingRegistrationTokenRefreshed);
#else
/**
* Notification sent when the upstream message has been delivered
* successfully to the server. The notification object will be the messageID
* of the successfully delivered message.
*/
FOUNDATION_EXPORT NSString *const FIRMessagingSendSuccessNotification
NS_SWIFT_NAME(MessagingSendSuccessNotification) DEPRECATED_ATTRIBUTE;
/**
* Notification sent when the upstream message was failed to be sent to the
* server. The notification object will be the messageID of the failed
* message. The userInfo dictionary will contain the relevant error
* information for the failure.
*/
FOUNDATION_EXPORT NSString *const FIRMessagingSendErrorNotification
NS_SWIFT_NAME(MessagingSendErrorNotification) DEPRECATED_ATTRIBUTE;
/**
* Notification sent when the Firebase messaging server deletes pending
* messages due to exceeded storage limits. This may occur, for example, when
* the device cannot be reached for an extended period of time.
*
* It is recommended to retrieve any missing messages directly from the
* server.
*/
FOUNDATION_EXPORT NSString *const FIRMessagingMessagesDeletedNotification
NS_SWIFT_NAME(MessagingMessagesDeletedNotification) DEPRECATED_ATTRIBUTE;
/**
* Notification sent when Firebase Messaging establishes or disconnects from
* an FCM socket connection. You can query the connection state in this
* notification by checking the `isDirectChannelEstablished` property of FIRMessaging.
*/
FOUNDATION_EXPORT NSString *const FIRMessagingConnectionStateChangedNotification
NS_SWIFT_NAME(MessagingConnectionStateChangedNotification) DEPRECATED_ATTRIBUTE;
/**
* Notification sent when the FCM registration token has been refreshed. Please use the
* FIRMessaging delegate method `messaging:didReceiveRegistrationToken:` to receive current and
* updated tokens.
*/
FOUNDATION_EXPORT NSString *const FIRMessagingRegistrationTokenRefreshedNotification
NS_SWIFT_NAME(MessagingRegistrationTokenRefreshedNotification);
#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
/**
* @enum FIRMessagingError
*/
typedef NS_ENUM(NSUInteger, FIRMessagingError) {
/// Unknown error.
FIRMessagingErrorUnknown = 0,
/// FIRMessaging couldn't validate request from this client.
FIRMessagingErrorAuthentication = 1,
/// InstanceID service cannot be accessed.
FIRMessagingErrorNoAccess = 2,
/// Request to InstanceID backend timed out.
FIRMessagingErrorTimeout = 3,
/// No network available to reach the servers.
FIRMessagingErrorNetwork = 4,
/// Another similar operation in progress, bailing this one.
FIRMessagingErrorOperationInProgress = 5,
/// Some parameters of the request were invalid.
FIRMessagingErrorInvalidRequest = 7,
/// Topic name is invalid for subscription/unsubscription.
FIRMessagingErrorInvalidTopicName = 8,
} NS_SWIFT_NAME(MessagingError);
/// Status for the downstream message received by the app.
typedef NS_ENUM(NSInteger, FIRMessagingMessageStatus) {
/// Unknown status.
FIRMessagingMessageStatusUnknown,
/// New downstream message received by the app.
FIRMessagingMessageStatusNew,
} NS_SWIFT_NAME(MessagingMessageStatus);
/**
* The APNS token type for the app. If the token type is set to `UNKNOWN`
* Firebase Messaging will implicitly try to figure out what the actual token type
* is from the provisioning profile.
* Unless you really need to specify the type, you should use the `APNSToken`
* property instead.
*/
typedef NS_ENUM(NSInteger, FIRMessagingAPNSTokenType) {
/// Unknown token type.
FIRMessagingAPNSTokenTypeUnknown,
/// Sandbox token type.
FIRMessagingAPNSTokenTypeSandbox,
/// Production token type.
FIRMessagingAPNSTokenTypeProd,
} NS_SWIFT_NAME(MessagingAPNSTokenType);
/// Information about a downstream message received by the app.
NS_SWIFT_NAME(MessagingMessageInfo)
@interface FIRMessagingMessageInfo : NSObject
/// The status of the downstream message
@property(nonatomic, readonly, assign) FIRMessagingMessageStatus status;
@end
/**
* A remote data message received by the app via FCM (not just the APNs interface).
*
* This is only for devices running iOS 10 or above. To support devices running iOS 9 or below, use
* the local and remote notifications handlers defined in UIApplicationDelegate protocol.
*/
NS_SWIFT_NAME(MessagingRemoteMessage)
__deprecated_msg(
"FCM direct channel is deprecated, please use APNs for downstream message handling.")
@interface FIRMessagingRemoteMessage : NSObject
/// The message ID of downstream message.
@property(nonatomic, readonly, copy) NSString *messageID DEPRECATED_ATTRIBUTE;
/// The downstream message received by the application.
@property(nonatomic, readonly, strong) NSDictionary *appData DEPRECATED_ATTRIBUTE;
@end
@class FIRMessaging;
@class FIRMessagingExtensionHelper;
/**
* A protocol to handle token update or data message delivery from FCM.
*
*/
NS_SWIFT_NAME(MessagingDelegate)
@protocol FIRMessagingDelegate <NSObject>
@optional
/// This method will be called once a token is available, or has been refreshed. Typically it
/// will be called once per app start, but may be called more often, if token is invalidated or
/// updated. In this method, you should perform operations such as:
///
/// * Uploading the FCM token to your application server, so targeted notifications can be sent.
///
/// * Subscribing to any topics.
- (void)messaging:(FIRMessaging *)messaging
didReceiveRegistrationToken:(NSString *)fcmToken
NS_SWIFT_NAME(messaging(_:didReceiveRegistrationToken:));
/// Handle data messages received via FCM direct channel (not via APNS).
- (void)messaging:(FIRMessaging *)messaging
didReceiveMessage:(FIRMessagingRemoteMessage *)remoteMessage
NS_SWIFT_NAME(messaging(_:didReceive:))__deprecated_msg(
"FCM direct channel is deprecated, please use APNs for downstream message handling.");
@end
/**
* Firebase Messaging lets you reliably deliver messages at no cost.
*
* To send or receive messages, the app must get a
* registration token from FIRInstanceID. This token authorizes an
* app server to send messages to an app instance.
*
* In order to receive FIRMessaging messages, declare
* `application:didReceiveRemoteNotification::fetchCompletionHandler:`.
*/
NS_SWIFT_NAME(Messaging)
@interface FIRMessaging : NSObject
/**
* Delegate to handle FCM token refreshes, and remote data messages received via FCM direct channel.
*/
@property(nonatomic, weak, nullable) id<FIRMessagingDelegate> delegate;
/**
* When set to `YES`, Firebase Messaging will automatically establish a socket-based, direct
* channel to the FCM server. Enable this only if you are sending upstream messages or
* receiving non-APNS, data-only messages in foregrounded apps.
* Default is `NO`.
*/
@property(nonatomic) BOOL shouldEstablishDirectChannel DEPRECATED_MSG_ATTRIBUTE(
"FCM direct channel is deprecated, please use APNs channel for downstream message delivery.");
/**
* Returns `YES` if the direct channel to the FCM server is active, and `NO` otherwise.
*/
@property(nonatomic, readonly) BOOL isDirectChannelEstablished DEPRECATED_MSG_ATTRIBUTE(
"FCM direct channel is deprecated, please use APNs channel for downstream message delivery.");
/**
* FIRMessaging
*
* @return An instance of FIRMessaging.
*/
+ (instancetype)messaging NS_SWIFT_NAME(messaging());
/**
* FIRMessagingExtensionHelper
*
* Use FIRMessagingExtensionHelper to populate rich UI contents for your notifications.
* e.g. If an image URL is set in your notification payload or on the console, call
* FIRMessagingExtensionHelper API to render it on your notification.
*
* @return An instance of FIRMessagingExtensionHelper that handles the extensions API.
*/
+ (FIRMessagingExtensionHelper *)extensionHelper NS_SWIFT_NAME(serviceExtension())
NS_AVAILABLE(10.14, 10.0);
/**
* Unavailable. Use +messaging instead.
*/
- (instancetype)init __attribute__((unavailable("Use +messaging instead.")));
#pragma mark - APNS
/**
* This property is used to set the APNS Token received by the application delegate.
*
* FIRMessaging uses method swizzling to ensure that the APNS token is set
* automatically. However, if you have disabled swizzling by setting
* `FirebaseAppDelegateProxyEnabled` to `NO` in your app's
* Info.plist, you should manually set the APNS token in your application
* delegate's `-application:didRegisterForRemoteNotificationsWithDeviceToken:`
* method.
*
* If you would like to set the type of the APNS token, rather than relying on
* automatic detection, see: `-setAPNSToken:type:`.
*/
@property(nonatomic, copy, nullable) NSData *APNSToken NS_SWIFT_NAME(apnsToken);
/**
* Set APNS token for the application. This APNS token will be used to register
* with Firebase Messaging using `FCMToken` or
* `tokenWithAuthorizedEntity:scope:options:handler`.
*
* @param apnsToken The APNS token for the application.
* @param type The type of APNS token. Debug builds should use
* FIRMessagingAPNSTokenTypeSandbox. Alternatively, you can supply
* FIRMessagingAPNSTokenTypeUnknown to have the type automatically
* detected based on your provisioning profile.
*/
- (void)setAPNSToken:(NSData *)apnsToken type:(FIRMessagingAPNSTokenType)type;
#pragma mark - FCM Tokens
/**
* Is Firebase Messaging token auto generation enabled? If this flag is disabled,
* Firebase Messaging will not generate token automatically for message delivery.
*
* If this flag is disabled, Firebase Messaging does not generate new tokens automatically for
* message delivery. If this flag is enabled, FCM generates a registration token on application
* start when there is no existing valid token. FCM also generates a new token when an existing
* token is deleted.
*
* This setting is persisted, and is applied on future
* invocations of your application. Once explicitly set, it overrides any
* settings in your Info.plist.
*
* By default, FCM automatic initialization is enabled. If you need to change the
* default (for example, because you want to prompt the user before getting token)
* set FirebaseMessagingAutoInitEnabled to false in your application's Info.plist.
*/
@property(nonatomic, assign, getter=isAutoInitEnabled) BOOL autoInitEnabled;
/**
* The FCM token is used to identify this device so that FCM can send notifications to it.
* It is associated with your APNS token when the APNS token is supplied, so that sending
* messages to the FCM token will be delivered over APNS.
*
* The FCM token is sometimes refreshed automatically. In your FIRMessaging delegate, the
* delegate method `messaging:didReceiveRegistrationToken:` will be called once a token is
* available, or has been refreshed. Typically it should be called once per app start, but
* may be called more often, if token is invalidated or updated.
*
* Once you have an FCM token, you should send it to your application server, so it can use
* the FCM token to send notifications to your device.
*/
@property(nonatomic, readonly, nullable) NSString *FCMToken NS_SWIFT_NAME(fcmToken);
/**
* Retrieves an FCM registration token for a particular Sender ID. This can be used to allow
* multiple senders to send notifications to the same device. By providing a different Sender
* ID than your default when fetching a token, you can create a new FCM token which you can
* give to a different sender. Both tokens will deliver notifications to your device, and you
* can revoke a token when you need to.
*
* This registration token is not cached by FIRMessaging. FIRMessaging should have an APNS
* token set before calling this to ensure that notifications can be delivered via APNS using
* this FCM token. You may re-retrieve the FCM token once you have the APNS token set, to
* associate it with the FCM token. The default FCM token is automatically associated with
* the APNS token, if the APNS token data is available.
*
* @param senderID The Sender ID for a particular Firebase project.
* @param completion The completion handler to handle the token request.
*/
- (void)retrieveFCMTokenForSenderID:(NSString *)senderID
completion:(FIRMessagingFCMTokenFetchCompletion)completion
NS_SWIFT_NAME(retrieveFCMToken(forSenderID:completion:));
/**
* Invalidates an FCM token for a particular Sender ID. That Sender ID cannot no longer send
* notifications to that FCM token.
*
* @param senderID The senderID for a particular Firebase project.
* @param completion The completion handler to handle the token deletion.
*/
- (void)deleteFCMTokenForSenderID:(NSString *)senderID
completion:(FIRMessagingDeleteFCMTokenCompletion)completion
NS_SWIFT_NAME(deleteFCMToken(forSenderID:completion:));
#pragma mark - Topics
/**
* Asynchronously subscribes to a topic. This uses a FCM Token to identify
* the app instance and periodically sends data to the Firebase backend. To stop this, see
* `[FIRInstanceID deleteIDWithHandler:]`.
*
* @param topic The name of the topic, for example, @"sports".
*/
- (void)subscribeToTopic:(NSString *)topic NS_SWIFT_NAME(subscribe(toTopic:));
/**
* Asynchronously subscribe to the provided topic, retrying on failure. This uses a FCM Token
* to identify the app instance and periodically sends data to the Firebase backend. To stop this,
* see `[FIRInstanceID deleteIDWithHandler:]`.
*
* @param topic The topic name to subscribe to, for example, @"sports".
* @param completion The completion that is invoked once the subscribe call ends.
* In case of success, nil error is returned. Otherwise, an
* appropriate error object is returned.
*/
- (void)subscribeToTopic:(nonnull NSString *)topic
completion:(nullable FIRMessagingTopicOperationCompletion)completion;
/**
* Asynchronously unsubscribe from a topic. This uses a FCM Token
* to identify the app instance and periodically sends data to the Firebase backend. To stop this,
* see `[FIRInstanceID deleteIDWithHandler:]`.
*
* @param topic The name of the topic, for example @"sports".
*/
- (void)unsubscribeFromTopic:(NSString *)topic NS_SWIFT_NAME(unsubscribe(fromTopic:));
/**
* Asynchronously unsubscribe from the provided topic, retrying on failure. This uses a FCM Token
* to identify the app instance and periodically sends data to the Firebase backend. To stop this,
* see `[FIRInstanceID deleteIDWithHandler:]`.
*
* @param topic The topic name to unsubscribe from, for example @"sports".
* @param completion The completion that is invoked once the unsubscribe call ends.
* In case of success, nil error is returned. Otherwise, an
* appropriate error object is returned.
*/
- (void)unsubscribeFromTopic:(nonnull NSString *)topic
completion:(nullable FIRMessagingTopicOperationCompletion)completion;
#pragma mark - Upstream
/**
* Sends an upstream ("device to cloud") message.
*
* The message is queued if we don't have an active connection.
* You can only use the upstream feature if your FCM implementation
* uses the XMPP server protocol.
*
* @param message Key/Value pairs to be sent. Values must be String, any
* other type will be ignored.
* @param receiver A string identifying the receiver of the message. For FCM
* project IDs the value is `SENDER_ID@gcm.googleapis.com`.
* @param messageID The ID of the message. This is generated by the application. It
* must be unique for each message generated by this application.
* It allows error callbacks and debugging, to uniquely identify
* each message.
* @param ttl The time to live for the message. In case we aren't able to
* send the message before the TTL expires we will send you a
* callback. If 0, we'll attempt to send immediately and return
* an error if we're not connected. Otherwise, the message will
* be queued. As for server-side messages, we don't return an error
* if the message has been dropped because of TTL; this can happen
* on the server side, and it would require extra communication.
*/
- (void)sendMessage:(NSDictionary *)message
to:(NSString *)receiver
withMessageID:(NSString *)messageID
timeToLive:(int64_t)ttl
__deprecated_msg("Upstream messaging through direct channel is deprecated. For realtime "
"updates, use Cloud Firestore, Realtime Database, or other services. ");
#pragma mark - Analytics
/**
* Use this to track message delivery and analytics for messages, typically
* when you receive a notification in `application:didReceiveRemoteNotification:`.
* However, you only need to call this if you set the `FirebaseAppDelegateProxyEnabled`
* flag to `NO` in your Info.plist. If `FirebaseAppDelegateProxyEnabled` is either missing
* or set to `YES` in your Info.plist, the library will call this automatically.
*
* @param message The downstream message received by the application.
*
* @return Information about the downstream message.
*/
- (FIRMessagingMessageInfo *)appDidReceiveMessage:(NSDictionary *)message;
@end
NS_ASSUME_NONNULL_END

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.
*/
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 || \
__MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_14
#import <UserNotifications/UserNotifications.h>
#endif
NS_ASSUME_NONNULL_BEGIN
/// This class is used to automatically populate a notification with an image if it is
/// specified in the notification body via the `image` parameter. Images and other
/// rich content can be populated manually without the use of this class. See the
/// `UNNotificationServiceExtension` type for more details.
__IOS_AVAILABLE(10.0) __OSX_AVAILABLE(10.14) @interface FIRMessagingExtensionHelper : NSObject
/// Call this API to complete your notification content modification. If you like to
/// overwrite some properties of the content instead of using the default payload,
/// make sure to make your customized motification to the content before passing it to
/// this call.
- (void)populateNotificationContent:(UNMutableNotificationContent *)content
withContentHandler:(void (^)(UNNotificationContent *_Nonnull))contentHandler;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,18 @@
/*
* 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 <FirebaseMessaging/FIRMessaging.h>
#import <FirebaseMessaging/FIRMessagingExtensionHelper.h>

View File

@ -0,0 +1,12 @@
framework module FirebaseMessaging {
umbrella header "FirebaseMessaging.h"
export *
module * { export * }
link framework "CoreTelephony"
link framework "Foundation"
link framework "Security"
link framework "SystemConfiguration"
link framework "UIKit"
link "sqlite3"
link "z"
}

View File

@ -0,0 +1,183 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/any.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBAnyRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBAnyRoot : GPBRootObject
@end
#pragma mark - GPBAny
typedef GPB_ENUM(GPBAny_FieldNumber) {
GPBAny_FieldNumber_TypeURL = 1,
GPBAny_FieldNumber_Value = 2,
};
/**
* `Any` contains an arbitrary serialized protocol buffer message along with a
* URL that describes the type of the serialized message.
*
* Protobuf library provides support to pack/unpack Any values in the form
* of utility functions or additional generated methods of the Any type.
*
* Example 1: Pack and unpack a message in C++.
*
* Foo foo = ...;
* Any any;
* any.PackFrom(foo);
* ...
* if (any.UnpackTo(&foo)) {
* ...
* }
*
* Example 2: Pack and unpack a message in Java.
*
* Foo foo = ...;
* Any any = Any.pack(foo);
* ...
* if (any.is(Foo.class)) {
* foo = any.unpack(Foo.class);
* }
*
* Example 3: Pack and unpack a message in Python.
*
* foo = Foo(...)
* any = Any()
* any.Pack(foo)
* ...
* if any.Is(Foo.DESCRIPTOR):
* any.Unpack(foo)
* ...
*
* Example 4: Pack and unpack a message in Go
*
* foo := &pb.Foo{...}
* any, err := ptypes.MarshalAny(foo)
* ...
* foo := &pb.Foo{}
* if err := ptypes.UnmarshalAny(any, foo); err != nil {
* ...
* }
*
* The pack methods provided by protobuf library will by default use
* 'type.googleapis.com/full.type.name' as the type URL and the unpack
* methods only use the fully qualified type name after the last '/'
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
* name "y.z".
*
*
* JSON
* ====
* The JSON representation of an `Any` value uses the regular
* representation of the deserialized, embedded message, with an
* additional field `\@type` which contains the type URL. Example:
*
* package google.profile;
* message Person {
* string first_name = 1;
* string last_name = 2;
* }
*
* {
* "\@type": "type.googleapis.com/google.profile.Person",
* "firstName": <string>,
* "lastName": <string>
* }
*
* If the embedded message type is well-known and has a custom JSON
* representation, that representation will be embedded adding a field
* `value` which holds the custom JSON in addition to the `\@type`
* field. Example (for message [google.protobuf.Duration][]):
*
* {
* "\@type": "type.googleapis.com/google.protobuf.Duration",
* "value": "1.212s"
* }
**/
@interface GPBAny : GPBMessage
/**
* A URL/resource name that uniquely identifies the type of the serialized
* protocol buffer message. This string must contain at least
* one "/" character. The last segment of the URL's path must represent
* the fully qualified name of the type (as in
* `path/google.protobuf.Duration`). The name should be in a canonical form
* (e.g., leading "." is not accepted).
*
* In practice, teams usually precompile into the binary all types that they
* expect it to use in the context of Any. However, for URLs which use the
* scheme `http`, `https`, or no scheme, one can optionally set up a type
* server that maps type URLs to message definitions as follows:
*
* * If no scheme is provided, `https` is assumed.
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
* value in binary format, or produce an error.
* * Applications are allowed to cache lookup results based on the
* URL, or have them precompiled into a binary to avoid any
* lookup. Therefore, binary compatibility needs to be preserved
* on changes to types. (Use versioned type names to manage
* breaking changes.)
*
* Note: this functionality is not currently available in the official
* protobuf release, and it is not used for type URLs beginning with
* type.googleapis.com.
*
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
/** Must be a valid serialized protocol buffer of the above specified type. */
@property(nonatomic, readwrite, copy, null_resettable) NSData *value;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,311 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/api.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
@class GPBMethod;
@class GPBMixin;
@class GPBOption;
@class GPBSourceContext;
GPB_ENUM_FWD_DECLARE(GPBSyntax);
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBApiRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBApiRoot : GPBRootObject
@end
#pragma mark - GPBApi
typedef GPB_ENUM(GPBApi_FieldNumber) {
GPBApi_FieldNumber_Name = 1,
GPBApi_FieldNumber_MethodsArray = 2,
GPBApi_FieldNumber_OptionsArray = 3,
GPBApi_FieldNumber_Version = 4,
GPBApi_FieldNumber_SourceContext = 5,
GPBApi_FieldNumber_MixinsArray = 6,
GPBApi_FieldNumber_Syntax = 7,
};
/**
* Api is a light-weight descriptor for an API Interface.
*
* Interfaces are also described as "protocol buffer services" in some contexts,
* such as by the "service" keyword in a .proto file, but they are different
* from API Services, which represent a concrete implementation of an interface
* as opposed to simply a description of methods and bindings. They are also
* sometimes simply referred to as "APIs" in other contexts, such as the name of
* this message itself. See https://cloud.google.com/apis/design/glossary for
* detailed terminology.
**/
@interface GPBApi : GPBMessage
/**
* The fully qualified name of this interface, including package name
* followed by the interface's simple name.
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/** The methods of this interface, in unspecified order. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMethod*> *methodsArray;
/** The number of items in @c methodsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger methodsArray_Count;
/** Any metadata attached to the interface. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
/**
* A version string for this interface. If specified, must have the form
* `major-version.minor-version`, as in `1.10`. If the minor version is
* omitted, it defaults to zero. If the entire version field is empty, the
* major version is derived from the package name, as outlined below. If the
* field is not empty, the version in the package name will be verified to be
* consistent with what is provided here.
*
* The versioning schema uses [semantic
* versioning](http://semver.org) where the major version number
* indicates a breaking change and the minor version an additive,
* non-breaking change. Both version numbers are signals to users
* what to expect from different versions, and should be carefully
* chosen based on the product plan.
*
* The major version is also reflected in the package name of the
* interface, which must end in `v<major-version>`, as in
* `google.feature.v1`. For major versions 0 and 1, the suffix can
* be omitted. Zero major versions must only be used for
* experimental, non-GA interfaces.
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *version;
/**
* Source context for the protocol buffer service represented by this
* message.
**/
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
/** Test to see if @c sourceContext has been set. */
@property(nonatomic, readwrite) BOOL hasSourceContext;
/** Included interfaces. See [Mixin][]. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMixin*> *mixinsArray;
/** The number of items in @c mixinsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger mixinsArray_Count;
/** The source syntax of the service. */
@property(nonatomic, readwrite) enum GPBSyntax syntax;
@end
/**
* Fetches the raw value of a @c GPBApi's @c syntax property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t GPBApi_Syntax_RawValue(GPBApi *message);
/**
* Sets the raw value of an @c GPBApi's @c syntax property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value);
#pragma mark - GPBMethod
typedef GPB_ENUM(GPBMethod_FieldNumber) {
GPBMethod_FieldNumber_Name = 1,
GPBMethod_FieldNumber_RequestTypeURL = 2,
GPBMethod_FieldNumber_RequestStreaming = 3,
GPBMethod_FieldNumber_ResponseTypeURL = 4,
GPBMethod_FieldNumber_ResponseStreaming = 5,
GPBMethod_FieldNumber_OptionsArray = 6,
GPBMethod_FieldNumber_Syntax = 7,
};
/**
* Method represents a method of an API interface.
**/
@interface GPBMethod : GPBMessage
/** The simple name of this method. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/** A URL of the input message type. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *requestTypeURL;
/** If true, the request is streamed. */
@property(nonatomic, readwrite) BOOL requestStreaming;
/** The URL of the output message type. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *responseTypeURL;
/** If true, the response is streamed. */
@property(nonatomic, readwrite) BOOL responseStreaming;
/** Any metadata attached to the method. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
/** The source syntax of this method. */
@property(nonatomic, readwrite) enum GPBSyntax syntax;
@end
/**
* Fetches the raw value of a @c GPBMethod's @c syntax property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t GPBMethod_Syntax_RawValue(GPBMethod *message);
/**
* Sets the raw value of an @c GPBMethod's @c syntax property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value);
#pragma mark - GPBMixin
typedef GPB_ENUM(GPBMixin_FieldNumber) {
GPBMixin_FieldNumber_Name = 1,
GPBMixin_FieldNumber_Root = 2,
};
/**
* Declares an API Interface to be included in this interface. The including
* interface must redeclare all the methods from the included interface, but
* documentation and options are inherited as follows:
*
* - If after comment and whitespace stripping, the documentation
* string of the redeclared method is empty, it will be inherited
* from the original method.
*
* - Each annotation belonging to the service config (http,
* visibility) which is not set in the redeclared method will be
* inherited.
*
* - If an http annotation is inherited, the path pattern will be
* modified as follows. Any version prefix will be replaced by the
* version of the including interface plus the [root][] path if
* specified.
*
* Example of a simple mixin:
*
* package google.acl.v1;
* service AccessControl {
* // Get the underlying ACL object.
* rpc GetAcl(GetAclRequest) returns (Acl) {
* option (google.api.http).get = "/v1/{resource=**}:getAcl";
* }
* }
*
* package google.storage.v2;
* service Storage {
* rpc GetAcl(GetAclRequest) returns (Acl);
*
* // Get a data record.
* rpc GetData(GetDataRequest) returns (Data) {
* option (google.api.http).get = "/v2/{resource=**}";
* }
* }
*
* Example of a mixin configuration:
*
* apis:
* - name: google.storage.v2.Storage
* mixins:
* - name: google.acl.v1.AccessControl
*
* The mixin construct implies that all methods in `AccessControl` are
* also declared with same name and request/response types in
* `Storage`. A documentation generator or annotation processor will
* see the effective `Storage.GetAcl` method after inherting
* documentation and annotations as follows:
*
* service Storage {
* // Get the underlying ACL object.
* rpc GetAcl(GetAclRequest) returns (Acl) {
* option (google.api.http).get = "/v2/{resource=**}:getAcl";
* }
* ...
* }
*
* Note how the version in the path pattern changed from `v1` to `v2`.
*
* If the `root` field in the mixin is specified, it should be a
* relative path under which inherited HTTP paths are placed. Example:
*
* apis:
* - name: google.storage.v2.Storage
* mixins:
* - name: google.acl.v1.AccessControl
* root: acls
*
* This implies the following inherited HTTP annotation:
*
* service Storage {
* // Get the underlying ACL object.
* rpc GetAcl(GetAclRequest) returns (Acl) {
* option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
* }
* ...
* }
**/
@interface GPBMixin : GPBMessage
/** The fully qualified name of the interface which is included. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/**
* If non-empty specifies a path under which inherited HTTP paths
* are rooted.
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *root;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,145 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/duration.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBDurationRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBDurationRoot : GPBRootObject
@end
#pragma mark - GPBDuration
typedef GPB_ENUM(GPBDuration_FieldNumber) {
GPBDuration_FieldNumber_Seconds = 1,
GPBDuration_FieldNumber_Nanos = 2,
};
/**
* A Duration represents a signed, fixed-length span of time represented
* as a count of seconds and fractions of seconds at nanosecond
* resolution. It is independent of any calendar and concepts like "day"
* or "month". It is related to Timestamp in that the difference between
* two Timestamp values is a Duration and it can be added or subtracted
* from a Timestamp. Range is approximately +-10,000 years.
*
* # Examples
*
* Example 1: Compute Duration from two Timestamps in pseudo code.
*
* Timestamp start = ...;
* Timestamp end = ...;
* Duration duration = ...;
*
* duration.seconds = end.seconds - start.seconds;
* duration.nanos = end.nanos - start.nanos;
*
* if (duration.seconds < 0 && duration.nanos > 0) {
* duration.seconds += 1;
* duration.nanos -= 1000000000;
* } else if (duration.seconds > 0 && duration.nanos < 0) {
* duration.seconds -= 1;
* duration.nanos += 1000000000;
* }
*
* Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
*
* Timestamp start = ...;
* Duration duration = ...;
* Timestamp end = ...;
*
* end.seconds = start.seconds + duration.seconds;
* end.nanos = start.nanos + duration.nanos;
*
* if (end.nanos < 0) {
* end.seconds -= 1;
* end.nanos += 1000000000;
* } else if (end.nanos >= 1000000000) {
* end.seconds += 1;
* end.nanos -= 1000000000;
* }
*
* Example 3: Compute Duration from datetime.timedelta in Python.
*
* td = datetime.timedelta(days=3, minutes=10)
* duration = Duration()
* duration.FromTimedelta(td)
*
* # JSON Mapping
*
* In JSON format, the Duration type is encoded as a string rather than an
* object, where the string ends in the suffix "s" (indicating seconds) and
* is preceded by the number of seconds, with nanoseconds expressed as
* fractional seconds. For example, 3 seconds with 0 nanoseconds should be
* encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
* be expressed in JSON format as "3.000000001s", and 3 seconds and 1
* microsecond should be expressed in JSON format as "3.000001s".
**/
@interface GPBDuration : GPBMessage
/**
* Signed seconds of the span of time. Must be from -315,576,000,000
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
**/
@property(nonatomic, readwrite) int64_t seconds;
/**
* Signed fractions of a second at nanosecond resolution of the span
* of time. Durations less than one second are represented with a 0
* `seconds` field and a positive or negative `nanos` field. For durations
* of one second or more, a non-zero value for the `nanos` field must be
* of the same sign as the `seconds` field. Must be from -999,999,999
* to +999,999,999 inclusive.
**/
@property(nonatomic, readwrite) int32_t nanos;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,74 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/empty.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBEmptyRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBEmptyRoot : GPBRootObject
@end
#pragma mark - GPBEmpty
/**
* A generic empty message that you can re-use to avoid defining duplicated
* empty messages in your APIs. A typical example is to use it as the request
* or the response type of an API method. For instance:
*
* service Foo {
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
* }
*
* The JSON representation for `Empty` is empty JSON object `{}`.
**/
@interface GPBEmpty : GPBMessage
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,273 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/field_mask.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBFieldMaskRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBFieldMaskRoot : GPBRootObject
@end
#pragma mark - GPBFieldMask
typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
GPBFieldMask_FieldNumber_PathsArray = 1,
};
/**
* `FieldMask` represents a set of symbolic field paths, for example:
*
* paths: "f.a"
* paths: "f.b.d"
*
* Here `f` represents a field in some root message, `a` and `b`
* fields in the message found in `f`, and `d` a field found in the
* message in `f.b`.
*
* Field masks are used to specify a subset of fields that should be
* returned by a get operation or modified by an update operation.
* Field masks also have a custom JSON encoding (see below).
*
* # Field Masks in Projections
*
* When used in the context of a projection, a response message or
* sub-message is filtered by the API to only contain those fields as
* specified in the mask. For example, if the mask in the previous
* example is applied to a response message as follows:
*
* f {
* a : 22
* b {
* d : 1
* x : 2
* }
* y : 13
* }
* z: 8
*
* The result will not contain specific values for fields x,y and z
* (their value will be set to the default, and omitted in proto text
* output):
*
*
* f {
* a : 22
* b {
* d : 1
* }
* }
*
* A repeated field is not allowed except at the last position of a
* paths string.
*
* If a FieldMask object is not present in a get operation, the
* operation applies to all fields (as if a FieldMask of all fields
* had been specified).
*
* Note that a field mask does not necessarily apply to the
* top-level response message. In case of a REST get operation, the
* field mask applies directly to the response, but in case of a REST
* list operation, the mask instead applies to each individual message
* in the returned resource list. In case of a REST custom method,
* other definitions may be used. Where the mask applies will be
* clearly documented together with its declaration in the API. In
* any case, the effect on the returned resource/resources is required
* behavior for APIs.
*
* # Field Masks in Update Operations
*
* A field mask in update operations specifies which fields of the
* targeted resource are going to be updated. The API is required
* to only change the values of the fields as specified in the mask
* and leave the others untouched. If a resource is passed in to
* describe the updated values, the API ignores the values of all
* fields not covered by the mask.
*
* If a repeated field is specified for an update operation, new values will
* be appended to the existing repeated field in the target resource. Note that
* a repeated field is only allowed in the last position of a `paths` string.
*
* If a sub-message is specified in the last position of the field mask for an
* update operation, then new value will be merged into the existing sub-message
* in the target resource.
*
* For example, given the target message:
*
* f {
* b {
* d: 1
* x: 2
* }
* c: [1]
* }
*
* And an update message:
*
* f {
* b {
* d: 10
* }
* c: [2]
* }
*
* then if the field mask is:
*
* paths: ["f.b", "f.c"]
*
* then the result will be:
*
* f {
* b {
* d: 10
* x: 2
* }
* c: [1, 2]
* }
*
* An implementation may provide options to override this default behavior for
* repeated and message fields.
*
* In order to reset a field's value to the default, the field must
* be in the mask and set to the default value in the provided resource.
* Hence, in order to reset all fields of a resource, provide a default
* instance of the resource and set all fields in the mask, or do
* not provide a mask as described below.
*
* If a field mask is not present on update, the operation applies to
* all fields (as if a field mask of all fields has been specified).
* Note that in the presence of schema evolution, this may mean that
* fields the client does not know and has therefore not filled into
* the request will be reset to their default. If this is unwanted
* behavior, a specific service may require a client to always specify
* a field mask, producing an error if not.
*
* As with get operations, the location of the resource which
* describes the updated values in the request message depends on the
* operation kind. In any case, the effect of the field mask is
* required to be honored by the API.
*
* ## Considerations for HTTP REST
*
* The HTTP kind of an update operation which uses a field mask must
* be set to PATCH instead of PUT in order to satisfy HTTP semantics
* (PUT must only be used for full updates).
*
* # JSON Encoding of Field Masks
*
* In JSON, a field mask is encoded as a single string where paths are
* separated by a comma. Fields name in each path are converted
* to/from lower-camel naming conventions.
*
* As an example, consider the following message declarations:
*
* message Profile {
* User user = 1;
* Photo photo = 2;
* }
* message User {
* string display_name = 1;
* string address = 2;
* }
*
* In proto a field mask for `Profile` may look as such:
*
* mask {
* paths: "user.display_name"
* paths: "photo"
* }
*
* In JSON, the same mask is represented as below:
*
* {
* mask: "user.displayName,photo"
* }
*
* # Field Masks and Oneof Fields
*
* Field masks treat fields in oneofs just as regular fields. Consider the
* following message:
*
* message SampleMessage {
* oneof test_oneof {
* string name = 4;
* SubMessage sub_message = 9;
* }
* }
*
* The field mask can be:
*
* mask {
* paths: "name"
* }
*
* Or:
*
* mask {
* paths: "sub_message"
* }
*
* Note that oneof type names ("test_oneof" in this case) cannot be used in
* paths.
*
* ## Field Mask Verification
*
* The implementation of any API method which has a FieldMask type field in the
* request should verify the included field paths, and return an
* `INVALID_ARGUMENT` error if any path is unmappable.
**/
@interface GPBFieldMask : GPBMessage
/** The set of field mask paths. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *pathsArray;
/** The number of items in @c pathsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger pathsArray_Count;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,130 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2015 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import "GPBArray.h"
@class GPBMessage;
//%PDDM-DEFINE DECLARE_ARRAY_EXTRAS()
//%ARRAY_INTERFACE_EXTRAS(Int32, int32_t)
//%ARRAY_INTERFACE_EXTRAS(UInt32, uint32_t)
//%ARRAY_INTERFACE_EXTRAS(Int64, int64_t)
//%ARRAY_INTERFACE_EXTRAS(UInt64, uint64_t)
//%ARRAY_INTERFACE_EXTRAS(Float, float)
//%ARRAY_INTERFACE_EXTRAS(Double, double)
//%ARRAY_INTERFACE_EXTRAS(Bool, BOOL)
//%ARRAY_INTERFACE_EXTRAS(Enum, int32_t)
//%PDDM-DEFINE ARRAY_INTERFACE_EXTRAS(NAME, TYPE)
//%#pragma mark - NAME
//%
//%@interface GPB##NAME##Array () {
//% @package
//% GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
//%}
//%@end
//%
//%PDDM-EXPAND DECLARE_ARRAY_EXTRAS()
// This block of code is generated, do not edit it directly.
#pragma mark - Int32
@interface GPBInt32Array () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - UInt32
@interface GPBUInt32Array () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Int64
@interface GPBInt64Array () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - UInt64
@interface GPBUInt64Array () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Float
@interface GPBFloatArray () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Double
@interface GPBDoubleArray () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Bool
@interface GPBBoolArray () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Enum
@interface GPBEnumArray () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
//%PDDM-EXPAND-END DECLARE_ARRAY_EXTRAS()
#pragma mark - NSArray Subclass
@interface GPBAutocreatedArray : NSMutableArray {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end

View File

@ -0,0 +1,141 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/**
* The Objective C runtime has complete enough info that most protos dont end
* up using this, so leaving it on is no cost or very little cost. If you
* happen to see it causing bloat, this is the way to disable it. If you do
* need to disable it, try only disabling it for Release builds as having
* full TextFormat can be useful for debugging.
**/
#ifndef GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
#define GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS 0
#endif
// Used in the generated code to give sizes to enums. int32_t was chosen based
// on the fact that Protocol Buffers enums are limited to this range.
#if !__has_feature(objc_fixed_enum)
#error All supported Xcode versions should support objc_fixed_enum.
#endif
// If the headers are imported into Objective-C++, we can run into an issue
// where the defintion of NS_ENUM (really CF_ENUM) changes based on the C++
// standard that is in effect. If it isn't C++11 or higher, the definition
// doesn't allow us to forward declare. We work around this one case by
// providing a local definition. The default case has to use NS_ENUM for the
// magic that is Swift bridging of enums.
#if (defined(__cplusplus) && __cplusplus && __cplusplus < 201103L)
#define GPB_ENUM(X) enum X : int32_t X; enum X : int32_t
#else
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
#endif
/**
* GPB_ENUM_FWD_DECLARE is used for forward declaring enums, for example:
*
* ```
* GPB_ENUM_FWD_DECLARE(Foo_Enum)
*
* @interface BarClass : NSObject
* @property (nonatomic) enum Foo_Enum value;
* - (void)bazMethod:(enum Foo_Enum):value;
* @end
* ```
**/
#define GPB_ENUM_FWD_DECLARE(X) enum X : int32_t
/**
* Based upon CF_INLINE. Forces inlining in non DEBUG builds.
**/
#if !defined(DEBUG)
#define GPB_INLINE static __inline__ __attribute__((always_inline))
#else
#define GPB_INLINE static __inline__
#endif
/**
* For use in public headers that might need to deal with ARC.
**/
#ifndef GPB_UNSAFE_UNRETAINED
#if __has_feature(objc_arc)
#define GPB_UNSAFE_UNRETAINED __unsafe_unretained
#else
#define GPB_UNSAFE_UNRETAINED
#endif
#endif
/**
* Attribute used for Objective-C proto interface deprecations without messages.
**/
#ifndef GPB_DEPRECATED
#define GPB_DEPRECATED __attribute__((deprecated))
#endif
/**
* Attribute used for Objective-C proto interface deprecations with messages.
**/
#ifndef GPB_DEPRECATED_MSG
#if __has_extension(attribute_deprecated_with_message)
#define GPB_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
#else
#define GPB_DEPRECATED_MSG(msg) __attribute__((deprecated))
#endif
#endif
// If property name starts with init we need to annotate it to get past ARC.
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
//
// Meant to be used internally by generated code.
#define GPB_METHOD_FAMILY_NONE __attribute__((objc_method_family(none)))
// ----------------------------------------------------------------------------
// These version numbers are all internal to the ObjC Protobuf runtime; they
// are used to ensure compatibility between the generated sources and the
// headers being compiled against and/or the version of sources being run
// against.
//
// They are all #defines so the values are captured into every .o file they
// are used in and to allow comparisons in the preprocessor.
// Current library runtime version.
// - Gets bumped when the runtime makes changes to the interfaces between the
// generated code and runtime (things added/removed, etc).
#define GOOGLE_PROTOBUF_OBJC_VERSION 30002
// Minimum runtime version supported for compiling/running against.
// - Gets changed when support for the older generated code is dropped.
#define GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION 30001
// This is a legacy constant now frozen in time for old generated code. If
// GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION ever gets moved above 30001 then
// this should also change to break code compiled with an old runtime that
// can't be supported any more.
#define GOOGLE_PROTOBUF_OBJC_GEN_VERSION 30001

View File

@ -0,0 +1,253 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
@class GPBMessage;
@class GPBExtensionRegistry;
NS_ASSUME_NONNULL_BEGIN
CF_EXTERN_C_BEGIN
/**
* @c GPBCodedInputStream exception name. Exceptions raised from
* @c GPBCodedInputStream contain an underlying error in the userInfo dictionary
* under the GPBCodedInputStreamUnderlyingErrorKey key.
**/
extern NSString *const GPBCodedInputStreamException;
/** The key under which the underlying NSError from the exception is stored. */
extern NSString *const GPBCodedInputStreamUnderlyingErrorKey;
/** NSError domain used for @c GPBCodedInputStream errors. */
extern NSString *const GPBCodedInputStreamErrorDomain;
/**
* Error code for NSError with @c GPBCodedInputStreamErrorDomain.
**/
typedef NS_ENUM(NSInteger, GPBCodedInputStreamErrorCode) {
/** The size does not fit in the remaining bytes to be read. */
GPBCodedInputStreamErrorInvalidSize = -100,
/** Attempted to read beyond the subsection limit. */
GPBCodedInputStreamErrorSubsectionLimitReached = -101,
/** The requested subsection limit is invalid. */
GPBCodedInputStreamErrorInvalidSubsectionLimit = -102,
/** Invalid tag read. */
GPBCodedInputStreamErrorInvalidTag = -103,
/** Invalid UTF-8 character in a string. */
GPBCodedInputStreamErrorInvalidUTF8 = -104,
/** Invalid VarInt read. */
GPBCodedInputStreamErrorInvalidVarInt = -105,
/** The maximum recursion depth of messages was exceeded. */
GPBCodedInputStreamErrorRecursionDepthExceeded = -106,
};
CF_EXTERN_C_END
/**
* Reads and decodes protocol message fields.
*
* The common uses of protocol buffers shouldn't need to use this class.
* @c GPBMessage's provide a @c +parseFromData:error: and
* @c +parseFromData:extensionRegistry:error: method that will decode a
* message for you.
*
* @note Subclassing of @c GPBCodedInputStream is NOT supported.
**/
@interface GPBCodedInputStream : NSObject
/**
* Creates a new stream wrapping some data.
*
* @param data The data to wrap inside the stream.
*
* @return A newly instanced GPBCodedInputStream.
**/
+ (instancetype)streamWithData:(NSData *)data;
/**
* Initializes a stream wrapping some data.
*
* @param data The data to wrap inside the stream.
*
* @return A newly initialized GPBCodedInputStream.
**/
- (instancetype)initWithData:(NSData *)data;
/**
* Attempts to read a field tag, returning zero if we have reached EOF.
* Protocol message parsers use this to read tags, since a protocol message
* may legally end wherever a tag occurs, and zero is not a valid tag number.
*
* @return The field tag, or zero if EOF was reached.
**/
- (int32_t)readTag;
/**
* @return A double read from the stream.
**/
- (double)readDouble;
/**
* @return A float read from the stream.
**/
- (float)readFloat;
/**
* @return A uint64 read from the stream.
**/
- (uint64_t)readUInt64;
/**
* @return A uint32 read from the stream.
**/
- (uint32_t)readUInt32;
/**
* @return An int64 read from the stream.
**/
- (int64_t)readInt64;
/**
* @return An int32 read from the stream.
**/
- (int32_t)readInt32;
/**
* @return A fixed64 read from the stream.
**/
- (uint64_t)readFixed64;
/**
* @return A fixed32 read from the stream.
**/
- (uint32_t)readFixed32;
/**
* @return An enum read from the stream.
**/
- (int32_t)readEnum;
/**
* @return A sfixed32 read from the stream.
**/
- (int32_t)readSFixed32;
/**
* @return A fixed64 read from the stream.
**/
- (int64_t)readSFixed64;
/**
* @return A sint32 read from the stream.
**/
- (int32_t)readSInt32;
/**
* @return A sint64 read from the stream.
**/
- (int64_t)readSInt64;
/**
* @return A boolean read from the stream.
**/
- (BOOL)readBool;
/**
* @return A string read from the stream.
**/
- (NSString *)readString;
/**
* @return Data read from the stream.
**/
- (NSData *)readBytes;
/**
* Read an embedded message field value from the stream.
*
* @param message The message to set fields on as they are read.
* @param extensionRegistry An optional extension registry to use to lookup
* extensions for message.
**/
- (void)readMessage:(GPBMessage *)message
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
/**
* Reads and discards a single field, given its tag value.
*
* @param tag The tag number of the field to skip.
*
* @return NO if the tag is an endgroup tag (in which case nothing is skipped),
* YES in all other cases.
**/
- (BOOL)skipField:(int32_t)tag;
/**
* Reads and discards an entire message. This will read either until EOF or
* until an endgroup tag, whichever comes first.
**/
- (void)skipMessage;
/**
* Check to see if the logical end of the stream has been reached.
*
* @note This can return NO when there is no more data, but the current parsing
* expected more data.
*
* @return YES if the logical end of the stream has been reached, NO otherwise.
**/
- (BOOL)isAtEnd;
/**
* @return The offset into the stream.
**/
- (size_t)position;
/**
* Moves the limit to the given byte offset starting at the current location.
*
* @exception GPBCodedInputStreamException If the requested bytes exceeed the
* current limit.
*
* @param byteLimit The number of bytes to move the limit, offset to the current
* location.
*
* @return The limit offset before moving the new limit.
*/
- (size_t)pushLimit:(size_t)byteLimit;
/**
* Moves the limit back to the offset as it was before calling pushLimit:.
*
* @param oldLimit The number of bytes to move the current limit. Usually this
* is the value returned by the pushLimit: method.
*/
- (void)popLimit:(size_t)oldLimit;
/**
* Verifies that the last call to -readTag returned the given tag value. This
* is used to verify that a nested group ended with the correct end tag.
*
* @exception NSParseErrorException If the value does not match the last tag.
*
* @param expected The tag that was expected.
**/
- (void)checkLastTagWas:(int32_t)expected;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,112 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This header is private to the ProtobolBuffers library and must NOT be
// included by any sources outside this library. The contents of this file are
// subject to change at any time without notice.
#import "GPBCodedInputStream.h"
@class GPBUnknownFieldSet;
@class GPBFieldDescriptor;
typedef struct GPBCodedInputStreamState {
const uint8_t *bytes;
size_t bufferSize;
size_t bufferPos;
// For parsing subsections of an input stream you can put a hard limit on
// how much should be read. Normally the limit is the end of the stream,
// but you can adjust it to anywhere, and if you hit it you will be at the
// end of the stream, until you adjust the limit.
size_t currentLimit;
int32_t lastTag;
NSUInteger recursionDepth;
} GPBCodedInputStreamState;
@interface GPBCodedInputStream () {
@package
struct GPBCodedInputStreamState state_;
NSData *buffer_;
}
// Group support is deprecated, so we hide this interface from users, but
// support for older data.
- (void)readGroup:(int32_t)fieldNumber
message:(GPBMessage *)message
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry;
// Reads a group field value from the stream and merges it into the given
// UnknownFieldSet.
- (void)readUnknownGroup:(int32_t)fieldNumber
message:(GPBUnknownFieldSet *)message;
// Reads a map entry.
- (void)readMapEntry:(id)mapDictionary
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
field:(GPBFieldDescriptor *)field
parentMessage:(GPBMessage *)parentMessage;
@end
CF_EXTERN_C_BEGIN
int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state);
double GPBCodedInputStreamReadDouble(GPBCodedInputStreamState *state);
float GPBCodedInputStreamReadFloat(GPBCodedInputStreamState *state);
uint64_t GPBCodedInputStreamReadUInt64(GPBCodedInputStreamState *state);
uint32_t GPBCodedInputStreamReadUInt32(GPBCodedInputStreamState *state);
int64_t GPBCodedInputStreamReadInt64(GPBCodedInputStreamState *state);
int32_t GPBCodedInputStreamReadInt32(GPBCodedInputStreamState *state);
uint64_t GPBCodedInputStreamReadFixed64(GPBCodedInputStreamState *state);
uint32_t GPBCodedInputStreamReadFixed32(GPBCodedInputStreamState *state);
int32_t GPBCodedInputStreamReadEnum(GPBCodedInputStreamState *state);
int32_t GPBCodedInputStreamReadSFixed32(GPBCodedInputStreamState *state);
int64_t GPBCodedInputStreamReadSFixed64(GPBCodedInputStreamState *state);
int32_t GPBCodedInputStreamReadSInt32(GPBCodedInputStreamState *state);
int64_t GPBCodedInputStreamReadSInt64(GPBCodedInputStreamState *state);
BOOL GPBCodedInputStreamReadBool(GPBCodedInputStreamState *state);
NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state)
__attribute((ns_returns_retained));
NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state)
__attribute((ns_returns_retained));
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(
GPBCodedInputStreamState *state) __attribute((ns_returns_retained));
size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state,
size_t byteLimit);
void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state,
size_t oldLimit);
size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state);
BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state);
void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
int32_t value);
CF_EXTERN_C_END

View File

@ -0,0 +1,748 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBRuntimeTypes.h"
#import "GPBWireFormat.h"
@class GPBBoolArray;
@class GPBDoubleArray;
@class GPBEnumArray;
@class GPBFloatArray;
@class GPBMessage;
@class GPBInt32Array;
@class GPBInt64Array;
@class GPBUInt32Array;
@class GPBUInt64Array;
@class GPBUnknownFieldSet;
NS_ASSUME_NONNULL_BEGIN
/**
* @c GPBCodedOutputStream exception names.
**/
extern NSString *const GPBCodedOutputStreamException_OutOfSpace;
extern NSString *const GPBCodedOutputStreamException_WriteFailed;
/**
* Writes out protocol message fields.
*
* The common uses of protocol buffers shouldn't need to use this class.
* GPBMessage's provide a -data method that will serialize the message for you.
*
* @note Any -write* api can raise the GPBCodedOutputStreamException_*
* exceptions.
*
* @note Subclassing of GPBCodedOutputStream is NOT supported.
**/
@interface GPBCodedOutputStream : NSObject
/**
* Creates a stream to fill in the given data. Data must be sized to fit or
* an error will be raised when out of space.
*
* @param data The data where the stream will be written to.
*
* @return A newly instanced GPBCodedOutputStream.
**/
+ (instancetype)streamWithData:(NSMutableData *)data;
/**
* Creates a stream to write into the given NSOutputStream.
*
* @param output The output stream where the stream will be written to.
*
* @return A newly instanced GPBCodedOutputStream.
**/
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output;
/**
* Initializes a stream to fill in the given data. Data must be sized to fit
* or an error will be raised when out of space.
*
* @param data The data where the stream will be written to.
*
* @return A newly initialized GPBCodedOutputStream.
**/
- (instancetype)initWithData:(NSMutableData *)data;
/**
* Initializes a stream to write into the given @c NSOutputStream.
*
* @param output The output stream where the stream will be written to.
*
* @return A newly initialized GPBCodedOutputStream.
**/
- (instancetype)initWithOutputStream:(NSOutputStream *)output;
/**
* Flush any buffered data out.
**/
- (void)flush;
/**
* Write the raw byte out.
*
* @param value The value to write out.
**/
- (void)writeRawByte:(uint8_t)value;
/**
* Write the tag for the given field number and wire format.
*
* @param fieldNumber The field number.
* @param format The wire format the data for the field will be in.
**/
- (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;
/**
* Write a 32bit value out in little endian format.
*
* @param value The value to write out.
**/
- (void)writeRawLittleEndian32:(int32_t)value;
/**
* Write a 64bit value out in little endian format.
*
* @param value The value to write out.
**/
- (void)writeRawLittleEndian64:(int64_t)value;
/**
* Write a 32bit value out in varint format.
*
* @param value The value to write out.
**/
- (void)writeRawVarint32:(int32_t)value;
/**
* Write a 64bit value out in varint format.
*
* @param value The value to write out.
**/
- (void)writeRawVarint64:(int64_t)value;
/**
* Write a size_t out as a 32bit varint value.
*
* @note This will truncate 64 bit values to 32.
*
* @param value The value to write out.
**/
- (void)writeRawVarintSizeTAs32:(size_t)value;
/**
* Writes the contents of an NSData out.
*
* @param data The data to write out.
**/
- (void)writeRawData:(NSData *)data;
/**
* Writes out the given data.
*
* @param data The data blob to write out.
* @param offset The offset into the blob to start writing out.
* @param length The number of bytes from the blob to write out.
**/
- (void)writeRawPtr:(const void *)data
offset:(size_t)offset
length:(size_t)length;
//%PDDM-EXPAND _WRITE_DECLS()
// This block of code is generated, do not edit it directly.
/**
* Write a double for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeDouble:(int32_t)fieldNumber value:(double)value;
/**
* Write a packed array of double for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeDoubleArray:(int32_t)fieldNumber
values:(GPBDoubleArray *)values
tag:(uint32_t)tag;
/**
* Write a double without any tag.
*
* @param value The value to write out.
**/
- (void)writeDoubleNoTag:(double)value;
/**
* Write a float for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeFloat:(int32_t)fieldNumber value:(float)value;
/**
* Write a packed array of float for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeFloatArray:(int32_t)fieldNumber
values:(GPBFloatArray *)values
tag:(uint32_t)tag;
/**
* Write a float without any tag.
*
* @param value The value to write out.
**/
- (void)writeFloatNoTag:(float)value;
/**
* Write a uint64_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
/**
* Write a packed array of uint64_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeUInt64Array:(int32_t)fieldNumber
values:(GPBUInt64Array *)values
tag:(uint32_t)tag;
/**
* Write a uint64_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeUInt64NoTag:(uint64_t)value;
/**
* Write a int64_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
/**
* Write a packed array of int64_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeInt64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
tag:(uint32_t)tag;
/**
* Write a int64_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeInt64NoTag:(int64_t)value;
/**
* Write a int32_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
/**
* Write a packed array of int32_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeInt32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
tag:(uint32_t)tag;
/**
* Write a int32_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeInt32NoTag:(int32_t)value;
/**
* Write a uint32_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
/**
* Write a packed array of uint32_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeUInt32Array:(int32_t)fieldNumber
values:(GPBUInt32Array *)values
tag:(uint32_t)tag;
/**
* Write a uint32_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeUInt32NoTag:(uint32_t)value;
/**
* Write a uint64_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
/**
* Write a packed array of uint64_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeFixed64Array:(int32_t)fieldNumber
values:(GPBUInt64Array *)values
tag:(uint32_t)tag;
/**
* Write a uint64_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeFixed64NoTag:(uint64_t)value;
/**
* Write a uint32_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
/**
* Write a packed array of uint32_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeFixed32Array:(int32_t)fieldNumber
values:(GPBUInt32Array *)values
tag:(uint32_t)tag;
/**
* Write a uint32_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeFixed32NoTag:(uint32_t)value;
/**
* Write a int32_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
/**
* Write a packed array of int32_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeSInt32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
tag:(uint32_t)tag;
/**
* Write a int32_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeSInt32NoTag:(int32_t)value;
/**
* Write a int64_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
/**
* Write a packed array of int64_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeSInt64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
tag:(uint32_t)tag;
/**
* Write a int64_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeSInt64NoTag:(int64_t)value;
/**
* Write a int64_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
/**
* Write a packed array of int64_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeSFixed64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
tag:(uint32_t)tag;
/**
* Write a int64_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeSFixed64NoTag:(int64_t)value;
/**
* Write a int32_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
/**
* Write a packed array of int32_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeSFixed32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
tag:(uint32_t)tag;
/**
* Write a int32_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeSFixed32NoTag:(int32_t)value;
/**
* Write a BOOL for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
/**
* Write a packed array of BOOL for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeBoolArray:(int32_t)fieldNumber
values:(GPBBoolArray *)values
tag:(uint32_t)tag;
/**
* Write a BOOL without any tag.
*
* @param value The value to write out.
**/
- (void)writeBoolNoTag:(BOOL)value;
/**
* Write a int32_t for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
/**
* Write a packed array of int32_t for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
* @param tag The tag assigned to the values.
**/
- (void)writeEnumArray:(int32_t)fieldNumber
values:(GPBEnumArray *)values
tag:(uint32_t)tag;
/**
* Write a int32_t without any tag.
*
* @param value The value to write out.
**/
- (void)writeEnumNoTag:(int32_t)value;
/**
* Write a NSString for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
/**
* Write an array of NSString for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
**/
- (void)writeStringArray:(int32_t)fieldNumber values:(NSArray<NSString*> *)values;
/**
* Write a NSString without any tag.
*
* @param value The value to write out.
**/
- (void)writeStringNoTag:(NSString *)value;
/**
* Write a GPBMessage for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
/**
* Write an array of GPBMessage for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
**/
- (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
/**
* Write a GPBMessage without any tag.
*
* @param value The value to write out.
**/
- (void)writeMessageNoTag:(GPBMessage *)value;
/**
* Write a NSData for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
/**
* Write an array of NSData for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
**/
- (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray<NSData*> *)values;
/**
* Write a NSData without any tag.
*
* @param value The value to write out.
**/
- (void)writeBytesNoTag:(NSData *)value;
/**
* Write a GPBMessage for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeGroup:(int32_t)fieldNumber
value:(GPBMessage *)value;
/**
* Write an array of GPBMessage for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
**/
- (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
/**
* Write a GPBMessage without any tag (but does write the endGroup tag).
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeGroupNoTag:(int32_t)fieldNumber
value:(GPBMessage *)value;
/**
* Write a GPBUnknownFieldSet for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeUnknownGroup:(int32_t)fieldNumber
value:(GPBUnknownFieldSet *)value;
/**
* Write an array of GPBUnknownFieldSet for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
**/
- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray<GPBUnknownFieldSet*> *)values;
/**
* Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
value:(GPBUnknownFieldSet *)value;
//%PDDM-EXPAND-END _WRITE_DECLS()
/**
Write a MessageSet extension field to the stream. For historical reasons,
the wire format differs from normal fields.
@param fieldNumber The extension field number to write out.
@param value The message from where to get the extension.
*/
- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
/**
Write an unparsed MessageSet extension field to the stream. For historical
reasons, the wire format differs from normal fields.
@param fieldNumber The extension field number to write out.
@param value The raw message from where to get the extension.
*/
- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
@end
NS_ASSUME_NONNULL_END
// Write methods for types that can be in packed arrays.
//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
//%/**
//% * Write a TYPE for the given field number.
//% *
//% * @param fieldNumber The field number assigned to the value.
//% * @param value The value to write out.
//% **/
//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
//%/**
//% * Write a packed array of TYPE for the given field number.
//% *
//% * @param fieldNumber The field number assigned to the values.
//% * @param values The values to write out.
//% * @param tag The tag assigned to the values.
//% **/
//%- (void)write##NAME##Array:(int32_t)fieldNumber
//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
//% NAME$S tag:(uint32_t)tag;
//%/**
//% * Write a TYPE without any tag.
//% *
//% * @param value The value to write out.
//% **/
//%- (void)write##NAME##NoTag:(TYPE)value;
//%
// Write methods for types that aren't in packed arrays.
//%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
//%/**
//% * Write a TYPE for the given field number.
//% *
//% * @param fieldNumber The field number assigned to the value.
//% * @param value The value to write out.
//% **/
//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
//%/**
//% * Write an array of TYPE for the given field number.
//% *
//% * @param fieldNumber The field number assigned to the values.
//% * @param values The values to write out.
//% **/
//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
//%/**
//% * Write a TYPE without any tag.
//% *
//% * @param value The value to write out.
//% **/
//%- (void)write##NAME##NoTag:(TYPE *)value;
//%
// Special write methods for Groups.
//%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
//%/**
//% * Write a TYPE for the given field number.
//% *
//% * @param fieldNumber The field number assigned to the value.
//% * @param value The value to write out.
//% **/
//%- (void)write##NAME:(int32_t)fieldNumber
//% NAME$S value:(TYPE *)value;
//%/**
//% * Write an array of TYPE for the given field number.
//% *
//% * @param fieldNumber The field number assigned to the values.
//% * @param values The values to write out.
//% **/
//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
//%/**
//% * Write a TYPE without any tag (but does write the endGroup tag).
//% *
//% * @param fieldNumber The field number assigned to the value.
//% * @param value The value to write out.
//% **/
//%- (void)write##NAME##NoTag:(int32_t)fieldNumber
//% NAME$S value:(TYPE *)value;
//%
// One macro to hide it all up above.
//%PDDM-DEFINE _WRITE_DECLS()
//%_WRITE_PACKABLE_DECLS(Double, Double, double)
//%_WRITE_PACKABLE_DECLS(Float, Float, float)
//%_WRITE_PACKABLE_DECLS(UInt64, UInt64, uint64_t)
//%_WRITE_PACKABLE_DECLS(Int64, Int64, int64_t)
//%_WRITE_PACKABLE_DECLS(Int32, Int32, int32_t)
//%_WRITE_PACKABLE_DECLS(UInt32, UInt32, uint32_t)
//%_WRITE_PACKABLE_DECLS(Fixed64, UInt64, uint64_t)
//%_WRITE_PACKABLE_DECLS(Fixed32, UInt32, uint32_t)
//%_WRITE_PACKABLE_DECLS(SInt32, Int32, int32_t)
//%_WRITE_PACKABLE_DECLS(SInt64, Int64, int64_t)
//%_WRITE_PACKABLE_DECLS(SFixed64, Int64, int64_t)
//%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t)
//%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL)
//%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t)
//%_WRITE_UNPACKABLE_DECLS(String, NSString)
//%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage)
//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)
//%_WRITE_GROUP_DECLS(Group, GPBMessage)
//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet)

View File

@ -0,0 +1,126 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import "GPBCodedOutputStream.h"
NS_ASSUME_NONNULL_BEGIN
CF_EXTERN_C_BEGIN
size_t GPBComputeDoubleSize(int32_t fieldNumber, double value)
__attribute__((const));
size_t GPBComputeFloatSize(int32_t fieldNumber, float value)
__attribute__((const));
size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value)
__attribute__((const));
size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value)
__attribute__((const));
size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value)
__attribute__((const));
size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value)
__attribute__((const));
size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value)
__attribute__((const));
size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value)
__attribute__((const));
size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value)
__attribute__((const));
size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value)
__attribute__((const));
size_t GPBComputeUnknownGroupSize(int32_t fieldNumber,
GPBUnknownFieldSet *value)
__attribute__((const));
size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value)
__attribute__((const));
size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value)
__attribute__((const));
size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value)
__attribute__((const));
size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value)
__attribute__((const));
size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value)
__attribute__((const));
size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value)
__attribute__((const));
size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value)
__attribute__((const));
size_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const));
size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType)
__attribute__((const));
size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const));
size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const));
size_t GPBComputeUInt64SizeNoTag(uint64_t value) __attribute__((const));
size_t GPBComputeInt64SizeNoTag(int64_t value) __attribute__((const));
size_t GPBComputeInt32SizeNoTag(int32_t value) __attribute__((const));
size_t GPBComputeFixed64SizeNoTag(uint64_t value) __attribute__((const));
size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const));
size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const));
size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const));
size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const));
size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value)
__attribute__((const));
size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const));
size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const));
size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const));
size_t GPBComputeEnumSizeNoTag(int32_t value) __attribute__((const));
size_t GPBComputeSFixed32SizeNoTag(int32_t value) __attribute__((const));
size_t GPBComputeSFixed64SizeNoTag(int64_t value) __attribute__((const));
size_t GPBComputeSInt32SizeNoTag(int32_t value) __attribute__((const));
size_t GPBComputeSInt64SizeNoTag(int64_t value) __attribute__((const));
// Note that this will calculate the size of 64 bit values truncated to 32.
size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) __attribute__((const));
size_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const));
size_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const));
// Note that this will calculate the size of 64 bit values truncated to 32.
size_t GPBComputeRawVarint32SizeForInteger(NSInteger value)
__attribute__((const));
// Compute the number of bytes that would be needed to encode a
// MessageSet extension to the stream. For historical reasons,
// the wire format differs from normal fields.
size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value)
__attribute__((const));
// Compute the number of bytes that would be needed to encode an
// unparsed MessageSet extension field to the stream. For
// historical reasons, the wire format differs from normal fields.
size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value)
__attribute__((const));
size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value)
__attribute__((const));
CF_EXTERN_C_END
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,318 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBRuntimeTypes.h"
@class GPBEnumDescriptor;
@class GPBFieldDescriptor;
@class GPBFileDescriptor;
@class GPBOneofDescriptor;
NS_ASSUME_NONNULL_BEGIN
/** Syntax used in the proto file. */
typedef NS_ENUM(uint8_t, GPBFileSyntax) {
/** Unknown syntax. */
GPBFileSyntaxUnknown = 0,
/** Proto2 syntax. */
GPBFileSyntaxProto2 = 2,
/** Proto3 syntax. */
GPBFileSyntaxProto3 = 3,
};
/** Type of proto field. */
typedef NS_ENUM(uint8_t, GPBFieldType) {
/** Optional/required field. Only valid for proto2 fields. */
GPBFieldTypeSingle,
/** Repeated field. */
GPBFieldTypeRepeated,
/** Map field. */
GPBFieldTypeMap,
};
/**
* Describes a proto message.
**/
@interface GPBDescriptor : NSObject<NSCopying>
/** Name of the message. */
@property(nonatomic, readonly, copy) NSString *name;
/** Fields declared in the message. */
@property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor*> *fields;
/** Oneofs declared in the message. */
@property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor*> *oneofs;
/** Extension range declared for the message. */
@property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges;
/** Number of extension ranges declared for the message. */
@property(nonatomic, readonly) uint32_t extensionRangesCount;
/** Descriptor for the file where the message was defined. */
@property(nonatomic, readonly) GPBFileDescriptor *file;
/** Whether the message is in wire format or not. */
@property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat;
/** The class of this message. */
@property(nonatomic, readonly) Class messageClass;
/** Containing message descriptor if this message is nested, or nil otherwise. */
@property(readonly, nullable) GPBDescriptor *containingType;
/**
* Fully qualified name for this message (package.message). Can be nil if the
* value is unable to be computed.
*/
@property(readonly, nullable) NSString *fullName;
/**
* Gets the field for the given number.
*
* @param fieldNumber The number for the field to get.
*
* @return The field descriptor for the given number, or nil if not found.
**/
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
/**
* Gets the field for the given name.
*
* @param name The name for the field to get.
*
* @return The field descriptor for the given name, or nil if not found.
**/
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
/**
* Gets the oneof for the given name.
*
* @param name The name for the oneof to get.
*
* @return The oneof descriptor for the given name, or nil if not found.
**/
- (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name;
@end
/**
* Describes a proto file.
**/
@interface GPBFileDescriptor : NSObject
/** The package declared in the proto file. */
@property(nonatomic, readonly, copy) NSString *package;
/** The objc prefix declared in the proto file. */
@property(nonatomic, readonly, copy, nullable) NSString *objcPrefix;
/** The syntax of the proto file. */
@property(nonatomic, readonly) GPBFileSyntax syntax;
@end
/**
* Describes a oneof field.
**/
@interface GPBOneofDescriptor : NSObject
/** Name of the oneof field. */
@property(nonatomic, readonly) NSString *name;
/** Fields declared in the oneof. */
@property(nonatomic, readonly) NSArray<GPBFieldDescriptor*> *fields;
/**
* Gets the field for the given number.
*
* @param fieldNumber The number for the field to get.
*
* @return The field descriptor for the given number, or nil if not found.
**/
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
/**
* Gets the field for the given name.
*
* @param name The name for the field to get.
*
* @return The field descriptor for the given name, or nil if not found.
**/
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
@end
/**
* Describes a proto field.
**/
@interface GPBFieldDescriptor : NSObject
/** Name of the field. */
@property(nonatomic, readonly, copy) NSString *name;
/** Number associated with the field. */
@property(nonatomic, readonly) uint32_t number;
/** Data type contained in the field. */
@property(nonatomic, readonly) GPBDataType dataType;
/** Whether it has a default value or not. */
@property(nonatomic, readonly) BOOL hasDefaultValue;
/** Default value for the field. */
@property(nonatomic, readonly) GPBGenericValue defaultValue;
/** Whether this field is required. Only valid for proto2 fields. */
@property(nonatomic, readonly, getter=isRequired) BOOL required;
/** Whether this field is optional. */
@property(nonatomic, readonly, getter=isOptional) BOOL optional;
/** Type of field (single, repeated, map). */
@property(nonatomic, readonly) GPBFieldType fieldType;
/** Type of the key if the field is a map. The value's type is -fieldType. */
@property(nonatomic, readonly) GPBDataType mapKeyDataType;
/** Whether the field is packable. */
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
/** The containing oneof if this field is part of one, nil otherwise. */
@property(nonatomic, readonly, nullable) GPBOneofDescriptor *containingOneof;
/** Class of the message if the field is of message type. */
@property(nonatomic, readonly, nullable) Class msgClass;
/** Descriptor for the enum if this field is an enum. */
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
/**
* Checks whether the given enum raw value is a valid enum value.
*
* @param value The raw enum value to check.
*
* @return YES if value is a valid enum raw value.
**/
- (BOOL)isValidEnumValue:(int32_t)value;
/** @return Name for the text format, or nil if not known. */
- (nullable NSString *)textFormatName;
@end
/**
* Describes a proto enum.
**/
@interface GPBEnumDescriptor : NSObject
/** Name of the enum. */
@property(nonatomic, readonly, copy) NSString *name;
/** Function that validates that raw values are valid enum values. */
@property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier;
/**
* Returns the enum value name for the given raw enum.
*
* Note that there can be more than one name corresponding to a given value
* if the allow_alias option is used.
*
* @param number The raw enum value.
*
* @return The first name that matches the enum value passed, or nil if not valid.
**/
- (nullable NSString *)enumNameForValue:(int32_t)number;
/**
* Gets the enum raw value for the given enum name.
*
* @param outValue A pointer where the value will be set.
* @param name The enum name for which to get the raw value.
*
* @return YES if a value was copied into the pointer, NO otherwise.
**/
- (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name;
/**
* Returns the text format for the given raw enum value.
*
* @param number The raw enum value.
*
* @return The first text format name which matches the enum value, or nil if not valid.
**/
- (nullable NSString *)textFormatNameForValue:(int32_t)number;
/**
* Gets the enum raw value for the given text format name.
*
* @param outValue A pointer where the value will be set.
* @param textFormatName The text format name for which to get the raw value.
*
* @return YES if a value was copied into the pointer, NO otherwise.
**/
- (BOOL)getValue:(nullable int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName;
/**
* Gets the number of defined enum names.
*
* @return Count of the number of enum names, including any aliases.
*/
@property(nonatomic, readonly) uint32_t enumNameCount;
/**
* Gets the enum name corresponding to the given index.
*
* @param index Index into the available names. The defined range is from 0
* to self.enumNameCount - 1.
*
* @returns The enum name at the given index, or nil if the index is out of range.
*/
- (nullable NSString *)getEnumNameForIndex:(uint32_t)index;
/**
* Gets the enum text format name corresponding to the given index.
*
* @param index Index into the available names. The defined range is from 0
* to self.enumNameCount - 1.
*
* @returns The text format name at the given index, or nil if the index is out of range.
*/
- (nullable NSString *)getEnumTextFormatNameForIndex:(uint32_t)index;
@end
/**
* Describes a proto extension.
**/
@interface GPBExtensionDescriptor : NSObject<NSCopying>
/** Field number under which the extension is stored. */
@property(nonatomic, readonly) uint32_t fieldNumber;
/** The containing message class, i.e. the class extended by this extension. */
@property(nonatomic, readonly) Class containingMessageClass;
/** Data type contained in the extension. */
@property(nonatomic, readonly) GPBDataType dataType;
/** Whether the extension is repeated. */
@property(nonatomic, readonly, getter=isRepeated) BOOL repeated;
/** Whether the extension is packable. */
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
/** The class of the message if the extension is of message type. */
@property(nonatomic, readonly) Class msgClass;
/** The singleton name for the extension. */
@property(nonatomic, readonly) NSString *singletonName;
/** The enum descriptor if the extension is of enum type. */
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
/** The default value for the extension. */
@property(nonatomic, readonly, nullable) id defaultValue;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,325 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This header is private to the ProtobolBuffers library and must NOT be
// included by any sources outside this library. The contents of this file are
// subject to change at any time without notice.
#import "GPBDescriptor.h"
#import "GPBWireFormat.h"
// Describes attributes of the field.
typedef NS_OPTIONS(uint16_t, GPBFieldFlags) {
GPBFieldNone = 0,
// These map to standard protobuf concepts.
GPBFieldRequired = 1 << 0,
GPBFieldRepeated = 1 << 1,
GPBFieldPacked = 1 << 2,
GPBFieldOptional = 1 << 3,
GPBFieldHasDefaultValue = 1 << 4,
// Indicates the field needs custom handling for the TextFormat name, if not
// set, the name can be derived from the ObjC name.
GPBFieldTextFormatNameCustom = 1 << 6,
// Indicates the field has an enum descriptor.
GPBFieldHasEnumDescriptor = 1 << 7,
// These are not standard protobuf concepts, they are specific to the
// Objective C runtime.
// These bits are used to mark the field as a map and what the key
// type is.
GPBFieldMapKeyMask = 0xF << 8,
GPBFieldMapKeyInt32 = 1 << 8,
GPBFieldMapKeyInt64 = 2 << 8,
GPBFieldMapKeyUInt32 = 3 << 8,
GPBFieldMapKeyUInt64 = 4 << 8,
GPBFieldMapKeySInt32 = 5 << 8,
GPBFieldMapKeySInt64 = 6 << 8,
GPBFieldMapKeyFixed32 = 7 << 8,
GPBFieldMapKeyFixed64 = 8 << 8,
GPBFieldMapKeySFixed32 = 9 << 8,
GPBFieldMapKeySFixed64 = 10 << 8,
GPBFieldMapKeyBool = 11 << 8,
GPBFieldMapKeyString = 12 << 8,
};
// NOTE: The structures defined here have their members ordered to minimize
// their size. This directly impacts the size of apps since these exist per
// field/extension.
// Describes a single field in a protobuf as it is represented as an ivar.
typedef struct GPBMessageFieldDescription {
// Name of ivar.
const char *name;
union {
const char *className; // Name for message class.
// For enums only: If EnumDescriptors are compiled in, it will be that,
// otherwise it will be the verifier.
GPBEnumDescriptorFunc enumDescFunc;
GPBEnumValidationFunc enumVerifier;
} dataTypeSpecific;
// The field number for the ivar.
uint32_t number;
// The index (in bits) into _has_storage_.
// >= 0: the bit to use for a value being set.
// = GPBNoHasBit(INT32_MAX): no storage used.
// < 0: in a oneOf, use a full int32 to record the field active.
int32_t hasIndex;
// Offset of the variable into it's structure struct.
uint32_t offset;
// Field flags. Use accessor functions below.
GPBFieldFlags flags;
// Data type of the ivar.
GPBDataType dataType;
} GPBMessageFieldDescription;
// Fields in messages defined in a 'proto2' syntax file can provide a default
// value. This struct provides the default along with the field info.
typedef struct GPBMessageFieldDescriptionWithDefault {
// Default value for the ivar.
GPBGenericValue defaultValue;
GPBMessageFieldDescription core;
} GPBMessageFieldDescriptionWithDefault;
// Describes attributes of the extension.
typedef NS_OPTIONS(uint8_t, GPBExtensionOptions) {
GPBExtensionNone = 0,
// These map to standard protobuf concepts.
GPBExtensionRepeated = 1 << 0,
GPBExtensionPacked = 1 << 1,
GPBExtensionSetWireFormat = 1 << 2,
};
// An extension
typedef struct GPBExtensionDescription {
GPBGenericValue defaultValue;
const char *singletonName;
const char *extendedClass;
const char *messageOrGroupClassName;
GPBEnumDescriptorFunc enumDescriptorFunc;
int32_t fieldNumber;
GPBDataType dataType;
GPBExtensionOptions options;
} GPBExtensionDescription;
typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
GPBDescriptorInitializationFlag_None = 0,
GPBDescriptorInitializationFlag_FieldsWithDefault = 1 << 0,
GPBDescriptorInitializationFlag_WireFormat = 1 << 1,
};
@interface GPBDescriptor () {
@package
NSArray *fields_;
NSArray *oneofs_;
uint32_t storageSize_;
}
// fieldDescriptions have to be long lived, they are held as raw pointers.
+ (instancetype)
allocDescriptorForClass:(Class)messageClass
rootClass:(Class)rootClass
file:(GPBFileDescriptor *)file
fields:(void *)fieldDescriptions
fieldCount:(uint32_t)fieldCount
storageSize:(uint32_t)storageSize
flags:(GPBDescriptorInitializationFlags)flags;
- (instancetype)initWithClass:(Class)messageClass
file:(GPBFileDescriptor *)file
fields:(NSArray *)fields
storageSize:(uint32_t)storage
wireFormat:(BOOL)wireFormat;
// Called right after init to provide extra information to avoid init having
// an explosion of args. These pointers are recorded, so they are expected
// to live for the lifetime of the app.
- (void)setupOneofs:(const char **)oneofNames
count:(uint32_t)count
firstHasIndex:(int32_t)firstHasIndex;
- (void)setupExtraTextInfo:(const char *)extraTextFormatInfo;
- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count;
- (void)setupContainingMessageClassName:(const char *)msgClassName;
- (void)setupMessageClassNameSuffix:(NSString *)suffix;
@end
@interface GPBFileDescriptor ()
- (instancetype)initWithPackage:(NSString *)package
objcPrefix:(NSString *)objcPrefix
syntax:(GPBFileSyntax)syntax;
- (instancetype)initWithPackage:(NSString *)package
syntax:(GPBFileSyntax)syntax;
@end
@interface GPBOneofDescriptor () {
@package
const char *name_;
NSArray *fields_;
SEL caseSel_;
}
// name must be long lived.
- (instancetype)initWithName:(const char *)name fields:(NSArray *)fields;
@end
@interface GPBFieldDescriptor () {
@package
GPBMessageFieldDescription *description_;
GPB_UNSAFE_UNRETAINED GPBOneofDescriptor *containingOneof_;
SEL getSel_;
SEL setSel_;
SEL hasOrCountSel_; // *Count for map<>/repeated fields, has* otherwise.
SEL setHasSel_;
}
// Single initializer
// description has to be long lived, it is held as a raw pointer.
- (instancetype)initWithFieldDescription:(void *)description
includesDefault:(BOOL)includesDefault
syntax:(GPBFileSyntax)syntax;
@end
@interface GPBEnumDescriptor ()
// valueNames, values and extraTextFormatInfo have to be long lived, they are
// held as raw pointers.
+ (instancetype)
allocDescriptorForName:(NSString *)name
valueNames:(const char *)valueNames
values:(const int32_t *)values
count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier;
+ (instancetype)
allocDescriptorForName:(NSString *)name
valueNames:(const char *)valueNames
values:(const int32_t *)values
count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier
extraTextFormatInfo:(const char *)extraTextFormatInfo;
- (instancetype)initWithName:(NSString *)name
valueNames:(const char *)valueNames
values:(const int32_t *)values
count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier;
@end
@interface GPBExtensionDescriptor () {
@package
GPBExtensionDescription *description_;
}
@property(nonatomic, readonly) GPBWireFormat wireType;
// For repeated extensions, alternateWireType is the wireType with the opposite
// value for the packable property. i.e. - if the extension was marked packed
// it would be the wire type for unpacked; if the extension was marked unpacked,
// it would be the wire type for packed.
@property(nonatomic, readonly) GPBWireFormat alternateWireType;
// description has to be long lived, it is held as a raw pointer.
- (instancetype)initWithExtensionDescription:
(GPBExtensionDescription *)description;
- (NSComparisonResult)compareByFieldNumber:(GPBExtensionDescriptor *)other;
@end
CF_EXTERN_C_BEGIN
// Direct access is use for speed, to avoid even internally declaring things
// read/write, etc. The warning is enabled in the project to ensure code calling
// protos can turn on -Wdirect-ivar-access without issues.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
GPB_INLINE BOOL GPBFieldIsMapOrArray(GPBFieldDescriptor *field) {
return (field->description_->flags &
(GPBFieldRepeated | GPBFieldMapKeyMask)) != 0;
}
GPB_INLINE GPBDataType GPBGetFieldDataType(GPBFieldDescriptor *field) {
return field->description_->dataType;
}
GPB_INLINE int32_t GPBFieldHasIndex(GPBFieldDescriptor *field) {
return field->description_->hasIndex;
}
GPB_INLINE uint32_t GPBFieldNumber(GPBFieldDescriptor *field) {
return field->description_->number;
}
#pragma clang diagnostic pop
uint32_t GPBFieldTag(GPBFieldDescriptor *self);
// For repeated fields, alternateWireType is the wireType with the opposite
// value for the packable property. i.e. - if the field was marked packed it
// would be the wire type for unpacked; if the field was marked unpacked, it
// would be the wire type for packed.
uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self);
GPB_INLINE BOOL GPBHasPreservingUnknownEnumSemantics(GPBFileSyntax syntax) {
return syntax == GPBFileSyntaxProto3;
}
GPB_INLINE BOOL GPBExtensionIsRepeated(GPBExtensionDescription *description) {
return (description->options & GPBExtensionRepeated) != 0;
}
GPB_INLINE BOOL GPBExtensionIsPacked(GPBExtensionDescription *description) {
return (description->options & GPBExtensionPacked) != 0;
}
GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) {
return (description->options & GPBExtensionSetWireFormat) != 0;
}
// Helper for compile time assets.
#ifndef GPBInternalCompileAssert
#if __has_feature(c_static_assert) || __has_extension(c_static_assert)
#define GPBInternalCompileAssert(test, msg) _Static_assert((test), #msg)
#else
// Pre-Xcode 7 support.
#define GPBInternalCompileAssertSymbolInner(line, msg) GPBInternalCompileAssert ## line ## __ ## msg
#define GPBInternalCompileAssertSymbol(line, msg) GPBInternalCompileAssertSymbolInner(line, msg)
#define GPBInternalCompileAssert(test, msg) \
typedef char GPBInternalCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
#endif // __has_feature(c_static_assert) || __has_extension(c_static_assert)
#endif // GPBInternalCompileAssert
// Sanity check that there isn't padding between the field description
// structures with and without a default.
GPBInternalCompileAssert(sizeof(GPBMessageFieldDescriptionWithDefault) ==
(sizeof(GPBGenericValue) +
sizeof(GPBMessageFieldDescription)),
DescriptionsWithDefault_different_size_than_expected);
CF_EXTERN_C_END

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,488 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBDictionary.h"
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@class GPBExtensionRegistry;
@class GPBFieldDescriptor;
@protocol GPBDictionaryInternalsProtocol
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field;
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream
asField:(GPBFieldDescriptor *)field;
- (void)setGPBGenericValue:(GPBGenericValue *)value
forGPBGenericValueKey:(GPBGenericValue *)key;
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block;
@end
//%PDDM-DEFINE DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(KEY_NAME)
//%DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(KEY_NAME)
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Object, Object)
//%PDDM-DEFINE DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(KEY_NAME)
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, UInt32, Basic)
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Int32, Basic)
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, UInt64, Basic)
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Int64, Basic)
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Bool, Basic)
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Float, Basic)
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Double, Basic)
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Enum, Enum)
//%PDDM-DEFINE DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, VALUE_NAME, HELPER)
//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary () <GPBDictionaryInternalsProtocol> {
//% @package
//% GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
//%}
//%EXTRA_DICTIONARY_PRIVATE_INTERFACES_##HELPER()@end
//%
//%PDDM-DEFINE EXTRA_DICTIONARY_PRIVATE_INTERFACES_Basic()
// Empty
//%PDDM-DEFINE EXTRA_DICTIONARY_PRIVATE_INTERFACES_Object()
//%- (BOOL)isInitialized;
//%- (instancetype)deepCopyWithZone:(NSZone *)zone
//% __attribute__((ns_returns_retained));
//%
//%PDDM-DEFINE EXTRA_DICTIONARY_PRIVATE_INTERFACES_Enum()
//%- (NSData *)serializedDataForUnknownValue:(int32_t)value
//% forKey:(GPBGenericValue *)key
//% keyDataType:(GPBDataType)keyDataType;
//%
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(UInt32)
// This block of code is generated, do not edit it directly.
@interface GPBUInt32UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt32Int32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt32UInt64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt32Int64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt32BoolDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt32FloatDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt32DoubleDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt32EnumDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
forKey:(GPBGenericValue *)key
keyDataType:(GPBDataType)keyDataType;
@end
@interface GPBUInt32ObjectDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (BOOL)isInitialized;
- (instancetype)deepCopyWithZone:(NSZone *)zone
__attribute__((ns_returns_retained));
@end
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Int32)
// This block of code is generated, do not edit it directly.
@interface GPBInt32UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt32Int32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt32UInt64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt32Int64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt32BoolDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt32FloatDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt32DoubleDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt32EnumDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
forKey:(GPBGenericValue *)key
keyDataType:(GPBDataType)keyDataType;
@end
@interface GPBInt32ObjectDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (BOOL)isInitialized;
- (instancetype)deepCopyWithZone:(NSZone *)zone
__attribute__((ns_returns_retained));
@end
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(UInt64)
// This block of code is generated, do not edit it directly.
@interface GPBUInt64UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt64Int32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt64UInt64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt64Int64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt64BoolDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt64FloatDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt64DoubleDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBUInt64EnumDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
forKey:(GPBGenericValue *)key
keyDataType:(GPBDataType)keyDataType;
@end
@interface GPBUInt64ObjectDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (BOOL)isInitialized;
- (instancetype)deepCopyWithZone:(NSZone *)zone
__attribute__((ns_returns_retained));
@end
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Int64)
// This block of code is generated, do not edit it directly.
@interface GPBInt64UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt64Int32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt64UInt64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt64Int64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt64BoolDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt64FloatDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt64DoubleDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBInt64EnumDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
forKey:(GPBGenericValue *)key
keyDataType:(GPBDataType)keyDataType;
@end
@interface GPBInt64ObjectDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (BOOL)isInitialized;
- (instancetype)deepCopyWithZone:(NSZone *)zone
__attribute__((ns_returns_retained));
@end
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Bool)
// This block of code is generated, do not edit it directly.
@interface GPBBoolUInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBBoolInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBBoolUInt64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBBoolInt64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBBoolBoolDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBBoolFloatDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBBoolDoubleDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBBoolEnumDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
forKey:(GPBGenericValue *)key
keyDataType:(GPBDataType)keyDataType;
@end
@interface GPBBoolObjectDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (BOOL)isInitialized;
- (instancetype)deepCopyWithZone:(NSZone *)zone
__attribute__((ns_returns_retained));
@end
//%PDDM-EXPAND DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(String)
// This block of code is generated, do not edit it directly.
@interface GPBStringUInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBStringInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBStringUInt64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBStringInt64Dictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBStringBoolDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBStringFloatDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBStringDoubleDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@interface GPBStringEnumDictionary () <GPBDictionaryInternalsProtocol> {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
forKey:(GPBGenericValue *)key
keyDataType:(GPBDataType)keyDataType;
@end
//%PDDM-EXPAND-END (6 expansions)
#pragma mark - NSDictionary Subclass
@interface GPBAutocreatedDictionary : NSMutableDictionary {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Helpers
CF_EXTERN_C_BEGIN
// Helper to compute size when an NSDictionary is used for the map instead
// of a custom type.
size_t GPBDictionaryComputeSizeInternalHelper(NSDictionary *dict,
GPBFieldDescriptor *field);
// Helper to write out when an NSDictionary is used for the map instead
// of a custom type.
void GPBDictionaryWriteToStreamInternalHelper(
GPBCodedOutputStream *outputStream, NSDictionary *dict,
GPBFieldDescriptor *field);
// Helper to check message initialization when an NSDictionary is used for
// the map instead of a custom type.
BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict,
GPBFieldDescriptor *field);
// Helper to read a map instead.
void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream,
GPBExtensionRegistry *registry,
GPBFieldDescriptor *field,
GPBMessage *parentMessage);
CF_EXTERN_C_END

View File

@ -0,0 +1,50 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBDescriptor.h"
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@class GPBExtensionRegistry;
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension,
BOOL isPackedOnStream,
GPBCodedInputStream *input,
GPBExtensionRegistry *extensionRegistry,
GPBMessage *message);
size_t GPBComputeExtensionSerializedSizeIncludingTag(
GPBExtensionDescriptor *extension, id value);
void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension,
id value,
GPBCodedOutputStream *output);

View File

@ -0,0 +1,87 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
@class GPBDescriptor;
@class GPBExtensionDescriptor;
NS_ASSUME_NONNULL_BEGIN
/**
* A table of known extensions, searchable by name or field number. When
* parsing a protocol message that might have extensions, you must provide a
* GPBExtensionRegistry in which you have registered any extensions that you
* want to be able to parse. Otherwise, those extensions will just be treated
* like unknown fields.
*
* The *Root classes provide `+extensionRegistry` for the extensions defined
* in a given file *and* all files it imports. You can also create a
* GPBExtensionRegistry, and merge those registries to handle parsing
* extensions defined from non overlapping files.
*
* ```
* GPBExtensionRegistry *registry = [[MyProtoFileRoot extensionRegistry] copy];
* [registry addExtension:[OtherMessage neededExtension]]; // Not in MyProtoFile
* NSError *parseError;
* MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError];
* ```
**/
@interface GPBExtensionRegistry : NSObject<NSCopying>
/**
* Adds the given GPBExtensionDescriptor to this registry.
*
* @param extension The extension description to add.
**/
- (void)addExtension:(GPBExtensionDescriptor *)extension;
/**
* Adds all the extensions from another registry to this registry.
*
* @param registry The registry to merge into this registry.
**/
- (void)addExtensions:(GPBExtensionRegistry *)registry;
/**
* Looks for the extension registered for the given field number on a given
* GPBDescriptor.
*
* @param descriptor The descriptor to look for a registered extension on.
* @param fieldNumber The field number of the extension to look for.
*
* @return The registered GPBExtensionDescriptor or nil if none was found.
**/
- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
fieldNumber:(NSInteger)fieldNumber;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,470 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBBootstrap.h"
@class GPBDescriptor;
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@class GPBExtensionDescriptor;
@class GPBExtensionRegistry;
@class GPBFieldDescriptor;
@class GPBUnknownFieldSet;
NS_ASSUME_NONNULL_BEGIN
CF_EXTERN_C_BEGIN
/** NSError domain used for errors. */
extern NSString *const GPBMessageErrorDomain;
/** Error codes for NSErrors originated in GPBMessage. */
typedef NS_ENUM(NSInteger, GPBMessageErrorCode) {
/** Uncategorized error. */
GPBMessageErrorCodeOther = -100,
/** Message couldn't be serialized because it is missing required fields. */
GPBMessageErrorCodeMissingRequiredField = -101,
};
/**
* Key under which the GPBMessage error's reason is stored inside the userInfo
* dictionary.
**/
extern NSString *const GPBErrorReasonKey;
CF_EXTERN_C_END
/**
* Base class that each generated message subclasses from.
*
* @note @c NSCopying support is a "deep copy", in that all sub objects are
* copied. Just like you wouldn't want a UIView/NSView trying to
* exist in two places, you don't want a sub message to be a property
* property of two other messages.
*
* @note While the class support NSSecureCoding, if the message has any
* extensions, they will end up reloaded in @c unknownFields as there is
* no way for the @c NSCoding plumbing to pass through a
* @c GPBExtensionRegistry. To support extensions, instead of passing the
* calls off to the Message, simple store the result of @c data, and then
* when loading, fetch the data and use
* @c +parseFromData:extensionRegistry:error: to provide an extension
* registry.
**/
@interface GPBMessage : NSObject<NSSecureCoding, NSCopying>
// If you add an instance method/property to this class that may conflict with
// fields declared in protos, you need to update objective_helpers.cc. The main
// cases are methods that take no arguments, or setFoo:/hasFoo: type methods.
/**
* The set of unknown fields for this message.
*
* Only messages from proto files declared with "proto2" syntax support unknown
* fields. For "proto3" syntax, any unknown fields found while parsing are
* dropped.
**/
@property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields;
/**
* Whether the message, along with all submessages, have the required fields
* set. This is only applicable for files declared with "proto2" syntax, as
* there are no required fields for "proto3" syntax.
**/
@property(nonatomic, readonly, getter=isInitialized) BOOL initialized;
/**
* @return An autoreleased message with the default values set.
**/
+ (instancetype)message;
/**
* Creates a new instance by parsing the provided data. This method should be
* sent to the generated message class that the data should be interpreted as.
* If there is an error the method returns nil and the error is returned in
* errorPtr (when provided).
*
* @note In DEBUG builds, the parsed message is checked to be sure all required
* fields were provided, and the parse will fail if some are missing.
*
* @note The errors returned are likely coming from the domain and codes listed
* at the top of this file and GPBCodedInputStream.h.
*
* @param data The data to parse.
* @param errorPtr An optional error pointer to fill in with a failure reason if
* the data can not be parsed.
*
* @return A new instance of the generated class.
**/
+ (nullable instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr;
/**
* Creates a new instance by parsing the data. This method should be sent to
* the generated message class that the data should be interpreted as. If
* there is an error the method returns nil and the error is returned in
* errorPtr (when provided).
*
* @note In DEBUG builds, the parsed message is checked to be sure all required
* fields were provided, and the parse will fail if some are missing.
*
* @note The errors returned are likely coming from the domain and codes listed
* at the top of this file and GPBCodedInputStream.h.
*
* @param data The data to parse.
* @param extensionRegistry The extension registry to use to look up extensions.
* @param errorPtr An optional error pointer to fill in with a failure
* reason if the data can not be parsed.
*
* @return A new instance of the generated class.
**/
+ (nullable instancetype)parseFromData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
* Creates a new instance by parsing the data from the given input stream. This
* method should be sent to the generated message class that the data should
* be interpreted as. If there is an error the method returns nil and the error
* is returned in errorPtr (when provided).
*
* @note In DEBUG builds, the parsed message is checked to be sure all required
* fields were provided, and the parse will fail if some are missing.
*
* @note The errors returned are likely coming from the domain and codes listed
* at the top of this file and GPBCodedInputStream.h.
*
* @param input The stream to read data from.
* @param extensionRegistry The extension registry to use to look up extensions.
* @param errorPtr An optional error pointer to fill in with a failure
* reason if the data can not be parsed.
*
* @return A new instance of the generated class.
**/
+ (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
* Creates a new instance by parsing the data from the given input stream. This
* method should be sent to the generated message class that the data should
* be interpreted as. If there is an error the method returns nil and the error
* is returned in errorPtr (when provided).
*
* @note Unlike the parseFrom... methods, this never checks to see if all of
* the required fields are set. So this method can be used to reload
* messages that may not be complete.
*
* @note The errors returned are likely coming from the domain and codes listed
* at the top of this file and GPBCodedInputStream.h.
*
* @param input The stream to read data from.
* @param extensionRegistry The extension registry to use to look up extensions.
* @param errorPtr An optional error pointer to fill in with a failure
* reason if the data can not be parsed.
*
* @return A new instance of the generated class.
**/
+ (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
* Initializes an instance by parsing the data. This method should be sent to
* the generated message class that the data should be interpreted as. If
* there is an error the method returns nil and the error is returned in
* errorPtr (when provided).
*
* @note In DEBUG builds, the parsed message is checked to be sure all required
* fields were provided, and the parse will fail if some are missing.
*
* @note The errors returned are likely coming from the domain and codes listed
* at the top of this file and GPBCodedInputStream.h.
*
* @param data The data to parse.
* @param errorPtr An optional error pointer to fill in with a failure reason if
* the data can not be parsed.
*
* @return An initialized instance of the generated class.
**/
- (nullable instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr;
/**
* Initializes an instance by parsing the data. This method should be sent to
* the generated message class that the data should be interpreted as. If
* there is an error the method returns nil and the error is returned in
* errorPtr (when provided).
*
* @note In DEBUG builds, the parsed message is checked to be sure all required
* fields were provided, and the parse will fail if some are missing.
*
* @note The errors returned are likely coming from the domain and codes listed
* at the top of this file and GPBCodedInputStream.h.
*
* @param data The data to parse.
* @param extensionRegistry The extension registry to use to look up extensions.
* @param errorPtr An optional error pointer to fill in with a failure
* reason if the data can not be parsed.
*
* @return An initialized instance of the generated class.
**/
- (nullable instancetype)initWithData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
* Initializes an instance by parsing the data from the given input stream. This
* method should be sent to the generated message class that the data should
* be interpreted as. If there is an error the method returns nil and the error
* is returned in errorPtr (when provided).
*
* @note Unlike the parseFrom... methods, this never checks to see if all of
* the required fields are set. So this method can be used to reload
* messages that may not be complete.
*
* @note The errors returned are likely coming from the domain and codes listed
* at the top of this file and GPBCodedInputStream.h.
*
* @param input The stream to read data from.
* @param extensionRegistry The extension registry to use to look up extensions.
* @param errorPtr An optional error pointer to fill in with a failure
* reason if the data can not be parsed.
*
* @return An initialized instance of the generated class.
**/
- (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
* Parses the given data as this message's class, and merges those values into
* this message.
*
* @param data The binary representation of the message to merge.
* @param extensionRegistry The extension registry to use to look up extensions.
*
* @exception GPBCodedInputStreamException Exception thrown when parsing was
* unsuccessful.
**/
- (void)mergeFromData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
/**
* Merges the fields from another message (of the same type) into this
* message.
*
* @param other Message to merge into this message.
**/
- (void)mergeFrom:(GPBMessage *)other;
/**
* Writes out the message to the given coded output stream.
*
* @param output The coded output stream into which to write the message.
*
* @note This can raise the GPBCodedOutputStreamException_* exceptions.
*
**/
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output;
/**
* Writes out the message to the given output stream.
*
* @param output The output stream into which to write the message.
*
* @note This can raise the GPBCodedOutputStreamException_* exceptions.
**/
- (void)writeToOutputStream:(NSOutputStream *)output;
/**
* Writes out a varint for the message size followed by the message to
* the given output stream.
*
* @param output The coded output stream into which to write the message.
*
* @note This can raise the GPBCodedOutputStreamException_* exceptions.
**/
- (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output;
/**
* Writes out a varint for the message size followed by the message to
* the given output stream.
*
* @param output The output stream into which to write the message.
*
* @note This can raise the GPBCodedOutputStreamException_* exceptions.
**/
- (void)writeDelimitedToOutputStream:(NSOutputStream *)output;
/**
* Serializes the message to an NSData.
*
* If there is an error while generating the data, nil is returned.
*
* @note This value is not cached, so if you are using it repeatedly, cache
* it yourself.
*
* @note In DEBUG ONLY, the message is also checked for all required field,
* if one is missing, nil will be returned.
*
* @return The binary representation of the message.
**/
- (nullable NSData *)data;
/**
* Serializes a varint with the message size followed by the message data,
* returning that as an NSData.
*
* @note This value is not cached, so if you are using it repeatedly, it is
* recommended to keep a local copy.
*
* @return The binary representation of the size along with the message.
**/
- (NSData *)delimitedData;
/**
* Calculates the size of the object if it were serialized.
*
* This is not a cached value. If you are following a pattern like this:
*
* ```
* size_t size = [aMsg serializedSize];
* NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
* [foo writeSize:size];
* [foo appendData:[aMsg data]];
* ```
*
* you would be better doing:
*
* ```
* NSData *data = [aMsg data];
* NSUInteger size = [aMsg length];
* NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
* [foo writeSize:size];
* [foo appendData:data];
* ```
*
* @return The size of the message in it's binary representation.
**/
- (size_t)serializedSize;
/**
* @return The descriptor for the message class.
**/
+ (GPBDescriptor *)descriptor;
/**
* Return the descriptor for the message.
**/
- (GPBDescriptor *)descriptor;
/**
* @return An array with the extension descriptors that are currently set on the
* message.
**/
- (NSArray *)extensionsCurrentlySet;
/**
* Checks whether there is an extension set on the message which matches the
* given extension descriptor.
*
* @param extension Extension descriptor to check if it's set on the message.
*
* @return Whether the extension is currently set on the message.
**/
- (BOOL)hasExtension:(GPBExtensionDescriptor *)extension;
/*
* Fetches the given extension's value for this message.
*
* Extensions use boxed values (NSNumbers) for PODs and NSMutableArrays for
* repeated fields. If the extension is a Message one will be auto created for
* you and returned similar to fields.
*
* @param extension The extension descriptor of the extension to fetch.
*
* @return The extension matching the given descriptor, or nil if none found.
**/
- (nullable id)getExtension:(GPBExtensionDescriptor *)extension;
/**
* Sets the given extension's value for this message. This only applies for
* single field extensions (i.e. - not repeated fields).
*
* Extensions use boxed values (NSNumbers).
*
* @param extension The extension descriptor under which to set the value.
* @param value The value to be set as the extension.
**/
- (void)setExtension:(GPBExtensionDescriptor *)extension
value:(nullable id)value;
/**
* Adds the given value to the extension for this message. This only applies
* to repeated field extensions. If the field is a repeated POD type, the value
* should be an NSNumber.
*
* @param extension The extension descriptor under which to add the value.
* @param value The value to be added to the repeated extension.
**/
- (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value;
/**
* Replaces the value at the given index with the given value for the extension
* on this message. This only applies to repeated field extensions. If the field
* is a repeated POD type, the value is should be an NSNumber.
*
* @param extension The extension descriptor under which to replace the value.
* @param index The index of the extension to be replaced.
* @param value The value to be replaced in the repeated extension.
**/
- (void)setExtension:(GPBExtensionDescriptor *)extension
index:(NSUInteger)index
value:(id)value;
/**
* Clears the given extension for this message.
*
* @param extension The extension descriptor to be cleared from this message.
**/
- (void)clearExtension:(GPBExtensionDescriptor *)extension;
/**
* Resets all of the fields of this message to their default values.
**/
- (void)clear;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,124 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This header is private to the ProtobolBuffers library and must NOT be
// included by any sources outside this library. The contents of this file are
// subject to change at any time without notice.
#import "GPBMessage.h"
// TODO: Remove this import. Older generated code use the OSAtomic* apis,
// so anyone that hasn't regenerated says building by having this. After
// enough time has passed, this likely can be removed as folks should have
// regenerated.
#import <libkern/OSAtomic.h>
#import "GPBBootstrap.h"
typedef struct GPBMessage_Storage {
uint32_t _has_storage_[0];
} GPBMessage_Storage;
typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
@interface GPBMessage () {
@package
// NOTE: Because of the +allocWithZone code using NSAllocateObject(),
// this structure should ideally always be kept pointer aligned where the
// real storage starts is also pointer aligned. The compiler/runtime already
// do this, but it may not be documented.
// A pointer to the actual fields of the subclasses. The actual structure
// pointed to by this pointer will depend on the subclass.
// All of the actual structures will start the same as
// GPBMessage_Storage with _has_storage__ as the first field.
// Kept public because static functions need to access it.
GPBMessage_StoragePtr messageStorage_;
}
// Gets an extension value without autocreating the result if not found. (i.e.
// returns nil if the extension is not set)
- (id)getExistingExtension:(GPBExtensionDescriptor *)extension;
// Parses a message of this type from the input and merges it with this
// message.
//
// Warning: This does not verify that all required fields are present in
// the input message.
// Note: The caller should call
// -[CodedInputStream checkLastTagWas:] after calling this to
// verify that the last tag seen was the appropriate end-group tag,
// or zero for EOF.
// NOTE: This will throw if there is an error while parsing.
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry;
// Parses the next delimited message of this type from the input and merges it
// with this message.
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(GPBExtensionRegistry *)extensionRegistry;
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
@end
CF_EXTERN_C_BEGIN
// Call this before using the readOnlySemaphore_. This ensures it is created only once.
void GPBPrepareReadOnlySemaphore(GPBMessage *self);
// Returns a new instance that was automatically created by |autocreator| for
// its field |field|.
GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass,
GPBMessage *autocreator,
GPBFieldDescriptor *field)
__attribute__((ns_returns_retained));
// Returns whether |message| autocreated this message. This is NO if the message
// was not autocreated by |message| or if it has been mutated since
// autocreation.
BOOL GPBWasMessageAutocreatedBy(GPBMessage *message, GPBMessage *parent);
// Call this when you mutate a message. It will cause the message to become
// visible to its autocreator.
void GPBBecomeVisibleToAutocreator(GPBMessage *self);
// Call this when an array/dictionary is mutated so the parent message that
// autocreated it can react.
void GPBAutocreatedArrayModified(GPBMessage *self, id array);
void GPBAutocreatedDictionaryModified(GPBMessage *self, id dictionary);
// Clear the autocreator, if any. Asserts if the autocreator still has an
// autocreated reference to this message.
void GPBClearMessageAutocreator(GPBMessage *self);
CF_EXTERN_C_END

View File

@ -0,0 +1,76 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import "GPBBootstrap.h"
#import "GPBArray.h"
#import "GPBCodedInputStream.h"
#import "GPBCodedOutputStream.h"
#import "GPBDescriptor.h"
#import "GPBDictionary.h"
#import "GPBExtensionRegistry.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#import "GPBUnknownField.h"
#import "GPBUnknownFieldSet.h"
#import "GPBUtilities.h"
#import "GPBWellKnownTypes.h"
#import "GPBWireFormat.h"
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
// Well-known proto types
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/Any.pbobjc.h>
#import <protobuf/Api.pbobjc.h>
#import <protobuf/Duration.pbobjc.h>
#import <protobuf/Empty.pbobjc.h>
#import <protobuf/FieldMask.pbobjc.h>
#import <protobuf/SourceContext.pbobjc.h>
#import <protobuf/Struct.pbobjc.h>
#import <protobuf/Timestamp.pbobjc.h>
#import <protobuf/Type.pbobjc.h>
#import <protobuf/Wrappers.pbobjc.h>
#else
#import "google/protobuf/Any.pbobjc.h"
#import "google/protobuf/Api.pbobjc.h"
#import "google/protobuf/Duration.pbobjc.h"
#import "google/protobuf/Empty.pbobjc.h"
#import "google/protobuf/FieldMask.pbobjc.h"
#import "google/protobuf/SourceContext.pbobjc.h"
#import "google/protobuf/Struct.pbobjc.h"
#import "google/protobuf/Timestamp.pbobjc.h"
#import "google/protobuf/Type.pbobjc.h"
#import "google/protobuf/Wrappers.pbobjc.h"
#endif

View File

@ -0,0 +1,40 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This header is meant to only be used by the generated source, it should not
// be included in code using protocol buffers.
#import "GPBBootstrap.h"
#import "GPBDescriptor_PackagePrivate.h"
#import "GPBExtensionInternals.h"
#import "GPBMessage_PackagePrivate.h"
#import "GPBRootObject_PackagePrivate.h"
#import "GPBUtilities_PackagePrivate.h"

View File

@ -0,0 +1,52 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
@class GPBExtensionRegistry;
NS_ASSUME_NONNULL_BEGIN
/**
* Every generated proto file defines a local "Root" class that exposes a
* GPBExtensionRegistry for all the extensions defined by that file and
* the files it depends on.
**/
@interface GPBRootObject : NSObject
/**
* @return An extension registry for the given file and all the files it depends
* on.
**/
+ (GPBExtensionRegistry *)extensionRegistry;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,46 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBRootObject.h"
@class GPBExtensionDescriptor;
@interface GPBRootObject ()
// Globally register.
+ (void)globallyRegisterExtension:(GPBExtensionDescriptor *)field;
@end
// Returns YES if the selector was resolved and added to the class,
// NO otherwise.
BOOL GPBResolveExtensionClassMethod(Class self, SEL sel);

View File

@ -0,0 +1,144 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBBootstrap.h"
@class GPBEnumDescriptor;
@class GPBMessage;
@class GPBInt32Array;
/**
* Verifies that a given value can be represented by an enum type.
* */
typedef BOOL (*GPBEnumValidationFunc)(int32_t);
/**
* Fetches an EnumDescriptor.
* */
typedef GPBEnumDescriptor *(*GPBEnumDescriptorFunc)(void);
/**
* Magic value used at runtime to indicate an enum value that wasn't know at
* compile time.
* */
enum {
kGPBUnrecognizedEnumeratorValue = (int32_t)0xFBADBEEF,
};
/**
* A union for storing all possible Protobuf values. Note that owner is
* responsible for memory management of object types.
* */
typedef union {
BOOL valueBool;
int32_t valueInt32;
int64_t valueInt64;
uint32_t valueUInt32;
uint64_t valueUInt64;
float valueFloat;
double valueDouble;
GPB_UNSAFE_UNRETAINED NSData *valueData;
GPB_UNSAFE_UNRETAINED NSString *valueString;
GPB_UNSAFE_UNRETAINED GPBMessage *valueMessage;
int32_t valueEnum;
} GPBGenericValue;
/**
* Enum listing the possible data types that a field can contain.
*
* @note Do not change the order of this enum (or add things to it) without
* thinking about it very carefully. There are several things that depend
* on the order.
* */
typedef NS_ENUM(uint8_t, GPBDataType) {
/** Field contains boolean value(s). */
GPBDataTypeBool = 0,
/** Field contains unsigned 4 byte value(s). */
GPBDataTypeFixed32,
/** Field contains signed 4 byte value(s). */
GPBDataTypeSFixed32,
/** Field contains float value(s). */
GPBDataTypeFloat,
/** Field contains unsigned 8 byte value(s). */
GPBDataTypeFixed64,
/** Field contains signed 8 byte value(s). */
GPBDataTypeSFixed64,
/** Field contains double value(s). */
GPBDataTypeDouble,
/**
* Field contains variable length value(s). Inefficient for encoding negative
* numbers if your field is likely to have negative values, use
* GPBDataTypeSInt32 instead.
**/
GPBDataTypeInt32,
/**
* Field contains variable length value(s). Inefficient for encoding negative
* numbers if your field is likely to have negative values, use
* GPBDataTypeSInt64 instead.
**/
GPBDataTypeInt64,
/** Field contains signed variable length integer value(s). */
GPBDataTypeSInt32,
/** Field contains signed variable length integer value(s). */
GPBDataTypeSInt64,
/** Field contains unsigned variable length integer value(s). */
GPBDataTypeUInt32,
/** Field contains unsigned variable length integer value(s). */
GPBDataTypeUInt64,
/** Field contains an arbitrary sequence of bytes. */
GPBDataTypeBytes,
/** Field contains UTF-8 encoded or 7-bit ASCII text. */
GPBDataTypeString,
/** Field contains message type(s). */
GPBDataTypeMessage,
/** Field contains message type(s). */
GPBDataTypeGroup,
/** Field contains enum value(s). */
GPBDataTypeEnum,
};
enum {
/**
* A count of the number of types in GPBDataType. Separated out from the
* GPBDataType enum to avoid warnings regarding not handling GPBDataType_Count
* in switch statements.
**/
GPBDataType_Count = GPBDataTypeEnum + 1
};
/** An extension range. */
typedef struct GPBExtensionRange {
/** Inclusive. */
uint32_t start;
/** Exclusive. */
uint32_t end;
} GPBExtensionRange;

View File

@ -0,0 +1,99 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
@class GPBCodedOutputStream;
@class GPBUInt32Array;
@class GPBUInt64Array;
@class GPBUnknownFieldSet;
NS_ASSUME_NONNULL_BEGIN
/**
* Store an unknown field. These are used in conjunction with
* GPBUnknownFieldSet.
**/
@interface GPBUnknownField : NSObject<NSCopying>
/** Initialize a field with the given number. */
- (instancetype)initWithNumber:(int32_t)number;
/** The field number the data is stored under. */
@property(nonatomic, readonly, assign) int32_t number;
/** An array of varint values for this field. */
@property(nonatomic, readonly, strong) GPBUInt64Array *varintList;
/** An array of fixed32 values for this field. */
@property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List;
/** An array of fixed64 values for this field. */
@property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List;
/** An array of data values for this field. */
@property(nonatomic, readonly, strong) NSArray<NSData*> *lengthDelimitedList;
/** An array of groups of values for this field. */
@property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet*> *groupList;
/**
* Add a value to the varintList.
*
* @param value The value to add.
**/
- (void)addVarint:(uint64_t)value;
/**
* Add a value to the fixed32List.
*
* @param value The value to add.
**/
- (void)addFixed32:(uint32_t)value;
/**
* Add a value to the fixed64List.
*
* @param value The value to add.
**/
- (void)addFixed64:(uint64_t)value;
/**
* Add a value to the lengthDelimitedList.
*
* @param value The value to add.
**/
- (void)addLengthDelimited:(NSData *)value;
/**
* Add a value to the groupList.
*
* @param value The value to add.
**/
- (void)addGroup:(GPBUnknownFieldSet *)value;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,82 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
@class GPBUnknownField;
NS_ASSUME_NONNULL_BEGIN
/**
* A collection of unknown fields. Fields parsed from the binary representation
* of a message that are unknown end up in an instance of this set. This only
* applies for files declared with the "proto2" syntax. Files declared with the
* "proto3" syntax discard the unknown values.
**/
@interface GPBUnknownFieldSet : NSObject<NSCopying>
/**
* Tests to see if the given field number has a value.
*
* @param number The field number to check.
*
* @return YES if there is an unknown field for the given field number.
**/
- (BOOL)hasField:(int32_t)number;
/**
* Fetches the GPBUnknownField for the given field number.
*
* @param number The field number to look up.
*
* @return The GPBUnknownField or nil if none found.
**/
- (nullable GPBUnknownField *)getField:(int32_t)number;
/**
* @return The number of fields in this set.
**/
- (NSUInteger)countOfFields;
/**
* Adds the given field to the set.
*
* @param field The field to add to the set.
**/
- (void)addField:(GPBUnknownField *)field;
/**
* @return An array of the GPBUnknownFields sorted by the field numbers.
**/
- (NSArray<GPBUnknownField *> *)sortedFields;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,61 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBUnknownFieldSet.h"
@class GPBCodedOutputStream;
@class GPBCodedInputStream;
@interface GPBUnknownFieldSet ()
+ (BOOL)isFieldTag:(int32_t)tag;
- (NSData *)data;
- (size_t)serializedSize;
- (size_t)serializedSizeAsMessageSet;
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output;
- (void)writeAsMessageSetTo:(GPBCodedOutputStream *)output;
- (void)mergeUnknownFields:(GPBUnknownFieldSet *)other;
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input;
- (void)mergeFromData:(NSData *)data;
- (void)mergeVarintField:(int32_t)number value:(int32_t)value;
- (BOOL)mergeFieldFrom:(int32_t)tag input:(GPBCodedInputStream *)input;
- (void)mergeMessageSetMessage:(int32_t)number data:(NSData *)messageData;
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
@end

View File

@ -0,0 +1,47 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBUnknownField.h"
@class GPBCodedOutputStream;
@interface GPBUnknownField ()
- (void)writeToOutput:(GPBCodedOutputStream *)output;
- (size_t)serializedSize;
- (void)writeAsMessageSetExtensionToOutput:(GPBCodedOutputStream *)output;
- (size_t)serializedSizeAsMessageSetExtension;
- (void)mergeFromField:(GPBUnknownField *)other;
@end

View File

@ -0,0 +1,539 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBArray.h"
#import "GPBMessage.h"
#import "GPBRuntimeTypes.h"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
/**
* Generates a string that should be a valid "TextFormat" for the C++ version
* of Protocol Buffers.
*
* @param message The message to generate from.
* @param lineIndent A string to use as the prefix for all lines generated. Can
* be nil if no extra indent is needed.
*
* @return An NSString with the TextFormat of the message.
**/
NSString *GPBTextFormatForMessage(GPBMessage *message,
NSString * __nullable lineIndent);
/**
* Generates a string that should be a valid "TextFormat" for the C++ version
* of Protocol Buffers.
*
* @param unknownSet The unknown field set to generate from.
* @param lineIndent A string to use as the prefix for all lines generated. Can
* be nil if no extra indent is needed.
*
* @return An NSString with the TextFormat of the unknown field set.
**/
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet,
NSString * __nullable lineIndent);
/**
* Checks if the given field number is set on a message.
*
* @param self The message to check.
* @param fieldNumber The field number to check.
*
* @return YES if the field number is set on the given message.
**/
BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber);
/**
* Checks if the given field is set on a message.
*
* @param self The message to check.
* @param field The field to check.
*
* @return YES if the field is set on the given message.
**/
BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Clears the given field for the given message.
*
* @param self The message for which to clear the field.
* @param field The field to clear.
**/
void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field);
//%PDDM-EXPAND GPB_ACCESSORS()
// This block of code is generated, do not edit it directly.
//
// Get/Set a given field from/to a message.
//
// Single Fields
/**
* Gets the value of a bytes field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
NSData *GPBGetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of a bytes field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field, NSData *value);
/**
* Gets the value of a string field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
NSString *GPBGetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of a string field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field, NSString *value);
/**
* Gets the value of a message field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
GPBMessage *GPBGetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of a message field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
/**
* Gets the value of a group field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
GPBMessage *GPBGetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of a group field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
/**
* Gets the value of a bool field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of a bool field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field, BOOL value);
/**
* Gets the value of an int32 field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
int32_t GPBGetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of an int32 field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
/**
* Gets the value of an uint32 field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
uint32_t GPBGetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of an uint32 field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field, uint32_t value);
/**
* Gets the value of an int64 field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
int64_t GPBGetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of an int64 field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field, int64_t value);
/**
* Gets the value of an uint64 field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
uint64_t GPBGetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of an uint64 field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field, uint64_t value);
/**
* Gets the value of a float field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
float GPBGetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of a float field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field, float value);
/**
* Gets the value of a double field.
*
* @param self The message from which to get the field.
* @param field The field to get.
**/
double GPBGetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of a double field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The to set in the field.
**/
void GPBSetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field, double value);
/**
* Gets the given enum field of a message. For proto3, if the value isn't a
* member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned.
* GPBGetMessageRawEnumField will bypass the check and return whatever value
* was set.
*
* @param self The message from which to get the field.
* @param field The field to get.
*
* @return The enum value for the given field.
**/
int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Set the given enum field of a message. You can only set values that are
* members of the enum.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The enum value to set in the field.
**/
void GPBSetMessageEnumField(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value);
/**
* Get the given enum field of a message. No check is done to ensure the value
* was defined in the enum.
*
* @param self The message from which to get the field.
* @param field The field to get.
*
* @return The raw enum value for the given field.
**/
int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Set the given enum field of a message. You can set the value to anything,
* even a value that is not a member of the enum.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param value The raw enum value to set in the field.
**/
void GPBSetMessageRawEnumField(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value);
// Repeated Fields
/**
* Gets the value of a repeated field.
*
* @param self The message from which to get the field.
* @param field The repeated field to get.
*
* @return A GPB*Array or an NSMutableArray based on the field's type.
**/
id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of a repeated field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param array A GPB*Array or NSMutableArray based on the field's type.
**/
void GPBSetMessageRepeatedField(GPBMessage *self,
GPBFieldDescriptor *field,
id array);
// Map Fields
/**
* Gets the value of a map<> field.
*
* @param self The message from which to get the field.
* @param field The repeated field to get.
*
* @return A GPB*Dictionary or NSMutableDictionary based on the field's type.
**/
id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
/**
* Sets the value of a map<> field.
*
* @param self The message into which to set the field.
* @param field The field to set.
* @param dictionary A GPB*Dictionary or NSMutableDictionary based on the
* field's type.
**/
void GPBSetMessageMapField(GPBMessage *self,
GPBFieldDescriptor *field,
id dictionary);
//%PDDM-EXPAND-END GPB_ACCESSORS()
/**
* Returns an empty NSData to assign to byte fields when you wish to assign them
* to empty. Prevents allocating a lot of little [NSData data] objects.
**/
NSData *GPBEmptyNSData(void) __attribute__((pure));
/**
* Drops the `unknownFields` from the given message and from all sub message.
**/
void GPBMessageDropUnknownFieldsRecursively(GPBMessage *message);
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
//%PDDM-DEFINE GPB_ACCESSORS()
//%
//%//
//%// Get/Set a given field from/to a message.
//%//
//%
//%// Single Fields
//%
//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, , *)
//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, , *)
//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, , *)
//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, , *)
//%GPB_ACCESSOR_SINGLE(Bool, BOOL, )
//%GPB_ACCESSOR_SINGLE(Int32, int32_t, n)
//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t, n)
//%GPB_ACCESSOR_SINGLE(Int64, int64_t, n)
//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t, n)
//%GPB_ACCESSOR_SINGLE(Float, float, )
//%GPB_ACCESSOR_SINGLE(Double, double, )
//%/**
//% * Gets the given enum field of a message. For proto3, if the value isn't a
//% * member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned.
//% * GPBGetMessageRawEnumField will bypass the check and return whatever value
//% * was set.
//% *
//% * @param self The message from which to get the field.
//% * @param field The field to get.
//% *
//% * @return The enum value for the given field.
//% **/
//%int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
//%
//%/**
//% * Set the given enum field of a message. You can only set values that are
//% * members of the enum.
//% *
//% * @param self The message into which to set the field.
//% * @param field The field to set.
//% * @param value The enum value to set in the field.
//% **/
//%void GPBSetMessageEnumField(GPBMessage *self,
//% GPBFieldDescriptor *field,
//% int32_t value);
//%
//%/**
//% * Get the given enum field of a message. No check is done to ensure the value
//% * was defined in the enum.
//% *
//% * @param self The message from which to get the field.
//% * @param field The field to get.
//% *
//% * @return The raw enum value for the given field.
//% **/
//%int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
//%
//%/**
//% * Set the given enum field of a message. You can set the value to anything,
//% * even a value that is not a member of the enum.
//% *
//% * @param self The message into which to set the field.
//% * @param field The field to set.
//% * @param value The raw enum value to set in the field.
//% **/
//%void GPBSetMessageRawEnumField(GPBMessage *self,
//% GPBFieldDescriptor *field,
//% int32_t value);
//%
//%// Repeated Fields
//%
//%/**
//% * Gets the value of a repeated field.
//% *
//% * @param self The message from which to get the field.
//% * @param field The repeated field to get.
//% *
//% * @return A GPB*Array or an NSMutableArray based on the field's type.
//% **/
//%id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
//%
//%/**
//% * Sets the value of a repeated field.
//% *
//% * @param self The message into which to set the field.
//% * @param field The field to set.
//% * @param array A GPB*Array or NSMutableArray based on the field's type.
//% **/
//%void GPBSetMessageRepeatedField(GPBMessage *self,
//% GPBFieldDescriptor *field,
//% id array);
//%
//%// Map Fields
//%
//%/**
//% * Gets the value of a map<> field.
//% *
//% * @param self The message from which to get the field.
//% * @param field The repeated field to get.
//% *
//% * @return A GPB*Dictionary or NSMutableDictionary based on the field's type.
//% **/
//%id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
//%
//%/**
//% * Sets the value of a map<> field.
//% *
//% * @param self The message into which to set the field.
//% * @param field The field to set.
//% * @param dictionary A GPB*Dictionary or NSMutableDictionary based on the
//% * field's type.
//% **/
//%void GPBSetMessageMapField(GPBMessage *self,
//% GPBFieldDescriptor *field,
//% id dictionary);
//%
//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE, AN)
//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, )
//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, TisP)
//%/**
//% * Gets the value of a##AN NAME$L field.
//% *
//% * @param self The message from which to get the field.
//% * @param field The field to get.
//% **/
//%TYPE TisP##GPBGetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field);
//%
//%/**
//% * Sets the value of a##AN NAME$L field.
//% *
//% * @param self The message into which to set the field.
//% * @param field The field to set.
//% * @param value The to set in the field.
//% **/
//%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value);
//%

View File

@ -0,0 +1,355 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "GPBUtilities.h"
#import "GPBDescriptor_PackagePrivate.h"
// Macros for stringifying library symbols. These are used in the generated
// PB descriptor classes wherever a library symbol name is represented as a
// string. See README.google for more information.
#define GPBStringify(S) #S
#define GPBStringifySymbol(S) GPBStringify(S)
#define GPBNSStringify(S) @#S
#define GPBNSStringifySymbol(S) GPBNSStringify(S)
// Constant to internally mark when there is no has bit.
#define GPBNoHasBit INT32_MAX
CF_EXTERN_C_BEGIN
// These two are used to inject a runtime check for version mismatch into the
// generated sources to make sure they are linked with a supporting runtime.
void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion);
GPB_INLINE void GPB_DEBUG_CHECK_RUNTIME_VERSIONS() {
// NOTE: By being inline here, this captures the value from the library's
// headers at the time the generated code was compiled.
#if defined(DEBUG) && DEBUG
GPBCheckRuntimeVersionSupport(GOOGLE_PROTOBUF_OBJC_VERSION);
#endif
}
// Legacy version of the checks, remove when GOOGLE_PROTOBUF_OBJC_GEN_VERSION
// goes away (see more info in GPBBootstrap.h).
void GPBCheckRuntimeVersionInternal(int32_t version);
GPB_INLINE void GPBDebugCheckRuntimeVersion() {
#if defined(DEBUG) && DEBUG
GPBCheckRuntimeVersionInternal(GOOGLE_PROTOBUF_OBJC_GEN_VERSION);
#endif
}
// Conversion functions for de/serializing floating point types.
GPB_INLINE int64_t GPBConvertDoubleToInt64(double v) {
GPBInternalCompileAssert(sizeof(double) == sizeof(int64_t), double_not_64_bits);
int64_t result;
memcpy(&result, &v, sizeof(result));
return result;
}
GPB_INLINE int32_t GPBConvertFloatToInt32(float v) {
GPBInternalCompileAssert(sizeof(float) == sizeof(int32_t), float_not_32_bits);
int32_t result;
memcpy(&result, &v, sizeof(result));
return result;
}
GPB_INLINE double GPBConvertInt64ToDouble(int64_t v) {
GPBInternalCompileAssert(sizeof(double) == sizeof(int64_t), double_not_64_bits);
double result;
memcpy(&result, &v, sizeof(result));
return result;
}
GPB_INLINE float GPBConvertInt32ToFloat(int32_t v) {
GPBInternalCompileAssert(sizeof(float) == sizeof(int32_t), float_not_32_bits);
float result;
memcpy(&result, &v, sizeof(result));
return result;
}
GPB_INLINE int32_t GPBLogicalRightShift32(int32_t value, int32_t spaces) {
return (int32_t)((uint32_t)(value) >> spaces);
}
GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) {
return (int64_t)((uint64_t)(value) >> spaces);
}
// Decode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers
// into values that can be efficiently encoded with varint. (Otherwise,
// negative values must be sign-extended to 64 bits to be varint encoded,
// thus always taking 10 bytes on the wire.)
GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) {
return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n) & 1));
}
// Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
// into values that can be efficiently encoded with varint. (Otherwise,
// negative values must be sign-extended to 64 bits to be varint encoded,
// thus always taking 10 bytes on the wire.)
GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) {
return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n) & 1));
}
// Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers
// into values that can be efficiently encoded with varint. (Otherwise,
// negative values must be sign-extended to 64 bits to be varint encoded,
// thus always taking 10 bytes on the wire.)
GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) {
// Note: the right-shift must be arithmetic
return ((uint32_t)n << 1) ^ (uint32_t)(n >> 31);
}
// Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
// into values that can be efficiently encoded with varint. (Otherwise,
// negative values must be sign-extended to 64 bits to be varint encoded,
// thus always taking 10 bytes on the wire.)
GPB_INLINE uint64_t GPBEncodeZigZag64(int64_t n) {
// Note: the right-shift must be arithmetic
return ((uint64_t)n << 1) ^ (uint64_t)(n >> 63);
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wswitch-enum"
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
GPB_INLINE BOOL GPBDataTypeIsObject(GPBDataType type) {
switch (type) {
case GPBDataTypeBytes:
case GPBDataTypeString:
case GPBDataTypeMessage:
case GPBDataTypeGroup:
return YES;
default:
return NO;
}
}
GPB_INLINE BOOL GPBDataTypeIsMessage(GPBDataType type) {
switch (type) {
case GPBDataTypeMessage:
case GPBDataTypeGroup:
return YES;
default:
return NO;
}
}
GPB_INLINE BOOL GPBFieldDataTypeIsMessage(GPBFieldDescriptor *field) {
return GPBDataTypeIsMessage(field->description_->dataType);
}
GPB_INLINE BOOL GPBFieldDataTypeIsObject(GPBFieldDescriptor *field) {
return GPBDataTypeIsObject(field->description_->dataType);
}
GPB_INLINE BOOL GPBExtensionIsMessage(GPBExtensionDescriptor *ext) {
return GPBDataTypeIsMessage(ext->description_->dataType);
}
// The field is an array/map or it has an object value.
GPB_INLINE BOOL GPBFieldStoresObject(GPBFieldDescriptor *field) {
GPBMessageFieldDescription *desc = field->description_;
if ((desc->flags & (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0) {
return YES;
}
return GPBDataTypeIsObject(desc->dataType);
}
BOOL GPBGetHasIvar(GPBMessage *self, int32_t index, uint32_t fieldNumber);
void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber,
BOOL value);
uint32_t GPBGetHasOneof(GPBMessage *self, int32_t index);
GPB_INLINE BOOL
GPBGetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field) {
GPBMessageFieldDescription *fieldDesc = field->description_;
return GPBGetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number);
}
GPB_INLINE void GPBSetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field,
BOOL value) {
GPBMessageFieldDescription *fieldDesc = field->description_;
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, value);
}
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
int32_t oneofHasIndex, uint32_t fieldNumberNotToClear);
#pragma clang diagnostic pop
//%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE)
//%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self,
//% NAME$S GPBFieldDescriptor *field,
//% NAME$S TYPE value,
//% NAME$S GPBFileSyntax syntax);
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Bool, BOOL)
// This block of code is generated, do not edit it directly.
void GPBSetBoolIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
BOOL value,
GPBFileSyntax syntax);
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Int32, int32_t)
// This block of code is generated, do not edit it directly.
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value,
GPBFileSyntax syntax);
//%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt32, uint32_t)
// This block of code is generated, do not edit it directly.
void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
uint32_t value,
GPBFileSyntax syntax);
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Int64, int64_t)
// This block of code is generated, do not edit it directly.
void GPBSetInt64IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
int64_t value,
GPBFileSyntax syntax);
//%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt64, uint64_t)
// This block of code is generated, do not edit it directly.
void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
uint64_t value,
GPBFileSyntax syntax);
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Float, float)
// This block of code is generated, do not edit it directly.
void GPBSetFloatIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
float value,
GPBFileSyntax syntax);
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Double, double)
// This block of code is generated, do not edit it directly.
void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
double value,
GPBFileSyntax syntax);
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Enum, int32_t)
// This block of code is generated, do not edit it directly.
void GPBSetEnumIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value,
GPBFileSyntax syntax);
//%PDDM-EXPAND-END (8 expansions)
int32_t GPBGetEnumIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
GPBFileSyntax syntax);
id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
void GPBSetObjectIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field, id value,
GPBFileSyntax syntax);
void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
id __attribute__((ns_consumed))
value,
GPBFileSyntax syntax);
// GPBGetObjectIvarWithField will automatically create the field (message) if
// it doesn't exist. GPBGetObjectIvarWithFieldNoAutocreate will return nil.
id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self,
GPBFieldDescriptor *field);
void GPBSetAutocreatedRetainedObjectIvarWithField(
GPBMessage *self, GPBFieldDescriptor *field,
id __attribute__((ns_consumed)) value);
// Clears and releases the autocreated message ivar, if it's autocreated. If
// it's not set as autocreated, this method does nothing.
void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self,
GPBFieldDescriptor *field);
// Returns an Objective C encoding for |selector|. |instanceSel| should be
// YES if it's an instance selector (as opposed to a class selector).
// |selector| must be a selector from MessageSignatureProtocol.
const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel);
// Helper for text format name encoding.
// decodeData is the data describing the sepecial decodes.
// key and inputString are the input that needs decoding.
NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key,
NSString *inputString);
// A series of selectors that are used solely to get @encoding values
// for them by the dynamic protobuf runtime code. See
// GPBMessageEncodingForSelector for details. GPBRootObject conforms to
// the protocol so that it is encoded in the Objective C runtime.
@protocol GPBMessageSignatureProtocol
@optional
#define GPB_MESSAGE_SIGNATURE_ENTRY(TYPE, NAME) \
-(TYPE)get##NAME; \
-(void)set##NAME : (TYPE)value; \
-(TYPE)get##NAME##AtIndex : (NSUInteger)index;
GPB_MESSAGE_SIGNATURE_ENTRY(BOOL, Bool)
GPB_MESSAGE_SIGNATURE_ENTRY(uint32_t, Fixed32)
GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, SFixed32)
GPB_MESSAGE_SIGNATURE_ENTRY(float, Float)
GPB_MESSAGE_SIGNATURE_ENTRY(uint64_t, Fixed64)
GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, SFixed64)
GPB_MESSAGE_SIGNATURE_ENTRY(double, Double)
GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Int32)
GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, Int64)
GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, SInt32)
GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, SInt64)
GPB_MESSAGE_SIGNATURE_ENTRY(uint32_t, UInt32)
GPB_MESSAGE_SIGNATURE_ENTRY(uint64_t, UInt64)
GPB_MESSAGE_SIGNATURE_ENTRY(NSData *, Bytes)
GPB_MESSAGE_SIGNATURE_ENTRY(NSString *, String)
GPB_MESSAGE_SIGNATURE_ENTRY(GPBMessage *, Message)
GPB_MESSAGE_SIGNATURE_ENTRY(GPBMessage *, Group)
GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Enum)
#undef GPB_MESSAGE_SIGNATURE_ENTRY
- (id)getArray;
- (NSUInteger)getArrayCount;
- (void)setArray:(NSArray *)array;
+ (id)getClassValue;
@end
BOOL GPBClassHasSel(Class aClass, SEL sel);
CF_EXTERN_C_END

View File

@ -0,0 +1,245 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2015 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/Any.pbobjc.h>
#import <protobuf/Duration.pbobjc.h>
#import <protobuf/Timestamp.pbobjc.h>
#else
#import "google/protobuf/Any.pbobjc.h"
#import "google/protobuf/Duration.pbobjc.h"
#import "google/protobuf/Timestamp.pbobjc.h"
#endif
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Errors
/** NSError domain used for errors. */
extern NSString *const GPBWellKnownTypesErrorDomain;
/** Error code for NSError with GPBWellKnownTypesErrorDomain. */
typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
/** The type_url could not be computed for the requested GPBMessage class. */
GPBWellKnownTypesErrorCodeFailedToComputeTypeURL = -100,
/** type_url in a Any doesnt match that of the requested GPBMessage class. */
GPBWellKnownTypesErrorCodeTypeURLMismatch = -101,
};
#pragma mark - GPBTimestamp
/**
* Category for GPBTimestamp to work with standard Foundation time/date types.
**/
@interface GPBTimestamp (GBPWellKnownTypes)
/** The NSDate representation of this GPBTimestamp. */
@property(nonatomic, readwrite, strong) NSDate *date;
/**
* The NSTimeInterval representation of this GPBTimestamp.
*
* @note: Not all second/nanos combinations can be represented in a
* NSTimeInterval, so getting this could be a lossy transform.
**/
@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970;
/**
* Initializes a GPBTimestamp with the given NSDate.
*
* @param date The date to configure the GPBTimestamp with.
*
* @return A newly initialized GPBTimestamp.
**/
- (instancetype)initWithDate:(NSDate *)date;
/**
* Initializes a GPBTimestamp with the given NSTimeInterval.
*
* @param timeIntervalSince1970 Time interval to configure the GPBTimestamp with.
*
* @return A newly initialized GPBTimestamp.
**/
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970;
@end
#pragma mark - GPBDuration
/**
* Category for GPBDuration to work with standard Foundation time type.
**/
@interface GPBDuration (GBPWellKnownTypes)
/**
* The NSTimeInterval representation of this GPBDuration.
*
* @note: Not all second/nanos combinations can be represented in a
* NSTimeInterval, so getting this could be a lossy transform.
**/
@property(nonatomic, readwrite) NSTimeInterval timeInterval;
/**
* Initializes a GPBDuration with the given NSTimeInterval.
*
* @param timeInterval Time interval to configure the GPBDuration with.
*
* @return A newly initialized GPBDuration.
**/
- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval;
// These next two methods are deprecated because GBPDuration has no need of a
// "base" time. The older methods were about symmetry with GBPTimestamp, but
// the unix epoch usage is too confusing.
/** Deprecated, use timeInterval instead. */
@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970
__attribute__((deprecated("Use timeInterval")));
/** Deprecated, use initWithTimeInterval: instead. */
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970
__attribute__((deprecated("Use initWithTimeInterval:")));
@end
#pragma mark - GPBAny
/**
* Category for GPBAny to help work with the message within the object.
**/
@interface GPBAny (GBPWellKnownTypes)
/**
* Convenience method to create a GPBAny containing the serialized message.
* This uses type.googleapis.com/ as the type_url's prefix.
*
* @param message The message to be packed into the GPBAny.
* @param errorPtr Pointer to an error that will be populated if something goes
* wrong.
*
* @return A newly configured GPBAny with the given message, or nil on failure.
*/
+ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message
error:(NSError **)errorPtr;
/**
* Convenience method to create a GPBAny containing the serialized message.
*
* @param message The message to be packed into the GPBAny.
* @param typeURLPrefix The URL prefix to apply for type_url.
* @param errorPtr Pointer to an error that will be populated if something
* goes wrong.
*
* @return A newly configured GPBAny with the given message, or nil on failure.
*/
+ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message
typeURLPrefix:(nonnull NSString *)typeURLPrefix
error:(NSError **)errorPtr;
/**
* Initializes a GPBAny to contain the serialized message. This uses
* type.googleapis.com/ as the type_url's prefix.
*
* @param message The message to be packed into the GPBAny.
* @param errorPtr Pointer to an error that will be populated if something goes
* wrong.
*
* @return A newly configured GPBAny with the given message, or nil on failure.
*/
- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message
error:(NSError **)errorPtr;
/**
* Initializes a GPBAny to contain the serialized message.
*
* @param message The message to be packed into the GPBAny.
* @param typeURLPrefix The URL prefix to apply for type_url.
* @param errorPtr Pointer to an error that will be populated if something
* goes wrong.
*
* @return A newly configured GPBAny with the given message, or nil on failure.
*/
- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message
typeURLPrefix:(nonnull NSString *)typeURLPrefix
error:(NSError **)errorPtr;
/**
* Packs the serialized message into this GPBAny. This uses
* type.googleapis.com/ as the type_url's prefix.
*
* @param message The message to be packed into the GPBAny.
* @param errorPtr Pointer to an error that will be populated if something goes
* wrong.
*
* @return Whether the packing was successful or not.
*/
- (BOOL)packWithMessage:(nonnull GPBMessage *)message
error:(NSError **)errorPtr;
/**
* Packs the serialized message into this GPBAny.
*
* @param message The message to be packed into the GPBAny.
* @param typeURLPrefix The URL prefix to apply for type_url.
* @param errorPtr Pointer to an error that will be populated if something
* goes wrong.
*
* @return Whether the packing was successful or not.
*/
- (BOOL)packWithMessage:(nonnull GPBMessage *)message
typeURLPrefix:(nonnull NSString *)typeURLPrefix
error:(NSError **)errorPtr;
/**
* Unpacks the serialized message as if it was an instance of the given class.
*
* @note When checking type_url, the base URL is not checked, only the fully
* qualified name.
*
* @param messageClass The class to use to deserialize the contained message.
* @param errorPtr Pointer to an error that will be populated if something
* goes wrong.
*
* @return An instance of the given class populated with the contained data, or
* nil on failure.
*/
- (nullable GPBMessage *)unpackMessageClass:(Class)messageClass
error:(NSError **)errorPtr;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,73 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import "GPBRuntimeTypes.h"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
typedef enum {
GPBWireFormatVarint = 0,
GPBWireFormatFixed64 = 1,
GPBWireFormatLengthDelimited = 2,
GPBWireFormatStartGroup = 3,
GPBWireFormatEndGroup = 4,
GPBWireFormatFixed32 = 5,
} GPBWireFormat;
enum {
GPBWireFormatMessageSetItem = 1,
GPBWireFormatMessageSetTypeId = 2,
GPBWireFormatMessageSetMessage = 3
};
uint32_t GPBWireFormatMakeTag(uint32_t fieldNumber, GPBWireFormat wireType)
__attribute__((const));
GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) __attribute__((const));
uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) __attribute__((const));
BOOL GPBWireFormatIsValidTag(uint32_t tag) __attribute__((const));
GPBWireFormat GPBWireFormatForType(GPBDataType dataType, BOOL isPacked)
__attribute__((const));
#define GPBWireFormatMessageSetItemTag \
(GPBWireFormatMakeTag(GPBWireFormatMessageSetItem, GPBWireFormatStartGroup))
#define GPBWireFormatMessageSetItemEndTag \
(GPBWireFormatMakeTag(GPBWireFormatMessageSetItem, GPBWireFormatEndGroup))
#define GPBWireFormatMessageSetTypeIdTag \
(GPBWireFormatMakeTag(GPBWireFormatMessageSetTypeId, GPBWireFormatVarint))
#define GPBWireFormatMessageSetMessageTag \
(GPBWireFormatMakeTag(GPBWireFormatMessageSetMessage, \
GPBWireFormatLengthDelimited))
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END

View File

@ -0,0 +1,77 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/source_context.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBSourceContextRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBSourceContextRoot : GPBRootObject
@end
#pragma mark - GPBSourceContext
typedef GPB_ENUM(GPBSourceContext_FieldNumber) {
GPBSourceContext_FieldNumber_FileName = 1,
};
/**
* `SourceContext` represents information about the source of a
* protobuf element, like the file in which it is defined.
**/
@interface GPBSourceContext : GPBMessage
/**
* The path-qualified name of the .proto file that contained the associated
* protobuf element. For example: `"google/protobuf/source_context.proto"`.
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *fileName;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,204 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/struct.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
@class GPBListValue;
@class GPBStruct;
@class GPBValue;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum GPBNullValue
/**
* `NullValue` is a singleton enumeration to represent the null value for the
* `Value` type union.
*
* The JSON representation for `NullValue` is JSON `null`.
**/
typedef GPB_ENUM(GPBNullValue) {
/**
* Value used if any message's field encounters a value that is not defined
* by this enum. The message will also have C functions to get/set the rawValue
* of the field.
**/
GPBNullValue_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
/** Null value. */
GPBNullValue_NullValue = 0,
};
GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void);
/**
* Checks to see if the given value is defined by the enum or was not known at
* the time this source was generated.
**/
BOOL GPBNullValue_IsValidValue(int32_t value);
#pragma mark - GPBStructRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBStructRoot : GPBRootObject
@end
#pragma mark - GPBStruct
typedef GPB_ENUM(GPBStruct_FieldNumber) {
GPBStruct_FieldNumber_Fields = 1,
};
/**
* `Struct` represents a structured data value, consisting of fields
* which map to dynamically typed values. In some languages, `Struct`
* might be supported by a native representation. For example, in
* scripting languages like JS a struct is represented as an
* object. The details of that representation are described together
* with the proto support for the language.
*
* The JSON representation for `Struct` is JSON object.
**/
@interface GPBStruct : GPBMessage
/** Unordered map of dynamically typed values. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, GPBValue*> *fields;
/** The number of items in @c fields without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger fields_Count;
@end
#pragma mark - GPBValue
typedef GPB_ENUM(GPBValue_FieldNumber) {
GPBValue_FieldNumber_NullValue = 1,
GPBValue_FieldNumber_NumberValue = 2,
GPBValue_FieldNumber_StringValue = 3,
GPBValue_FieldNumber_BoolValue = 4,
GPBValue_FieldNumber_StructValue = 5,
GPBValue_FieldNumber_ListValue = 6,
};
typedef GPB_ENUM(GPBValue_Kind_OneOfCase) {
GPBValue_Kind_OneOfCase_GPBUnsetOneOfCase = 0,
GPBValue_Kind_OneOfCase_NullValue = 1,
GPBValue_Kind_OneOfCase_NumberValue = 2,
GPBValue_Kind_OneOfCase_StringValue = 3,
GPBValue_Kind_OneOfCase_BoolValue = 4,
GPBValue_Kind_OneOfCase_StructValue = 5,
GPBValue_Kind_OneOfCase_ListValue = 6,
};
/**
* `Value` represents a dynamically typed value which can be either
* null, a number, a string, a boolean, a recursive struct value, or a
* list of values. A producer of value is expected to set one of that
* variants, absence of any variant indicates an error.
*
* The JSON representation for `Value` is JSON value.
**/
@interface GPBValue : GPBMessage
/** The kind of value. */
@property(nonatomic, readonly) GPBValue_Kind_OneOfCase kindOneOfCase;
/** Represents a null value. */
@property(nonatomic, readwrite) GPBNullValue nullValue;
/** Represents a double value. */
@property(nonatomic, readwrite) double numberValue;
/** Represents a string value. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *stringValue;
/** Represents a boolean value. */
@property(nonatomic, readwrite) BOOL boolValue;
/** Represents a structured value. */
@property(nonatomic, readwrite, strong, null_resettable) GPBStruct *structValue;
/** Represents a repeated `Value`. */
@property(nonatomic, readwrite, strong, null_resettable) GPBListValue *listValue;
@end
/**
* Fetches the raw value of a @c GPBValue's @c nullValue property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t GPBValue_NullValue_RawValue(GPBValue *message);
/**
* Sets the raw value of an @c GPBValue's @c nullValue property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value);
/**
* Clears whatever value was set for the oneof 'kind'.
**/
void GPBValue_ClearKindOneOfCase(GPBValue *message);
#pragma mark - GPBListValue
typedef GPB_ENUM(GPBListValue_FieldNumber) {
GPBListValue_FieldNumber_ValuesArray = 1,
};
/**
* `ListValue` is a wrapper around a repeated field of values.
*
* The JSON representation for `ListValue` is JSON array.
**/
@interface GPBListValue : GPBMessage
/** Repeated field of dynamically typed values. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBValue*> *valuesArray;
/** The number of items in @c valuesArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger valuesArray_Count;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,167 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/timestamp.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBTimestampRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBTimestampRoot : GPBRootObject
@end
#pragma mark - GPBTimestamp
typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
GPBTimestamp_FieldNumber_Seconds = 1,
GPBTimestamp_FieldNumber_Nanos = 2,
};
/**
* A Timestamp represents a point in time independent of any time zone or local
* calendar, encoded as a count of seconds and fractions of seconds at
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
* January 1, 1970, in the proleptic Gregorian calendar which extends the
* Gregorian calendar backwards to year one.
*
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
* second table is needed for interpretation, using a [24-hour linear
* smear](https://developers.google.com/time/smear).
*
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
* restricting to that range, we ensure that we can convert to and from [RFC
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
*
* # Examples
*
* Example 1: Compute Timestamp from POSIX `time()`.
*
* Timestamp timestamp;
* timestamp.set_seconds(time(NULL));
* timestamp.set_nanos(0);
*
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
*
* struct timeval tv;
* gettimeofday(&tv, NULL);
*
* Timestamp timestamp;
* timestamp.set_seconds(tv.tv_sec);
* timestamp.set_nanos(tv.tv_usec * 1000);
*
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
*
* FILETIME ft;
* GetSystemTimeAsFileTime(&ft);
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
*
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
* Timestamp timestamp;
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
*
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
*
* long millis = System.currentTimeMillis();
*
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
* .setNanos((int) ((millis % 1000) * 1000000)).build();
*
*
* Example 5: Compute Timestamp from current time in Python.
*
* timestamp = Timestamp()
* timestamp.GetCurrentTime()
*
* # JSON Mapping
*
* In JSON format, the Timestamp type is encoded as a string in the
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
* where {year} is always expressed using four digits while {month}, {day},
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
* is required. A proto3 JSON serializer should always use UTC (as indicated by
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
* able to accept both UTC and other timezones (as indicated by an offset).
*
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
* 01:30 UTC on January 15, 2017.
*
* In JavaScript, one can convert a Date object to this format using the
* standard
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
* method. In Python, a standard `datetime.datetime` object can be converted
* to this format using
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
* http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
* ) to obtain a formatter capable of generating timestamps in this format.
**/
@interface GPBTimestamp : GPBMessage
/**
* Represents seconds of UTC time since Unix epoch
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
* 9999-12-31T23:59:59Z inclusive.
**/
@property(nonatomic, readwrite) int64_t seconds;
/**
* Non-negative fractions of a second at nanosecond resolution. Negative
* second values with fractions must still have non-negative nanos values
* that count forward in time. Must be from 0 to 999,999,999
* inclusive.
**/
@property(nonatomic, readwrite) int32_t nanos;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,444 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/type.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
@class GPBAny;
@class GPBEnumValue;
@class GPBField;
@class GPBOption;
@class GPBSourceContext;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum GPBSyntax
/** The syntax in which a protocol buffer element is defined. */
typedef GPB_ENUM(GPBSyntax) {
/**
* Value used if any message's field encounters a value that is not defined
* by this enum. The message will also have C functions to get/set the rawValue
* of the field.
**/
GPBSyntax_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
/** Syntax `proto2`. */
GPBSyntax_SyntaxProto2 = 0,
/** Syntax `proto3`. */
GPBSyntax_SyntaxProto3 = 1,
};
GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void);
/**
* Checks to see if the given value is defined by the enum or was not known at
* the time this source was generated.
**/
BOOL GPBSyntax_IsValidValue(int32_t value);
#pragma mark - Enum GPBField_Kind
/** Basic field types. */
typedef GPB_ENUM(GPBField_Kind) {
/**
* Value used if any message's field encounters a value that is not defined
* by this enum. The message will also have C functions to get/set the rawValue
* of the field.
**/
GPBField_Kind_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
/** Field type unknown. */
GPBField_Kind_TypeUnknown = 0,
/** Field type double. */
GPBField_Kind_TypeDouble = 1,
/** Field type float. */
GPBField_Kind_TypeFloat = 2,
/** Field type int64. */
GPBField_Kind_TypeInt64 = 3,
/** Field type uint64. */
GPBField_Kind_TypeUint64 = 4,
/** Field type int32. */
GPBField_Kind_TypeInt32 = 5,
/** Field type fixed64. */
GPBField_Kind_TypeFixed64 = 6,
/** Field type fixed32. */
GPBField_Kind_TypeFixed32 = 7,
/** Field type bool. */
GPBField_Kind_TypeBool = 8,
/** Field type string. */
GPBField_Kind_TypeString = 9,
/** Field type group. Proto2 syntax only, and deprecated. */
GPBField_Kind_TypeGroup = 10,
/** Field type message. */
GPBField_Kind_TypeMessage = 11,
/** Field type bytes. */
GPBField_Kind_TypeBytes = 12,
/** Field type uint32. */
GPBField_Kind_TypeUint32 = 13,
/** Field type enum. */
GPBField_Kind_TypeEnum = 14,
/** Field type sfixed32. */
GPBField_Kind_TypeSfixed32 = 15,
/** Field type sfixed64. */
GPBField_Kind_TypeSfixed64 = 16,
/** Field type sint32. */
GPBField_Kind_TypeSint32 = 17,
/** Field type sint64. */
GPBField_Kind_TypeSint64 = 18,
};
GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void);
/**
* Checks to see if the given value is defined by the enum or was not known at
* the time this source was generated.
**/
BOOL GPBField_Kind_IsValidValue(int32_t value);
#pragma mark - Enum GPBField_Cardinality
/** Whether a field is optional, required, or repeated. */
typedef GPB_ENUM(GPBField_Cardinality) {
/**
* Value used if any message's field encounters a value that is not defined
* by this enum. The message will also have C functions to get/set the rawValue
* of the field.
**/
GPBField_Cardinality_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
/** For fields with unknown cardinality. */
GPBField_Cardinality_CardinalityUnknown = 0,
/** For optional fields. */
GPBField_Cardinality_CardinalityOptional = 1,
/** For required fields. Proto2 syntax only. */
GPBField_Cardinality_CardinalityRequired = 2,
/** For repeated fields. */
GPBField_Cardinality_CardinalityRepeated = 3,
};
GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void);
/**
* Checks to see if the given value is defined by the enum or was not known at
* the time this source was generated.
**/
BOOL GPBField_Cardinality_IsValidValue(int32_t value);
#pragma mark - GPBTypeRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBTypeRoot : GPBRootObject
@end
#pragma mark - GPBType
typedef GPB_ENUM(GPBType_FieldNumber) {
GPBType_FieldNumber_Name = 1,
GPBType_FieldNumber_FieldsArray = 2,
GPBType_FieldNumber_OneofsArray = 3,
GPBType_FieldNumber_OptionsArray = 4,
GPBType_FieldNumber_SourceContext = 5,
GPBType_FieldNumber_Syntax = 6,
};
/**
* A protocol buffer message type.
**/
@interface GPBType : GPBMessage
/** The fully qualified message name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/** The list of fields. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBField*> *fieldsArray;
/** The number of items in @c fieldsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger fieldsArray_Count;
/** The list of types appearing in `oneof` definitions in this type. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *oneofsArray;
/** The number of items in @c oneofsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger oneofsArray_Count;
/** The protocol buffer options. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
/** The source context. */
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
/** Test to see if @c sourceContext has been set. */
@property(nonatomic, readwrite) BOOL hasSourceContext;
/** The source syntax. */
@property(nonatomic, readwrite) GPBSyntax syntax;
@end
/**
* Fetches the raw value of a @c GPBType's @c syntax property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t GPBType_Syntax_RawValue(GPBType *message);
/**
* Sets the raw value of an @c GPBType's @c syntax property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value);
#pragma mark - GPBField
typedef GPB_ENUM(GPBField_FieldNumber) {
GPBField_FieldNumber_Kind = 1,
GPBField_FieldNumber_Cardinality = 2,
GPBField_FieldNumber_Number = 3,
GPBField_FieldNumber_Name = 4,
GPBField_FieldNumber_TypeURL = 6,
GPBField_FieldNumber_OneofIndex = 7,
GPBField_FieldNumber_Packed = 8,
GPBField_FieldNumber_OptionsArray = 9,
GPBField_FieldNumber_JsonName = 10,
GPBField_FieldNumber_DefaultValue = 11,
};
/**
* A single field of a message type.
**/
@interface GPBField : GPBMessage
/** The field type. */
@property(nonatomic, readwrite) GPBField_Kind kind;
/** The field cardinality. */
@property(nonatomic, readwrite) GPBField_Cardinality cardinality;
/** The field number. */
@property(nonatomic, readwrite) int32_t number;
/** The field name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/**
* The field type URL, without the scheme, for message or enumeration
* types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
/**
* The index of the field type in `Type.oneofs`, for message or enumeration
* types. The first type has index 1; zero means the type is not in the list.
**/
@property(nonatomic, readwrite) int32_t oneofIndex;
/** Whether to use alternative packed wire representation. */
@property(nonatomic, readwrite) BOOL packed;
/** The protocol buffer options. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
/** The field JSON name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName;
/** The string value of the default value of this field. Proto2 syntax only. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue;
@end
/**
* Fetches the raw value of a @c GPBField's @c kind property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t GPBField_Kind_RawValue(GPBField *message);
/**
* Sets the raw value of an @c GPBField's @c kind property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void SetGPBField_Kind_RawValue(GPBField *message, int32_t value);
/**
* Fetches the raw value of a @c GPBField's @c cardinality property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t GPBField_Cardinality_RawValue(GPBField *message);
/**
* Sets the raw value of an @c GPBField's @c cardinality property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value);
#pragma mark - GPBEnum
typedef GPB_ENUM(GPBEnum_FieldNumber) {
GPBEnum_FieldNumber_Name = 1,
GPBEnum_FieldNumber_EnumvalueArray = 2,
GPBEnum_FieldNumber_OptionsArray = 3,
GPBEnum_FieldNumber_SourceContext = 4,
GPBEnum_FieldNumber_Syntax = 5,
};
/**
* Enum type definition.
**/
@interface GPBEnum : GPBMessage
/** Enum type name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/** Enum value definitions. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBEnumValue*> *enumvalueArray;
/** The number of items in @c enumvalueArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger enumvalueArray_Count;
/** Protocol buffer options. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
/** The source context. */
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
/** Test to see if @c sourceContext has been set. */
@property(nonatomic, readwrite) BOOL hasSourceContext;
/** The source syntax. */
@property(nonatomic, readwrite) GPBSyntax syntax;
@end
/**
* Fetches the raw value of a @c GPBEnum's @c syntax property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t GPBEnum_Syntax_RawValue(GPBEnum *message);
/**
* Sets the raw value of an @c GPBEnum's @c syntax property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value);
#pragma mark - GPBEnumValue
typedef GPB_ENUM(GPBEnumValue_FieldNumber) {
GPBEnumValue_FieldNumber_Name = 1,
GPBEnumValue_FieldNumber_Number = 2,
GPBEnumValue_FieldNumber_OptionsArray = 3,
};
/**
* Enum value definition.
**/
@interface GPBEnumValue : GPBMessage
/** Enum value name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/** Enum value number. */
@property(nonatomic, readwrite) int32_t number;
/** Protocol buffer options. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
@end
#pragma mark - GPBOption
typedef GPB_ENUM(GPBOption_FieldNumber) {
GPBOption_FieldNumber_Name = 1,
GPBOption_FieldNumber_Value = 2,
};
/**
* A protocol buffer option, which can be attached to a message, field,
* enumeration, etc.
**/
@interface GPBOption : GPBMessage
/**
* The option's name. For protobuf built-in options (options defined in
* descriptor.proto), this is the short name. For example, `"map_entry"`.
* For custom options, it should be the fully-qualified name. For example,
* `"google.api.http"`.
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/**
* The option's value packed in an Any message. If the value is a primitive,
* the corresponding wrapper type defined in google/protobuf/wrappers.proto
* should be used. If the value is an enum, it should be stored as an int32
* value using the google.protobuf.Int32Value type.
**/
@property(nonatomic, readwrite, strong, null_resettable) GPBAny *value;
/** Test to see if @c value has been set. */
@property(nonatomic, readwrite) BOOL hasValue;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,219 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/wrappers.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <protobuf/GPBDescriptor.h>
#import <protobuf/GPBMessage.h>
#import <protobuf/GPBRootObject.h>
#else
#import "GPBDescriptor.h"
#import "GPBMessage.h"
#import "GPBRootObject.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBWrappersRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface GPBWrappersRoot : GPBRootObject
@end
#pragma mark - GPBDoubleValue
typedef GPB_ENUM(GPBDoubleValue_FieldNumber) {
GPBDoubleValue_FieldNumber_Value = 1,
};
/**
* Wrapper message for `double`.
*
* The JSON representation for `DoubleValue` is JSON number.
**/
@interface GPBDoubleValue : GPBMessage
/** The double value. */
@property(nonatomic, readwrite) double value;
@end
#pragma mark - GPBFloatValue
typedef GPB_ENUM(GPBFloatValue_FieldNumber) {
GPBFloatValue_FieldNumber_Value = 1,
};
/**
* Wrapper message for `float`.
*
* The JSON representation for `FloatValue` is JSON number.
**/
@interface GPBFloatValue : GPBMessage
/** The float value. */
@property(nonatomic, readwrite) float value;
@end
#pragma mark - GPBInt64Value
typedef GPB_ENUM(GPBInt64Value_FieldNumber) {
GPBInt64Value_FieldNumber_Value = 1,
};
/**
* Wrapper message for `int64`.
*
* The JSON representation for `Int64Value` is JSON string.
**/
@interface GPBInt64Value : GPBMessage
/** The int64 value. */
@property(nonatomic, readwrite) int64_t value;
@end
#pragma mark - GPBUInt64Value
typedef GPB_ENUM(GPBUInt64Value_FieldNumber) {
GPBUInt64Value_FieldNumber_Value = 1,
};
/**
* Wrapper message for `uint64`.
*
* The JSON representation for `UInt64Value` is JSON string.
**/
@interface GPBUInt64Value : GPBMessage
/** The uint64 value. */
@property(nonatomic, readwrite) uint64_t value;
@end
#pragma mark - GPBInt32Value
typedef GPB_ENUM(GPBInt32Value_FieldNumber) {
GPBInt32Value_FieldNumber_Value = 1,
};
/**
* Wrapper message for `int32`.
*
* The JSON representation for `Int32Value` is JSON number.
**/
@interface GPBInt32Value : GPBMessage
/** The int32 value. */
@property(nonatomic, readwrite) int32_t value;
@end
#pragma mark - GPBUInt32Value
typedef GPB_ENUM(GPBUInt32Value_FieldNumber) {
GPBUInt32Value_FieldNumber_Value = 1,
};
/**
* Wrapper message for `uint32`.
*
* The JSON representation for `UInt32Value` is JSON number.
**/
@interface GPBUInt32Value : GPBMessage
/** The uint32 value. */
@property(nonatomic, readwrite) uint32_t value;
@end
#pragma mark - GPBBoolValue
typedef GPB_ENUM(GPBBoolValue_FieldNumber) {
GPBBoolValue_FieldNumber_Value = 1,
};
/**
* Wrapper message for `bool`.
*
* The JSON representation for `BoolValue` is JSON `true` and `false`.
**/
@interface GPBBoolValue : GPBMessage
/** The bool value. */
@property(nonatomic, readwrite) BOOL value;
@end
#pragma mark - GPBStringValue
typedef GPB_ENUM(GPBStringValue_FieldNumber) {
GPBStringValue_FieldNumber_Value = 1,
};
/**
* Wrapper message for `string`.
*
* The JSON representation for `StringValue` is JSON string.
**/
@interface GPBStringValue : GPBMessage
/** The string value. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *value;
@end
#pragma mark - GPBBytesValue
typedef GPB_ENUM(GPBBytesValue_FieldNumber) {
GPBBytesValue_FieldNumber_Value = 1,
};
/**
* Wrapper message for `bytes`.
*
* The JSON representation for `BytesValue` is JSON string.
**/
@interface GPBBytesValue : GPBMessage
/** The bytes value. */
@property(nonatomic, readwrite, copy, null_resettable) NSData *value;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,5 @@
framework module Protobuf {
umbrella header "Protobuf.h"
export *
module * { export * }
}

Binary file not shown.

11310
3rdParty/ios/Firebase/NOTICES vendored Normal file

File diff suppressed because it is too large Load Diff

359
3rdParty/ios/Firebase/README.md vendored Normal file
View File

@ -0,0 +1,359 @@
# Firebase iOS SDKs
This directory contains the full Firebase distribution, packaged as static
frameworks that can be integrated into your app.
# Integration Instructions
Each Firebase component requires several frameworks in order to function
properly. Each section below lists the frameworks you'll need to include
in your project in order to use that Firebase SDK in your application.
To integrate a Firebase SDK with your app:
1. Find the desired SDK in the list below.
2. Make sure you have an Xcode project open in Xcode.
3. In Xcode, hit `⌘-1` to open the Project Navigator pane. It will open on
left side of the Xcode window if it wasn't already open.
4. Drag each framework from the "FirebaseAnalytics" directory into the Project
Navigator pane. In the dialog box that appears, make sure the target you
want the framework to be added to has a checkmark next to it, and that
you've selected "Copy items if needed". If you already have Firebase
frameworks in your project, make sure that you replace them with the new
versions.
5. Drag each framework from the directory named after the SDK into the Project
Navigator pane. Note that there may be no additional frameworks, in which
case this directory will be empty. For instance, if you want the Database
SDK, look in the Database folder for the required frameworks. In the dialog
box that appears, make sure the target you want this framework to be added to
has a checkmark next to it, and that you've selected "Copy items if needed."
*Do not add the Firebase frameworks to the "Embed Frameworks" Xcode build
phase. The Firebase frameworks are not embedded dynamic frameworks, but are
[static frameworks](https://www.raywenderlich.com/65964/create-a-framework-for-ios)
which cannot be embedded into your application's bundle.*
6. If the SDK has resources, go into the Resources folders, which will be in
the SDK folder. Drag all of those resources into the Project Navigator, just
like the frameworks, again making sure that the target you want to add these
resources to has a checkmark next to it, and that you've selected "Copy items
if needed".
7. Add the -ObjC flag to "Other Linker Settings":
a. In your project settings, open the Settings panel for your target
b. Go to the Build Settings tab and find the "Other Linker Flags" setting
in the Linking section.
c. Double-click the setting, click the '+' button, and add "-ObjC" (without
quotes)
8. Drag the `Firebase.h` header in this directory into your project. This will
allow you to `#import "Firebase.h"` and start using any Firebase SDK that you
have.
9. If you're using Swift, or you want to use modules, drag module.modulemap into
your project and update your User Header Search Paths to contain the
directory that contains your module map.
10. You're done! Compile your target and start using Firebase.
If you want to add another SDK, repeat the steps above with the frameworks for
the new SDK. You only need to add each framework once, so if you've already
added a framework for one SDK, you don't need to add it again. Note that some
frameworks are required by multiple SDKs, and so appear in multiple folders.
The Firebase frameworks list the system libraries and frameworks they depend on
in their modulemaps. If you have disabled the "Link Frameworks Automatically"
option in your Xcode project/workspace, you will need to add the system
frameworks and libraries listed in each Firebase framework's
<Name>.framework/Modules/module.modulemap file to your target's or targets'
"Link Binary With Libraries" build phase.
"(~> X)" below means that the SDK requires all of the frameworks from X. You
should make sure to include all of the frameworks from X when including the SDK.
## FirebaseAnalytics
- FIRAnalyticsConnector.framework
- FirebaseAnalytics.framework
- FirebaseCore.framework
- FirebaseCoreDiagnostics.framework
- FirebaseInstallations.framework
- GoogleAppMeasurement.framework
- GoogleDataTransport.framework
- GoogleDataTransportCCTSupport.framework
- GoogleUtilities.framework
- PromisesObjC.framework
- nanopb.framework
## FirebaseABTesting (~> FirebaseAnalytics)
- FirebaseABTesting.framework
- Protobuf.framework
## FirebaseAuth (~> FirebaseAnalytics)
- FirebaseAuth.framework
- GTMSessionFetcher.framework
## FirebaseCrashlytics (~> FirebaseAnalytics)
- FirebaseCrashlytics.framework
## FirebaseDatabase (~> FirebaseAnalytics)
- FirebaseDatabase.framework
- leveldb-library.framework
## FirebaseDynamicLinks (~> FirebaseAnalytics)
- FirebaseDynamicLinks.framework
## FirebaseFirestore (~> FirebaseAnalytics)
- BoringSSL-GRPC.framework
- FirebaseFirestore.framework
- abseil.framework
- gRPC-C++.framework
- gRPC-Core.framework
- leveldb-library.framework
You'll also need to add the resources in the Resources
directory into your target's main bundle.
## FirebaseFunctions (~> FirebaseAnalytics)
- FirebaseFunctions.framework
- GTMSessionFetcher.framework
## FirebaseInAppMessaging (~> FirebaseAnalytics)
- FirebaseABTesting.framework
- FirebaseInAppMessaging.framework
- FirebaseInstanceID.framework
- Protobuf.framework
You'll also need to add the resources in the Resources
directory into your target's main bundle.
## FirebaseMLModelInterpreter (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLModelInterpreter.framework
- GTMSessionFetcher.framework
- GoogleToolboxForMac.framework
- Protobuf.framework
- TensorFlowLiteC.framework
- TensorFlowLiteObjC.framework
## FirebaseMLNLLanguageID (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLNLLanguageID.framework
- FirebaseMLNaturalLanguage.framework
- GTMSessionFetcher.framework
- GoogleToolboxForMac.framework
- Protobuf.framework
## FirebaseMLNLSmartReply (~> FirebaseAnalytics)
- FirebaseABTesting.framework
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLNLLanguageID.framework
- FirebaseMLNLSmartReply.framework
- FirebaseMLNaturalLanguage.framework
- FirebaseRemoteConfig.framework
- GTMSessionFetcher.framework
- GoogleToolboxForMac.framework
- Protobuf.framework
You'll also need to add the resources in the Resources
directory into your target's main bundle.
## FirebaseMLNLTranslate (~> FirebaseAnalytics)
- FirebaseABTesting.framework
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLNLTranslate.framework
- FirebaseMLNaturalLanguage.framework
- FirebaseRemoteConfig.framework
- GTMSessionFetcher.framework
- GoogleToolboxForMac.framework
- Protobuf.framework
You'll also need to add the resources in the Resources
directory into your target's main bundle.
## FirebaseMLNaturalLanguage (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLNaturalLanguage.framework
- GTMSessionFetcher.framework
- GoogleToolboxForMac.framework
- Protobuf.framework
## FirebaseMLVision (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLVision.framework
- GTMSessionFetcher.framework
- GoogleAPIClientForREST.framework
- GoogleToolboxForMac.framework
- Protobuf.framework
## FirebaseMLVisionAutoML (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLVision.framework
- FirebaseMLVisionAutoML.framework
- GTMSessionFetcher.framework
- GoogleAPIClientForREST.framework
- GoogleToolboxForMac.framework
- Protobuf.framework
- TensorFlowLiteC.framework
- TensorFlowLiteObjC.framework
## FirebaseMLVisionBarcodeModel (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLVision.framework
- FirebaseMLVisionBarcodeModel.framework
- GoogleAPIClientForREST.framework
- GoogleToolboxForMac.framework
## FirebaseMLVisionFaceModel (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLVision.framework
- FirebaseMLVisionFaceModel.framework
- GoogleAPIClientForREST.framework
- GoogleToolboxForMac.framework
You'll also need to add the resources in the Resources
directory into your target's main bundle.
## FirebaseMLVisionLabelModel (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLVision.framework
- FirebaseMLVisionLabelModel.framework
- GoogleAPIClientForREST.framework
- GoogleToolboxForMac.framework
## FirebaseMLVisionObjectDetection (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLVision.framework
- FirebaseMLVisionObjectDetection.framework
- GTMSessionFetcher.framework
- GoogleAPIClientForREST.framework
- GoogleToolboxForMac.framework
- Protobuf.framework
## FirebaseMLVisionTextModel (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMLCommon.framework
- FirebaseMLVision.framework
- FirebaseMLVisionTextModel.framework
- GoogleAPIClientForREST.framework
- GoogleToolboxForMac.framework
You'll also need to add the resources in the Resources
directory into your target's main bundle.
## FirebaseMessaging (~> FirebaseAnalytics)
- FirebaseInstanceID.framework
- FirebaseMessaging.framework
- Protobuf.framework
## FirebasePerformance (~> FirebaseAnalytics)
- FirebaseABTesting.framework
- FirebaseInstanceID.framework
- FirebasePerformance.framework
- FirebaseRemoteConfig.framework
- GTMSessionFetcher.framework
- GoogleToolboxForMac.framework
- Protobuf.framework
## FirebaseRemoteConfig (~> FirebaseAnalytics)
- FirebaseABTesting.framework
- FirebaseInstanceID.framework
- FirebaseRemoteConfig.framework
- Protobuf.framework
## FirebaseStorage (~> FirebaseAnalytics)
- FirebaseStorage.framework
- GTMSessionFetcher.framework
## Google-Mobile-Ads-SDK (~> FirebaseAnalytics)
- GoogleMobileAds.framework
## GoogleSignIn
- AppAuth.framework
- GTMAppAuth.framework
- GTMSessionFetcher.framework
- GoogleSignIn.framework
You'll also need to add the resources in the Resources
directory into your target's main bundle.
# Samples
You can get samples for Firebase from https://github.com/firebase/quickstart-ios:
git clone https://github.com/firebase/quickstart-ios
Note that several of the samples depend on SDKs that are not included with
this archive; for example, FirebaseUI. For the samples that depend on SDKs not
included in this archive, you'll need to use CocoaPods.
# Versions
The frameworks in this directory map to these versions of the Firebase SDKs in
CocoaPods.
CocoaPod | Version
--------------------------------|---------
AppAuth | 1.3.0
BoringSSL-GRPC | 0.0.3
Firebase | 6.19.0
FirebaseABTesting | 3.2.0
FirebaseAnalytics | 6.3.1
FirebaseAnalyticsInterop | 1.5.0
FirebaseAuth | 6.4.3
FirebaseAuthInterop | 1.1.0
FirebaseCore | 6.6.4
FirebaseCoreDiagnostics | 1.2.2
FirebaseCoreDiagnosticsInterop | 1.2.0
FirebaseCrashlytics | 4.0.0-beta.5
FirebaseDatabase | 6.1.4
FirebaseDynamicLinks | 4.0.7
FirebaseFirestore | 1.11.1
FirebaseFunctions | 2.5.1
FirebaseInAppMessaging | 0.19.0
FirebaseInstallations | 1.1.0
FirebaseInstanceID | 4.3.2
FirebaseMLCommon | 0.19.0
FirebaseMLModelInterpreter | 0.19.0
FirebaseMLNLLanguageID | 0.17.0
FirebaseMLNLSmartReply | 0.17.0
FirebaseMLNLTranslate | 0.17.0
FirebaseMLNaturalLanguage | 0.17.0
FirebaseMLVision | 0.19.0
FirebaseMLVisionAutoML | 0.19.0
FirebaseMLVisionBarcodeModel | 0.19.0
FirebaseMLVisionFaceModel | 0.19.0
FirebaseMLVisionLabelModel | 0.19.0
FirebaseMLVisionObjectDetection | 0.19.0
FirebaseMLVisionTextModel | 0.19.0
FirebaseMessaging | 4.3.0
FirebasePerformance | 3.1.10
FirebaseRemoteConfig | 4.4.9
FirebaseStorage | 3.6.0
GTMAppAuth | 1.0.0
GTMSessionFetcher | 1.3.1
Google-Mobile-Ads-SDK | 7.56.0
GoogleAPIClientForREST | 1.3.11
GoogleAppMeasurement | 6.3.1
GoogleDataTransport | 5.0.0
GoogleDataTransportCCTSupport | 2.0.0
GoogleSignIn | 5.0.2
GoogleToolboxForMac | 2.2.2
GoogleUtilities | 6.5.1
PromisesObjC | 1.2.8
Protobuf | 3.11.4
TensorFlowLiteC | 1.14.0
TensorFlowLiteObjC | 1.14.0
abseil | 0.20190808
gRPC-C++ | 0.0.9
gRPC-Core | 1.21.0
leveldb-library | 1.22
nanopb | 0.3.9011

4
3rdParty/ios/Firebase/module.modulemap vendored Executable file
View File

@ -0,0 +1,4 @@
module Firebase {
export *
header "Firebase.h"
}

View File

@ -23,3 +23,6 @@ android: {
!no-firebase:DEFINES+=WITH_FIREBASE
}
ios: {
!no-firebase:DEFINES+=WITH_FIREBASE
}

View File

@ -84,7 +84,6 @@ android {
INCLUDEPATH += /opt/firebase_cpp_sdk/include
LIBS += -L/opt/firebase_cpp_sdk/libs/android/$$ANDROID_TARGET_ARCH/$$FIREBASE_STL_VARIANT/ -lfirebase_messaging -lfirebase_app
}
}
macx: {
@ -113,10 +112,31 @@ ios: {
QT += webview
HEADERS += platformintegration/ios/platformhelperios.h
SOURCES += platformintegration/ios/platformhelperios.cpp
OBJECTIVE_SOURCES += $$PWD/../packaging/ios/pushnotifications.mm \
$$PWD/../packaging/ios/platformhelperios.mm
OBJECTIVE_SOURCES += $$PWD/../packaging/ios/platformhelperios.mm \
$$PWD/../packaging/ios/pushnotifications.mm \
# Firebase CPP SDK
# QMAKE_LFLAGS += -ObjC $(inherited)
# INCLUDEPATH += /Users/micha/Downloads/firebase_cpp_sdk/include/
# LIBS += -F/Users/micha/Downloads/firebase_cpp_sdk/libs/ios/arm64/
# LIBS += -ObjC -L/Users/micha/Downloads/firebase_cpp_sdk/libs/ios/arm64/ -lfirebase_messaging -lfirebase_app
# LIBS += -framework "FirebaseCore"
# Add Firebase SDK
QMAKE_LFLAGS += -ObjC $(inherited)
firebase_files.files += $$files(../packaging/ios/GoogleService-Info.plist)
QMAKE_BUNDLE_DATA += firebase_files
INCLUDEPATH += ../3rdParty/ios/
LIBS += -F$$PWD/../3rdParty/ios/Firebase/FirebaseAnalytics/ \
-F$$PWD/../3rdParty/ios/Firebase/FirebaseMessaging
LIBS += -framework "FirebaseMessaging" \
-framework "GoogleUtilities" \
-framework "Protobuf" \
-framework "FirebaseCore" \
-framework "FirebaseInstanceID" \
-framework "FirebaseInstallations" \
-framework "PromisesObjC" \
LIBS += -framework "UserNotifications"
QMAKE_TARGET_BUNDLE_PREFIX = io.guh
QMAKE_BUNDLE = nymeaApp
@ -128,7 +148,8 @@ ios: {
QMAKE_SUBSTITUTES += plist
QMAKE_INFO_PLIST = $$OUT_PWD/Info.plist
OTHER_FILES += ../packaging/ios/Info.plist.in \
../packaging/ios/pushnotifications.entitlements
../packaging/ios/pushnotifications.entitlements \
../packaging/ios/GoogleService-Info.plist
ios_icon_files.files += $$files(../packaging/ios/AppIcons.xcassets/AppIcon.appiconset/AppIcon*.png)
ios_launch_images.files += $$files(../packaging/ios/LaunchImage*.png) ../packaging/ios/LaunchScreen1.xib

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>484445295371-s8duts7vmgefl9ti97d9oe3j8ptseucg.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.484445295371-s8duts7vmgefl9ti97d9oe3j8ptseucg</string>
<key>API_KEY</key>
<string>AIzaSyBym9KR23-2lDOUSLMHm6BQrwNqyKE_QGg</string>
<key>GCM_SENDER_ID</key>
<string>484445295371</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>io.guh.nymeaApp</string>
<key>PROJECT_ID</key>
<string>nymea-app</string>
<key>STORAGE_BUCKET</key>
<string>nymea-app.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:484445295371:ios:cfb8ca8591d9d289a3080e</string>
<key>DATABASE_URL</key>
<string>https://nymea-app.firebaseio.com</string>
</dict>
</plist>

View File

@ -6,7 +6,6 @@
#include <QtDebug>
#include "platformintegration/ios/platformhelperios.h"
QString PlatformHelperIOS::readKeyChainEntry(const QString &service, const QString &key)
{
NSDictionary *const query = @{

View File

@ -6,8 +6,11 @@
#include <QDebug>
#import "Firebase/Firebase.h"
// This is hidden, so we declare it here to hook into it
@interface QIOSApplicationDelegate: UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>
@interface QIOSApplicationDelegate: UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate,FIRMessagingDelegate>
@end
//add a category to QIOSApplicationDelegate
@ -19,6 +22,12 @@
@implementation QIOSApplicationDelegate (APNSApplicationDelegate)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Use Firebase library to configure APIs
[FIRApp configure];
[FIRMessaging messaging].delegate = self;
// Register to receive notifications from the system
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
@ -30,6 +39,8 @@
NSLog(@"registering for remote notifications");
qDebug() << "Registering for remote notifications";
return YES;
}
@ -45,7 +56,8 @@
qDebug() << "Registering for remote notifications";
qDebug() << "Token description:" << QString::fromNSString(deviceToken.description);
qDebug() << "Parsed token:" << QString::fromNSString(tokenStr);
PushNotifications::instance()->setAPNSRegistrationToken(QString::fromNSString(tokenStr));
// We've switched to firebase... Not emitting the native APNS token
// PushNotifications::instance()->setAPNSRegistrationToken(QString::fromNSString(tokenStr));
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
@ -66,4 +78,24 @@
completionHandler();
}
- (void)tokenRefreshNotification:(NSNotification *)notification {
NSLog(@"instanceId_notification=>%@",[notification object]);
NSString *InstanceID = [NSString stringWithFormat:@"%@",[notification object]];
qDebug() << "Firebase token:" << QString::fromNSString(InstanceID);
}
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {
NSLog(@"FCM registration token: %@", fcmToken);
// Notify about received token.
NSDictionary *dataDict = [NSDictionary dictionaryWithObject:fcmToken forKey:@"token"];
[[NSNotificationCenter defaultCenter] postNotificationName:
@"FCMToken" object:nil userInfo:dataDict];
// TODO: If necessary send token to application server.
// Note: This callback is fired at each app startup and whenever a new token is generated.
qDebug() << "Firebase token received:" << QString::fromNSString(fcmToken);
PushNotifications::instance()->setAPNSRegistrationToken(QString::fromNSString(fcmToken));
}
@end