ADD: added new version of protobuf

This commit is contained in:
Henry Winkel
2022-12-20 10:09:28 +01:00
parent 4a79559129
commit 1e2b3dda7b
1513 changed files with 123720 additions and 83381 deletions

View File

@@ -1 +1,7 @@
BasedOnStyle: Google
# Ignore pddm directives.
CommentPragmas: '^%'
# Following the rest of the protobuf code.
ColumnLimit: 80

View File

@@ -1,6 +1,5 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("//conformance:defs.bzl", "conformance_test")
objc_library(
name = "objectivec",
@@ -91,20 +90,6 @@ objc_library(
visibility = ["//visibility:public"],
)
################################################################################
# Tests
################################################################################
conformance_test(
name = "conformance_test",
failure_list = "//conformance:failure_list_objc.txt",
testee = "//conformance:conformance_objc",
)
################################################################################
# Distribution files
################################################################################
pkg_files(
name = "dist_files",
srcs = glob([

View File

@@ -16,7 +16,7 @@ die() {
exit 1
}
readonly GeneratorSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/file.cc"
readonly GeneratorSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc"
readonly RuntimeSrc="${ProtoRootDir}/objectivec/GPBBootstrap.h"
check_constant() {

View File

@@ -25,16 +25,46 @@ case "${ACTION}" in
;;
esac
# -----------------------------------------------------------------------------
# Reusing a bunch of the protos from the protocolbuffers/protobuf tree, this
# can include some extras as there is no harm in ensuring work for C++
# generation.
CORE_PROTO_FILES=(
src/google/protobuf/any_test.proto
src/google/protobuf/unittest_arena.proto
src/google/protobuf/unittest_custom_options.proto
src/google/protobuf/unittest_enormous_descriptor.proto
src/google/protobuf/unittest_embed_optimize_for.proto
src/google/protobuf/unittest_empty.proto
src/google/protobuf/unittest_import.proto
src/google/protobuf/unittest_import_lite.proto
src/google/protobuf/unittest_lite.proto
src/google/protobuf/unittest_mset.proto
src/google/protobuf/unittest_mset_wire_format.proto
src/google/protobuf/unittest_no_generic_services.proto
src/google/protobuf/unittest_optimize_for.proto
src/google/protobuf/unittest.proto
src/google/protobuf/unittest_import_public.proto
src/google/protobuf/unittest_import_public_lite.proto
src/google/protobuf/unittest_drop_unknown_fields.proto
src/google/protobuf/unittest_preserve_unknown_enum.proto
src/google/protobuf/map_lite_unittest.proto
src/google/protobuf/map_proto2_unittest.proto
src/google/protobuf/map_unittest.proto
# The unittest_custom_options.proto extends the messages in descriptor.proto
# so we build it in to test extending in general. The library doesn't provide
# a descriptor as it doesn't use the classes/enums.
src/google/protobuf/descriptor.proto
)
# -----------------------------------------------------------------------------
# The objc unittest specific proto files.
OBJC_TEST_PROTO_FILES=(
objectivec/Tests/any_test.proto
objectivec/Tests/map_proto2_unittest.proto
objectivec/Tests/map_unittest.proto
objectivec/Tests/unittest_cycle.proto
objectivec/Tests/unittest_deprecated_file.proto
objectivec/Tests/unittest_deprecated.proto
objectivec/Tests/unittest_deprecated_file.proto
objectivec/Tests/unittest_extension_chain_a.proto
objectivec/Tests/unittest_extension_chain_b.proto
objectivec/Tests/unittest_extension_chain_c.proto
@@ -42,30 +72,24 @@ OBJC_TEST_PROTO_FILES=(
objectivec/Tests/unittest_extension_chain_e.proto
objectivec/Tests/unittest_extension_chain_f.proto
objectivec/Tests/unittest_extension_chain_g.proto
objectivec/Tests/unittest_import_public.proto
objectivec/Tests/unittest_import.proto
objectivec/Tests/unittest_mset.proto
objectivec/Tests/unittest_objc_options.proto
objectivec/Tests/unittest_objc_startup.proto
objectivec/Tests/unittest_objc.proto
objectivec/Tests/unittest_preserve_unknown_enum.proto
objectivec/Tests/unittest_objc_startup.proto
objectivec/Tests/unittest_objc_options.proto
objectivec/Tests/unittest_runtime_proto2.proto
objectivec/Tests/unittest_runtime_proto3.proto
objectivec/Tests/unittest.proto
)
OBJC_EXTENSIONS=( .pbobjc.h .pbobjc.m )
# -----------------------------------------------------------------------------
# Ensure the output dir exists
mkdir -p "${OUTPUT_DIR}"
mkdir -p "${OUTPUT_DIR}/google/protobuf"
# -----------------------------------------------------------------------------
# Move to the top of the protobuf directories and ensure there is a protoc
# binary to use.
cd "${SRCROOT}/.."
readonly PROTOC="bazel-bin/protoc"
[[ -x "${PROTOC}" ]] || \
[[ -x src/protoc ]] || \
die "Could not find the protoc binary; make sure you have built it (objectivec/DevTools/full_mac_build.sh -h)."
# -----------------------------------------------------------------------------
@@ -73,7 +97,7 @@ RUN_PROTOC=no
# Check to if all the output files exist (in case a new one got added).
for PROTO_FILE in "${OBJC_TEST_PROTO_FILES[@]}"; do
for PROTO_FILE in "${CORE_PROTO_FILES[@]}" "${OBJC_TEST_PROTO_FILES[@]}"; do
DIR=${PROTO_FILE%/*}
BASE_NAME=${PROTO_FILE##*/}
# Drop the extension
@@ -81,7 +105,7 @@ for PROTO_FILE in "${OBJC_TEST_PROTO_FILES[@]}"; do
OBJC_NAME=$(echo "${BASE_NAME}" | awk -F _ '{for(i=1; i<=NF; i++) printf "%s", toupper(substr($i,1,1)) substr($i,2);}')
for EXT in "${OBJC_EXTENSIONS[@]}"; do
if [[ ! -f "${OUTPUT_DIR}/${DIR}/${OBJC_NAME}${EXT}" ]]; then
if [[ ! -f "${OUTPUT_DIR}/google/protobuf/${OBJC_NAME}${EXT}" ]]; then
RUN_PROTOC=yes
fi
done
@@ -94,7 +118,9 @@ if [[ "${RUN_PROTOC}" != "yes" ]] ; then
# (these patterns catch some extra stuff, but better to over sample than
# under)
readonly NewestInput=$(find \
objectivec/Tests/*.proto "${PROTOC}" \
src/google/protobuf/*.proto \
objectivec/Tests/*.proto \
src/.libs src/*.la src/protoc \
objectivec/DevTools/compile_testing_protos.sh \
-type f -print0 \
| xargs -0 stat -f "%m %N" \
@@ -124,13 +150,28 @@ find "${OUTPUT_DIR}" \
| xargs -0 rm -rf
# -----------------------------------------------------------------------------
# Generate the Objective C specific testing protos.
# Helper to invoke protoc
compile_protos() {
src/protoc \
--objc_out="${OUTPUT_DIR}/google/protobuf" \
--proto_path=src/google/protobuf/ \
--proto_path=src \
--experimental_allow_proto3_optional \
"$@"
}
"${PROTOC}" \
--objc_out="${OUTPUT_DIR}" \
--objc_opt=expected_prefixes_path=objectivec/Tests/expected_prefixes.txt \
--objc_opt=prefixes_must_be_registered=yes \
--objc_opt=require_prefixes=yes \
--proto_path=. \
--proto_path=src \
# -----------------------------------------------------------------------------
# Generate most of the proto files that exist in the C++ src tree.
# Note: there is overlap in package.Message names between some of the test
# files, so they can't be generated all at once. This works because the overlap
# isn't linked into a single binary.
for a_proto in "${CORE_PROTO_FILES[@]}" ; do
compile_protos "${a_proto}"
done
# -----------------------------------------------------------------------------
# Generate the Objective C specific testing protos.
compile_protos \
--proto_path="objectivec/Tests" \
"${OBJC_TEST_PROTO_FILES[@]}"

View File

@@ -8,11 +8,6 @@ set -eu
# Some base locations.
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/../.."
readonly BazelFlags="--announce_rc --macos_minimum_os=10.9 \
$(${ScriptDir}/../../kokoro/common/bazel_flags.sh)"
# Invoke with BAZEL=bazelisk to use that instead.
readonly BazelBin="${BAZEL:=bazel}"
printUsage() {
NAME=$(basename "${0}")
@@ -29,9 +24,13 @@ OPTIONS:
Show this message
-c, --clean
Issue a clean before the normal build.
-a, --autogen
Start by rerunning autogen & configure.
-r, --regenerate-descriptors
Run generate_descriptor_proto.sh to regenerate all the checked in
proto sources.
-j #, --jobs #
Force the number of parallel jobs (useful for debugging build issues).
--core-only
Skip some of the core protobuf build/checks to shorten the build time.
--skip-xcode
@@ -61,7 +60,25 @@ header() {
echo "========================================================================"
}
BAZEL=bazel
# Thanks to libtool, builds can fail in odd ways and since it eats some output
# it can be hard to spot, so force error output if make exits with a non zero.
wrapped_make() {
set +e # Don't stop if the command fails.
make $*
MAKE_EXIT_STATUS=$?
if [ ${MAKE_EXIT_STATUS} -ne 0 ]; then
echo "Error: 'make $*' exited with status ${MAKE_EXIT_STATUS}"
exit ${MAKE_EXIT_STATUS}
fi
set -e
}
NUM_MAKE_JOBS=$(/usr/sbin/sysctl -n hw.ncpu)
if [[ "${NUM_MAKE_JOBS}" -lt 2 ]] ; then
NUM_MAKE_JOBS=2
fi
DO_AUTOGEN=no
DO_CLEAN=no
REGEN_DESCRIPTORS=no
CORE_ONLY=no
@@ -81,9 +98,16 @@ while [[ $# != 0 ]]; do
-c | --clean )
DO_CLEAN=yes
;;
-a | --autogen )
DO_AUTOGEN=yes
;;
-r | --regenerate-descriptors )
REGEN_DESCRIPTORS=yes
;;
-j | --jobs )
shift
NUM_MAKE_JOBS="${1}"
;;
--core-only )
CORE_ONLY=yes
;;
@@ -130,9 +154,21 @@ done
# Into the proto dir.
cd "${ProtoRootDir}"
# if no Makefile, force the autogen.
if [[ ! -f Makefile ]] ; then
DO_AUTOGEN=yes
fi
if [[ "${DO_AUTOGEN}" == "yes" ]] ; then
header "Running autogen & configure"
./autogen.sh
./configure \
CPPFLAGS="-mmacosx-version-min=10.9 -Wunused-const-variable -Wunused-function"
fi
if [[ "${DO_CLEAN}" == "yes" ]] ; then
header "Cleaning"
"${BazelBin}" clean
wrapped_make clean
if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
XCODEBUILD_CLEAN_BASE_IOS=(
xcodebuild
@@ -176,23 +212,26 @@ fi
if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then
header "Regenerating the descriptor sources."
./generate_descriptor_proto.sh
./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}"
fi
if [[ "${CORE_ONLY}" == "yes" ]] ; then
header "Building core Only"
"${BazelBin}" build //:protoc //:protobuf //:protobuf_lite $BazelFlags
wrapped_make -j "${NUM_MAKE_JOBS}"
else
header "Building"
# Can't issue these together, when fully parallel, something sometimes chokes
# at random.
"${BazelBin}" test //src/... $BazelFlags
wrapped_make -j "${NUM_MAKE_JOBS}" all
wrapped_make -j "${NUM_MAKE_JOBS}" check
# Fire off the conformance tests also.
"${BazelBin}" test //objectivec:conformance_test $BazelFlags
cd conformance
wrapped_make -j "${NUM_MAKE_JOBS}" test_cpp
cd ..
fi
# Ensure the WKT sources checked in are current.
BAZEL="${BazelBin}" objectivec/generate_well_known_types.sh --check-only $BazelFlags
objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}"
header "Checking on the ObjC Runtime Code"
# Some of the kokoro machines don't have python3 yet, so fall back to python if need be.
@@ -225,11 +264,38 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
# just pick a mix of OS Versions and 32/64 bit.
# NOTE: Different Xcode have different simulated hardware/os support.
case "${XCODE_VERSION}" in
[6-9].* | 1[0-2].* )
echo "ERROR: Xcode 13.3.1 or higher is required." 1>&2
[6-8].* )
echo "ERROR: The unittests include Swift code that is now Swift 4.0." 1>&2
echo "ERROR: Xcode 9.0 or higher is required to build the test suite, but the library works with Xcode 7.x." 1>&2
exit 11
;;
13.* | 14.*)
9.[0-2]* )
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
# 9.0-9.2 all seem to often fail running destinations in parallel
-disable-concurrent-testing
)
;;
9.[3-4]* )
XCODEBUILD_TEST_BASE_IOS+=(
# Xcode 9.3 chokes targeting iOS 8.x - http://www.openradar.me/39335367
-destination "platform=iOS Simulator,name=iPhone 4s,OS=9.0" # 32bit
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
# 9.3 also seems to often fail running destinations in parallel
-disable-concurrent-testing
)
;;
10.*)
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
# 10.x also seems to often fail running destinations in parallel (with
# 32bit one include at least)
-disable-concurrent-destination-testing
)
;;
11.* | 12.* | 13.* | 14.*)
# Dropped 32bit as Apple doesn't seem support the simulators either.
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 8,OS=latest" # 64bit
@@ -266,8 +332,9 @@ if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
XCODEBUILD_TEST_BASE_OSX+=( -quiet )
fi
case "${XCODE_VERSION}" in
[6-9].* | 1[0-2].* )
echo "ERROR: Xcode 13.3.1 or higher is required." 1>&2
[6-8].* )
echo "ERROR: The unittests include Swift code that is now Swift 4.0." 1>&2
echo "ERROR: Xcode 9.0 or higher is required to build the test suite, but the library works with Xcode 7.x." 1>&2
exit 11
;;
esac
@@ -287,10 +354,15 @@ if [[ "${DO_XCODE_TVOS_TESTS}" == "yes" ]] ; then
-scheme ProtocolBuffers
)
case "${XCODE_VERSION}" in
[6-9].* | 1[0-2].* )
echo "ERROR: Xcode 13.3.1 or higher is required." 1>&2
[6-9].* )
echo "ERROR: Xcode 10.0 or higher is required to build the test suite." 1>&2
exit 11
;;
10.* | 11.* | 12.*)
XCODEBUILD_TEST_BASE_TVOS+=(
-destination "platform=tvOS Simulator,name=Apple TV 4K,OS=latest"
)
;;
13.* | 14.*)
XCODEBUILD_TEST_BASE_TVOS+=(
-destination "platform=tvOS Simulator,name=Apple TV 4K (2nd generation),OS=latest"
@@ -319,7 +391,9 @@ fi
if [[ "${DO_OBJC_CONFORMANCE_TESTS}" == "yes" ]] ; then
header "Running ObjC Conformance Tests"
"${BazelBin}" test //objectivec:conformance_test $BazelFlags
cd conformance
wrapped_make -j "${NUM_MAKE_JOBS}" test_objc
cd ..
fi
echo ""

View File

@@ -485,13 +485,14 @@ class SourceFile(object):
if self._macro_collection:
# Always add a blank line, seems to read better. (If need be, add an
# option to the EXPAND to indicate if this should be done.)
result.extend([_GENERATED_CODE_LINE, ''])
result.extend([_GENERATED_CODE_LINE, '// clang-format off', ''])
macro = line[directive_len:].strip()
try:
expand_result = self._macro_collection.Expand(macro)
# Since expansions are line oriented, strip trailing whitespace
# from the lines.
lines = [x.rstrip() for x in expand_result.split('\n')]
lines.append('// clang-format on')
result.append('\n'.join(lines))
except PDDMError as e:
raise PDDMError('%s\n...while expanding "%s" from the section'

View File

@@ -418,18 +418,24 @@ baz
foo
//%PDDM-EXPAND mumble(abc)
// This block of code is generated, do not edit it directly.
// clang-format off
abc: doAbc(int abc);
// clang-format on
//%PDDM-EXPAND-END mumble(abc)
bar
//%PDDM-EXPAND mumble(def)
// This block of code is generated, do not edit it directly.
// clang-format off
def: doDef(int def);
// clang-format on
//%PDDM-EXPAND mumble(ghi)
// This block of code is generated, do not edit it directly.
// clang-format off
ghi: doGhi(int ghi);
// clang-format on
//%PDDM-EXPAND-END (2 expansions)
baz
//%PDDM-DEFINE mumble(a_)

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/any.proto
#import "GPBDescriptor.h"
@@ -99,6 +98,7 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
* 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
@@ -172,5 +172,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/any.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -99,5 +98,3 @@ typedef struct GPBAny__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/api.proto
#import "GPBDescriptor.h"
@@ -75,12 +74,12 @@ GPB_FINAL @interface GPBApi : GPBMessage
/** 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 container to be created. */
/** 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 container to be created. */
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
/**
@@ -116,7 +115,7 @@ GPB_FINAL @interface GPBApi : GPBMessage
/** Included interfaces. See [Mixin][]. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMixin*> *mixinsArray;
/** The number of items in @c mixinsArray without causing the container to be created. */
/** 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. */
@@ -170,7 +169,7 @@ GPB_FINAL @interface GPBMethod : GPBMessage
/** 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 container to be created. */
/** 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. */
@@ -297,5 +296,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/api.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -353,5 +352,3 @@ typedef struct GPBMixin__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -34,11 +34,9 @@
NS_ASSUME_NONNULL_BEGIN
// Disable clang-format for the macros.
// clang-format off
//%PDDM-EXPAND DECLARE_ARRAYS()
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Int32
@@ -137,8 +135,7 @@ NS_ASSUME_NONNULL_BEGIN
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -150,8 +147,7 @@ NS_ASSUME_NONNULL_BEGIN
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
BOOL *stop))block;
usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -311,8 +307,7 @@ NS_ASSUME_NONNULL_BEGIN
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -324,8 +319,7 @@ NS_ASSUME_NONNULL_BEGIN
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx,
BOOL *stop))block;
usingBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -485,8 +479,7 @@ NS_ASSUME_NONNULL_BEGIN
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -498,8 +491,7 @@ NS_ASSUME_NONNULL_BEGIN
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx,
BOOL *stop))block;
usingBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -659,8 +651,7 @@ NS_ASSUME_NONNULL_BEGIN
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -672,8 +663,7 @@ NS_ASSUME_NONNULL_BEGIN
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx,
BOOL *stop))block;
usingBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -833,8 +823,7 @@ NS_ASSUME_NONNULL_BEGIN
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -846,8 +835,7 @@ NS_ASSUME_NONNULL_BEGIN
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx,
BOOL *stop))block;
usingBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -1007,8 +995,7 @@ NS_ASSUME_NONNULL_BEGIN
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -1020,8 +1007,7 @@ NS_ASSUME_NONNULL_BEGIN
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx,
BOOL *stop))block;
usingBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -1181,8 +1167,7 @@ NS_ASSUME_NONNULL_BEGIN
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -1194,8 +1179,7 @@ NS_ASSUME_NONNULL_BEGIN
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx,
BOOL *stop))block;
usingBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -1386,8 +1370,7 @@ NS_ASSUME_NONNULL_BEGIN
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -1399,8 +1382,7 @@ NS_ASSUME_NONNULL_BEGIN
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
BOOL *stop))block;
usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
// These methods bypass the validationFunc to provide access to values that were not
// known at the time the binary was compiled.
@@ -1422,8 +1404,7 @@ NS_ASSUME_NONNULL_BEGIN
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -1435,8 +1416,7 @@ NS_ASSUME_NONNULL_BEGIN
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
BOOL *stop))block;
usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
// If value is not a valid enumerator as defined by validationFunc, these
// methods will assert in debug, and will log in release and assign the value
@@ -1556,6 +1536,7 @@ NS_ASSUME_NONNULL_BEGIN
@end
// clang-format on
//%PDDM-EXPAND-END DECLARE_ARRAYS()
NS_ASSUME_NONNULL_END
@@ -1800,8 +1781,7 @@ NS_ASSUME_NONNULL_END
//% * **idx**: The index of the current value.
//% * **stop**: A pointer to a boolean that when set stops the enumeration.
//% **/
//%- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx,
//% BOOL *stop))block;
//%- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%
//%/**
//% * Enumerates the values on this array with the given block.
@@ -1813,8 +1793,7 @@ NS_ASSUME_NONNULL_END
//% * **stop**: A pointer to a boolean that when set stops the enumeration.
//% **/
//%- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
//% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx,
//% BOOL *stop))block;
//% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%
//%// If value is not a valid enumerator as defined by validationFunc, these
//%// methods will assert in debug, and will log in release and assign the value
@@ -1844,8 +1823,7 @@ NS_ASSUME_NONNULL_END
//% * **idx**: The index of the current value.
//% * **stop**: A pointer to a boolean that when set stops the enumeration.
//% **/
//%- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx,
//% BOOL *stop))block;
//%- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%
//%/**
//% * Enumerates the values on this array with the given block.
@@ -1857,8 +1835,7 @@ NS_ASSUME_NONNULL_END
//% * **stop**: A pointer to a boolean that when set stops the enumeration.
//% **/
//%- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
//% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx,
//% BOOL *stop))block;
//% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%PDDM-DEFINE ARRAY_MUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME)
//%/**
@@ -1990,5 +1967,3 @@ NS_ASSUME_NONNULL_END
//%
//%// No validation applies to these methods.
//%
// clang-format on

View File

@@ -47,9 +47,6 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return (value != kGPBUnrecognizedEnumeratorValue);
}
// Disable clang-format for the macros.
// clang-format off
//%PDDM-DEFINE VALIDATE_RANGE(INDEX, COUNT)
//% if (INDEX >= COUNT) {
//% [NSException raise:NSRangeException
@@ -197,12 +194,12 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
//% return result;
//%}
//%
//%- (void)enumerate##ACCESSOR_NAME##ValuesWithBlock:(void(NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block {
//%- (void)enumerate##ACCESSOR_NAME##ValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block {
//% [self enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
//%}
//%
//%- (void)enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)opts
//% ACCESSOR_NAME$S usingBlock:(void(NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block {
//% ACCESSOR_NAME$S usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block {
//% // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
//% BOOL stop = NO;
//% if ((opts & NSEnumerationReverse) == 0) {
@@ -295,8 +292,10 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
//% _values[idx2] = temp;
//%}
//%
//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Int32, int32_t, %d)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Int32
@@ -407,12 +406,12 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return result;
}
- (void)enumerateValuesWithBlock:(void(NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -543,8 +542,10 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t, %u)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - UInt32
@@ -655,12 +656,12 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return result;
}
- (void)enumerateValuesWithBlock:(void(NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block {
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block {
usingBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -791,8 +792,10 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Int64, int64_t, %lld)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Int64
@@ -903,12 +906,12 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return result;
}
- (void)enumerateValuesWithBlock:(void(NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block {
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block {
usingBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -1039,8 +1042,10 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(UInt64, uint64_t, %llu)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - UInt64
@@ -1151,12 +1156,12 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return result;
}
- (void)enumerateValuesWithBlock:(void(NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block {
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block {
usingBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -1287,8 +1292,10 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Float, float, %f)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Float
@@ -1399,12 +1406,12 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return result;
}
- (void)enumerateValuesWithBlock:(void(NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block {
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block {
usingBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -1535,8 +1542,10 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Double, double, %lf)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Double
@@ -1647,12 +1656,12 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return result;
}
- (void)enumerateValuesWithBlock:(void(NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block {
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block {
usingBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -1783,8 +1792,10 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Bool, BOOL, %d)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool
@@ -1895,12 +1906,12 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return result;
}
- (void)enumerateValuesWithBlock:(void(NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block {
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block {
usingBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -2031,9 +2042,8 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@end
//%PDDM-EXPAND-END (7 expansions)
// clang-format on
//%PDDM-EXPAND-END (7 expansions)
#pragma mark - Enum
@@ -2056,15 +2066,19 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return [[[self alloc] initWithValidationFunction:func] autorelease];
}
+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func rawValue:(int32_t)value {
return [[[self alloc] initWithValidationFunction:func rawValues:&value count:1] autorelease];
+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func
rawValue:(int32_t)value {
return [[[self alloc] initWithValidationFunction:func
rawValues:&value
count:1] autorelease];
}
+ (instancetype)arrayWithValueArray:(GPBEnumArray *)array {
return [[(GPBEnumArray *)[self alloc] initWithValueArray:array] autorelease];
return [[(GPBEnumArray*)[self alloc] initWithValueArray:array] autorelease];
}
+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func capacity:(NSUInteger)count {
+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func
capacity:(NSUInteger)count {
return [[[self alloc] initWithValidationFunction:func capacity:count] autorelease];
}
@@ -2087,7 +2101,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func
rawValues:(const int32_t[])values
rawValues:(const int32_t [])values
count:(NSUInteger)count {
self = [self initWithValidationFunction:func];
if (self) {
@@ -2099,16 +2113,17 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
_count = count;
} else {
[self release];
[NSException
raise:NSMallocException
format:@"Failed to allocate %lu bytes", (unsigned long)(count * sizeof(int32_t))];
[NSException raise:NSMallocException
format:@"Failed to allocate %lu bytes",
(unsigned long)(count * sizeof(int32_t))];
}
}
}
return self;
}
- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func capacity:(NSUInteger)count {
- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func
capacity:(NSUInteger)count {
self = [self initWithValidationFunction:func];
if (self && count) {
[self internalResizeToCapacity:count];
@@ -2117,16 +2132,15 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)copyWithZone:(NSZone *)zone {
return [[GPBEnumArray allocWithZone:zone] initWithValidationFunction:_validationFunc
rawValues:_values
count:_count];
return [[GPBEnumArray allocWithZone:zone]
initWithValidationFunction:_validationFunc
rawValues:_values
count:_count];
}
// Disable clang-format for the macros.
// clang-format off
//%PDDM-EXPAND ARRAY_IMMUTABLE_CORE(Enum, int32_t, Raw, %d)
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)dealloc {
NSAssert(!_autocreator,
@@ -2166,12 +2180,12 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return result;
}
- (void)enumerateRawValuesWithBlock:(void(NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateRawValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -2186,22 +2200,21 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
}
}
// clang-format on
//%PDDM-EXPAND-END ARRAY_IMMUTABLE_CORE(Enum, int32_t, Raw, %d)
// clang-format on
- (int32_t)valueAtIndex:(NSUInteger)index {
// clang-format off
//%PDDM-EXPAND VALIDATE_RANGE(index, _count)
// This block of code is generated, do not edit it directly.
// clang-format off
if (index >= _count) {
[NSException raise:NSRangeException
format:@"Index (%lu) beyond bounds (%lu)",
(unsigned long)index, (unsigned long)_count];
}
// clang-format on
//%PDDM-EXPAND-END VALIDATE_RANGE(index, _count)
// clang-format on
int32_t result = _values[index];
if (!_validationFunc(result)) {
result = kGPBUnrecognizedEnumeratorValue;
@@ -2210,28 +2223,26 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (int32_t)rawValueAtIndex:(NSUInteger)index {
// clang-format off
//%PDDM-EXPAND VALIDATE_RANGE(index, _count)
// This block of code is generated, do not edit it directly.
// clang-format off
if (index >= _count) {
[NSException raise:NSRangeException
format:@"Index (%lu) beyond bounds (%lu)",
(unsigned long)index, (unsigned long)_count];
}
// clang-format on
//%PDDM-EXPAND-END VALIDATE_RANGE(index, _count)
// clang-format on
return _values[index];
}
- (void)enumerateValuesWithBlock:(void(NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))
block {
- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))
block {
usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
GPBEnumValidationFunc func = _validationFunc;
@@ -2260,10 +2271,9 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
}
// clang-format off
//%PDDM-EXPAND ARRAY_MUTABLE_CORE(Enum, int32_t, Raw, %d)
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)internalResizeToCapacity:(NSUInteger)newCapacity {
_values = reallocf(_values, newCapacity * sizeof(int32_t));
@@ -2369,8 +2379,10 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
_values[idx2] = temp;
}
// clang-format on
//%PDDM-EXPAND MUTATION_METHODS(Enum, int32_t, , EnumValidationList, EnumValidationOne)
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)addValue:(int32_t)value {
[self addValues:&value count:1];
@@ -2437,6 +2449,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
_values[index] = value;
}
// clang-format on
//%PDDM-EXPAND-END (2 expansions)
//%PDDM-DEFINE MUTATION_HOOK_EnumValidationList()
@@ -2457,8 +2470,6 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
//% }
//%
// clang-format on
@end
#pragma mark - NSArray Subclass
@@ -2468,7 +2479,8 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)dealloc {
NSAssert(!_autocreator, @"%@: Autocreator must be cleared before release, autocreator: %@",
NSAssert(!_autocreator,
@"%@: Autocreator must be cleared before release, autocreator: %@",
[self class], _autocreator);
[_array release];
[super dealloc];
@@ -2544,17 +2556,17 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
objects:(id __unsafe_unretained[])buffer
objects:(id __unsafe_unretained [])buffer
count:(NSUInteger)len {
return [_array countByEnumeratingWithState:state objects:buffer count:len];
}
- (void)enumerateObjectsUsingBlock:(void(NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))block {
- (void)enumerateObjectsUsingBlock:(void (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))block {
[_array enumerateObjectsUsingBlock:block];
}
- (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts
usingBlock:(void(NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))block {
usingBlock:(void (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))block {
[_array enumerateObjectsWithOptions:opts usingBlock:block];
}

View File

@@ -54,6 +54,7 @@
//%PDDM-EXPAND DECLARE_ARRAY_EXTRAS()
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Int32
@@ -119,6 +120,7 @@
}
@end
// clang-format on
//%PDDM-EXPAND-END DECLARE_ARRAY_EXTRAS()
#pragma mark - NSArray Subclass

View File

@@ -42,7 +42,7 @@
// 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.
#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
@@ -52,11 +52,9 @@
// 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
#define GPB_ENUM(X) enum X : int32_t X; enum X : int32_t
#else
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
#endif
/**
@@ -140,6 +138,7 @@
// - 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

View File

@@ -30,9 +30,8 @@
#import <Foundation/Foundation.h>
#import "GPBExtensionRegistry.h"
@class GPBMessage;
@class GPBExtensionRegistry;
NS_ASSUME_NONNULL_BEGIN
@@ -185,7 +184,7 @@ CF_EXTERN_C_END
* extensions for message.
**/
- (void)readMessage:(GPBMessage *)message
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry;
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
/**
* Reads and discards a single field, given its tag value.

View File

@@ -36,7 +36,8 @@
#import "GPBUtilities_PackagePrivate.h"
#import "GPBWireFormat.h"
NSString *const GPBCodedInputStreamException = GPBNSStringifySymbol(GPBCodedInputStreamException);
NSString *const GPBCodedInputStreamException =
GPBNSStringifySymbol(GPBCodedInputStreamException);
NSString *const GPBCodedInputStreamUnderlyingErrorKey =
GPBNSStringifySymbol(GPBCodedInputStreamUnderlyingErrorKey);
@@ -54,14 +55,16 @@ static const NSUInteger kDefaultRecursionLimit = 100;
static void RaiseException(NSInteger code, NSString *reason) {
NSDictionary *errorInfo = nil;
if ([reason length]) {
errorInfo = @{GPBErrorReasonKey : reason};
errorInfo = @{ GPBErrorReasonKey: reason };
}
NSError *error = [NSError errorWithDomain:GPBCodedInputStreamErrorDomain
code:code
userInfo:errorInfo];
NSDictionary *exceptionInfo = @{GPBCodedInputStreamUnderlyingErrorKey : error};
[[NSException exceptionWithName:GPBCodedInputStreamException reason:reason
NSDictionary *exceptionInfo =
@{ GPBCodedInputStreamUnderlyingErrorKey: error };
[[NSException exceptionWithName:GPBCodedInputStreamException
reason:reason
userInfo:exceptionInfo] raise];
}
@@ -102,7 +105,7 @@ static int32_t ReadRawLittleEndian32(GPBCodedInputStreamState *state) {
static int64_t ReadRawLittleEndian64(GPBCodedInputStreamState *state) {
CheckSize(state, sizeof(int64_t));
// Not using OSReadLittleInt64 because it has undocumented dependency
// on reads being aligned.
// on reads being aligned.
int64_t value;
memcpy(&value, state->bytes + state->bufferPos, sizeof(int64_t));
value = OSSwapLittleToHostInt64(value);
@@ -212,7 +215,8 @@ int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
state->lastTag = ReadRawVarint32(state);
// Tags have to include a valid wireformat.
if (!GPBWireFormatIsValidTag(state->lastTag)) {
RaiseException(GPBCodedInputStreamErrorInvalidTag, @"Invalid wireformat in tag.");
RaiseException(GPBCodedInputStreamErrorInvalidTag,
@"Invalid wireformat in tag.");
}
// Zero is not a valid field number.
if (GPBWireFormatGetTagFieldNumber(state->lastTag) == 0) {
@@ -222,7 +226,8 @@ int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
return state->lastTag;
}
NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state) {
NSString *GPBCodedInputStreamReadRetainedString(
GPBCodedInputStreamState *state) {
int32_t size = ReadRawVarint32(state);
NSString *result;
if (size == 0) {
@@ -249,24 +254,28 @@ NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) {
int32_t size = ReadRawVarint32(state);
if (size < 0) return nil;
CheckSize(state, size);
NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos length:size];
NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos
length:size];
state->bufferPos += size;
return result;
}
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(GPBCodedInputStreamState *state) {
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(
GPBCodedInputStreamState *state) {
int32_t size = ReadRawVarint32(state);
if (size < 0) return nil;
CheckSize(state, size);
// Cast is safe because freeWhenDone is NO.
NSData *result = [[NSData alloc] initWithBytesNoCopy:(void *)(state->bytes + state->bufferPos)
length:size
freeWhenDone:NO];
NSData *result = [[NSData alloc]
initWithBytesNoCopy:(void *)(state->bytes + state->bufferPos)
length:size
freeWhenDone:NO];
state->bufferPos += size;
return result;
}
size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state, size_t byteLimit) {
size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state,
size_t byteLimit) {
byteLimit += state->bufferPos;
size_t oldLimit = state->currentLimit;
if (byteLimit > oldLimit) {
@@ -276,7 +285,8 @@ size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state, size_t byte
return oldLimit;
}
void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state, size_t oldLimit) {
void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state,
size_t oldLimit) {
state->currentLimit = oldLimit;
}
@@ -285,10 +295,12 @@ size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state) {
}
BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state) {
return (state->bufferPos == state->bufferSize) || (state->bufferPos == state->currentLimit);
return (state->bufferPos == state->bufferSize) ||
(state->bufferPos == state->currentLimit);
}
void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t value) {
void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
int32_t value) {
if (state->lastTag != value) {
RaiseException(GPBCodedInputStreamErrorInvalidTag, @"Unexpected tag read");
}
@@ -348,8 +360,8 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t
case GPBWireFormatStartGroup:
[self skipMessage];
GPBCodedInputStreamCheckLastTagWas(
&state_,
GPBWireFormatMakeTag(GPBWireFormatGetTagFieldNumber(tag), GPBWireFormatEndGroup));
&state_, GPBWireFormatMakeTag(GPBWireFormatGetTagFieldNumber(tag),
GPBWireFormatEndGroup));
return YES;
case GPBWireFormatEndGroup:
return NO;
@@ -422,26 +434,27 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t
- (void)readGroup:(int32_t)fieldNumber
message:(GPBMessage *)message
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
CheckRecursionLimit(&state_);
++state_.recursionDepth;
[message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
GPBCodedInputStreamCheckLastTagWas(&state_,
GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
GPBCodedInputStreamCheckLastTagWas(
&state_, GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
--state_.recursionDepth;
}
- (void)readUnknownGroup:(int32_t)fieldNumber message:(GPBUnknownFieldSet *)message {
- (void)readUnknownGroup:(int32_t)fieldNumber
message:(GPBUnknownFieldSet *)message {
CheckRecursionLimit(&state_);
++state_.recursionDepth;
[message mergeFromCodedInputStream:self];
GPBCodedInputStreamCheckLastTagWas(&state_,
GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
GPBCodedInputStreamCheckLastTagWas(
&state_, GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
--state_.recursionDepth;
}
- (void)readMessage:(GPBMessage *)message
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
CheckRecursionLimit(&state_);
int32_t length = ReadRawVarint32(&state_);
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
@@ -453,14 +466,15 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t
}
- (void)readMapEntry:(id)mapDictionary
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
field:(GPBFieldDescriptor *)field
parentMessage:(GPBMessage *)parentMessage {
CheckRecursionLimit(&state_);
int32_t length = ReadRawVarint32(&state_);
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
++state_.recursionDepth;
GPBDictionaryReadEntry(mapDictionary, self, extensionRegistry, field, parentMessage);
GPBDictionaryReadEntry(mapDictionary, self, extensionRegistry, field,
parentMessage);
GPBCodedInputStreamCheckLastTagWas(&state_, 0);
--state_.recursionDepth;
GPBCodedInputStreamPopLimit(&state_, oldLimit);

View File

@@ -61,15 +61,16 @@ typedef struct GPBCodedInputStreamState {
// support for older data.
- (void)readGroup:(int32_t)fieldNumber
message:(GPBMessage *)message
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
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;
- (void)readUnknownGroup:(int32_t)fieldNumber
message:(GPBUnknownFieldSet *)message;
// Reads a map entry.
- (void)readMapEntry:(id)mapDictionary
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
field:(GPBFieldDescriptor *)field
parentMessage:(GPBMessage *)parentMessage;
@end
@@ -96,13 +97,16 @@ NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state)
__attribute((ns_returns_retained));
NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state)
__attribute((ns_returns_retained));
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(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 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);
void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
int32_t value);
CF_EXTERN_C_END

View File

@@ -171,13 +171,13 @@ extern NSString *const GPBCodedOutputStreamException_WriteFailed;
* @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;
// Disable clang-format for the macros.
// clang-format off
- (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.
// clang-format off
/**
* Write a double for the given field number.
@@ -631,9 +631,8 @@ extern NSString *const GPBCodedOutputStreamException_WriteFailed;
- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
value:(GPBUnknownFieldSet *)value;
//%PDDM-EXPAND-END _WRITE_DECLS()
// clang-format on
//%PDDM-EXPAND-END _WRITE_DECLS()
/**
Write a MessageSet extension field to the stream. For historical reasons,
@@ -657,9 +656,6 @@ reasons, the wire format differs from normal fields.
NS_ASSUME_NONNULL_END
// Disable clang-format for the macros.
// clang-format off
// Write methods for types that can be in packed arrays.
//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
//%/**
@@ -759,5 +755,3 @@ NS_ASSUME_NONNULL_END
//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)
//%_WRITE_GROUP_DECLS(Group, GPBMessage)
//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet)
// clang-format on

View File

@@ -67,7 +67,8 @@ static void GPBRefreshBuffer(GPBOutputBufferState *state) {
[NSException raise:GPBCodedOutputStreamException_OutOfSpace format:@""];
}
if (state->position != 0) {
NSInteger written = [state->output write:state->bytes maxLength:state->position];
NSInteger written =
[state->output write:state->bytes maxLength:state->position];
if (written != (NSInteger)state->position) {
[NSException raise:GPBCodedOutputStreamException_WriteFailed format:@""];
}
@@ -117,24 +118,27 @@ static void GPBWriteInt32NoTag(GPBOutputBufferState *state, int32_t value) {
}
}
static void GPBWriteUInt32(GPBOutputBufferState *state, int32_t fieldNumber, uint32_t value) {
static void GPBWriteUInt32(GPBOutputBufferState *state, int32_t fieldNumber,
uint32_t value) {
GPBWriteTagWithFormat(state, fieldNumber, GPBWireFormatVarint);
GPBWriteRawVarint32(state, value);
}
static void GPBWriteTagWithFormat(GPBOutputBufferState *state, uint32_t fieldNumber,
GPBWireFormat format) {
static void GPBWriteTagWithFormat(GPBOutputBufferState *state,
uint32_t fieldNumber, GPBWireFormat format) {
GPBWriteRawVarint32(state, GPBWireFormatMakeTag(fieldNumber, format));
}
static void GPBWriteRawLittleEndian32(GPBOutputBufferState *state, int32_t value) {
static void GPBWriteRawLittleEndian32(GPBOutputBufferState *state,
int32_t value) {
GPBWriteRawByte(state, (value)&0xFF);
GPBWriteRawByte(state, (value >> 8) & 0xFF);
GPBWriteRawByte(state, (value >> 16) & 0xFF);
GPBWriteRawByte(state, (value >> 24) & 0xFF);
}
static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value) {
static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
int64_t value) {
GPBWriteRawByte(state, (int32_t)(value)&0xFF);
GPBWriteRawByte(state, (int32_t)(value >> 8) & 0xFF);
GPBWriteRawByte(state, (int32_t)(value >> 16) & 0xFF);
@@ -166,7 +170,8 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
// This initializer isn't exposed, but it is the designated initializer.
// Setting OutputStream and NSData is to control the buffering behavior/size
// of the work, but that is more obvious via the bufferSize: version.
- (instancetype)initWithOutputStream:(NSOutputStream *)output data:(NSMutableData *)data {
- (instancetype)initWithOutputStream:(NSOutputStream *)output
data:(NSMutableData *)data {
if ((self = [super init])) {
buffer_ = [data retain];
state_.bytes = [data mutableBytes];
@@ -179,7 +184,8 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output {
NSMutableData *data = [NSMutableData dataWithLength:PAGE_SIZE];
return [[[self alloc] initWithOutputStream:output data:data] autorelease];
return [[[self alloc] initWithOutputStream:output
data:data] autorelease];
}
+ (instancetype)streamWithData:(NSMutableData *)data {
@@ -271,7 +277,8 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
return;
}
const char *quickString = CFStringGetCStringPtr((CFStringRef)value, kCFStringEncodingUTF8);
const char *quickString =
CFStringGetCStringPtr((CFStringRef)value, kCFStringEncodingUTF8);
// Fast path: Most strings are short, if the buffer already has space,
// add to it directly.
@@ -293,8 +300,9 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
remainingRange:NULL];
}
if (result) {
NSAssert2((usedBufferLength == length), @"Our UTF8 calc was wrong? %tu vs %zd",
usedBufferLength, length);
NSAssert2((usedBufferLength == length),
@"Our UTF8 calc was wrong? %tu vs %zd", usedBufferLength,
length);
state_.position += usedBufferLength;
return;
}
@@ -303,8 +311,9 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
} else {
// Slow path: just get it as data and write it out.
NSData *utf8Data = [value dataUsingEncoding:NSUTF8StringEncoding];
NSAssert2(([utf8Data length] == length), @"Strings UTF8 length was wrong? %tu vs %zd",
[utf8Data length], length);
NSAssert2(([utf8Data length] == length),
@"Strings UTF8 length was wrong? %tu vs %zd", [utf8Data length],
length);
[self writeRawData:utf8Data];
}
}
@@ -324,12 +333,14 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
[self writeGroupNoTag:fieldNumber value:value];
}
- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber value:(const GPBUnknownFieldSet *)value {
- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
value:(const GPBUnknownFieldSet *)value {
[value writeToCodedOutputStream:self];
GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatEndGroup);
}
- (void)writeUnknownGroup:(int32_t)fieldNumber value:(GPBUnknownFieldSet *)value {
- (void)writeUnknownGroup:(int32_t)fieldNumber
value:(GPBUnknownFieldSet *)value {
GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatStartGroup);
[self writeUnknownGroupNoTag:fieldNumber value:value];
}
@@ -407,8 +418,6 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
GPBWriteRawVarint64(&state_, GPBEncodeZigZag64(value));
}
// clang-format off
//%PDDM-DEFINE WRITE_PACKABLE_DEFNS(NAME, ARRAY_TYPE, TYPE, ACCESSOR_NAME)
//%- (void)write##NAME##Array:(int32_t)fieldNumber
//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
@@ -416,16 +425,19 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
//% if (tag != 0) {
//% if (values.count == 0) return;
//% __block size_t dataSize = 0;
//% [values enumerate##ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, __unused NSUInteger idx,__unused BOOL *stop) {
//% [values enumerate##ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) {
//%#pragma unused(idx, stop)
//% dataSize += GPBCompute##NAME##SizeNoTag(value);
//% }];
//% GPBWriteRawVarint32(&state_, tag);
//% GPBWriteRawVarint32(&state_, (int32_t)dataSize);
//% [values enumerate##ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, __unused NSUInteger idx, __unused BOOL *stop) {
//% [values enumerate##ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) {
//%#pragma unused(idx, stop)
//% [self write##NAME##NoTag:value];
//% }];
//% } else {
//% [values enumerate##ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, __unused NSUInteger idx, __unused BOOL *stop) {
//% [values enumerate##ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) {
//%#pragma unused(idx, stop)
//% [self write##NAME:fieldNumber value:value];
//% }];
//% }
@@ -440,6 +452,7 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
//%
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Double, Double, double, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeDoubleArray:(int32_t)fieldNumber
values:(GPBDoubleArray *)values
@@ -447,23 +460,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(double value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(double value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeDoubleSizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(double value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(double value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeDoubleNoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(double value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(double value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeDouble:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Float, Float, float, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeFloatArray:(int32_t)fieldNumber
values:(GPBFloatArray *)values
@@ -471,23 +489,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(float value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(float value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeFloatSizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(float value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(float value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeFloatNoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(float value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(float value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeFloat:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(UInt64, UInt64, uint64_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeUInt64Array:(int32_t)fieldNumber
values:(GPBUInt64Array *)values
@@ -495,23 +518,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeUInt64SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeUInt64NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeUInt64:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Int64, Int64, int64_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeInt64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
@@ -519,23 +547,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(int64_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeInt64SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeInt64NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeInt64:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Int32, Int32, int32_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeInt32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
@@ -543,23 +576,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(int32_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeInt32SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeInt32NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeInt32:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(UInt32, UInt32, uint32_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeUInt32Array:(int32_t)fieldNumber
values:(GPBUInt32Array *)values
@@ -567,23 +605,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeUInt32SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeUInt32NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeUInt32:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Fixed64, UInt64, uint64_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeFixed64Array:(int32_t)fieldNumber
values:(GPBUInt64Array *)values
@@ -591,23 +634,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeFixed64SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeFixed64NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeFixed64:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Fixed32, UInt32, uint32_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeFixed32Array:(int32_t)fieldNumber
values:(GPBUInt32Array *)values
@@ -615,23 +663,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeFixed32SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeFixed32NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeFixed32:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(SInt32, Int32, int32_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeSInt32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
@@ -639,23 +692,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(int32_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeSInt32SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeSInt32NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeSInt32:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(SInt64, Int64, int64_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeSInt64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
@@ -663,23 +721,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(int64_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeSInt64SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeSInt64NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeSInt64:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(SFixed64, Int64, int64_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeSFixed64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
@@ -687,23 +750,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(int64_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeSFixed64SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeSFixed64NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeSFixed64:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(SFixed32, Int32, int32_t, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeSFixed32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
@@ -711,23 +779,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(int32_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeSFixed32SizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeSFixed32NoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeSFixed32:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Bool, Bool, BOOL, )
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeBoolArray:(int32_t)fieldNumber
values:(GPBBoolArray *)values
@@ -735,23 +808,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateValuesWithBlock:^(BOOL value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateValuesWithBlock:^(BOOL value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeBoolSizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateValuesWithBlock:^(BOOL value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(BOOL value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeBoolNoTag:value];
}];
} else {
[values enumerateValuesWithBlock:^(BOOL value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateValuesWithBlock:^(BOOL value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeBool:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Enum, Enum, int32_t, Raw)
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeEnumArray:(int32_t)fieldNumber
values:(GPBEnumArray *)values
@@ -759,23 +837,28 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
if (tag != 0) {
if (values.count == 0) return;
__block size_t dataSize = 0;
[values enumerateRawValuesWithBlock:^(int32_t value, __unused NSUInteger idx,__unused BOOL *stop) {
[values enumerateRawValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
dataSize += GPBComputeEnumSizeNoTag(value);
}];
GPBWriteRawVarint32(&state_, tag);
GPBWriteRawVarint32(&state_, (int32_t)dataSize);
[values enumerateRawValuesWithBlock:^(int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateRawValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeEnumNoTag:value];
}];
} else {
[values enumerateRawValuesWithBlock:^(int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[values enumerateRawValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[self writeEnum:fieldNumber value:value];
}];
}
}
// clang-format on
//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(String, NSString)
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeStringArray:(int32_t)fieldNumber values:(NSArray *)values {
for (NSString *value in values) {
@@ -783,8 +866,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
}
}
// clang-format on
//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(Message, GPBMessage)
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray *)values {
for (GPBMessage *value in values) {
@@ -792,8 +877,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
}
}
// clang-format on
//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(Bytes, NSData)
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray *)values {
for (NSData *value in values) {
@@ -801,8 +888,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
}
}
// clang-format on
//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(Group, GPBMessage)
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray *)values {
for (GPBMessage *value in values) {
@@ -810,8 +899,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
}
}
// clang-format on
//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(UnknownGroup, GPBUnknownFieldSet)
// This block of code is generated, do not edit it directly.
// clang-format off
- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray *)values {
for (GPBUnknownFieldSet *value in values) {
@@ -819,22 +910,26 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
}
}
// clang-format on
//%PDDM-EXPAND-END (19 expansions)
// clang-format on
- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value {
GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem, GPBWireFormatStartGroup);
- (void)writeMessageSetExtension:(int32_t)fieldNumber
value:(GPBMessage *)value {
GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem,
GPBWireFormatStartGroup);
GPBWriteUInt32(&state_, GPBWireFormatMessageSetTypeId, fieldNumber);
[self writeMessage:GPBWireFormatMessageSetMessage value:value];
GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem, GPBWireFormatEndGroup);
GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem,
GPBWireFormatEndGroup);
}
- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value {
GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem, GPBWireFormatStartGroup);
GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem,
GPBWireFormatStartGroup);
GPBWriteUInt32(&state_, GPBWireFormatMessageSetTypeId, fieldNumber);
[self writeBytes:GPBWireFormatMessageSetMessage value:value];
GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem, GPBWireFormatEndGroup);
GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem,
GPBWireFormatEndGroup);
}
- (void)flush {
@@ -851,7 +946,9 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
[self writeRawPtr:[data bytes] offset:0 length:[data length]];
}
- (void)writeRawPtr:(const void *)value offset:(size_t)offset length:(size_t)length {
- (void)writeRawPtr:(const void *)value
offset:(size_t)offset
length:(size_t)length {
if (value == nil || length == 0) {
return;
}
@@ -866,7 +963,8 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
// Write extends past current buffer. Fill the rest of this buffer and
// flush.
size_t bytesWritten = bufferBytesLeft;
memcpy(state_.bytes + state_.position, ((uint8_t *)value) + offset, bytesWritten);
memcpy(state_.bytes + state_.position, ((uint8_t *)value) + offset,
bytesWritten);
offset += bytesWritten;
length -= bytesWritten;
state_.position = bufferLength;
@@ -919,13 +1017,23 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
@end
size_t GPBComputeDoubleSizeNoTag(__unused Float64 value) { return LITTLE_ENDIAN_64_SIZE; }
size_t GPBComputeDoubleSizeNoTag(Float64 value) {
#pragma unused(value)
return LITTLE_ENDIAN_64_SIZE;
}
size_t GPBComputeFloatSizeNoTag(__unused Float32 value) { return LITTLE_ENDIAN_32_SIZE; }
size_t GPBComputeFloatSizeNoTag(Float32 value) {
#pragma unused(value)
return LITTLE_ENDIAN_32_SIZE;
}
size_t GPBComputeUInt64SizeNoTag(uint64_t value) { return GPBComputeRawVarint64Size(value); }
size_t GPBComputeUInt64SizeNoTag(uint64_t value) {
return GPBComputeRawVarint64Size(value);
}
size_t GPBComputeInt64SizeNoTag(int64_t value) { return GPBComputeRawVarint64Size(value); }
size_t GPBComputeInt64SizeNoTag(int64_t value) {
return GPBComputeRawVarint64Size(value);
}
size_t GPBComputeInt32SizeNoTag(int32_t value) {
if (value >= 0) {
@@ -940,20 +1048,33 @@ size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) {
return GPBComputeInt32SizeNoTag((int32_t)value);
}
size_t GPBComputeFixed64SizeNoTag(__unused uint64_t value) { return LITTLE_ENDIAN_64_SIZE; }
size_t GPBComputeFixed64SizeNoTag(uint64_t value) {
#pragma unused(value)
return LITTLE_ENDIAN_64_SIZE;
}
size_t GPBComputeFixed32SizeNoTag(__unused uint32_t value) { return LITTLE_ENDIAN_32_SIZE; }
size_t GPBComputeFixed32SizeNoTag(uint32_t value) {
#pragma unused(value)
return LITTLE_ENDIAN_32_SIZE;
}
size_t GPBComputeBoolSizeNoTag(__unused BOOL value) { return 1; }
size_t GPBComputeBoolSizeNoTag(BOOL value) {
#pragma unused(value)
return 1;
}
size_t GPBComputeStringSizeNoTag(NSString *value) {
NSUInteger length = [value lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
return GPBComputeRawVarint32SizeForInteger(length) + length;
}
size_t GPBComputeGroupSizeNoTag(GPBMessage *value) { return [value serializedSize]; }
size_t GPBComputeGroupSizeNoTag(GPBMessage *value) {
return [value serializedSize];
}
size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) { return value.serializedSize; }
size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) {
return value.serializedSize;
}
size_t GPBComputeMessageSizeNoTag(GPBMessage *value) {
size_t size = [value serializedSize];
@@ -965,13 +1086,23 @@ size_t GPBComputeBytesSizeNoTag(NSData *value) {
return GPBComputeRawVarint32SizeForInteger(valueLength) + valueLength;
}
size_t GPBComputeUInt32SizeNoTag(int32_t value) { return GPBComputeRawVarint32Size(value); }
size_t GPBComputeUInt32SizeNoTag(int32_t value) {
return GPBComputeRawVarint32Size(value);
}
size_t GPBComputeEnumSizeNoTag(int32_t value) { return GPBComputeInt32SizeNoTag(value); }
size_t GPBComputeEnumSizeNoTag(int32_t value) {
return GPBComputeInt32SizeNoTag(value);
}
size_t GPBComputeSFixed32SizeNoTag(__unused int32_t value) { return LITTLE_ENDIAN_32_SIZE; }
size_t GPBComputeSFixed32SizeNoTag(int32_t value) {
#pragma unused(value)
return LITTLE_ENDIAN_32_SIZE;
}
size_t GPBComputeSFixed64SizeNoTag(__unused int64_t value) { return LITTLE_ENDIAN_64_SIZE; }
size_t GPBComputeSFixed64SizeNoTag(int64_t value) {
#pragma unused(value)
return LITTLE_ENDIAN_64_SIZE;
}
size_t GPBComputeSInt32SizeNoTag(int32_t value) {
return GPBComputeRawVarint32Size(GPBEncodeZigZag32(value));
@@ -1021,8 +1152,10 @@ size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value) {
return GPBComputeTagSize(fieldNumber) * 2 + GPBComputeGroupSizeNoTag(value);
}
size_t GPBComputeUnknownGroupSize(int32_t fieldNumber, GPBUnknownFieldSet *value) {
return GPBComputeTagSize(fieldNumber) * 2 + GPBComputeUnknownGroupSizeNoTag(value);
size_t GPBComputeUnknownGroupSize(int32_t fieldNumber,
GPBUnknownFieldSet *value) {
return GPBComputeTagSize(fieldNumber) * 2 +
GPBComputeUnknownGroupSizeNoTag(value);
}
size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value) {
@@ -1054,23 +1187,27 @@ size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value) {
}
size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value) {
return GPBComputeTagSize(fieldNumber) + GPBComputeRawVarint64Size(GPBEncodeZigZag64(value));
return GPBComputeTagSize(fieldNumber) +
GPBComputeRawVarint64Size(GPBEncodeZigZag64(value));
}
size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value) {
size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber,
GPBMessage *value) {
return GPBComputeTagSize(GPBWireFormatMessageSetItem) * 2 +
GPBComputeUInt32Size(GPBWireFormatMessageSetTypeId, fieldNumber) +
GPBComputeMessageSize(GPBWireFormatMessageSetMessage, value);
}
size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value) {
size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber,
NSData *value) {
return GPBComputeTagSize(GPBWireFormatMessageSetItem) * 2 +
GPBComputeUInt32Size(GPBWireFormatMessageSetTypeId, fieldNumber) +
GPBComputeBytesSize(GPBWireFormatMessageSetMessage, value);
}
size_t GPBComputeTagSize(int32_t fieldNumber) {
return GPBComputeRawVarint32Size(GPBWireFormatMakeTag(fieldNumber, GPBWireFormatVarint));
return GPBComputeRawVarint32Size(
GPBWireFormatMakeTag(fieldNumber, GPBWireFormatVarint));
}
size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType) {

View File

@@ -34,27 +34,46 @@ 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)
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 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 GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType)
__attribute__((const));
size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const));
size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const));
@@ -66,7 +85,8 @@ 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 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));
@@ -83,7 +103,8 @@ 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));
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,
@@ -97,7 +118,8 @@ size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value)
size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value)
__attribute__((const));
size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value) __attribute__((const));
size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value)
__attribute__((const));
CF_EXTERN_C_END

View File

@@ -62,14 +62,14 @@ typedef NS_ENUM(uint8_t, GPBFieldType) {
/**
* Describes a proto message.
**/
@interface GPBDescriptor : NSObject <NSCopying>
@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;
@property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor*> *fields;
/** Oneofs declared in the message. */
@property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor *> *oneofs;
@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. */
@@ -139,7 +139,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) {
/** Name of the oneof field. */
@property(nonatomic, readonly) NSString *name;
/** Fields declared in the oneof. */
@property(nonatomic, readonly) NSArray<GPBFieldDescriptor *> *fields;
@property(nonatomic, readonly) NSArray<GPBFieldDescriptor*> *fields;
/**
* Gets the field for the given number.
@@ -293,7 +293,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) {
/**
* Describes a proto extension.
**/
@interface GPBExtensionDescriptor : NSObject <NSCopying>
@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. */

View File

@@ -32,9 +32,9 @@
#import <objc/runtime.h>
#import "GPBMessage_PackagePrivate.h"
#import "GPBUtilities_PackagePrivate.h"
#import "GPBWireFormat.h"
#import "GPBMessage_PackagePrivate.h"
// 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
@@ -48,15 +48,16 @@ static const char kParentClassValueKey = 0;
static const char kClassNameSuffixKey = 0;
// Utility function to generate selectors on the fly.
static SEL SelFromStrings(const char *prefix, const char *middle, const char *suffix,
BOOL takesArg) {
static SEL SelFromStrings(const char *prefix, const char *middle,
const char *suffix, BOOL takesArg) {
if (prefix == NULL && suffix == NULL && !takesArg) {
return sel_getUid(middle);
}
const size_t prefixLen = prefix != NULL ? strlen(prefix) : 0;
const size_t middleLen = strlen(middle);
const size_t suffixLen = suffix != NULL ? strlen(suffix) : 0;
size_t totalLen = prefixLen + middleLen + suffixLen + 1; // include space for null on end.
size_t totalLen =
prefixLen + middleLen + suffixLen + 1; // include space for null on end.
if (takesArg) {
totalLen += 1;
}
@@ -81,10 +82,12 @@ static SEL SelFromStrings(const char *prefix, const char *middle, const char *su
return result;
}
static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageFields)
static NSArray *NewFieldsArrayForHasIndex(int hasIndex,
NSArray *allMessageFields)
__attribute__((ns_returns_retained));
static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageFields) {
static NSArray *NewFieldsArrayForHasIndex(int hasIndex,
NSArray *allMessageFields) {
NSMutableArray *result = [[NSMutableArray alloc] init];
for (GPBFieldDescriptor *fieldDesc in allMessageFields) {
if (fieldDesc->description_->hasIndex == hasIndex) {
@@ -108,21 +111,25 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
@synthesize file = file_;
@synthesize wireFormat = wireFormat_;
+ (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)
allocDescriptorForClass:(Class)messageClass
rootClass:(Class)rootClass
file:(GPBFileDescriptor *)file
fields:(void *)fieldDescriptions
fieldCount:(uint32_t)fieldCount
storageSize:(uint32_t)storageSize
flags:(GPBDescriptorInitializationFlags)flags {
// The rootClass is no longer used, but it is passed in to ensure it
// was started up during initialization also.
(void)rootClass;
NSMutableArray *fields = nil;
GPBFileSyntax syntax = file.syntax;
BOOL fieldsIncludeDefault = (flags & GPBDescriptorInitializationFlag_FieldsWithDefault) != 0;
BOOL usesClassRefs = (flags & GPBDescriptorInitializationFlag_UsesClassRefs) != 0;
BOOL proto3OptionalKnown = (flags & GPBDescriptorInitializationFlag_Proto3OptionalKnown) != 0;
BOOL fieldsIncludeDefault =
(flags & GPBDescriptorInitializationFlag_FieldsWithDefault) != 0;
BOOL usesClassRefs =
(flags & GPBDescriptorInitializationFlag_UsesClassRefs) != 0;
BOOL proto3OptionalKnown =
(flags & GPBDescriptorInitializationFlag_Proto3OptionalKnown) != 0;
void *desc;
for (uint32_t i = 0; i < fieldCount; ++i) {
@@ -186,9 +193,10 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
for (uint32_t i = 0, hasIndex = firstHasIndex; i < count; ++i, --hasIndex) {
const char *name = oneofNames[i];
NSArray *fieldsForOneof = NewFieldsArrayForHasIndex(hasIndex, fields_);
NSCAssert(fieldsForOneof.count > 0, @"No fields for this oneof? (%s:%d)", name, hasIndex);
GPBOneofDescriptor *oneofDescriptor = [[GPBOneofDescriptor alloc] initWithName:name
fields:fieldsForOneof];
NSCAssert(fieldsForOneof.count > 0,
@"No fields for this oneof? (%s:%d)", name, hasIndex);
GPBOneofDescriptor *oneofDescriptor =
[[GPBOneofDescriptor alloc] initWithName:name fields:fieldsForOneof];
[oneofs addObject:oneofDescriptor];
[oneofDescriptor release];
[fieldsForOneof release];
@@ -202,7 +210,8 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
NSValue *extraInfoValue = [NSValue valueWithPointer:extraTextFormatInfo];
for (GPBFieldDescriptor *fieldDescriptor in fields_) {
if (fieldDescriptor->description_->flags & GPBFieldTextFormatNameCustom) {
objc_setAssociatedObject(fieldDescriptor, &kTextFormatExtraValueKey, extraInfoValue,
objc_setAssociatedObject(fieldDescriptor, &kTextFormatExtraValueKey,
extraInfoValue,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
}
@@ -215,7 +224,9 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
}
- (void)setupContainingMessageClass:(Class)messageClass {
objc_setAssociatedObject(self, &kParentClassValueKey, messageClass, OBJC_ASSOCIATION_ASSIGN);
objc_setAssociatedObject(self, &kParentClassValueKey,
messageClass,
OBJC_ASSOCIATION_ASSIGN);
}
- (void)setupContainingMessageClassName:(const char *)msgClassName {
@@ -229,7 +240,9 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
- (void)setupMessageClassNameSuffix:(NSString *)suffix {
if (suffix.length) {
objc_setAssociatedObject(self, &kClassNameSuffixKey, suffix, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
objc_setAssociatedObject(self, &kClassNameSuffixKey,
suffix,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
}
@@ -247,7 +260,9 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
GPBFileDescriptor *file = self.file;
NSString *objcPrefix = file.objcPrefix;
if (objcPrefix && ![className hasPrefix:objcPrefix]) {
NSAssert(0, @"Class didn't have correct prefix? (%@ - %@)", className, objcPrefix);
NSAssert(0,
@"Class didn't have correct prefix? (%@ - %@)",
className, objcPrefix);
return nil;
}
GPBDescriptor *parent = self.containingType;
@@ -259,16 +274,19 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
NSString *suffix = objc_getAssociatedObject(parent, &kClassNameSuffixKey);
if (suffix) {
if (![parentClassName hasSuffix:suffix]) {
NSAssert(0, @"ParentMessage class didn't have correct suffix? (%@ - %@)", className,
suffix);
NSAssert(0,
@"ParentMessage class didn't have correct suffix? (%@ - %@)",
className, suffix);
return nil;
}
parentClassName = [parentClassName substringToIndex:(parentClassName.length - suffix.length)];
parentClassName =
[parentClassName substringToIndex:(parentClassName.length - suffix.length)];
}
NSString *parentPrefix = [parentClassName stringByAppendingString:@"_"];
if (![className hasPrefix:parentPrefix]) {
NSAssert(0, @"Class didn't have the correct parent name prefix? (%@ - %@)", parentPrefix,
className);
NSAssert(0,
@"Class didn't have the correct parent name prefix? (%@ - %@)",
parentPrefix, className);
return nil;
}
name = [className substringFromIndex:parentPrefix.length];
@@ -280,7 +298,9 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
NSString *suffix = objc_getAssociatedObject(self, &kClassNameSuffixKey);
if (suffix) {
if (![name hasSuffix:suffix]) {
NSAssert(0, @"Message class didn't have correct suffix? (%@ - %@)", name, suffix);
NSAssert(0,
@"Message class didn't have correct suffix? (%@ - %@)",
name, suffix);
return nil;
}
name = [name substringToIndex:(name.length - suffix.length)];
@@ -296,7 +316,8 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
return result;
}
- (id)copyWithZone:(__unused NSZone *)zone {
- (id)copyWithZone:(NSZone *)zone {
#pragma unused(zone)
return [self retain];
}
@@ -351,7 +372,8 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
return self;
}
- (instancetype)initWithPackage:(NSString *)package syntax:(GPBFileSyntax)syntax {
- (instancetype)initWithPackage:(NSString *)package
syntax:(GPBFileSyntax)syntax {
self = [super init];
if (self) {
package_ = [package copy];
@@ -392,7 +414,7 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
}
- (NSString *)name {
return (NSString *_Nonnull)@(name_);
return (NSString * _Nonnull)@(name_);
}
- (GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber {
@@ -422,17 +444,19 @@ uint32_t GPBFieldTag(GPBFieldDescriptor *self) {
// Maps are repeated messages on the wire.
format = GPBWireFormatForType(GPBDataTypeMessage, NO);
} else {
format =
GPBWireFormatForType(description->dataType, ((description->flags & GPBFieldPacked) != 0));
format = GPBWireFormatForType(description->dataType,
((description->flags & GPBFieldPacked) != 0));
}
return GPBWireFormatMakeTag(description->number, format);
}
uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
GPBMessageFieldDescription *description = self->description_;
NSCAssert((description->flags & GPBFieldRepeated) != 0, @"Only valid on repeated fields");
NSCAssert((description->flags & GPBFieldRepeated) != 0,
@"Only valid on repeated fields");
GPBWireFormat format =
GPBWireFormatForType(description->dataType, ((description->flags & GPBFieldPacked) == 0));
GPBWireFormatForType(description->dataType,
((description->flags & GPBFieldPacked) == 0));
return GPBWireFormatMakeTag(description->number, format);
}
@@ -492,8 +516,10 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
// - not repeated/map
// - not in a oneof (negative has index)
// - not a message (the flag doesn't make sense for messages)
BOOL clearOnZero = ((syntax == GPBFileSyntaxProto3) && !isMapOrArray &&
(coreDesc->hasIndex >= 0) && !isMessage);
BOOL clearOnZero = ((syntax == GPBFileSyntaxProto3) &&
!isMapOrArray &&
(coreDesc->hasIndex >= 0) &&
!isMessage);
if (clearOnZero) {
coreDesc->flags |= GPBFieldClearHasIvarOnZero;
}
@@ -508,7 +534,8 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
// It is a single field; it gets has/setHas selectors if...
// - not in a oneof (negative has index)
// - not clearing on zero
if ((coreDesc->hasIndex >= 0) && ((coreDesc->flags & GPBFieldClearHasIvarOnZero) == 0)) {
if ((coreDesc->hasIndex >= 0) &&
((coreDesc->flags & GPBFieldClearHasIvarOnZero) == 0)) {
hasOrCountSel_ = SelFromStrings("has", coreDesc->name, NULL, NO);
setHasSel_ = SelFromStrings("setHas", coreDesc->name, NULL, YES);
}
@@ -529,9 +556,11 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
} else if (dataType == GPBDataTypeEnum) {
if ((coreDesc->flags & GPBFieldHasEnumDescriptor) != 0) {
enumHandling_.enumDescriptor_ = coreDesc->dataTypeSpecific.enumDescFunc();
enumHandling_.enumDescriptor_ =
coreDesc->dataTypeSpecific.enumDescFunc();
} else {
enumHandling_.enumVerifier_ = coreDesc->dataTypeSpecific.enumVerifier;
enumHandling_.enumVerifier_ =
coreDesc->dataTypeSpecific.enumVerifier;
}
}
@@ -547,7 +576,8 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
memcpy(&length, bytes, sizeof(length));
length = ntohl(length);
bytes += sizeof(length);
defaultValue_.valueData = [[NSData alloc] initWithBytes:bytes length:length];
defaultValue_.valueData =
[[NSData alloc] initWithBytes:bytes length:length];
}
}
}
@@ -556,7 +586,8 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
- (void)dealloc {
if (description_->dataType == GPBDataTypeBytes && !(description_->flags & GPBFieldRepeated)) {
if (description_->dataType == GPBDataTypeBytes &&
!(description_->flags & GPBFieldRepeated)) {
[defaultValue_.valueData release];
}
[super dealloc];
@@ -575,7 +606,7 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
- (NSString *)name {
return (NSString *_Nonnull)@(description_->name);
return (NSString * _Nonnull)@(description_->name);
}
- (BOOL)isRequired {
@@ -635,7 +666,8 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
- (BOOL)isValidEnumValue:(int32_t)value {
NSAssert(description_->dataType == GPBDataTypeEnum, @"Field Must be of type GPBDataTypeEnum");
NSAssert(description_->dataType == GPBDataTypeEnum,
@"Field Must be of type GPBDataTypeEnum");
if (description_->flags & GPBFieldHasEnumDescriptor) {
return enumHandling_.enumDescriptor_.enumVerifier(value);
} else {
@@ -671,17 +703,19 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
- (NSString *)textFormatName {
if ((description_->flags & GPBFieldTextFormatNameCustom) != 0) {
NSValue *extraInfoValue = objc_getAssociatedObject(self, &kTextFormatExtraValueKey);
NSValue *extraInfoValue =
objc_getAssociatedObject(self, &kTextFormatExtraValueKey);
// Support can be left out at generation time.
if (!extraInfoValue) {
return nil;
}
const uint8_t *extraTextFormatInfo = [extraInfoValue pointerValue];
return GPBDecodeTextFormatName(extraTextFormatInfo, GPBFieldNumber(self), self.name);
return GPBDecodeTextFormatName(extraTextFormatInfo, GPBFieldNumber(self),
self.name);
}
// The logic here has to match SetCommonFieldVariables() from
// objectivec/field.cc in the proto compiler.
// objectivec_field.cc in the proto compiler.
NSString *name = self.name;
NSUInteger len = [name length];
@@ -692,7 +726,8 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
// Remove "Array" from the end for repeated fields.
if (((description_->flags & GPBFieldRepeated) != 0) && [name hasSuffix:@"Array"]) {
if (((description_->flags & GPBFieldRepeated) != 0) &&
[name hasSuffix:@"Array"]) {
name = [name substringToIndex:(len - 5)];
len = [name length];
}
@@ -704,8 +739,9 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
if (firstChar >= 'a' && firstChar <= 'z') {
NSString *firstCharString =
[NSString stringWithFormat:@"%C", (unichar)(firstChar - 'a' + 'A')];
NSString *result = [name stringByReplacingCharactersInRange:NSMakeRange(0, 1)
withString:firstCharString];
NSString *result =
[name stringByReplacingCharactersInRange:NSMakeRange(0, 1)
withString:firstCharString];
return result;
}
return name;
@@ -748,11 +784,12 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
@synthesize name = name_;
@synthesize enumVerifier = enumVerifier_;
+ (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 {
GPBEnumDescriptor *descriptor = [[self alloc] initWithName:name
valueNames:valueNames
values:values
@@ -761,12 +798,13 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
return descriptor;
}
+ (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)
allocDescriptorForName:(NSString *)name
valueNames:(const char *)valueNames
values:(const int32_t *)values
count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier
extraTextFormatInfo:(const char *)extraTextFormatInfo {
// Call the common case.
GPBEnumDescriptor *descriptor = [self allocDescriptorForName:name
valueNames:valueNames
@@ -854,26 +892,27 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
- (BOOL)getValue:(int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName {
if (nameOffsets_ == NULL) [self calcValueNameOffsets];
if (nameOffsets_ == NULL) return NO;
if (nameOffsets_ == NULL) [self calcValueNameOffsets];
if (nameOffsets_ == NULL) return NO;
for (uint32_t i = 0; i < valueCount_; ++i) {
NSString *valueTextFormatName = [self getEnumTextFormatNameForIndex:i];
if ([valueTextFormatName isEqual:textFormatName]) {
if (outValue) {
*outValue = values_[i];
}
return YES;
for (uint32_t i = 0; i < valueCount_; ++i) {
NSString *valueTextFormatName = [self getEnumTextFormatNameForIndex:i];
if ([valueTextFormatName isEqual:textFormatName]) {
if (outValue) {
*outValue = values_[i];
}
return YES;
}
}
}
return NO;
return NO;
}
- (NSString *)textFormatNameForValue:(int32_t)number {
// Find the EnumValue descriptor and its index.
BOOL foundIt = NO;
uint32_t valueDescriptorIndex;
for (valueDescriptorIndex = 0; valueDescriptorIndex < valueCount_; ++valueDescriptorIndex) {
for (valueDescriptorIndex = 0; valueDescriptorIndex < valueCount_;
++valueDescriptorIndex) {
if (values_[valueDescriptorIndex] == number) {
foundIt = YES;
break;
@@ -916,9 +955,10 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
// See if it is in the map of special format handling.
if (extraTextFormatInfo_) {
result = GPBDecodeTextFormatName(extraTextFormatInfo_, (int32_t)index, shortName);
result = GPBDecodeTextFormatName(extraTextFormatInfo_,
(int32_t)index, shortName);
}
// Logic here needs to match what objectivec/enum.cc does in the proto
// Logic here needs to match what objectivec_enum.cc does in the proto
// compiler.
if (result == nil) {
NSUInteger len = [shortName length];
@@ -965,14 +1005,16 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
GPBDataType type = description_->dataType;
if (type == GPBDataTypeBytes) {
// Data stored as a length prefixed c-string in descriptor records.
const uint8_t *bytes = (const uint8_t *)description_->defaultValue.valueData;
const uint8_t *bytes =
(const uint8_t *)description_->defaultValue.valueData;
if (bytes) {
uint32_t length;
memcpy(&length, bytes, sizeof(length));
// The length is stored in network byte order.
length = ntohl(length);
bytes += sizeof(length);
defaultValue_.valueData = [[NSData alloc] initWithBytes:bytes length:length];
defaultValue_.valueData =
[[NSData alloc] initWithBytes:bytes length:length];
}
} else if (type == GPBDataTypeMessage || type == GPBDataTypeGroup) {
// The default is looked up in -defaultValue instead since extensions
@@ -990,19 +1032,21 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
- (void)dealloc {
if ((description_->dataType == GPBDataTypeBytes) && !GPBExtensionIsRepeated(description_)) {
if ((description_->dataType == GPBDataTypeBytes) &&
!GPBExtensionIsRepeated(description_)) {
[defaultValue_.valueData release];
}
[super dealloc];
}
- (instancetype)copyWithZone:(__unused NSZone *)zone {
- (instancetype)copyWithZone:(NSZone *)zone {
#pragma unused(zone)
// Immutable.
return [self retain];
}
- (NSString *)singletonName {
return (NSString *_Nonnull)@(description_->singletonName);
return (NSString * _Nonnull)@(description_->singletonName);
}
- (const char *)singletonNameC {
@@ -1018,12 +1062,15 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
- (GPBWireFormat)wireType {
return GPBWireFormatForType(description_->dataType, GPBExtensionIsPacked(description_));
return GPBWireFormatForType(description_->dataType,
GPBExtensionIsPacked(description_));
}
- (GPBWireFormat)alternateWireType {
NSAssert(GPBExtensionIsRepeated(description_), @"Only valid on repeated extensions");
return GPBWireFormatForType(description_->dataType, !GPBExtensionIsPacked(description_));
NSAssert(GPBExtensionIsRepeated(description_),
@"Only valid on repeated extensions");
return GPBWireFormatForType(description_->dataType,
!GPBExtensionIsPacked(description_));
}
- (BOOL)isRepeated {
@@ -1079,7 +1126,8 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
return @(defaultValue_.valueUInt64);
case GPBDataTypeBytes:
// Like message fields, the default is zero length data.
return (defaultValue_.valueData ? defaultValue_.valueData : GPBEmptyNSData());
return (defaultValue_.valueData ? defaultValue_.valueData
: GPBEmptyNSData());
case GPBDataTypeString:
// Like message fields, the default is zero length string.
return (defaultValue_.valueString ? defaultValue_.valueString : @"");

View File

@@ -37,12 +37,12 @@
// Describes attributes of the field.
typedef NS_OPTIONS(uint16_t, GPBFieldFlags) {
GPBFieldNone = 0,
GPBFieldNone = 0,
// These map to standard protobuf concepts.
GPBFieldRequired = 1 << 0,
GPBFieldRepeated = 1 << 1,
GPBFieldPacked = 1 << 2,
GPBFieldOptional = 1 << 3,
GPBFieldRequired = 1 << 0,
GPBFieldRepeated = 1 << 1,
GPBFieldPacked = 1 << 2,
GPBFieldOptional = 1 << 3,
GPBFieldHasDefaultValue = 1 << 4,
// Indicate that the field should "clear" when set to zero value. This is the
@@ -60,19 +60,19 @@ typedef NS_OPTIONS(uint16_t, GPBFieldFlags) {
// 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,
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,
GPBFieldMapKeyBool = 11 << 8,
GPBFieldMapKeyString = 12 << 8,
};
// NOTE: The structures defined here have their members ordered to minimize
@@ -88,7 +88,7 @@ typedef struct GPBMessageFieldDescription {
// kept around right now for backwards compatibility.
// clazz is used iff GPBDescriptorInitializationFlag_UsesClassRefs is set.
char *className; // Name of the class of the message.
Class clazz; // Class of the message.
Class clazz; // Class of the message.
// For enums only: If EnumDescriptors are compiled in, it will be that,
// otherwise it will be the verifier.
GPBEnumDescriptorFunc enumDescFunc;
@@ -120,10 +120,10 @@ typedef struct GPBMessageFieldDescriptionWithDefault {
// Describes attributes of the extension.
typedef NS_OPTIONS(uint8_t, GPBExtensionOptions) {
GPBExtensionNone = 0,
GPBExtensionNone = 0,
// These map to standard protobuf concepts.
GPBExtensionRepeated = 1 << 0,
GPBExtensionPacked = 1 << 1,
GPBExtensionRepeated = 1 << 0,
GPBExtensionPacked = 1 << 1,
GPBExtensionSetWireFormat = 1 << 2,
};
@@ -132,10 +132,10 @@ typedef struct GPBExtensionDescription {
GPBGenericValue defaultValue;
const char *singletonName;
// Before 3.12, `extendedClass` was just a `const char *`. Thanks to nested
// initialization
// (https://en.cppreference.com/w/c/language/struct_initialization#Nested_initialization) old
// generated code with `.extendedClass = GPBStringifySymbol(Something)` still works; and the
// current generator can use `extendedClass.clazz`, to pass a Class reference.
// initialization (https://en.cppreference.com/w/c/language/struct_initialization#Nested_initialization)
// old generated code with `.extendedClass = GPBStringifySymbol(Something)`
// still works; and the current generator can use `extendedClass.clazz`, to
// pass a Class reference.
union {
const char *name;
Class clazz;
@@ -150,9 +150,9 @@ typedef struct GPBExtensionDescription {
union {
const char *messageOrGroupClassName;
union {
const char *name;
Class clazz;
} messageOrGroupClass;
const char *name;
Class clazz;
} messageOrGroupClass;
};
GPBEnumDescriptorFunc enumDescriptorFunc;
int32_t fieldNumber;
@@ -161,14 +161,14 @@ typedef struct GPBExtensionDescription {
} GPBExtensionDescription;
typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
GPBDescriptorInitializationFlag_None = 0,
GPBDescriptorInitializationFlag_None = 0,
GPBDescriptorInitializationFlag_FieldsWithDefault = 1 << 0,
GPBDescriptorInitializationFlag_WireFormat = 1 << 1,
GPBDescriptorInitializationFlag_WireFormat = 1 << 1,
// This is used as a stopgap as we move from using class names to class
// references. The runtime needs to support both until we allow a
// breaking change in the runtime.
GPBDescriptorInitializationFlag_UsesClassRefs = 1 << 2,
GPBDescriptorInitializationFlag_UsesClassRefs = 1 << 2,
// This flag is used to indicate that the generated sources already contain
// the `GPBFieldClearHasIvarOnZero` flag and it doesn't have to be computed
@@ -185,13 +185,14 @@ typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
}
// 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)
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
@@ -219,7 +220,8 @@ typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
- (instancetype)initWithPackage:(NSString *)package
objcPrefix:(NSString *)objcPrefix
syntax:(GPBFileSyntax)syntax;
- (instancetype)initWithPackage:(NSString *)package syntax:(GPBFileSyntax)syntax;
- (instancetype)initWithPackage:(NSString *)package
syntax:(GPBFileSyntax)syntax;
@end
@interface GPBOneofDescriptor () {
@@ -256,17 +258,19 @@ typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
@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)
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
@@ -305,7 +309,8 @@ CF_EXTERN_C_BEGIN
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
GPB_INLINE BOOL GPBFieldIsMapOrArray(GPBFieldDescriptor *field) {
return (field->description_->flags & (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0;
return (field->description_->flags &
(GPBFieldRepeated | GPBFieldMapKeyMask)) != 0;
}
GPB_INLINE GPBDataType GPBGetFieldDataType(GPBFieldDescriptor *field) {
@@ -348,13 +353,22 @@ GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) {
// Helper for compile time assets.
#ifndef GPBInternalCompileAssert
#define GPBInternalCompileAssert(test, msg) _Static_assert((test), #msg)
#endif // 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)),
(sizeof(GPBGenericValue) +
sizeof(GPBMessageFieldDescription)),
DescriptionsWithDefault_different_size_than_expected);
CF_EXTERN_C_END

View File

@@ -43,11 +43,9 @@
NS_ASSUME_NONNULL_BEGIN
// Disable clang-format for the macros.
// clang-format off
//%PDDM-EXPAND DECLARE_DICTIONARIES()
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - UInt32 -> UInt32
@@ -5481,6 +5479,7 @@ NS_ASSUME_NONNULL_BEGIN
@end
// clang-format on
//%PDDM-EXPAND-END DECLARE_DICTIONARIES()
NS_ASSUME_NONNULL_END
@@ -5771,5 +5770,3 @@ NS_ASSUME_NONNULL_END
//% **/
//%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
//%
// clang-format on

File diff suppressed because it is too large Load Diff

View File

@@ -34,20 +34,18 @@
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@protocol GPBExtensionRegistry;
@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)setGPBGenericValue:(GPBGenericValue *)value
forGPBGenericValueKey:(GPBGenericValue *)key;
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block;
@end
// Disable clang-format for the macros.
// clang-format off
//%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)
@@ -84,6 +82,7 @@
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(UInt32)
// This block of code is generated, do not edit it directly.
// clang-format off
@interface GPBUInt32UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
@@ -145,8 +144,10 @@
__attribute__((ns_returns_retained));
@end
// clang-format on
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Int32)
// This block of code is generated, do not edit it directly.
// clang-format off
@interface GPBInt32UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
@@ -208,8 +209,10 @@
__attribute__((ns_returns_retained));
@end
// clang-format on
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(UInt64)
// This block of code is generated, do not edit it directly.
// clang-format off
@interface GPBUInt64UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
@@ -271,8 +274,10 @@
__attribute__((ns_returns_retained));
@end
// clang-format on
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Int64)
// This block of code is generated, do not edit it directly.
// clang-format off
@interface GPBInt64UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
@@ -334,8 +339,10 @@
__attribute__((ns_returns_retained));
@end
// clang-format on
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Bool)
// This block of code is generated, do not edit it directly.
// clang-format off
@interface GPBBoolUInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
@@ -397,8 +404,10 @@
__attribute__((ns_returns_retained));
@end
// clang-format on
//%PDDM-EXPAND DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(String)
// This block of code is generated, do not edit it directly.
// clang-format off
@interface GPBStringUInt32Dictionary () <GPBDictionaryInternalsProtocol> {
@package
@@ -451,14 +460,13 @@
keyDataType:(GPBDataType)keyDataType;
@end
//%PDDM-EXPAND-END (6 expansions)
// clang-format on
//%PDDM-EXPAND-END (6 expansions)
#pragma mark - NSDictionary Subclass
@interface GPBAutocreatedDictionary : NSMutableDictionary {
@package
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
@@ -469,20 +477,24 @@ 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);
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);
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);
BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict,
GPBFieldDescriptor *field);
// Helper to read a map instead.
void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream,
id<GPBExtensionRegistry> registry, GPBFieldDescriptor *field,
GPBExtensionRegistry *registry,
GPBFieldDescriptor *field,
GPBMessage *parentMessage);
CF_EXTERN_C_END

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/duration.proto
#import "GPBDescriptor.h"
@@ -132,5 +131,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/duration.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -94,5 +93,3 @@ typedef struct GPBDuration__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/empty.proto
#import "GPBDescriptor.h"
@@ -59,5 +58,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/empty.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -70,5 +69,3 @@ typedef struct GPBEmpty__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -34,14 +34,17 @@
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@protocol GPBExtensionRegistry;
@class GPBExtensionRegistry;
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, BOOL isPackedOnStream,
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension,
BOOL isPackedOnStream,
GPBCodedInputStream *input,
id<GPBExtensionRegistry> extensionRegistry,
GPBExtensionRegistry *extensionRegistry,
GPBMessage *message);
size_t GPBComputeExtensionSerializedSizeIncludingTag(GPBExtensionDescriptor *extension, id value);
size_t GPBComputeExtensionSerializedSizeIncludingTag(
GPBExtensionDescriptor *extension, id value);
void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension, id value,
void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension,
id value,
GPBCodedOutputStream *output);

View File

@@ -40,7 +40,7 @@
static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
GPBCodedInputStream *input,
id<GPBExtensionRegistry> extensionRegistry,
GPBExtensionRegistry *extensionRegistry,
GPBMessage *existingValue)
__attribute__((ns_returns_retained));
@@ -65,11 +65,11 @@ GPB_INLINE size_t DataTypeSize(GPBDataType dataType) {
}
static size_t ComputePBSerializedSizeNoTagOfObject(GPBDataType dataType, id object) {
#define FIELD_CASE(TYPE, ACCESSOR) \
case GPBDataType##TYPE: \
#define FIELD_CASE(TYPE, ACCESSOR) \
case GPBDataType##TYPE: \
return GPBCompute##TYPE##SizeNoTag([(NSNumber *)object ACCESSOR]);
#define FIELD_CASE2(TYPE) \
case GPBDataType##TYPE: \
#define FIELD_CASE2(TYPE) \
case GPBDataType##TYPE: \
return GPBCompute##TYPE##SizeNoTag(object);
switch (dataType) {
FIELD_CASE(Bool, boolValue)
@@ -95,13 +95,14 @@ static size_t ComputePBSerializedSizeNoTagOfObject(GPBDataType dataType, id obje
#undef FIELD_CASE2
}
static size_t ComputeSerializedSizeIncludingTagOfObject(GPBExtensionDescription *description,
id object) {
#define FIELD_CASE(TYPE, ACCESSOR) \
case GPBDataType##TYPE: \
return GPBCompute##TYPE##Size(description->fieldNumber, [(NSNumber *)object ACCESSOR]);
#define FIELD_CASE2(TYPE) \
case GPBDataType##TYPE: \
static size_t ComputeSerializedSizeIncludingTagOfObject(
GPBExtensionDescription *description, id object) {
#define FIELD_CASE(TYPE, ACCESSOR) \
case GPBDataType##TYPE: \
return GPBCompute##TYPE##Size(description->fieldNumber, \
[(NSNumber *)object ACCESSOR]);
#define FIELD_CASE2(TYPE) \
case GPBDataType##TYPE: \
return GPBCompute##TYPE##Size(description->fieldNumber, object);
switch (description->dataType) {
FIELD_CASE(Bool, boolValue)
@@ -123,7 +124,8 @@ static size_t ComputeSerializedSizeIncludingTagOfObject(GPBExtensionDescription
FIELD_CASE2(Group)
case GPBDataTypeMessage:
if (GPBExtensionIsWireFormat(description)) {
return GPBComputeMessageSetExtensionSize(description->fieldNumber, object);
return GPBComputeMessageSetExtensionSize(description->fieldNumber,
object);
} else {
return GPBComputeMessageSize(description->fieldNumber, object);
}
@@ -132,8 +134,8 @@ static size_t ComputeSerializedSizeIncludingTagOfObject(GPBExtensionDescription
#undef FIELD_CASE2
}
static size_t ComputeSerializedSizeIncludingTagOfArray(GPBExtensionDescription *description,
NSArray *values) {
static size_t ComputeSerializedSizeIncludingTagOfArray(
GPBExtensionDescription *description, NSArray *values) {
if (GPBExtensionIsPacked(description)) {
size_t size = 0;
size_t typeSize = DataTypeSize(description->dataType);
@@ -141,7 +143,8 @@ static size_t ComputeSerializedSizeIncludingTagOfArray(GPBExtensionDescription *
size = values.count * typeSize;
} else {
for (id value in values) {
size += ComputePBSerializedSizeNoTagOfObject(description->dataType, value);
size +=
ComputePBSerializedSizeNoTagOfObject(description->dataType, value);
}
}
return size + GPBComputeTagSize(description->fieldNumber) +
@@ -155,12 +158,13 @@ static size_t ComputeSerializedSizeIncludingTagOfArray(GPBExtensionDescription *
}
}
static void WriteObjectIncludingTagToCodedOutputStream(id object,
GPBExtensionDescription *description,
GPBCodedOutputStream *output) {
#define FIELD_CASE(TYPE, ACCESSOR) \
case GPBDataType##TYPE: \
[output write##TYPE:description->fieldNumber value:[(NSNumber *)object ACCESSOR]]; \
static void WriteObjectIncludingTagToCodedOutputStream(
id object, GPBExtensionDescription *description,
GPBCodedOutputStream *output) {
#define FIELD_CASE(TYPE, ACCESSOR) \
case GPBDataType##TYPE: \
[output write##TYPE:description->fieldNumber \
value:[(NSNumber *)object ACCESSOR]]; \
return;
#define FIELD_CASE2(TYPE) \
case GPBDataType##TYPE: \
@@ -196,8 +200,9 @@ static void WriteObjectIncludingTagToCodedOutputStream(id object,
#undef FIELD_CASE2
}
static void WriteObjectNoTagToCodedOutputStream(id object, GPBExtensionDescription *description,
GPBCodedOutputStream *output) {
static void WriteObjectNoTagToCodedOutputStream(
id object, GPBExtensionDescription *description,
GPBCodedOutputStream *output) {
#define FIELD_CASE(TYPE, ACCESSOR) \
case GPBDataType##TYPE: \
[output write##TYPE##NoTag:[(NSNumber *)object ACCESSOR]]; \
@@ -232,18 +237,20 @@ static void WriteObjectNoTagToCodedOutputStream(id object, GPBExtensionDescripti
#undef FIELD_CASE2
}
static void WriteArrayIncludingTagsToCodedOutputStream(NSArray *values,
GPBExtensionDescription *description,
GPBCodedOutputStream *output) {
static void WriteArrayIncludingTagsToCodedOutputStream(
NSArray *values, GPBExtensionDescription *description,
GPBCodedOutputStream *output) {
if (GPBExtensionIsPacked(description)) {
[output writeTag:description->fieldNumber format:GPBWireFormatLengthDelimited];
[output writeTag:description->fieldNumber
format:GPBWireFormatLengthDelimited];
size_t dataSize = 0;
size_t typeSize = DataTypeSize(description->dataType);
if (typeSize != 0) {
dataSize = values.count * typeSize;
} else {
for (id value in values) {
dataSize += ComputePBSerializedSizeNoTagOfObject(description->dataType, value);
dataSize +=
ComputePBSerializedSizeNoTagOfObject(description->dataType, value);
}
}
[output writeRawVarintSizeTAs32:dataSize];
@@ -263,18 +270,23 @@ static void WriteArrayIncludingTagsToCodedOutputStream(NSArray *values,
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, BOOL isPackedOnStream,
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension,
BOOL isPackedOnStream,
GPBCodedInputStream *input,
id<GPBExtensionRegistry> extensionRegistry,
GPBExtensionRegistry *extensionRegistry,
GPBMessage *message) {
GPBExtensionDescription *description = extension->description_;
GPBCodedInputStreamState *state = &input->state_;
if (isPackedOnStream) {
NSCAssert(GPBExtensionIsRepeated(description), @"How was it packed if it isn't repeated?");
NSCAssert(GPBExtensionIsRepeated(description),
@"How was it packed if it isn't repeated?");
int32_t length = GPBCodedInputStreamReadInt32(state);
size_t limit = GPBCodedInputStreamPushLimit(state, length);
while (GPBCodedInputStreamBytesUntilLimit(state) > 0) {
id value = NewSingleValueFromInputStream(extension, input, extensionRegistry, nil);
id value = NewSingleValueFromInputStream(extension,
input,
extensionRegistry,
nil);
[message addExtension:extension value:value];
[value release];
}
@@ -285,7 +297,10 @@ void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, BOOL is
if (!isRepeated && GPBDataTypeIsMessage(description->dataType)) {
existingValue = [message getExistingExtension:extension];
}
id value = NewSingleValueFromInputStream(extension, input, extensionRegistry, existingValue);
id value = NewSingleValueFromInputStream(extension,
input,
extensionRegistry,
existingValue);
if (isRepeated) {
[message addExtension:extension value:value];
} else {
@@ -295,7 +310,8 @@ void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, BOOL is
}
}
void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension, id value,
void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension,
id value,
GPBCodedOutputStream *output) {
GPBExtensionDescription *description = extension->description_;
if (GPBExtensionIsRepeated(description)) {
@@ -305,7 +321,8 @@ void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension, id
}
}
size_t GPBComputeExtensionSerializedSizeIncludingTag(GPBExtensionDescriptor *extension, id value) {
size_t GPBComputeExtensionSerializedSizeIncludingTag(
GPBExtensionDescriptor *extension, id value) {
GPBExtensionDescription *description = extension->description_;
if (GPBExtensionIsRepeated(description)) {
return ComputeSerializedSizeIncludingTagOfArray(description, value);
@@ -317,43 +334,27 @@ size_t GPBComputeExtensionSerializedSizeIncludingTag(GPBExtensionDescriptor *ext
// Note that this returns a retained value intentionally.
static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
GPBCodedInputStream *input,
id<GPBExtensionRegistry> extensionRegistry,
GPBExtensionRegistry *extensionRegistry,
GPBMessage *existingValue) {
GPBExtensionDescription *description = extension->description_;
GPBCodedInputStreamState *state = &input->state_;
switch (description->dataType) {
case GPBDataTypeBool:
return [[NSNumber alloc] initWithBool:GPBCodedInputStreamReadBool(state)];
case GPBDataTypeFixed32:
return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadFixed32(state)];
case GPBDataTypeSFixed32:
return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSFixed32(state)];
case GPBDataTypeFloat:
return [[NSNumber alloc] initWithFloat:GPBCodedInputStreamReadFloat(state)];
case GPBDataTypeFixed64:
return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadFixed64(state)];
case GPBDataTypeSFixed64:
return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSFixed64(state)];
case GPBDataTypeDouble:
return [[NSNumber alloc] initWithDouble:GPBCodedInputStreamReadDouble(state)];
case GPBDataTypeInt32:
return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadInt32(state)];
case GPBDataTypeInt64:
return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadInt64(state)];
case GPBDataTypeSInt32:
return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSInt32(state)];
case GPBDataTypeSInt64:
return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSInt64(state)];
case GPBDataTypeUInt32:
return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadUInt32(state)];
case GPBDataTypeUInt64:
return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadUInt64(state)];
case GPBDataTypeBytes:
return GPBCodedInputStreamReadRetainedBytes(state);
case GPBDataTypeString:
return GPBCodedInputStreamReadRetainedString(state);
case GPBDataTypeEnum:
return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadEnum(state)];
case GPBDataTypeBool: return [[NSNumber alloc] initWithBool:GPBCodedInputStreamReadBool(state)];
case GPBDataTypeFixed32: return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadFixed32(state)];
case GPBDataTypeSFixed32: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSFixed32(state)];
case GPBDataTypeFloat: return [[NSNumber alloc] initWithFloat:GPBCodedInputStreamReadFloat(state)];
case GPBDataTypeFixed64: return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadFixed64(state)];
case GPBDataTypeSFixed64: return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSFixed64(state)];
case GPBDataTypeDouble: return [[NSNumber alloc] initWithDouble:GPBCodedInputStreamReadDouble(state)];
case GPBDataTypeInt32: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadInt32(state)];
case GPBDataTypeInt64: return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadInt64(state)];
case GPBDataTypeSInt32: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSInt32(state)];
case GPBDataTypeSInt64: return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSInt64(state)];
case GPBDataTypeUInt32: return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadUInt32(state)];
case GPBDataTypeUInt64: return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadUInt64(state)];
case GPBDataTypeBytes: return GPBCodedInputStreamReadRetainedBytes(state);
case GPBDataTypeString: return GPBCodedInputStreamReadRetainedString(state);
case GPBDataTypeEnum: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadEnum(state)];
case GPBDataTypeGroup:
case GPBDataTypeMessage: {
GPBMessage *message;
@@ -366,14 +367,15 @@ static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
if (description->dataType == GPBDataTypeGroup) {
[input readGroup:description->fieldNumber
message:message
message:message
extensionRegistry:extensionRegistry];
} else {
// description->dataType == GPBDataTypeMessage
if (GPBExtensionIsWireFormat(description)) {
// For MessageSet fields the message length will have already been
// read.
[message mergeFromCodedInputStream:input extensionRegistry:extensionRegistry];
[message mergeFromCodedInputStream:input
extensionRegistry:extensionRegistry];
} else {
[input readMessage:message extensionRegistry:extensionRegistry];
}

View File

@@ -41,24 +41,6 @@ NS_ASSUME_NONNULL_BEGIN
* 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.
**/
@protocol GPBExtensionRegistry <NSObject>
/**
* 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
/**
* A concrete implementation of `GPBExtensionRegistry`.
*
* The *Root classes provide `+extensionRegistry` for the extensions defined
* in a given file *and* all files it imports. You can also create a
@@ -72,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
* MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError];
* ```
**/
@interface GPBExtensionRegistry : NSObject <NSCopying, GPBExtensionRegistry>
@interface GPBExtensionRegistry : NSObject<NSCopying>
/**
* Adds the given GPBExtensionDescriptor to this registry.
@@ -88,6 +70,18 @@ NS_ASSUME_NONNULL_BEGIN
**/
- (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

@@ -40,8 +40,8 @@
- (instancetype)init {
if ((self = [super init])) {
// The keys are ObjC classes, so straight up ptr comparisons are fine.
mutableClassMap_ =
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
mutableClassMap_ = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL,
&kCFTypeDictionaryValueCallBacks);
}
return self;
}
@@ -69,13 +69,13 @@
}
Class containingMessageClass = extension.containingMessageClass;
CFMutableDictionaryRef extensionMap =
(CFMutableDictionaryRef)CFDictionaryGetValue(mutableClassMap_, containingMessageClass);
CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
CFDictionaryGetValue(mutableClassMap_, containingMessageClass);
if (extensionMap == nil) {
// Use a custom dictionary here because the keys are numbers and conversion
// back and forth from NSNumber isn't worth the cost.
extensionMap =
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
extensionMap = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL,
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(mutableClassMap_, containingMessageClass, extensionMap);
CFRelease(extensionMap);
}
@@ -87,11 +87,13 @@
- (GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
fieldNumber:(NSInteger)fieldNumber {
Class messageClass = descriptor.messageClass;
CFMutableDictionaryRef extensionMap =
(CFMutableDictionaryRef)CFDictionaryGetValue(mutableClassMap_, messageClass);
CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
CFDictionaryGetValue(mutableClassMap_, messageClass);
ssize_t key = fieldNumber;
GPBExtensionDescriptor *result =
(extensionMap ? CFDictionaryGetValue(extensionMap, (const void *)key) : nil);
(extensionMap
? CFDictionaryGetValue(extensionMap, (const void *)key)
: nil);
return result;
}
@@ -105,8 +107,8 @@ static void CopySubDictionary(const void *key, const void *value, void *context)
Class containingMessageClass = key;
CFMutableDictionaryRef otherExtensionMap = (CFMutableDictionaryRef)value;
CFMutableDictionaryRef extensionMap =
(CFMutableDictionaryRef)CFDictionaryGetValue(mutableClassMap, containingMessageClass);
CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
CFDictionaryGetValue(mutableClassMap, containingMessageClass);
if (extensionMap == nil) {
extensionMap = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, otherExtensionMap);
CFDictionarySetValue(mutableClassMap, containingMessageClass, extensionMap);

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/field_mask.proto
#import "GPBDescriptor.h"
@@ -248,7 +247,7 @@ GPB_FINAL @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 container to be created. */
/** The number of items in @c pathsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger pathsArray_Count;
@end
@@ -260,5 +259,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/field_mask.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -83,5 +82,3 @@ typedef struct GPBFieldMask__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -31,12 +31,12 @@
#import <Foundation/Foundation.h>
#import "GPBBootstrap.h"
#import "GPBExtensionRegistry.h"
@class GPBDescriptor;
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@class GPBExtensionDescriptor;
@class GPBExtensionRegistry;
@class GPBFieldDescriptor;
@class GPBUnknownFieldSet;
@@ -80,7 +80,7 @@ CF_EXTERN_C_END
* @c +parseFromData:extensionRegistry:error: to provide an extension
* registry.
**/
@interface GPBMessage : NSObject <NSSecureCoding, NSCopying>
@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
@@ -147,7 +147,7 @@ CF_EXTERN_C_END
* @return A new instance of the generated class.
**/
+ (nullable instancetype)parseFromData:(NSData *)data
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -171,7 +171,7 @@ CF_EXTERN_C_END
**/
+ (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable id<GPBExtensionRegistry>)extensionRegistry
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -196,7 +196,7 @@ CF_EXTERN_C_END
**/
+ (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable id<GPBExtensionRegistry>)extensionRegistry
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -239,7 +239,7 @@ CF_EXTERN_C_END
* @return An initialized instance of the generated class.
**/
- (nullable instancetype)initWithData:(NSData *)data
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -264,7 +264,7 @@ CF_EXTERN_C_END
**/
- (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable id<GPBExtensionRegistry>)extensionRegistry
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -278,7 +278,7 @@ CF_EXTERN_C_END
* unsuccessful.
**/
- (void)mergeFromData:(NSData *)data
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry;
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
/**
* Merges the fields from another message (of the same type) into this
@@ -427,7 +427,8 @@ CF_EXTERN_C_END
* @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;
- (void)setExtension:(GPBExtensionDescriptor *)extension
value:(nullable id)value;
/**
* Adds the given value to the extension for this message. This only applies
@@ -448,7 +449,9 @@ CF_EXTERN_C_END
* @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;
- (void)setExtension:(GPBExtensionDescriptor *)extension
index:(NSUInteger)index
value:(id)value;
/**
* Clears the given extension for this message.

View File

@@ -30,9 +30,8 @@
#import "GPBMessage_PackagePrivate.h"
#import <objc/message.h>
#import <objc/runtime.h>
#import <os/lock.h>
#import <objc/message.h>
#import <stdatomic.h>
#import "GPBArray_PackagePrivate.h"
@@ -52,7 +51,8 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
NSString *const GPBMessageErrorDomain = GPBNSStringifySymbol(GPBMessageErrorDomain);
NSString *const GPBMessageErrorDomain =
GPBNSStringifySymbol(GPBMessageErrorDomain);
NSString *const GPBErrorReasonKey = @"Reason";
@@ -71,7 +71,8 @@ static NSString *const kGPBDataCoderKey = @"GPBData";
@package
GPBUnknownFieldSet *unknownFields_;
NSMutableDictionary *extensionMap_;
// Readonly access to autocreatedExtensionMap_ is protected via readOnlyLock_.
// Readonly access to autocreatedExtensionMap_ is protected via
// readOnlySemaphore_.
NSMutableDictionary *autocreatedExtensionMap_;
// If the object was autocreated, we remember the creator so that if we get
@@ -80,38 +81,43 @@ static NSString *const kGPBDataCoderKey = @"GPBData";
GPBFieldDescriptor *autocreatorField_;
GPBExtensionDescriptor *autocreatorExtension_;
// Messages can only be mutated from one thread. But some *readonly* operations modify internal
// state because they autocreate things. The autocreatedExtensionMap_ is one such structure.
// Access during readonly operations is protected via this lock.
//
// Long ago, this was an OSSpinLock, but then it came to light that there were issues for that on
// iOS:
// Message can only be mutated from one thread. But some *readonly* operations
// modify internal state because they autocreate things. The
// autocreatedExtensionMap_ is one such structure. Access during readonly
// operations is protected via this semaphore.
// NOTE: OSSpinLock may seem like a good fit here but Apple engineers have
// pointed out that they are vulnerable to live locking on iOS in cases of
// priority inversion:
// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html
// It was changed to a dispatch_semaphore_t, but that has potential for priority inversion issues.
// The minOS versions are now high enough that os_unfair_lock can be used, and should provide
// all the support we need. For more information in the concurrency/locking space see:
// https://gist.github.com/tclementdev/6af616354912b0347cdf6db159c37057
// https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html
// https://developer.apple.com/videos/play/wwdc2017/706/
os_unfair_lock readOnlyLock_;
// Use of readOnlySemaphore_ must be prefaced by a call to
// GPBPrepareReadOnlySemaphore to ensure it has been created. This allows
// readOnlySemaphore_ to be only created when actually needed.
_Atomic(dispatch_semaphore_t) readOnlySemaphore_;
}
@end
static id CreateArrayForField(GPBFieldDescriptor *field, GPBMessage *autocreator)
static id CreateArrayForField(GPBFieldDescriptor *field,
GPBMessage *autocreator)
__attribute__((ns_returns_retained));
static id GetOrCreateArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
static id GetOrCreateArrayIvarWithField(GPBMessage *self,
GPBFieldDescriptor *field);
static id GetArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
static id CreateMapForField(GPBFieldDescriptor *field, GPBMessage *autocreator)
static id CreateMapForField(GPBFieldDescriptor *field,
GPBMessage *autocreator)
__attribute__((ns_returns_retained));
static id GetOrCreateMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
static id GetOrCreateMapIvarWithField(GPBMessage *self,
GPBFieldDescriptor *field);
static id GetMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
static NSMutableDictionary *CloneExtensionMap(NSDictionary *extensionMap, NSZone *zone)
static NSMutableDictionary *CloneExtensionMap(NSDictionary *extensionMap,
NSZone *zone)
__attribute__((ns_returns_retained));
#ifdef DEBUG
static NSError *MessageError(NSInteger code, NSDictionary *userInfo) {
return [NSError errorWithDomain:GPBMessageErrorDomain code:code userInfo:userInfo];
return [NSError errorWithDomain:GPBMessageErrorDomain
code:code
userInfo:userInfo];
}
#endif
@@ -127,7 +133,7 @@ static NSError *ErrorFromException(NSException *exception) {
NSString *reason = exception.reason;
NSDictionary *userInfo = nil;
if ([reason length]) {
userInfo = @{GPBErrorReasonKey : reason};
userInfo = @{ GPBErrorReasonKey : reason };
}
error = [NSError errorWithDomain:GPBMessageErrorDomain
@@ -137,20 +143,24 @@ static NSError *ErrorFromException(NSException *exception) {
return error;
}
static void CheckExtension(GPBMessage *self, GPBExtensionDescriptor *extension) {
static void CheckExtension(GPBMessage *self,
GPBExtensionDescriptor *extension) {
if (![self isKindOfClass:extension.containingMessageClass]) {
[NSException raise:NSInvalidArgumentException
format:@"Extension %@ used on wrong class (%@ instead of %@)",
extension.singletonName, [self class], extension.containingMessageClass];
[NSException
raise:NSInvalidArgumentException
format:@"Extension %@ used on wrong class (%@ instead of %@)",
extension.singletonName,
[self class], extension.containingMessageClass];
}
}
static NSMutableDictionary *CloneExtensionMap(NSDictionary *extensionMap, NSZone *zone) {
static NSMutableDictionary *CloneExtensionMap(NSDictionary *extensionMap,
NSZone *zone) {
if (extensionMap.count == 0) {
return nil;
}
NSMutableDictionary *result =
[[NSMutableDictionary allocWithZone:zone] initWithCapacity:extensionMap.count];
NSMutableDictionary *result = [[NSMutableDictionary allocWithZone:zone]
initWithCapacity:extensionMap.count];
for (GPBExtensionDescriptor *extension in extensionMap) {
id value = [extensionMap objectForKey:extension];
@@ -158,7 +168,8 @@ static NSMutableDictionary *CloneExtensionMap(NSDictionary *extensionMap, NSZone
if (extension.repeated) {
if (isMessageExtension) {
NSMutableArray *list = [[NSMutableArray alloc] initWithCapacity:[value count]];
NSMutableArray *list =
[[NSMutableArray alloc] initWithCapacity:[value count]];
for (GPBMessage *listValue in value) {
GPBMessage *copiedValue = [listValue copyWithZone:zone];
[list addObject:copiedValue];
@@ -185,7 +196,8 @@ static NSMutableDictionary *CloneExtensionMap(NSDictionary *extensionMap, NSZone
return result;
}
static id CreateArrayForField(GPBFieldDescriptor *field, GPBMessage *autocreator) {
static id CreateArrayForField(GPBFieldDescriptor *field,
GPBMessage *autocreator) {
id result;
GPBDataType fieldDataType = GPBGetFieldDataType(field);
switch (fieldDataType) {
@@ -218,7 +230,8 @@ static id CreateArrayForField(GPBFieldDescriptor *field, GPBMessage *autocreator
break;
case GPBDataTypeEnum:
result = [[GPBEnumArray alloc] initWithValidationFunction:field.enumDescriptor.enumVerifier];
result = [[GPBEnumArray alloc]
initWithValidationFunction:field.enumDescriptor.enumVerifier];
break;
case GPBDataTypeBytes:
@@ -236,7 +249,7 @@ static id CreateArrayForField(GPBFieldDescriptor *field, GPBMessage *autocreator
if (autocreator) {
if (GPBDataTypeIsObject(fieldDataType)) {
GPBAutocreatedArray *autoArray = result;
autoArray->_autocreator = autocreator;
autoArray->_autocreator = autocreator;
} else {
GPBInt32Array *gpbArray = result;
gpbArray->_autocreator = autocreator;
@@ -246,7 +259,8 @@ static id CreateArrayForField(GPBFieldDescriptor *field, GPBMessage *autocreator
return result;
}
static id CreateMapForField(GPBFieldDescriptor *field, GPBMessage *autocreator) {
static id CreateMapForField(GPBFieldDescriptor *field,
GPBMessage *autocreator) {
id result;
GPBDataType keyDataType = field.mapKeyDataType;
GPBDataType valueDataType = GPBGetFieldDataType(field);
@@ -531,9 +545,10 @@ static id CreateMapForField(GPBFieldDescriptor *field, GPBMessage *autocreator)
}
if (autocreator) {
if ((keyDataType == GPBDataTypeString) && GPBDataTypeIsObject(valueDataType)) {
if ((keyDataType == GPBDataTypeString) &&
GPBDataTypeIsObject(valueDataType)) {
GPBAutocreatedDictionary *autoDict = result;
autoDict->_autocreator = autocreator;
autoDict->_autocreator = autocreator;
} else {
GPBInt32Int32Dictionary *gpbDict = result;
gpbDict->_autocreator = autocreator;
@@ -555,7 +570,8 @@ static id CreateMapForField(GPBFieldDescriptor *field, GPBMessage *autocreator)
// repeated/map field parsed into the autorelease pool which is both a memory
// and performance hit.
static id GetOrCreateArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
static id GetOrCreateArrayIvarWithField(GPBMessage *self,
GPBFieldDescriptor *field) {
id array = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!array) {
// No lock needed, this is called from places expecting to mutate
@@ -595,7 +611,8 @@ static id GetArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
return expected;
}
static id GetOrCreateMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
static id GetOrCreateMapIvarWithField(GPBMessage *self,
GPBFieldDescriptor *field) {
id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!dict) {
// No lock needed, this is called from places expecting to mutate
@@ -624,7 +641,8 @@ static id GetMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
}
// Some other thread set it, release the one created and return what got set.
if ((field.mapKeyDataType == GPBDataTypeString) && GPBFieldDataTypeIsObject(field)) {
if ((field.mapKeyDataType == GPBDataTypeString) &&
GPBFieldDataTypeIsObject(field)) {
GPBAutocreatedDictionary *autoDict = autocreated;
autoDict->_autocreator = nil;
} else {
@@ -637,7 +655,8 @@ static id GetMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
#endif // !defined(__clang_analyzer__)
GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass, GPBMessage *autocreator,
GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass,
GPBMessage *autocreator,
GPBFieldDescriptor *field) {
GPBMessage *message = [[msgClass alloc] init];
message->autocreator_ = autocreator;
@@ -645,12 +664,13 @@ GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass, GPBMessage *autocrea
return message;
}
static GPBMessage *CreateMessageWithAutocreatorForExtension(Class msgClass, GPBMessage *autocreator,
GPBExtensionDescriptor *extension)
static GPBMessage *CreateMessageWithAutocreatorForExtension(
Class msgClass, GPBMessage *autocreator, GPBExtensionDescriptor *extension)
__attribute__((ns_returns_retained));
static GPBMessage *CreateMessageWithAutocreatorForExtension(Class msgClass, GPBMessage *autocreator,
GPBExtensionDescriptor *extension) {
static GPBMessage *CreateMessageWithAutocreatorForExtension(
Class msgClass, GPBMessage *autocreator,
GPBExtensionDescriptor *extension) {
GPBMessage *message = [[msgClass alloc] init];
message->autocreator_ = autocreator;
message->autocreatorExtension_ = [extension retain];
@@ -669,7 +689,8 @@ void GPBBecomeVisibleToAutocreator(GPBMessage *self) {
// This will recursively make all parent messages visible until it reaches a
// super-creator that's visible.
if (self->autocreatorField_) {
GPBSetObjectIvarWithFieldPrivate(self->autocreator_, self->autocreatorField_, self);
GPBSetObjectIvarWithFieldPrivate(self->autocreator_,
self->autocreatorField_, self);
} else {
[self->autocreator_ setExtension:self->autocreatorExtension_ value:self];
}
@@ -705,7 +726,8 @@ void GPBAutocreatedDictionaryModified(GPBMessage *self, id dictionary) {
if (field.fieldType == GPBFieldTypeMap) {
id curDict = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (curDict == dictionary) {
if ((field.mapKeyDataType == GPBDataTypeString) && GPBFieldDataTypeIsObject(field)) {
if ((field.mapKeyDataType == GPBDataTypeString) &&
GPBFieldDataTypeIsObject(field)) {
GPBAutocreatedDictionary *autoDict = dictionary;
autoDict->_autocreator = nil;
} else {
@@ -729,15 +751,18 @@ void GPBClearMessageAutocreator(GPBMessage *self) {
// Either the autocreator must have its "has" flag set to YES, or it must be
// NO and not equal to ourselves.
BOOL autocreatorHas =
(self->autocreatorField_ ? GPBGetHasIvarField(self->autocreator_, self->autocreatorField_)
: [self->autocreator_ hasExtension:self->autocreatorExtension_]);
(self->autocreatorField_
? GPBGetHasIvarField(self->autocreator_, self->autocreatorField_)
: [self->autocreator_ hasExtension:self->autocreatorExtension_]);
GPBMessage *autocreatorFieldValue =
(self->autocreatorField_
? GPBGetObjectIvarWithFieldNoAutocreate(self->autocreator_, self->autocreatorField_)
? GPBGetObjectIvarWithFieldNoAutocreate(self->autocreator_,
self->autocreatorField_)
: [self->autocreator_->autocreatedExtensionMap_
objectForKey:self->autocreatorExtension_]);
NSCAssert(autocreatorHas || autocreatorFieldValue != self,
@"Cannot clear autocreator because it still refers to self, self: %@.", self);
@"Cannot clear autocreator because it still refers to self, self: %@.",
self);
#endif // DEBUG && !defined(NS_BLOCK_ASSERTIONS)
@@ -748,6 +773,31 @@ void GPBClearMessageAutocreator(GPBMessage *self) {
self->autocreatorExtension_ = nil;
}
// Call this before using the readOnlySemaphore_. This ensures it is created only once.
void GPBPrepareReadOnlySemaphore(GPBMessage *self) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
// Create the semaphore on demand (rather than init) as developers might not cause them
// to be needed, and the heap usage can add up. The atomic swap is used to avoid needing
// another lock around creating it.
if (self->readOnlySemaphore_ == nil) {
dispatch_semaphore_t worker = dispatch_semaphore_create(1);
dispatch_semaphore_t expected = nil;
if (!atomic_compare_exchange_strong(&self->readOnlySemaphore_, &expected, worker)) {
dispatch_release(worker);
}
#if defined(__clang_analyzer__)
// The Xcode 9.2 (and 9.3 beta) static analyzer thinks worker is leaked
// (doesn't seem to know about atomic_compare_exchange_strong); so just
// for the analyzer, let it think worker is also released in this case.
else { dispatch_release(worker); }
#endif
}
#pragma clang diagnostic pop
}
static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if (!self->unknownFields_) {
self->unknownFields_ = [[GPBUnknownFieldSet alloc] init];
@@ -798,8 +848,9 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if (!descriptor) {
// Use a dummy file that marks it as proto2 syntax so when used generically
// it supports unknowns/etc.
fileDescriptor = [[GPBFileDescriptor alloc] initWithPackage:@"internal"
syntax:GPBFileSyntaxProto2];
fileDescriptor =
[[GPBFileDescriptor alloc] initWithPackage:@"internal"
syntax:GPBFileSyntaxProto2];
descriptor = [GPBDescriptor allocDescriptorForClass:[GPBMessage class]
rootClass:Nil
@@ -818,9 +869,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
- (instancetype)init {
if ((self = [super init])) {
messageStorage_ =
(GPBMessage_StoragePtr)(((uint8_t *)self) + class_getInstanceSize([self class]));
readOnlyLock_ = OS_UNFAIR_LOCK_INIT;
messageStorage_ = (GPBMessage_StoragePtr)(
((uint8_t *)self) + class_getInstanceSize([self class]));
}
return self;
@@ -831,7 +881,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (instancetype)initWithData:(NSData *)data
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr {
if ((self = [self init])) {
@try {
@@ -839,7 +889,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if (errorPtr) {
*errorPtr = nil;
}
} @catch (NSException *exception) {
}
@catch (NSException *exception) {
[self release];
self = nil;
if (errorPtr) {
@@ -860,7 +911,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
extensionRegistry:
(GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr {
if ((self = [self init])) {
@try {
@@ -868,7 +920,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if (errorPtr) {
*errorPtr = nil;
}
} @catch (NSException *exception) {
}
@catch (NSException *exception) {
[self release];
self = nil;
if (errorPtr) {
@@ -891,6 +944,9 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
- (void)dealloc {
[self internalClear:NO];
NSCAssert(!autocreator_, @"Autocreator was not cleared before dealloc.");
if (readOnlySemaphore_) {
dispatch_release(readOnlySemaphore_);
}
[super dealloc];
}
@@ -923,11 +979,13 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if (field.mapKeyDataType == GPBDataTypeString) {
// Map is an NSDictionary.
NSDictionary *existingDict = value;
NSMutableDictionary *newDict =
[[NSMutableDictionary alloc] initWithCapacity:existingDict.count];
NSMutableDictionary *newDict = [[NSMutableDictionary alloc]
initWithCapacity:existingDict.count];
newValue = newDict;
[existingDict enumerateKeysAndObjectsUsingBlock:^(NSString *key, GPBMessage *msg,
__unused BOOL *stop) {
[existingDict enumerateKeysAndObjectsUsingBlock:^(NSString *key,
GPBMessage *msg,
BOOL *stop) {
#pragma unused(stop)
GPBMessage *copiedMsg = [msg copyWithZone:zone];
[newDict setObject:copiedMsg forKey:key];
[copiedMsg release];
@@ -950,7 +1008,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
newValue = [value copyWithZone:zone];
}
} else {
if ((field.mapKeyDataType == GPBDataTypeString) && GPBFieldDataTypeIsObject(field)) {
if ((field.mapKeyDataType == GPBDataTypeString) &&
GPBFieldDataTypeIsObject(field)) {
// NSDictionary
newValue = [value mutableCopyWithZone:zone];
} else {
@@ -982,7 +1041,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
id *typePtr = (id *)&storage[field->description_->offset];
*typePtr = NULL;
}
} else if (GPBFieldDataTypeIsObject(field) && GPBGetHasIvarField(self, field)) {
} else if (GPBFieldDataTypeIsObject(field) &&
GPBGetHasIvarField(self, field)) {
// A set string/data value (message picked off above), copy it.
id value = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
id newValue = [value copyWithZone:zone];
@@ -1033,7 +1093,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
}
} else {
if ((field.mapKeyDataType == GPBDataTypeString) && GPBFieldDataTypeIsObject(field)) {
if ((field.mapKeyDataType == GPBDataTypeString) &&
GPBFieldDataTypeIsObject(field)) {
if ([arrayOrMap isKindOfClass:[GPBAutocreatedDictionary class]]) {
GPBAutocreatedDictionary *autoDict = arrayOrMap;
if (autoDict->_autocreator == self) {
@@ -1054,7 +1115,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
GPBClearAutocreatedMessageIvarWithField(self, field);
GPBMessage *value = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
[value release];
} else if (GPBFieldDataTypeIsObject(field) && GPBGetHasIvarField(self, field)) {
} else if (GPBFieldDataTypeIsObject(field) &&
GPBGetHasIvarField(self, field)) {
id value = GPBGetObjectIvarWithField(self, field);
[value release];
}
@@ -1106,7 +1168,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
return NO;
}
} else {
NSAssert(field.isOptional, @"%@: Single message field %@ not required or optional?",
NSAssert(field.isOptional,
@"%@: Single message field %@ not required or optional?",
[self class], field.name);
if (GPBGetHasIvarField(self, field)) {
GPBMessage *message = GPBGetMessageMessageField(self, field);
@@ -1124,13 +1187,15 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
} else { // fieldType == GPBFieldTypeMap
if (field.mapKeyDataType == GPBDataTypeString) {
NSDictionary *map = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
NSDictionary *map =
GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (map && !GPBDictionaryIsInitializedInternalHelper(map, field)) {
return NO;
}
} else {
// Real type is GPB*ObjectDictionary, exact type doesn't matter.
GPBInt32ObjectDictionary *map = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
GPBInt32ObjectDictionary *map =
GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (map && ![map isInitialized]) {
return NO;
}
@@ -1141,7 +1206,9 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
__block BOOL result = YES;
[extensionMap_
enumerateKeysAndObjectsUsingBlock:^(GPBExtensionDescriptor *extension, id obj, BOOL *stop) {
enumerateKeysAndObjectsUsingBlock:^(GPBExtensionDescriptor *extension,
id obj,
BOOL *stop) {
if (GPBExtensionIsMessage(extension)) {
if (extension.isRepeated) {
for (GPBMessage *msg in obj) {
@@ -1174,15 +1241,18 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
#endif
NSMutableData *data = [NSMutableData dataWithLength:[self serializedSize]];
GPBCodedOutputStream *stream = [[GPBCodedOutputStream alloc] initWithData:data];
GPBCodedOutputStream *stream =
[[GPBCodedOutputStream alloc] initWithData:data];
@try {
[self writeToCodedOutputStream:stream];
} @catch (NSException *exception) {
}
@catch (NSException *exception) {
// This really shouldn't happen. The only way writeToCodedOutputStream:
// could throw is if something in the library has a bug and the
// serializedSize was wrong.
#ifdef DEBUG
NSLog(@"%@: Internal exception while building message data: %@", [self class], exception);
NSLog(@"%@: Internal exception while building message data: %@",
[self class], exception);
#endif
data = nil;
}
@@ -1193,17 +1263,20 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
- (NSData *)delimitedData {
size_t serializedSize = [self serializedSize];
size_t varintSize = GPBComputeRawVarint32SizeForInteger(serializedSize);
NSMutableData *data = [NSMutableData dataWithLength:(serializedSize + varintSize)];
GPBCodedOutputStream *stream = [[GPBCodedOutputStream alloc] initWithData:data];
NSMutableData *data =
[NSMutableData dataWithLength:(serializedSize + varintSize)];
GPBCodedOutputStream *stream =
[[GPBCodedOutputStream alloc] initWithData:data];
@try {
[self writeDelimitedToCodedOutputStream:stream];
} @catch (NSException *exception) {
}
@catch (NSException *exception) {
// This really shouldn't happen. The only way writeToCodedOutputStream:
// could throw is if something in the library has a bug and the
// serializedSize was wrong.
#ifdef DEBUG
NSLog(@"%@: Internal exception while building message delimitedData: %@", [self class],
exception);
NSLog(@"%@: Internal exception while building message delimitedData: %@",
[self class], exception);
#endif
// If it happens, truncate.
data.length = 0;
@@ -1213,7 +1286,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (void)writeToOutputStream:(NSOutputStream *)output {
GPBCodedOutputStream *stream = [[GPBCodedOutputStream alloc] initWithOutputStream:output];
GPBCodedOutputStream *stream =
[[GPBCodedOutputStream alloc] initWithOutputStream:output];
[self writeToCodedOutputStream:stream];
[stream release];
}
@@ -1248,7 +1322,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (void)writeDelimitedToOutputStream:(NSOutputStream *)output {
GPBCodedOutputStream *codedOutput = [[GPBCodedOutputStream alloc] initWithOutputStream:output];
GPBCodedOutputStream *codedOutput =
[[GPBCodedOutputStream alloc] initWithOutputStream:output];
[self writeDelimitedToCodedOutputStream:codedOutput];
[codedOutput release];
}
@@ -1258,7 +1333,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
[self writeToCodedOutputStream:output];
}
- (void)writeField:(GPBFieldDescriptor *)field toCodedOutputStream:(GPBCodedOutputStream *)output {
- (void)writeField:(GPBFieldDescriptor *)field
toCodedOutputStream:(GPBCodedOutputStream *)output {
GPBFieldType fieldType = field.fieldType;
if (fieldType == GPBFieldTypeSingle) {
BOOL has = GPBGetHasIvarField(self, field);
@@ -1268,9 +1344,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
uint32_t fieldNumber = GPBFieldNumber(field);
switch (GPBGetFieldDataType(field)) {
// clang-format off
//%PDDM-DEFINE FIELD_CASE(TYPE, REAL_TYPE)
//%FIELD_CASE_FULL(TYPE, REAL_TYPE, REAL_TYPE)
//%PDDM-DEFINE FIELD_CASE_FULL(TYPE, REAL_TYPE, ARRAY_TYPE)
@@ -1313,8 +1386,12 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
//% }
//% break;
//%
switch (GPBGetFieldDataType(field)) {
//%PDDM-EXPAND FIELD_CASE(Bool, Bool)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeBool:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1333,8 +1410,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(Fixed32, UInt32)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeFixed32:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1353,8 +1432,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(SFixed32, Int32)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeSFixed32:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1373,8 +1454,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(Float, Float)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeFloat:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1393,8 +1476,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(Fixed64, UInt64)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeFixed64:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1413,8 +1498,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(SFixed64, Int64)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeSFixed64:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1433,8 +1520,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(Double, Double)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeDouble:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1453,8 +1542,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(Int32, Int32)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeInt32:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1473,8 +1564,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(Int64, Int64)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeInt64:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1493,8 +1586,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(SInt32, Int32)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeSInt32:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1513,8 +1608,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(SInt64, Int64)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeSInt64:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1533,8 +1630,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(UInt32, UInt32)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeUInt32:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1553,8 +1652,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE(UInt64, UInt64)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeUInt64:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1573,8 +1674,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE_FULL(Enum, Int32, Enum)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeEnum:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1593,8 +1696,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE2(Bytes)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeBytes:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1617,8 +1722,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE2(String)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeString:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1641,8 +1748,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE2(Message)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeMessage:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1665,8 +1774,10 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND FIELD_CASE2(Group)
// This block of code is generated, do not edit it directly.
// clang-format off
case GPBDataTypeGroup:
if (fieldType == GPBFieldTypeRepeated) {
@@ -1689,9 +1800,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
break;
// clang-format on
//%PDDM-EXPAND-END (18 expansions)
// clang-format off
}
}
@@ -1714,7 +1824,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
// Check for an autocreated value.
os_unfair_lock_lock(&readOnlyLock_);
GPBPrepareReadOnlySemaphore(self);
dispatch_semaphore_wait(readOnlySemaphore_, DISPATCH_TIME_FOREVER);
value = [autocreatedExtensionMap_ objectForKey:extension];
if (!value) {
// Auto create the message extensions to match normal fields.
@@ -1731,7 +1842,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
[value release];
}
os_unfair_lock_unlock(&readOnlyLock_);
dispatch_semaphore_signal(readOnlySemaphore_);
return value;
}
@@ -1862,7 +1973,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
#pragma mark - mergeFrom
- (void)mergeFromData:(NSData *)data
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
GPBCodedInputStream *input = [[GPBCodedInputStream alloc] initWithData:data];
[self mergeFromCodedInputStream:input extensionRegistry:extensionRegistry];
[input checkLastTagWas:0];
@@ -1872,7 +1983,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
#pragma mark - mergeDelimitedFrom
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
GPBCodedInputStreamState *state = &input->state_;
if (GPBCodedInputStreamIsAtEnd(state)) {
return;
@@ -1892,7 +2003,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
+ (instancetype)parseFromData:(NSData *)data
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr {
return [[[self alloc] initWithData:data
extensionRegistry:extensionRegistry
@@ -1900,7 +2011,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
+ (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr {
return
[[[self alloc] initWithCodedInputStream:input
@@ -1912,7 +2023,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
+ (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(id<GPBExtensionRegistry>)extensionRegistry
(GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr {
GPBMessage *message = [[[self alloc] init] autorelease];
@try {
@@ -1954,7 +2065,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (void)parseMessageSet:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
uint32_t typeId = 0;
NSData *rawBytes = nil;
GPBExtensionDescriptor *extension = nil;
@@ -2006,7 +2117,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (BOOL)parseUnknownField:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
tag:(uint32_t)tag {
GPBWireFormat wireType = GPBWireFormatGetTagWireType(tag);
int32_t fieldNumber = GPBWireFormatGetTagFieldNumber(tag);
@@ -2059,7 +2170,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
static void MergeSingleFieldFromCodedInputStream(
GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax,
GPBCodedInputStream *input, id<GPBExtensionRegistry>extensionRegistry) {
GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) {
GPBDataType fieldDataType = GPBGetFieldDataType(field);
switch (fieldDataType) {
#define CASE_SINGLE_POD(NAME, TYPE, FUNC_TYPE) \
@@ -2195,7 +2306,7 @@ static void MergeRepeatedPackedFieldFromCodedInputStream(
static void MergeRepeatedNotPackedFieldFromCodedInputStream(
GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax,
GPBCodedInputStream *input, id<GPBExtensionRegistry>extensionRegistry) {
GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) {
GPBCodedInputStreamState *state = &input->state_;
id genericArray = GetOrCreateArrayIvarWithField(self, field);
switch (GPBGetFieldDataType(field)) {
@@ -2260,7 +2371,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
}
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
GPBDescriptor *descriptor = [self descriptor];
GPBFileSyntax syntax = descriptor.file.syntax;
GPBCodedInputStreamState *state = &input->state_;
@@ -2880,7 +2991,8 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
#define CASE_REPEATED_POD_EXTRA(NAME, TYPE, ARRAY_TYPE, ARRAY_ACCESSOR_NAME) \
case GPBDataType##NAME: { \
GPB##ARRAY_TYPE##Array *array = genericArray; \
[array enumerate##ARRAY_ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, __unused NSUInteger idx, __unused BOOL *stop) { \
[array enumerate##ARRAY_ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) { \
_Pragma("unused(idx, stop)"); \
dataSize += GPBCompute##NAME##SizeNoTag(value); \
}]; \
break; \

View File

@@ -78,12 +78,13 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
// or zero for EOF.
// NOTE: This will throw if there is an error while parsing.
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
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:(id<GPBExtensionRegistry>)extensionRegistry;
extensionRegistry:
(GPBExtensionRegistry *)extensionRegistry;
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
@@ -91,12 +92,14 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
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,
GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass,
GPBMessage *autocreator,
GPBFieldDescriptor *field)
__attribute__((ns_returns_retained));

View File

@@ -28,9 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// clang-format off
#import "GPBBootstrap.h"
// clang-format on
#import "GPBArray.h"
#import "GPBCodedInputStream.h"

View File

@@ -31,6 +31,7 @@
// If you want to build protocol buffers in your own project without adding the
// project dependency, you can just add this file.
// This warning seems to treat code differently when it is #imported than when
// it is inline in the file. GPBDictionary.m compiles cleanly in other targets,
// but when #imported here it triggers a bunch of warnings that don't make

View File

@@ -31,9 +31,7 @@
// This header is meant to only be used by the generated source, it should not
// be included in code using protocol buffers.
// clang-format off
#import "GPBBootstrap.h"
// clang-format on
#import "GPBDescriptor_PackagePrivate.h"
#import "GPBExtensionInternals.h"

View File

@@ -31,7 +31,6 @@
#import "GPBRootObject_PackagePrivate.h"
#import <objc/runtime.h>
#import <os/lock.h>
#import <CoreFoundation/CoreFoundation.h>
@@ -74,19 +73,26 @@ static uint32_t jenkins_one_at_a_time_hash(const char *key) {
// to worry about deallocation. All of the items are added to it at
// startup, and so the keys don't need to be retained/released.
// Keys are NULL terminated char *.
static const void *GPBRootExtensionKeyRetain(__unused CFAllocatorRef allocator, const void *value) {
static const void *GPBRootExtensionKeyRetain(CFAllocatorRef allocator,
const void *value) {
#pragma unused(allocator)
return value;
}
static void GPBRootExtensionKeyRelease(__unused CFAllocatorRef allocator,
__unused const void *value) {}
static void GPBRootExtensionKeyRelease(CFAllocatorRef allocator,
const void *value) {
#pragma unused(allocator)
#pragma unused(value)
}
static CFStringRef GPBRootExtensionCopyKeyDescription(const void *value) {
const char *key = (const char *)value;
return CFStringCreateWithCString(kCFAllocatorDefault, key, kCFStringEncodingUTF8);
return CFStringCreateWithCString(kCFAllocatorDefault, key,
kCFStringEncodingUTF8);
}
static Boolean GPBRootExtensionKeyEqual(const void *value1, const void *value2) {
static Boolean GPBRootExtensionKeyEqual(const void *value1,
const void *value2) {
const char *key1 = (const char *)value1;
const char *key2 = (const char *)value2;
return strcmp(key1, key2) == 0;
@@ -97,34 +103,31 @@ static CFHashCode GPBRootExtensionKeyHash(const void *value) {
return jenkins_one_at_a_time_hash(key);
}
// Long ago, this was an OSSpinLock, but then it came to light that there were issues for that on
// iOS:
// NOTE: OSSpinLock may seem like a good fit here but Apple engineers have
// pointed out that they are vulnerable to live locking on iOS in cases of
// priority inversion:
// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html
// It was changed to a dispatch_semaphore_t, but that has potential for priority inversion issues.
// The minOS versions are now high enough that os_unfair_lock can be used, and should provide
// all the support we need. For more information in the concurrency/locking space see:
// https://gist.github.com/tclementdev/6af616354912b0347cdf6db159c37057
// https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html
// https://developer.apple.com/videos/play/wwdc2017/706/
static os_unfair_lock gExtensionSingletonDictionaryLock = OS_UNFAIR_LOCK_INIT;
static dispatch_semaphore_t gExtensionSingletonDictionarySemaphore;
static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL;
static GPBExtensionRegistry *gDefaultExtensionRegistry = NULL;
+ (void)initialize {
// Ensure the global is started up.
if (!gExtensionSingletonDictionary) {
gExtensionSingletonDictionarySemaphore = dispatch_semaphore_create(1);
CFDictionaryKeyCallBacks keyCallBacks = {
// See description above for reason for using custom dictionary.
0,
GPBRootExtensionKeyRetain,
GPBRootExtensionKeyRelease,
GPBRootExtensionCopyKeyDescription,
GPBRootExtensionKeyEqual,
GPBRootExtensionKeyHash,
// See description above for reason for using custom dictionary.
0,
GPBRootExtensionKeyRetain,
GPBRootExtensionKeyRelease,
GPBRootExtensionCopyKeyDescription,
GPBRootExtensionKeyEqual,
GPBRootExtensionKeyHash,
};
gExtensionSingletonDictionary = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallBacks,
&kCFTypeDictionaryValueCallBacks);
gExtensionSingletonDictionary =
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallBacks,
&kCFTypeDictionaryValueCallBacks);
gDefaultExtensionRegistry = [[GPBExtensionRegistry alloc] init];
}
@@ -144,9 +147,10 @@ static GPBExtensionRegistry *gDefaultExtensionRegistry = NULL;
+ (void)globallyRegisterExtension:(GPBExtensionDescriptor *)field {
const char *key = [field singletonNameC];
os_unfair_lock_lock(&gExtensionSingletonDictionaryLock);
dispatch_semaphore_wait(gExtensionSingletonDictionarySemaphore,
DISPATCH_TIME_FOREVER);
CFDictionarySetValue(gExtensionSingletonDictionary, key, field);
os_unfair_lock_unlock(&gExtensionSingletonDictionaryLock);
dispatch_semaphore_signal(gExtensionSingletonDictionarySemaphore);
}
static id ExtensionForName(id self, SEL _cmd) {
@@ -178,20 +182,21 @@ static id ExtensionForName(id self, SEL _cmd) {
key[classNameLen + 1 + selNameLen] = '\0';
// NOTE: Even though this method is called from another C function,
// gExtensionSingletonDictionaryLock and gExtensionSingletonDictionary
// gExtensionSingletonDictionarySemaphore and gExtensionSingletonDictionary
// will always be initialized. This is because this call flow is just to
// lookup the Extension, meaning the code is calling an Extension class
// message on a Message or Root class. This guarantees that the class was
// initialized and Message classes ensure their Root was also initialized.
NSAssert(gExtensionSingletonDictionary, @"Startup order broken!");
os_unfair_lock_lock(&gExtensionSingletonDictionaryLock);
dispatch_semaphore_wait(gExtensionSingletonDictionarySemaphore,
DISPATCH_TIME_FOREVER);
id extension = (id)CFDictionaryGetValue(gExtensionSingletonDictionary, key);
// We can't remove the key from the dictionary here (as an optimization),
// two threads could have gone into +resolveClassMethod: for the same method,
// and ended up here; there's no way to ensure both return YES without letting
// both try to wire in the method.
os_unfair_lock_unlock(&gExtensionSingletonDictionaryLock);
dispatch_semaphore_signal(gExtensionSingletonDictionarySemaphore);
return extension;
}
@@ -207,9 +212,11 @@ BOOL GPBResolveExtensionClassMethod(Class self, SEL sel) {
// file.
id extension = ExtensionForName(self, sel);
if (extension != nil) {
const char *encoding = GPBMessageEncodingForSelector(@selector(getClassValue), NO);
const char *encoding =
GPBMessageEncodingForSelector(@selector(getClassValue), NO);
Class metaClass = objc_getMetaClass(class_getName(self));
IMP imp = imp_implementationWithBlock(^(__unused id obj) {
IMP imp = imp_implementationWithBlock(^(id obj) {
#pragma unused(obj)
return extension;
});
BOOL methodAdded = class_addMethod(metaClass, sel, imp, encoding);
@@ -227,6 +234,7 @@ BOOL GPBResolveExtensionClassMethod(Class self, SEL sel) {
return NO;
}
+ (BOOL)resolveClassMethod:(SEL)sel {
if (GPBResolveExtensionClassMethod(self, sel)) {
return YES;

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/source_context.proto
#import "GPBDescriptor.h"
@@ -64,5 +63,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/source_context.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -83,5 +82,3 @@ typedef struct GPBSourceContext__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/struct.proto
#import "GPBDescriptor.h"
@@ -88,7 +87,7 @@ GPB_FINAL @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 container to be created. */
/** The number of items in @c fields without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger fields_Count;
@end
@@ -179,7 +178,7 @@ GPB_FINAL @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 container to be created. */
/** The number of items in @c valuesArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger valuesArray_Count;
@end
@@ -191,5 +190,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/struct.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -296,5 +295,3 @@ typedef struct GPBListValue__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/timestamp.proto
#import "GPBDescriptor.h"
@@ -95,6 +94,7 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
* .setNanos((int) ((millis % 1000) * 1000000)).build();
*
*
* Example 5: Compute Timestamp from Java `Instant.now()`.
*
* Instant now = Instant.now();
@@ -103,6 +103,7 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
* .setNanos(now.getNano()).build();
*
*
* Example 6: Compute Timestamp from current time in Python.
*
* timestamp = Timestamp()
@@ -161,5 +162,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/timestamp.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -94,5 +93,3 @@ typedef struct GPBTimestamp__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/type.proto
#import "GPBDescriptor.h"
@@ -196,17 +195,17 @@ GPB_FINAL @interface GPBType : GPBMessage
/** The list of fields. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBField*> *fieldsArray;
/** The number of items in @c fieldsArray without causing the container to be created. */
/** 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 container to be created. */
/** 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 container to be created. */
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
/** The source context. */
@@ -280,7 +279,7 @@ GPB_FINAL @interface GPBField : GPBMessage
/** The protocol buffer options. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
/** The number of items in @c optionsArray without causing the container to be created. */
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
/** The field JSON name. */
@@ -335,12 +334,12 @@ GPB_FINAL @interface GPBEnum : GPBMessage
/** Enum value definitions. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBEnumValue*> *enumvalueArray;
/** The number of items in @c enumvalueArray without causing the container to be created. */
/** 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 container to be created. */
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
/** The source context. */
@@ -386,7 +385,7 @@ GPB_FINAL @interface GPBEnumValue : GPBMessage
/** Protocol buffer options. */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
/** The number of items in @c optionsArray without causing the container to be created. */
/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
@end
@@ -431,5 +430,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/type.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -708,5 +707,3 @@ typedef struct GPBOption__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
* Store an unknown field. These are used in conjunction with
* GPBUnknownFieldSet.
**/
@interface GPBUnknownField : NSObject <NSCopying>
@interface GPBUnknownField : NSObject<NSCopying>
/** Initialize a field with the given number. */
- (instancetype)initWithNumber:(int32_t)number;
@@ -58,10 +58,10 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List;
/** An array of data values for this field. */
@property(nonatomic, readonly, strong) NSArray<NSData *> *lengthDelimitedList;
@property(nonatomic, readonly, strong) NSArray<NSData*> *lengthDelimitedList;
/** An array of groups of values for this field. */
@property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet *> *groupList;
@property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet*> *groupList;
/**
* Add a value to the varintList.

View File

@@ -40,8 +40,8 @@
GPBUInt64Array *mutableVarintList_;
GPBUInt32Array *mutableFixed32List_;
GPBUInt64Array *mutableFixed64List_;
NSMutableArray<NSData *> *mutableLengthDelimitedList_;
NSMutableArray<GPBUnknownFieldSet *> *mutableGroupList_;
NSMutableArray<NSData*> *mutableLengthDelimitedList_;
NSMutableArray<GPBUnknownFieldSet*> *mutableGroupList_;
}
@synthesize number = number_;
@@ -75,14 +75,16 @@
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
- (id)copyWithZone:(NSZone *)zone {
GPBUnknownField *result = [[GPBUnknownField allocWithZone:zone] initWithNumber:number_];
GPBUnknownField *result =
[[GPBUnknownField allocWithZone:zone] initWithNumber:number_];
result->mutableFixed32List_ = [mutableFixed32List_ copyWithZone:zone];
result->mutableFixed64List_ = [mutableFixed64List_ copyWithZone:zone];
result->mutableLengthDelimitedList_ = [mutableLengthDelimitedList_ mutableCopyWithZone:zone];
result->mutableLengthDelimitedList_ =
[mutableLengthDelimitedList_ mutableCopyWithZone:zone];
result->mutableVarintList_ = [mutableVarintList_ copyWithZone:zone];
if (mutableGroupList_.count) {
result->mutableGroupList_ =
[[NSMutableArray allocWithZone:zone] initWithCapacity:mutableGroupList_.count];
result->mutableGroupList_ = [[NSMutableArray allocWithZone:zone]
initWithCapacity:mutableGroupList_.count];
for (GPBUnknownFieldSet *group in mutableGroupList_) {
GPBUnknownFieldSet *copied = [group copyWithZone:zone];
[result->mutableGroupList_ addObject:copied];
@@ -97,21 +99,26 @@
if (![object isKindOfClass:[GPBUnknownField class]]) return NO;
GPBUnknownField *field = (GPBUnknownField *)object;
if (number_ != field->number_) return NO;
BOOL equalVarint = (mutableVarintList_.count == 0 && field->mutableVarintList_.count == 0) ||
[mutableVarintList_ isEqual:field->mutableVarintList_];
BOOL equalVarint =
(mutableVarintList_.count == 0 && field->mutableVarintList_.count == 0) ||
[mutableVarintList_ isEqual:field->mutableVarintList_];
if (!equalVarint) return NO;
BOOL equalFixed32 = (mutableFixed32List_.count == 0 && field->mutableFixed32List_.count == 0) ||
BOOL equalFixed32 = (mutableFixed32List_.count == 0 &&
field->mutableFixed32List_.count == 0) ||
[mutableFixed32List_ isEqual:field->mutableFixed32List_];
if (!equalFixed32) return NO;
BOOL equalFixed64 = (mutableFixed64List_.count == 0 && field->mutableFixed64List_.count == 0) ||
BOOL equalFixed64 = (mutableFixed64List_.count == 0 &&
field->mutableFixed64List_.count == 0) ||
[mutableFixed64List_ isEqual:field->mutableFixed64List_];
if (!equalFixed64) return NO;
BOOL equalLDList =
(mutableLengthDelimitedList_.count == 0 && field->mutableLengthDelimitedList_.count == 0) ||
(mutableLengthDelimitedList_.count == 0 &&
field->mutableLengthDelimitedList_.count == 0) ||
[mutableLengthDelimitedList_ isEqual:field->mutableLengthDelimitedList_];
if (!equalLDList) return NO;
BOOL equalGroupList = (mutableGroupList_.count == 0 && field->mutableGroupList_.count == 0) ||
[mutableGroupList_ isEqual:field->mutableGroupList_];
BOOL equalGroupList =
(mutableGroupList_.count == 0 && field->mutableGroupList_.count == 0) ||
[mutableGroupList_ isEqual:field->mutableGroupList_];
if (!equalGroupList) return NO;
return YES;
}
@@ -154,17 +161,20 @@
__block size_t result = 0;
int32_t number = number_;
[mutableVarintList_
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
result += GPBComputeUInt64Size(number, value);
}];
[mutableFixed32List_
enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
result += GPBComputeFixed32Size(number, value);
}];
[mutableFixed64List_
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
result += GPBComputeFixed64Size(number, value);
}];
@@ -195,19 +205,23 @@
- (NSString *)description {
NSMutableString *description =
[NSMutableString stringWithFormat:@"<%@ %p>: Field: %d {\n", [self class], self, number_];
[NSMutableString stringWithFormat:@"<%@ %p>: Field: %d {\n",
[self class], self, number_];
[mutableVarintList_
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[description appendFormat:@"\t%llu\n", value];
}];
[mutableFixed32List_
enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[description appendFormat:@"\t%u\n", value];
}];
[mutableFixed64List_
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
[description appendFormat:@"\t%llu\n", value];
}];
@@ -255,14 +269,16 @@
if (mutableLengthDelimitedList_ == nil) {
mutableLengthDelimitedList_ = [otherLengthDelimitedList mutableCopy];
} else {
[mutableLengthDelimitedList_ addObjectsFromArray:otherLengthDelimitedList];
[mutableLengthDelimitedList_
addObjectsFromArray:otherLengthDelimitedList];
}
}
NSArray *otherGroupList = other.groupList;
if (otherGroupList.count > 0) {
if (mutableGroupList_ == nil) {
mutableGroupList_ = [[NSMutableArray alloc] initWithCapacity:otherGroupList.count];
mutableGroupList_ =
[[NSMutableArray alloc] initWithCapacity:otherGroupList.count];
}
// Make our own mutable copies.
for (GPBUnknownFieldSet *group in otherGroupList) {
@@ -283,7 +299,8 @@
- (void)addFixed32:(uint32_t)value {
if (mutableFixed32List_ == nil) {
mutableFixed32List_ = [[GPBUInt32Array alloc] initWithValues:&value count:1];
mutableFixed32List_ =
[[GPBUInt32Array alloc] initWithValues:&value count:1];
} else {
[mutableFixed32List_ addValue:value];
}
@@ -291,7 +308,8 @@
- (void)addFixed64:(uint64_t)value {
if (mutableFixed64List_ == nil) {
mutableFixed64List_ = [[GPBUInt64Array alloc] initWithValues:&value count:1];
mutableFixed64List_ =
[[GPBUInt64Array alloc] initWithValues:&value count:1];
} else {
[mutableFixed64List_ addValue:value];
}
@@ -299,7 +317,8 @@
- (void)addLengthDelimited:(NSData *)value {
if (mutableLengthDelimitedList_ == nil) {
mutableLengthDelimitedList_ = [[NSMutableArray alloc] initWithObjects:&value count:1];
mutableLengthDelimitedList_ =
[[NSMutableArray alloc] initWithObjects:&value count:1];
} else {
[mutableLengthDelimitedList_ addObject:value];
}

View File

@@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
* applies for files declared with the "proto2" syntax. Files declared with the
* "proto3" syntax discard the unknown values.
**/
@interface GPBUnknownFieldSet : NSObject <NSCopying>
@interface GPBUnknownFieldSet : NSObject<NSCopying>
/**
* Tests to see if the given field number has a value.

View File

@@ -40,7 +40,8 @@
static void checkNumber(int32_t number) {
if (number == 0) {
[NSException raise:NSInvalidArgumentException format:@"Zero is not a valid field number."];
[NSException raise:NSInvalidArgumentException
format:@"Zero is not a valid field number."];
}
}
@@ -49,7 +50,8 @@ static void checkNumber(int32_t number) {
CFMutableDictionaryRef fields_;
}
static void CopyWorker(__unused const void *key, const void *value, void *context) {
static void CopyWorker(const void *key, const void *value, void *context) {
#pragma unused(key)
GPBUnknownField *field = value;
GPBUnknownFieldSet *result = context;
@@ -109,7 +111,8 @@ static void CopyWorker(__unused const void *key, const void *value, void *contex
- (GPBUnknownField *)getField:(int32_t)number {
ssize_t key = number;
GPBUnknownField *result = fields_ ? CFDictionaryGetValue(fields_, (void *)key) : nil;
GPBUnknownField *result =
fields_ ? CFDictionaryGetValue(fields_, (void *)key) : nil;
return result;
}
@@ -122,7 +125,8 @@ static void CopyWorker(__unused const void *key, const void *value, void *contex
size_t count = CFDictionaryGetCount(fields_);
ssize_t keys[count];
GPBUnknownField *values[count];
CFDictionaryGetKeysAndValues(fields_, (const void **)keys, (const void **)values);
CFDictionaryGetKeysAndValues(fields_, (const void **)keys,
(const void **)values);
struct GPBFieldPair {
ssize_t key;
GPBUnknownField *value;
@@ -131,11 +135,12 @@ static void CopyWorker(__unused const void *key, const void *value, void *contex
pairs[i].key = keys[i];
pairs[i].value = values[i];
};
qsort_b(pairs, count, sizeof(struct GPBFieldPair), ^(const void *first, const void *second) {
const struct GPBFieldPair *a = first;
const struct GPBFieldPair *b = second;
return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1);
});
qsort_b(pairs, count, sizeof(struct GPBFieldPair),
^(const void *first, const void *second) {
const struct GPBFieldPair *a = first;
const struct GPBFieldPair *b = second;
return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1);
});
for (size_t i = 0; i < count; ++i) {
values[i] = pairs[i].value;
};
@@ -149,7 +154,8 @@ static void CopyWorker(__unused const void *key, const void *value, void *contex
size_t count = CFDictionaryGetCount(fields_);
ssize_t keys[count];
GPBUnknownField *values[count];
CFDictionaryGetKeysAndValues(fields_, (const void **)keys, (const void **)values);
CFDictionaryGetKeysAndValues(fields_, (const void **)keys,
(const void **)values);
if (count > 1) {
struct GPBFieldPair {
ssize_t key;
@@ -160,11 +166,12 @@ static void CopyWorker(__unused const void *key, const void *value, void *contex
pairs[i].key = keys[i];
pairs[i].value = values[i];
};
qsort_b(pairs, count, sizeof(struct GPBFieldPair), ^(const void *first, const void *second) {
const struct GPBFieldPair *a = first;
const struct GPBFieldPair *b = second;
return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1);
});
qsort_b(pairs, count, sizeof(struct GPBFieldPair),
^(const void *first, const void *second) {
const struct GPBFieldPair *a = first;
const struct GPBFieldPair *b = second;
return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1);
});
for (size_t i = 0; i < count; ++i) {
GPBUnknownField *value = pairs[i].value;
[value writeToOutput:output];
@@ -175,16 +182,17 @@ static void CopyWorker(__unused const void *key, const void *value, void *contex
}
- (NSString *)description {
NSMutableString *description =
[NSMutableString stringWithFormat:@"<%@ %p>: TextFormat: {\n", [self class], self];
NSMutableString *description = [NSMutableString
stringWithFormat:@"<%@ %p>: TextFormat: {\n", [self class], self];
NSString *textFormat = GPBTextFormatForUnknownFieldSet(self, @" ");
[description appendString:textFormat];
[description appendString:@"}"];
return description;
}
static void GPBUnknownFieldSetSerializedSize(__unused const void *key, const void *value,
static void GPBUnknownFieldSetSerializedSize(const void *key, const void *value,
void *context) {
#pragma unused(key)
GPBUnknownField *field = value;
size_t *result = context;
*result += [field serializedSize];
@@ -193,13 +201,16 @@ static void GPBUnknownFieldSetSerializedSize(__unused const void *key, const voi
- (size_t)serializedSize {
size_t result = 0;
if (fields_) {
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetSerializedSize, &result);
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetSerializedSize,
&result);
}
return result;
}
static void GPBUnknownFieldSetWriteAsMessageSetTo(__unused const void *key, const void *value,
static void GPBUnknownFieldSetWriteAsMessageSetTo(const void *key,
const void *value,
void *context) {
#pragma unused(key)
GPBUnknownField *field = value;
GPBCodedOutputStream *output = context;
[field writeAsMessageSetExtensionToOutput:output];
@@ -207,12 +218,15 @@ static void GPBUnknownFieldSetWriteAsMessageSetTo(__unused const void *key, cons
- (void)writeAsMessageSetTo:(GPBCodedOutputStream *)output {
if (fields_) {
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetWriteAsMessageSetTo, output);
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetWriteAsMessageSetTo,
output);
}
}
static void GPBUnknownFieldSetSerializedSizeAsMessageSet(__unused const void *key,
const void *value, void *context) {
static void GPBUnknownFieldSetSerializedSizeAsMessageSet(const void *key,
const void *value,
void *context) {
#pragma unused(key)
GPBUnknownField *field = value;
size_t *result = context;
*result += [field serializedSizeAsMessageSetExtension];
@@ -221,14 +235,16 @@ static void GPBUnknownFieldSetSerializedSizeAsMessageSet(__unused const void *ke
- (size_t)serializedSizeAsMessageSet {
size_t result = 0;
if (fields_) {
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetSerializedSizeAsMessageSet, &result);
CFDictionaryApplyFunction(
fields_, GPBUnknownFieldSetSerializedSizeAsMessageSet, &result);
}
return result;
}
- (NSData *)data {
NSMutableData *data = [NSMutableData dataWithLength:self.serializedSize];
GPBCodedOutputStream *output = [[GPBCodedOutputStream alloc] initWithData:data];
GPBCodedOutputStream *output =
[[GPBCodedOutputStream alloc] initWithData:data];
[self writeToCodedOutputStream:output];
[output release];
return data;
@@ -244,8 +260,8 @@ static void GPBUnknownFieldSetSerializedSizeAsMessageSet(__unused const void *ke
if (!fields_) {
// Use a custom dictionary here because the keys are numbers and conversion
// back and forth from NSNumber isn't worth the cost.
fields_ =
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
fields_ = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL,
&kCFTypeDictionaryValueCallBacks);
}
ssize_t key = number;
CFDictionarySetValue(fields_, (const void *)key, field);
@@ -253,7 +269,8 @@ static void GPBUnknownFieldSetSerializedSizeAsMessageSet(__unused const void *ke
- (GPBUnknownField *)mutableFieldForNumber:(int32_t)number create:(BOOL)create {
ssize_t key = number;
GPBUnknownField *existing = fields_ ? CFDictionaryGetValue(fields_, (const void *)key) : nil;
GPBUnknownField *existing =
fields_ ? CFDictionaryGetValue(fields_, (const void *)key) : nil;
if (!existing && create) {
existing = [[GPBUnknownField alloc] initWithNumber:number];
// This retains existing.
@@ -263,8 +280,10 @@ static void GPBUnknownFieldSetSerializedSizeAsMessageSet(__unused const void *ke
return existing;
}
static void GPBUnknownFieldSetMergeUnknownFields(__unused const void *key, const void *value,
static void GPBUnknownFieldSetMergeUnknownFields(const void *key,
const void *value,
void *context) {
#pragma unused(key)
GPBUnknownField *field = value;
GPBUnknownFieldSet *self = context;
@@ -285,7 +304,8 @@ static void GPBUnknownFieldSetMergeUnknownFields(__unused const void *key, const
- (void)mergeUnknownFields:(GPBUnknownFieldSet *)other {
if (other && other->fields_) {
CFDictionaryApplyFunction(other->fields_, GPBUnknownFieldSetMergeUnknownFields, self);
CFDictionaryApplyFunction(other->fields_,
GPBUnknownFieldSetMergeUnknownFields, self);
}
}
@@ -342,7 +362,8 @@ static void GPBUnknownFieldSetMergeUnknownFields(__unused const void *key, const
}
- (void)mergeMessageSetMessage:(int32_t)number data:(NSData *)messageData {
[[self mutableFieldForNumber:number create:YES] addLengthDelimited:messageData];
[[self mutableFieldForNumber:number create:YES]
addLengthDelimited:messageData];
}
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data {

View File

@@ -50,7 +50,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An NSString with the TextFormat of the message.
**/
NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *__nullable lineIndent);
NSString *GPBTextFormatForMessage(GPBMessage *message,
NSString * __nullable lineIndent);
/**
* Generates a string that should be a valid "TextFormat" for the C++ version
@@ -62,8 +63,8 @@ NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *__nullable line
*
* @return An NSString with the TextFormat of the unknown field set.
**/
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *__nullable unknownSet,
NSString *__nullable lineIndent);
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet,
NSString * __nullable lineIndent);
/**
* Checks if the given field number is set on a message.
@@ -101,11 +102,9 @@ void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field);
**/
void GPBClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof);
// Disable clang-format for the macros.
// clang-format off
//%PDDM-EXPAND GPB_ACCESSORS()
// This block of code is generated, do not edit it directly.
// clang-format off
//
@@ -396,9 +395,8 @@ void GPBSetMessageMapField(GPBMessage *self,
GPBFieldDescriptor *field,
id dictionary);
//%PDDM-EXPAND-END GPB_ACCESSORS()
// clang-format on
//%PDDM-EXPAND-END GPB_ACCESSORS()
/**
* Returns an empty NSData to assign to byte fields when you wish to assign them
@@ -415,8 +413,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
// Disable clang-format for the macros.
// clang-format off
//%PDDM-DEFINE GPB_ACCESSORS()
//%
@@ -553,5 +549,3 @@ CF_EXTERN_C_END
//% **/
//%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value);
//%
// clang-format on

File diff suppressed because it is too large Load Diff

View File

@@ -40,15 +40,17 @@
#define GPBStringify(S) #S
#define GPBStringifySymbol(S) GPBStringify(S)
#define GPBNSStringify(S) @ #S
#define GPBNSStringify(S) @#S
#define GPBNSStringifySymbol(S) GPBNSStringify(S)
// Macros for generating a Class from a class name. These are used in
// the generated GPB descriptor classes wherever an Objective C class
// reference is needed for a generated class.
#define GPBObjCClassSymbol(name) OBJC_CLASS_$_##name
#define GPBObjCClass(name) ((__bridge Class) & (GPBObjCClassSymbol(name)))
#define GPBObjCClassDeclaration(name) extern const GPBObjcClass_t GPBObjCClassSymbol(name)
#define GPBObjCClass(name) \
((__bridge Class)&(GPBObjCClassSymbol(name)))
#define GPBObjCClassDeclaration(name) \
extern const GPBObjcClass_t GPBObjCClassSymbol(name)
// Constant to internally mark when there is no has bit.
#define GPBNoHasBit INT32_MAX
@@ -118,7 +120,7 @@ GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) {
// 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));
return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n) & 1));
}
// Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
@@ -126,7 +128,7 @@ GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) {
// 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));
return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n) & 1));
}
// Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers
@@ -195,84 +197,102 @@ GPB_INLINE BOOL GPBFieldStoresObject(GPBFieldDescriptor *field) {
}
BOOL GPBGetHasIvar(GPBMessage *self, int32_t index, uint32_t fieldNumber);
void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, BOOL value);
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) {
GPB_INLINE BOOL
GPBGetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field) {
GPBMessageFieldDescription *fieldDesc = field->description_;
return GPBGetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number);
}
#pragma clang diagnostic pop
// Disable clang-format for the macros.
// clang-format off
//%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE)
//%void GPBSet##NAME##IvarWithFieldPrivate(GPBMessage *self,
//% NAME$S GPBFieldDescriptor *field,
//% NAME$S TYPE value);
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Bool, BOOL)
// This block of code is generated, do not edit it directly.
// clang-format off
void GPBSetBoolIvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
BOOL value);
// clang-format on
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Int32, int32_t)
// This block of code is generated, do not edit it directly.
// clang-format off
void GPBSetInt32IvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value);
// clang-format on
//%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt32, uint32_t)
// This block of code is generated, do not edit it directly.
// clang-format off
void GPBSetUInt32IvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
uint32_t value);
// clang-format on
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Int64, int64_t)
// This block of code is generated, do not edit it directly.
// clang-format off
void GPBSetInt64IvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
int64_t value);
// clang-format on
//%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt64, uint64_t)
// This block of code is generated, do not edit it directly.
// clang-format off
void GPBSetUInt64IvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
uint64_t value);
// clang-format on
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Float, float)
// This block of code is generated, do not edit it directly.
// clang-format off
void GPBSetFloatIvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
float value);
// clang-format on
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Double, double)
// This block of code is generated, do not edit it directly.
// clang-format off
void GPBSetDoubleIvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
double value);
// clang-format on
//%PDDM-EXPAND-END (7 expansions)
// clang-format on
void GPBSetEnumIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
void GPBSetEnumIvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value);
id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
void GPBSetObjectIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field, id value);
void GPBSetRetainedObjectIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field,
id __attribute__((ns_consumed)) value);
void GPBSetObjectIvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field, id value);
void GPBSetRetainedObjectIvarWithFieldPrivate(GPBMessage *self,
GPBFieldDescriptor *field,
id __attribute__((ns_consumed))
value);
// GPBGetObjectIvarWithField will automatically create the field (message) if
// it doesn't exist. GPBGetObjectIvarWithFieldNoAutocreate will return nil.
id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self, GPBFieldDescriptor *field);
id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self,
GPBFieldDescriptor *field);
// 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);
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).
@@ -282,13 +302,17 @@ const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel);
// Helper for text format name encoding.
// decodeData is the data describing the special decodes.
// key and inputString are the input that needs decoding.
NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, NSString *inputString);
NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key,
NSString *inputString);
// Shims from the older generated code into the runtime.
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, GPBFieldDescriptor *field, int32_t value,
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value,
GPBFileSyntax syntax);
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, int32_t oneofHasIndex,
uint32_t fieldNumberNotToClear);
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
int32_t oneofHasIndex, uint32_t fieldNumberNotToClear);
// A series of selectors that are used solely to get @encoding values
// for them by the dynamic protobuf runtime code. See

View File

@@ -141,7 +141,8 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
*
* @return A newly configured GPBAny with the given message, or nil on failure.
*/
+ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message error:(NSError **)errorPtr;
+ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message
error:(NSError **)errorPtr;
/**
* Convenience method to create a GPBAny containing the serialized message.
@@ -167,7 +168,8 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
*
* @return A newly configured GPBAny with the given message, or nil on failure.
*/
- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message error:(NSError **)errorPtr;
- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message
error:(NSError **)errorPtr;
/**
* Initializes a GPBAny to contain the serialized message.
@@ -193,7 +195,8 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
*
* @return Whether the packing was successful or not.
*/
- (BOOL)packWithMessage:(nonnull GPBMessage *)message error:(NSError **)errorPtr;
- (BOOL)packWithMessage:(nonnull GPBMessage *)message
error:(NSError **)errorPtr;
/**
* Packs the serialized message into this GPBAny.
@@ -222,7 +225,8 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
* @return An instance of the given class populated with the contained data, or
* nil on failure.
*/
- (nullable GPBMessage *)unpackMessageClass:(Class)messageClass error:(NSError **)errorPtr;
- (nullable GPBMessage *)unpackMessageClass:(Class)messageClass
error:(NSError **)errorPtr;
@end

View File

@@ -36,15 +36,18 @@
#import "GPBUtilities_PackagePrivate.h"
NSString *const GPBWellKnownTypesErrorDomain = GPBNSStringifySymbol(GPBWellKnownTypesErrorDomain);
NSString *const GPBWellKnownTypesErrorDomain =
GPBNSStringifySymbol(GPBWellKnownTypesErrorDomain);
static NSString *kTypePrefixGoogleApisCom = @"type.googleapis.com/";
static NSTimeInterval TimeIntervalFromSecondsAndNanos(int64_t seconds, int32_t nanos) {
static NSTimeInterval TimeIntervalFromSecondsAndNanos(int64_t seconds,
int32_t nanos) {
return seconds + (NSTimeInterval)nanos / 1e9;
}
static int32_t SecondsAndNanosFromTimeInterval(NSTimeInterval time, int64_t *outSeconds,
static int32_t SecondsAndNanosFromTimeInterval(NSTimeInterval time,
int64_t *outSeconds,
BOOL nanosMustBePositive) {
NSTimeInterval seconds;
NSTimeInterval nanos = modf(time, &seconds);
@@ -76,7 +79,8 @@ static NSString *BuildTypeURL(NSString *typeURLPrefix, NSString *fullName) {
static NSString *ParseTypeFromURL(NSString *typeURLString) {
NSRange range = [typeURLString rangeOfString:@"/" options:NSBackwardsSearch];
if ((range.location == NSNotFound) || (NSMaxRange(range) == typeURLString.length)) {
if ((range.location == NSNotFound) ||
(NSMaxRange(range) == typeURLString.length)) {
return nil;
}
NSString *result = [typeURLString substringFromIndex:range.location + 1];
@@ -94,7 +98,8 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
if ((self = [super init])) {
int64_t seconds;
int32_t nanos = SecondsAndNanosFromTimeInterval(timeIntervalSince1970, &seconds, YES);
int32_t nanos = SecondsAndNanosFromTimeInterval(
timeIntervalSince1970, &seconds, YES);
self.seconds = seconds;
self.nanos = nanos;
}
@@ -115,7 +120,8 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
int64_t seconds;
int32_t nanos = SecondsAndNanosFromTimeInterval(timeIntervalSince1970, &seconds, YES);
int32_t nanos =
SecondsAndNanosFromTimeInterval(timeIntervalSince1970, &seconds, YES);
self.seconds = seconds;
self.nanos = nanos;
}
@@ -129,7 +135,8 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval {
if ((self = [super init])) {
int64_t seconds;
int32_t nanos = SecondsAndNanosFromTimeInterval(timeInterval, &seconds, NO);
int32_t nanos = SecondsAndNanosFromTimeInterval(
timeInterval, &seconds, NO);
self.seconds = seconds;
self.nanos = nanos;
}
@@ -146,7 +153,8 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
- (void)setTimeInterval:(NSTimeInterval)timeInterval {
int64_t seconds;
int32_t nanos = SecondsAndNanosFromTimeInterval(timeInterval, &seconds, NO);
int32_t nanos =
SecondsAndNanosFromTimeInterval(timeInterval, &seconds, NO);
self.seconds = seconds;
self.nanos = nanos;
}
@@ -165,19 +173,26 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
@implementation GPBAny (GBPWellKnownTypes)
+ (instancetype)anyWithMessage:(GPBMessage *)message error:(NSError **)errorPtr {
return [self anyWithMessage:message typeURLPrefix:kTypePrefixGoogleApisCom error:errorPtr];
+ (instancetype)anyWithMessage:(GPBMessage *)message
error:(NSError **)errorPtr {
return [self anyWithMessage:message
typeURLPrefix:kTypePrefixGoogleApisCom
error:errorPtr];
}
+ (instancetype)anyWithMessage:(GPBMessage *)message
typeURLPrefix:(NSString *)typeURLPrefix
error:(NSError **)errorPtr {
return [[[self alloc] initWithMessage:message typeURLPrefix:typeURLPrefix
return [[[self alloc] initWithMessage:message
typeURLPrefix:typeURLPrefix
error:errorPtr] autorelease];
}
- (instancetype)initWithMessage:(GPBMessage *)message error:(NSError **)errorPtr {
return [self initWithMessage:message typeURLPrefix:kTypePrefixGoogleApisCom error:errorPtr];
- (instancetype)initWithMessage:(GPBMessage *)message
error:(NSError **)errorPtr {
return [self initWithMessage:message
typeURLPrefix:kTypePrefixGoogleApisCom
error:errorPtr];
}
- (instancetype)initWithMessage:(GPBMessage *)message
@@ -185,7 +200,9 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
error:(NSError **)errorPtr {
self = [self init];
if (self) {
if (![self packWithMessage:message typeURLPrefix:typeURLPrefix error:errorPtr]) {
if (![self packWithMessage:message
typeURLPrefix:typeURLPrefix
error:errorPtr]) {
[self release];
self = nil;
}
@@ -193,8 +210,11 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
return self;
}
- (BOOL)packWithMessage:(GPBMessage *)message error:(NSError **)errorPtr {
return [self packWithMessage:message typeURLPrefix:kTypePrefixGoogleApisCom error:errorPtr];
- (BOOL)packWithMessage:(GPBMessage *)message
error:(NSError **)errorPtr {
return [self packWithMessage:message
typeURLPrefix:kTypePrefixGoogleApisCom
error:errorPtr];
}
- (BOOL)packWithMessage:(GPBMessage *)message
@@ -203,9 +223,10 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
NSString *fullName = [message descriptor].fullName;
if (fullName.length == 0) {
if (errorPtr) {
*errorPtr = [NSError errorWithDomain:GPBWellKnownTypesErrorDomain
code:GPBWellKnownTypesErrorCodeFailedToComputeTypeURL
userInfo:nil];
*errorPtr =
[NSError errorWithDomain:GPBWellKnownTypesErrorDomain
code:GPBWellKnownTypesErrorCodeFailedToComputeTypeURL
userInfo:nil];
}
return NO;
}
@@ -217,13 +238,15 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
return YES;
}
- (GPBMessage *)unpackMessageClass:(Class)messageClass error:(NSError **)errorPtr {
- (GPBMessage *)unpackMessageClass:(Class)messageClass
error:(NSError **)errorPtr {
NSString *fullName = [messageClass descriptor].fullName;
if (fullName.length == 0) {
if (errorPtr) {
*errorPtr = [NSError errorWithDomain:GPBWellKnownTypesErrorDomain
code:GPBWellKnownTypesErrorCodeFailedToComputeTypeURL
userInfo:nil];
*errorPtr =
[NSError errorWithDomain:GPBWellKnownTypesErrorDomain
code:GPBWellKnownTypesErrorCodeFailedToComputeTypeURL
userInfo:nil];
}
return nil;
}
@@ -231,9 +254,10 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
NSString *expectedFullName = ParseTypeFromURL(self.typeURL);
if ((expectedFullName == nil) || ![expectedFullName isEqual:fullName]) {
if (errorPtr) {
*errorPtr = [NSError errorWithDomain:GPBWellKnownTypesErrorDomain
code:GPBWellKnownTypesErrorCodeTypeURLMismatch
userInfo:nil];
*errorPtr =
[NSError errorWithDomain:GPBWellKnownTypesErrorDomain
code:GPBWellKnownTypesErrorCodeTypeURLMismatch
userInfo:nil];
}
return nil;
}
@@ -241,7 +265,8 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
// Any is proto3, which means no extensions, so this assumes anything put
// within an any also won't need extensions. A second helper could be added
// if needed.
return [messageClass parseFromData:self.value error:errorPtr];
return [messageClass parseFromData:self.value
error:errorPtr];
}
@end

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/wrappers.proto
#import "GPBDescriptor.h"
@@ -206,5 +205,3 @@ CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clange-format on

View File

@@ -1,5 +1,4 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// clang-format off
// source: google/protobuf/wrappers.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
@@ -442,5 +441,3 @@ typedef struct GPBBytesValue__storage_ {
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
// clang-format on

View File

@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objectVersion = 47;
objects = {
/* Begin PBXBuildFile section */
@@ -26,7 +26,7 @@
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
8B96157414C8C38C00A2AC0B /* GPBDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */; };
8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */; };
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOutputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */; };
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */; };
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */; };
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */; };
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */; };
@@ -61,6 +61,8 @@
F40EE4BF206BF8B90071091A /* GPBCompileTest21.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE486206BF8AF0071091A /* GPBCompileTest21.m */; };
F40EE4C0206BF8B90071091A /* GPBCompileTest22.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48A206BF8B00071091A /* GPBCompileTest22.m */; };
F40EE4C1206BF8B90071091A /* GPBCompileTest23.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE487206BF8B00071091A /* GPBCompileTest23.m */; };
F40EE50B206C06640071091A /* GPBCompileTest24.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE508206C06440071091A /* GPBCompileTest24.m */; };
F40EE50C206C06640071091A /* GPBCompileTest25.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE507206C06440071091A /* GPBCompileTest25.m */; };
F41C175D1833D3310064ED4D /* GPBPerfTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F41C175C1833D3310064ED4D /* GPBPerfTests.m */; };
F4353D1D1AB8822D005A6198 /* GPBDescriptorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */; };
F4353D231ABB1537005A6198 /* GPBDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D211ABB1537005A6198 /* GPBDictionary.m */; };
@@ -139,7 +141,7 @@
7461B4E80F94F99000A0C422 /* GPBWireFormat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWireFormat.m; sourceTree = "<group>"; };
7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libProtocolBuffers.a; sourceTree = BUILT_PRODUCTS_DIR; };
7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCodedInputStreamTests.m; sourceTree = "<group>"; };
7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCodedOutputStreamTests.m; sourceTree = "<group>"; };
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCodedOuputStreamTests.m; sourceTree = "<group>"; };
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBMessageTests.m; sourceTree = "<group>"; };
7461B6AB0F94FDF800A0C422 /* GPBTestUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBTestUtilities.h; sourceTree = "<group>"; };
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBTestUtilities.m; sourceTree = "<group>"; };
@@ -159,11 +161,21 @@
8B42494D1A92A16600BC1EC6 /* timestamp.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = timestamp.proto; path = ../src/google/protobuf/timestamp.proto; sourceTree = "<group>"; };
8B79657814992E3E002FFBFC /* GPBRootObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBRootObject.h; sourceTree = "<group>"; };
8B79657914992E3E002FFBFC /* GPBRootObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBRootObject.m; sourceTree = "<group>"; };
8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_custom_options.proto; path = ../../src/google/protobuf/unittest_custom_options.proto; sourceTree = "<group>"; };
8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_embed_optimize_for.proto; path = ../../src/google/protobuf/unittest_embed_optimize_for.proto; sourceTree = "<group>"; };
8B7E6A7614893DBA00F8884A /* unittest_empty.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_empty.proto; path = ../../src/google/protobuf/unittest_empty.proto; sourceTree = "<group>"; };
8B7E6A7814893DBB00F8884A /* unittest_import.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_import.proto; path = ../../src/google/protobuf/unittest_import.proto; sourceTree = "<group>"; };
8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_mset.proto; path = ../../src/google/protobuf/unittest_mset.proto; sourceTree = "<group>"; };
8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_no_generic_services.proto; path = ../../src/google/protobuf/unittest_no_generic_services.proto; sourceTree = "<group>"; };
8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_optimize_for.proto; path = ../../src/google/protobuf/unittest_optimize_for.proto; sourceTree = "<group>"; };
8B7E6A7E14893DBC00F8884A /* unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest.proto; path = ../../src/google/protobuf/unittest.proto; sourceTree = "<group>"; };
8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBARCUnittestProtos.m; sourceTree = "<group>"; };
8B96157214C8B06000A2AC0B /* GPBDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBDescriptor.h; sourceTree = "<group>"; };
8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDescriptor.m; sourceTree = "<group>"; };
8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_lite.proto; path = ../../src/google/protobuf/unittest_lite.proto; sourceTree = "<group>"; };
8BBEA4A6147C727100C4ADB7 /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8BCF338814ED799900BC5317 /* GPBProtocolBuffers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GPBProtocolBuffers.m; sourceTree = "<group>"; };
8BD3981D14BE54220081D629 /* unittest_enormous_descriptor.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_enormous_descriptor.proto; path = ../../src/google/protobuf/unittest_enormous_descriptor.proto; sourceTree = "<group>"; };
8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnittestProtos.m; sourceTree = "<group>"; };
8BEB5AE01498033E0078BF9D /* GPBRuntimeTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRuntimeTypes.h; sourceTree = "<group>"; };
8BFF9D1923AD582200E63E32 /* GPBMessageTests+ClassNames.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+ClassNames.m"; sourceTree = "<group>"; };
@@ -193,6 +205,8 @@
F40EE491206BF8B10071091A /* GPBCompileTest03.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest03.m; sourceTree = "<group>"; };
F40EE492206BF8B10071091A /* GPBCompileTest06.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest06.m; sourceTree = "<group>"; };
F40EE493206BF8B20071091A /* GPBCompileTest11.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest11.m; sourceTree = "<group>"; };
F40EE507206C06440071091A /* GPBCompileTest25.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest25.m; sourceTree = "<group>"; };
F40EE508206C06440071091A /* GPBCompileTest24.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest24.m; sourceTree = "<group>"; };
F41C175C1833D3310064ED4D /* GPBPerfTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBPerfTests.m; sourceTree = "<group>"; };
F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDescriptorTests.m; sourceTree = "<group>"; };
F4353D201ABB1537005A6198 /* GPBDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBDictionary.h; sourceTree = "<group>"; };
@@ -215,23 +229,6 @@
F4487C7E1AAF62CD00531423 /* GPBMessageTests+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Serialization.m"; sourceTree = "<group>"; };
F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = "<group>"; };
F44929001C866B1900C2548A /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBCodedOutputStream_PackagePrivate.h; sourceTree = "<group>"; };
F44FEABE28B5465900EC57B3 /* unittest_deprecated_file.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_deprecated_file.proto; sourceTree = "<group>"; };
F44FEABF28B5465900EC57B3 /* unittest_mset.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_mset.proto; sourceTree = "<group>"; };
F44FEAC028B5465900EC57B3 /* unittest_import.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_import.proto; sourceTree = "<group>"; };
F44FEAC228B5465900EC57B3 /* unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest.proto; sourceTree = "<group>"; };
F44FEAC428B5465900EC57B3 /* unittest_preserve_unknown_enum.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_preserve_unknown_enum.proto; sourceTree = "<group>"; };
F44FEAC528B5465900EC57B3 /* any_test.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = any_test.proto; sourceTree = "<group>"; };
F44FEAC628B5465900EC57B3 /* unittest_import_public.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_import_public.proto; sourceTree = "<group>"; };
F44FEAC728B5465900EC57B3 /* map_unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = map_unittest.proto; sourceTree = "<group>"; };
F44FEAC828B5465900EC57B3 /* unittest_extension_chain_g.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_g.proto; sourceTree = "<group>"; };
F44FEAC928B5465900EC57B3 /* unittest_extension_chain_e.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_e.proto; sourceTree = "<group>"; };
F44FEACA28B5465900EC57B3 /* unittest_extension_chain_d.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_d.proto; sourceTree = "<group>"; };
F44FEACB28B5465900EC57B3 /* unittest_extension_chain_a.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_a.proto; sourceTree = "<group>"; };
F44FEACC28B5465900EC57B3 /* unittest_extension_chain_c.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_c.proto; sourceTree = "<group>"; };
F44FEACD28B5465900EC57B3 /* unittest_deprecated.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_deprecated.proto; sourceTree = "<group>"; };
F44FEACE28B5465A00EC57B3 /* unittest_extension_chain_b.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_b.proto; sourceTree = "<group>"; };
F44FEACF28B5465A00EC57B3 /* map_proto2_unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = map_proto2_unittest.proto; sourceTree = "<group>"; };
F44FEAD028B5465A00EC57B3 /* unittest_extension_chain_f.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_f.proto; sourceTree = "<group>"; };
F451D3F51A8AAE8700B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = "<group>"; };
F4584D7E1ECCB38900803AB6 /* GPBExtensionRegistryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionRegistryTest.m; sourceTree = "<group>"; };
F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = "<group>"; };
@@ -445,13 +442,12 @@
7461B6940F94FDDD00A0C422 /* Tests */ = {
isa = PBXGroup;
children = (
F44FEAC528B5465900EC57B3 /* any_test.proto */,
8B210CCD159383D60032D72D /* golden_message */,
8B210CCF159386920032D72D /* golden_packed_fields_message */,
8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */,
F401DC321A8E5C0200FCC765 /* GPBArrayTests.m */,
7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */,
7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */,
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */,
F40EE488206BF8B00071091A /* GPBCompileTest01.m */,
F40EE481206BF8AE0071091A /* GPBCompileTest02.m */,
F40EE491206BF8B10071091A /* GPBCompileTest03.m */,
@@ -475,6 +471,8 @@
F40EE486206BF8AF0071091A /* GPBCompileTest21.m */,
F40EE48A206BF8B00071091A /* GPBCompileTest22.m */,
F40EE487206BF8B00071091A /* GPBCompileTest23.m */,
F40EE508206C06440071091A /* GPBCompileTest24.m */,
F40EE507206C06440071091A /* GPBCompileTest25.m */,
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */,
F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */,
@@ -487,9 +485,9 @@
F4353D321AC06F10005A6198 /* GPBDictionaryTests+UInt64.m */,
F4584D7E1ECCB38900803AB6 /* GPBExtensionRegistryTest.m */,
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */,
8BFF9D1923AD582200E63E32 /* GPBMessageTests+ClassNames.m */,
F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */,
F4487C741AADF7F500531423 /* GPBMessageTests+Runtime.m */,
8BFF9D1923AD582200E63E32 /* GPBMessageTests+ClassNames.m */,
F4487C7E1AAF62CD00531423 /* GPBMessageTests+Serialization.m */,
F4B51B1D1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm */,
F41C175C1833D3310064ED4D /* GPBPerfTests.m */,
@@ -502,31 +500,25 @@
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */,
8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */,
7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */,
F44FEACF28B5465A00EC57B3 /* map_proto2_unittest.proto */,
F44FEAC728B5465900EC57B3 /* map_unittest.proto */,
F4F53F89219CC4F2001EABF4 /* text_format_extensions_unittest_data.txt */,
F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */,
F43C88CF191D77FC009E917D /* text_format_unittest_data.txt */,
8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */,
F4AC9E1D1A8BEB3500BD6E83 /* unittest_cycle.proto */,
F44FEABE28B5465900EC57B3 /* unittest_deprecated_file.proto */,
F44FEACD28B5465900EC57B3 /* unittest_deprecated.proto */,
F44FEACB28B5465900EC57B3 /* unittest_extension_chain_a.proto */,
F44FEACE28B5465A00EC57B3 /* unittest_extension_chain_b.proto */,
F44FEACC28B5465900EC57B3 /* unittest_extension_chain_c.proto */,
F44FEACA28B5465900EC57B3 /* unittest_extension_chain_d.proto */,
F44FEAC928B5465900EC57B3 /* unittest_extension_chain_e.proto */,
F44FEAD028B5465A00EC57B3 /* unittest_extension_chain_f.proto */,
F44FEAC828B5465900EC57B3 /* unittest_extension_chain_g.proto */,
F44FEAC628B5465900EC57B3 /* unittest_import_public.proto */,
F44FEAC028B5465900EC57B3 /* unittest_import.proto */,
F44FEABF28B5465900EC57B3 /* unittest_mset.proto */,
8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */,
8B7E6A7614893DBA00F8884A /* unittest_empty.proto */,
8BD3981D14BE54220081D629 /* unittest_enormous_descriptor.proto */,
8B7E6A7814893DBB00F8884A /* unittest_import.proto */,
8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */,
8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */,
8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */,
8B35468421A616F6000BD30D /* unittest_objc_options.proto */,
F4CF31701B162ED800BD9B06 /* unittest_objc_startup.proto */,
8B09AAF614B663A7007B4184 /* unittest_objc.proto */,
F44FEAC428B5465900EC57B3 /* unittest_preserve_unknown_enum.proto */,
8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */,
F4487C781AADFB3100531423 /* unittest_runtime_proto2.proto */,
F4487C791AADFB3200531423 /* unittest_runtime_proto3.proto */,
F44FEAC228B5465900EC57B3 /* unittest.proto */,
8B7E6A7E14893DBC00F8884A /* unittest.proto */,
8B4248B91A8C256900BC1EC6 /* UnitTests-Bridging-Header.h */,
7401C1A90F950347006D8281 /* UnitTests-Info.plist */,
);
@@ -663,7 +655,7 @@
};
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ProtocolBuffers_OSX" */;
compatibilityVersion = "Xcode 13.0";
compatibilityVersion = "Xcode 6.3";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -752,6 +744,7 @@
buildActionMask = 2147483647;
files = (
8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */,
F40EE50B206C06640071091A /* GPBCompileTest24.m in Sources */,
F40EE4BE206BF8B90071091A /* GPBCompileTest20.m in Sources */,
F401DC331A8E5C0200FCC765 /* GPBArrayTests.m in Sources */,
F40EE4B4206BF8B90071091A /* GPBCompileTest10.m in Sources */,
@@ -760,7 +753,7 @@
F40EE4B2206BF8B90071091A /* GPBCompileTest08.m in Sources */,
F40EE4BB206BF8B90071091A /* GPBCompileTest17.m in Sources */,
F4353D391AC06F10005A6198 /* GPBDictionaryTests+UInt64.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOutputStreamTests.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */,
F40EE4C1206BF8B90071091A /* GPBCompileTest23.m in Sources */,
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */,
F4B51B1E1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */,
@@ -779,6 +772,7 @@
F4F8D8831D789FD9002CE128 /* GPBUnittestProtos2.m in Sources */,
F4353D1D1AB8822D005A6198 /* GPBDescriptorTests.m in Sources */,
8B4248BB1A8C256A00BC1EC6 /* GPBSwiftTests.swift in Sources */,
F40EE50C206C06640071091A /* GPBCompileTest25.m in Sources */,
F4584D821ECCB52A00803AB6 /* GPBExtensionRegistryTest.m in Sources */,
8BFF9D1A23AD582300E63E32 /* GPBMessageTests+ClassNames.m in Sources */,
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
@@ -857,21 +851,14 @@
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
USER_HEADER_SEARCH_PATHS = (
"${PROJECT_DERIVED_FILE_DIR}/protos",
"$(SRCROOT)",
);
USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/protos $(SRCROOT)";
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-documentation-unknown-command",
@@ -888,20 +875,13 @@
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_VERSION = 4.0;
USER_HEADER_SEARCH_PATHS = (
"${PROJECT_DERIVED_FILE_DIR}/protos",
"$(SRCROOT)",
);
USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/protos $(SRCROOT)";
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-documentation-unknown-command",
@@ -966,7 +946,7 @@
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = NO;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = YES;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx;
@@ -1035,11 +1015,10 @@
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = NO;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.9;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
USE_HEADERMAP = NO;
WARNING_CFLAGS = (
"-Wdocumentation-unknown-command",

View File

@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objectVersion = 47;
objects = {
/* Begin PBXBuildFile section */
@@ -27,7 +27,7 @@
8B96157414C8C38C00A2AC0B /* GPBDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */; };
8B9A5EEC18330A0F00A9D33B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B9A5E9F1831913D00A9D33B /* UIKit.framework */; };
8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */; };
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOutputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */; };
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */; };
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */; };
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */; };
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */; };
@@ -61,6 +61,8 @@
F40EE504206BF91E0071091A /* GPBCompileTest21.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CB206BF9170071091A /* GPBCompileTest21.m */; };
F40EE505206BF91E0071091A /* GPBCompileTest22.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CF206BF9170071091A /* GPBCompileTest22.m */; };
F40EE506206BF91E0071091A /* GPBCompileTest23.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CC206BF9170071091A /* GPBCompileTest23.m */; };
F40EE511206C068D0071091A /* GPBCompileTest24.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE50E206C06880071091A /* GPBCompileTest24.m */; };
F40EE512206C068D0071091A /* GPBCompileTest25.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE50D206C06880071091A /* GPBCompileTest25.m */; };
F41C175D1833D3310064ED4D /* GPBPerfTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F41C175C1833D3310064ED4D /* GPBPerfTests.m */; };
F4353D1F1AB88243005A6198 /* GPBDescriptorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */; };
F4353D271ABB156F005A6198 /* GPBDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D251ABB156F005A6198 /* GPBDictionary.m */; };
@@ -140,7 +142,7 @@
7461B4E80F94F99000A0C422 /* GPBWireFormat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWireFormat.m; sourceTree = "<group>"; };
7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libProtocolBuffers.a; sourceTree = BUILT_PRODUCTS_DIR; };
7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCodedInputStreamTests.m; sourceTree = "<group>"; };
7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCodedOutputStreamTests.m; sourceTree = "<group>"; };
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCodedOuputStreamTests.m; sourceTree = "<group>"; };
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBMessageTests.m; sourceTree = "<group>"; };
7461B6AB0F94FDF800A0C422 /* GPBTestUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBTestUtilities.h; sourceTree = "<group>"; };
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBTestUtilities.m; sourceTree = "<group>"; };
@@ -160,13 +162,23 @@
8B42494A1A92A0BA00BC1EC6 /* duration.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = duration.proto; path = ../src/google/protobuf/duration.proto; sourceTree = "<group>"; };
8B79657814992E3E002FFBFC /* GPBRootObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBRootObject.h; sourceTree = "<group>"; };
8B79657914992E3E002FFBFC /* GPBRootObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBRootObject.m; sourceTree = "<group>"; };
8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_custom_options.proto; path = ../../src/google/protobuf/unittest_custom_options.proto; sourceTree = "<group>"; };
8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_embed_optimize_for.proto; path = ../../src/google/protobuf/unittest_embed_optimize_for.proto; sourceTree = "<group>"; };
8B7E6A7614893DBA00F8884A /* unittest_empty.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_empty.proto; path = ../../src/google/protobuf/unittest_empty.proto; sourceTree = "<group>"; };
8B7E6A7814893DBB00F8884A /* unittest_import.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_import.proto; path = ../../src/google/protobuf/unittest_import.proto; sourceTree = "<group>"; };
8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_mset.proto; path = ../../src/google/protobuf/unittest_mset.proto; sourceTree = "<group>"; };
8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_no_generic_services.proto; path = ../../src/google/protobuf/unittest_no_generic_services.proto; sourceTree = "<group>"; };
8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_optimize_for.proto; path = ../../src/google/protobuf/unittest_optimize_for.proto; sourceTree = "<group>"; };
8B7E6A7E14893DBC00F8884A /* unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest.proto; path = ../../src/google/protobuf/unittest.proto; sourceTree = "<group>"; };
8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBARCUnittestProtos.m; sourceTree = "<group>"; };
8B96157214C8B06000A2AC0B /* GPBDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBDescriptor.h; sourceTree = "<group>"; };
8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDescriptor.m; sourceTree = "<group>"; };
8B9742421A8AAA7800DCE92C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
8B9A5E9F1831913D00A9D33B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_lite.proto; path = ../../src/google/protobuf/unittest_lite.proto; sourceTree = "<group>"; };
8BBEA4A6147C727100C4ADB7 /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8BCF338814ED799900BC5317 /* GPBProtocolBuffers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GPBProtocolBuffers.m; sourceTree = "<group>"; };
8BD3981D14BE54220081D629 /* unittest_enormous_descriptor.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_enormous_descriptor.proto; path = ../../src/google/protobuf/unittest_enormous_descriptor.proto; sourceTree = "<group>"; };
8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnittestProtos.m; sourceTree = "<group>"; };
8BEB5AE01498033E0078BF9D /* GPBRuntimeTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRuntimeTypes.h; sourceTree = "<group>"; };
8BFF9D1B23AD593B00E63E32 /* GPBMessageTests+ClassNames.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+ClassNames.m"; sourceTree = "<group>"; };
@@ -194,6 +206,8 @@
F40EE4D6206BF9190071091A /* GPBCompileTest03.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest03.m; sourceTree = "<group>"; };
F40EE4D7206BF9190071091A /* GPBCompileTest06.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest06.m; sourceTree = "<group>"; };
F40EE4D8206BF9190071091A /* GPBCompileTest11.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest11.m; sourceTree = "<group>"; };
F40EE50D206C06880071091A /* GPBCompileTest25.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest25.m; sourceTree = "<group>"; };
F40EE50E206C06880071091A /* GPBCompileTest24.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest24.m; sourceTree = "<group>"; };
F41C175C1833D3310064ED4D /* GPBPerfTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBPerfTests.m; sourceTree = "<group>"; };
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDescriptorTests.m; sourceTree = "<group>"; };
F4353D241ABB156F005A6198 /* GPBDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBDictionary.h; sourceTree = "<group>"; };
@@ -218,23 +232,6 @@
F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Serialization.m"; sourceTree = "<group>"; };
F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = "<group>"; };
F44929021C866B3B00C2548A /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBCodedOutputStream_PackagePrivate.h; sourceTree = "<group>"; };
F44FEAD128B546E200EC57B3 /* unittest_preserve_unknown_enum.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_preserve_unknown_enum.proto; sourceTree = "<group>"; };
F44FEAD228B546E200EC57B3 /* map_proto2_unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = map_proto2_unittest.proto; sourceTree = "<group>"; };
F44FEAD328B546E200EC57B3 /* map_unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = map_unittest.proto; sourceTree = "<group>"; };
F44FEAD428B546E200EC57B3 /* unittest_extension_chain_a.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_a.proto; sourceTree = "<group>"; };
F44FEAD528B546E300EC57B3 /* unittest_extension_chain_d.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_d.proto; sourceTree = "<group>"; };
F44FEAD628B546E300EC57B3 /* unittest_deprecated.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_deprecated.proto; sourceTree = "<group>"; };
F44FEAD728B546E300EC57B3 /* any_test.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = any_test.proto; sourceTree = "<group>"; };
F44FEAD828B546E300EC57B3 /* unittest_extension_chain_b.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_b.proto; sourceTree = "<group>"; };
F44FEADB28B546E300EC57B3 /* unittest_import.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_import.proto; sourceTree = "<group>"; };
F44FEADC28B546E300EC57B3 /* unittest_mset.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_mset.proto; sourceTree = "<group>"; };
F44FEADD28B546E300EC57B3 /* unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest.proto; sourceTree = "<group>"; };
F44FEADE28B546E300EC57B3 /* unittest_extension_chain_f.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_f.proto; sourceTree = "<group>"; };
F44FEADF28B546E300EC57B3 /* unittest_deprecated_file.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_deprecated_file.proto; sourceTree = "<group>"; };
F44FEAE028B546E300EC57B3 /* unittest_import_public.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_import_public.proto; sourceTree = "<group>"; };
F44FEAE128B546E300EC57B3 /* unittest_extension_chain_g.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_g.proto; sourceTree = "<group>"; };
F44FEAE228B546E300EC57B3 /* unittest_extension_chain_c.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_c.proto; sourceTree = "<group>"; };
F44FEAE328B546E300EC57B3 /* unittest_extension_chain_e.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_e.proto; sourceTree = "<group>"; };
F451D3F61A8AAEA600B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = "<group>"; };
F4584D801ECCB39E00803AB6 /* GPBExtensionRegistryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPBExtensionRegistryTest.m; path = Tests/GPBExtensionRegistryTest.m; sourceTree = SOURCE_ROOT; };
F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = "<group>"; };
@@ -451,13 +448,12 @@
7461B6940F94FDDD00A0C422 /* Tests */ = {
isa = PBXGroup;
children = (
F44FEAD728B546E300EC57B3 /* any_test.proto */,
8B210CCD159383D60032D72D /* golden_message */,
8B210CCF159386920032D72D /* golden_packed_fields_message */,
8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */,
F401DC341A8E5C6F00FCC765 /* GPBArrayTests.m */,
7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */,
7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */,
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */,
F40EE4CD206BF9170071091A /* GPBCompileTest01.m */,
F40EE4C6206BF9170071091A /* GPBCompileTest02.m */,
F40EE4D6206BF9190071091A /* GPBCompileTest03.m */,
@@ -481,6 +477,8 @@
F40EE4CB206BF9170071091A /* GPBCompileTest21.m */,
F40EE4CF206BF9170071091A /* GPBCompileTest22.m */,
F40EE4CC206BF9170071091A /* GPBCompileTest23.m */,
F40EE50E206C06880071091A /* GPBCompileTest24.m */,
F40EE50D206C06880071091A /* GPBCompileTest25.m */,
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */,
F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */,
@@ -493,9 +491,9 @@
F4353D401AC06F31005A6198 /* GPBDictionaryTests+UInt64.m */,
F4584D801ECCB39E00803AB6 /* GPBExtensionRegistryTest.m */,
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */,
8BFF9D1B23AD593B00E63E32 /* GPBMessageTests+ClassNames.m */,
F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */,
F4487C761AADF84900531423 /* GPBMessageTests+Runtime.m */,
8BFF9D1B23AD593B00E63E32 /* GPBMessageTests+ClassNames.m */,
F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */,
F4B51B1B1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm */,
F41C175C1833D3310064ED4D /* GPBPerfTests.m */,
@@ -508,31 +506,25 @@
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */,
8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */,
7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */,
F44FEAD228B546E200EC57B3 /* map_proto2_unittest.proto */,
F44FEAD328B546E200EC57B3 /* map_unittest.proto */,
F4F53F8B219CC5DF001EABF4 /* text_format_extensions_unittest_data.txt */,
F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */,
F43C88CF191D77FC009E917D /* text_format_unittest_data.txt */,
8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */,
F4AC9E1C1A8BEB1000BD6E83 /* unittest_cycle.proto */,
F44FEADF28B546E300EC57B3 /* unittest_deprecated_file.proto */,
F44FEAD628B546E300EC57B3 /* unittest_deprecated.proto */,
F44FEAD428B546E200EC57B3 /* unittest_extension_chain_a.proto */,
F44FEAD828B546E300EC57B3 /* unittest_extension_chain_b.proto */,
F44FEAE228B546E300EC57B3 /* unittest_extension_chain_c.proto */,
F44FEAD528B546E300EC57B3 /* unittest_extension_chain_d.proto */,
F44FEAE328B546E300EC57B3 /* unittest_extension_chain_e.proto */,
F44FEADE28B546E300EC57B3 /* unittest_extension_chain_f.proto */,
F44FEAE128B546E300EC57B3 /* unittest_extension_chain_g.proto */,
F44FEAE028B546E300EC57B3 /* unittest_import_public.proto */,
F44FEADB28B546E300EC57B3 /* unittest_import.proto */,
F44FEADC28B546E300EC57B3 /* unittest_mset.proto */,
8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */,
8B7E6A7614893DBA00F8884A /* unittest_empty.proto */,
8BD3981D14BE54220081D629 /* unittest_enormous_descriptor.proto */,
8B7E6A7814893DBB00F8884A /* unittest_import.proto */,
8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */,
8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */,
8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */,
8B35468621A61EB2000BD30D /* unittest_objc_options.proto */,
F4CF31711B162EF500BD9B06 /* unittest_objc_startup.proto */,
8B09AAF614B663A7007B4184 /* unittest_objc.proto */,
F44FEAD128B546E200EC57B3 /* unittest_preserve_unknown_enum.proto */,
8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */,
F4487C7A1AADFB5500531423 /* unittest_runtime_proto2.proto */,
F4487C7B1AADFB5500531423 /* unittest_runtime_proto3.proto */,
F44FEADD28B546E300EC57B3 /* unittest.proto */,
8B7E6A7E14893DBC00F8884A /* unittest.proto */,
8B4248B21A8BD96D00BC1EC6 /* UnitTests-Bridging-Header.h */,
7401C1A90F950347006D8281 /* UnitTests-Info.plist */,
);
@@ -670,7 +662,7 @@
};
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ProtocolBuffers_iOS" */;
compatibilityVersion = "Xcode 13.0";
compatibilityVersion = "Xcode 6.3";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -759,6 +751,7 @@
buildActionMask = 2147483647;
files = (
8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */,
F40EE511206C068D0071091A /* GPBCompileTest24.m in Sources */,
F40EE503206BF91E0071091A /* GPBCompileTest20.m in Sources */,
F401DC351A8E5C6F00FCC765 /* GPBArrayTests.m in Sources */,
F40EE4F9206BF91E0071091A /* GPBCompileTest10.m in Sources */,
@@ -767,7 +760,7 @@
F40EE4F7206BF91E0071091A /* GPBCompileTest08.m in Sources */,
F40EE500206BF91E0071091A /* GPBCompileTest17.m in Sources */,
F4353D471AC06F31005A6198 /* GPBDictionaryTests+UInt64.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOutputStreamTests.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */,
F40EE506206BF91E0071091A /* GPBCompileTest23.m in Sources */,
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */,
F4487C811AAF62FC00531423 /* GPBMessageTests+Serialization.m in Sources */,
@@ -786,6 +779,7 @@
F4F8D8861D78A193002CE128 /* GPBUnittestProtos2.m in Sources */,
F4B51B1C1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */,
8B4248B41A8BD96E00BC1EC6 /* GPBSwiftTests.swift in Sources */,
F40EE512206C068D0071091A /* GPBCompileTest25.m in Sources */,
F4584D831ECCB53600803AB6 /* GPBExtensionRegistryTest.m in Sources */,
8BFF9D1C23AD593C00E63E32 /* GPBMessageTests+ClassNames.m in Sources */,
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
@@ -869,11 +863,7 @@
"$(inherited)",
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/usr/lib\"",
@@ -884,10 +874,7 @@
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = (
"${PROJECT_DERIVED_FILE_DIR}/protos",
"$(SRCROOT)",
);
USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/protos $(SRCROOT)";
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-documentation-unknown-command",
@@ -907,11 +894,7 @@
"$(inherited)",
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/usr/lib\"",
@@ -921,10 +904,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = (
"${PROJECT_DERIVED_FILE_DIR}/protos",
"$(SRCROOT)",
);
USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/protos $(SRCROOT)";
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-documentation-unknown-command",
@@ -990,7 +970,7 @@
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
ONLY_ACTIVE_ARCH = YES;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
@@ -1059,11 +1039,10 @@
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = NO;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
WARNING_CFLAGS = (
"-Wdocumentation-unknown-command",
"-Wundef",

View File

@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objectVersion = 47;
objects = {
/* Begin PBXBuildFile section */
@@ -27,7 +27,7 @@
8B96157414C8C38C00A2AC0B /* GPBDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */; };
8B9A5EEC18330A0F00A9D33B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B9A5E9F1831913D00A9D33B /* UIKit.framework */; };
8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */; };
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOutputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */; };
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */; };
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */; };
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */; };
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */; };
@@ -61,6 +61,8 @@
F40EE504206BF91E0071091A /* GPBCompileTest21.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CB206BF9170071091A /* GPBCompileTest21.m */; };
F40EE505206BF91E0071091A /* GPBCompileTest22.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CF206BF9170071091A /* GPBCompileTest22.m */; };
F40EE506206BF91E0071091A /* GPBCompileTest23.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CC206BF9170071091A /* GPBCompileTest23.m */; };
F40EE511206C068D0071091A /* GPBCompileTest24.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE50E206C06880071091A /* GPBCompileTest24.m */; };
F40EE512206C068D0071091A /* GPBCompileTest25.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE50D206C06880071091A /* GPBCompileTest25.m */; };
F41C175D1833D3310064ED4D /* GPBPerfTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F41C175C1833D3310064ED4D /* GPBPerfTests.m */; };
F4353D1F1AB88243005A6198 /* GPBDescriptorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */; };
F4353D271ABB156F005A6198 /* GPBDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D251ABB156F005A6198 /* GPBDictionary.m */; };
@@ -140,7 +142,7 @@
7461B4E80F94F99000A0C422 /* GPBWireFormat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWireFormat.m; sourceTree = "<group>"; };
7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libProtocolBuffers.a; sourceTree = BUILT_PRODUCTS_DIR; };
7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCodedInputStreamTests.m; sourceTree = "<group>"; };
7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCodedOutputStreamTests.m; sourceTree = "<group>"; };
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCodedOuputStreamTests.m; sourceTree = "<group>"; };
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBMessageTests.m; sourceTree = "<group>"; };
7461B6AB0F94FDF800A0C422 /* GPBTestUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBTestUtilities.h; sourceTree = "<group>"; };
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBTestUtilities.m; sourceTree = "<group>"; };
@@ -160,13 +162,23 @@
8B42494A1A92A0BA00BC1EC6 /* duration.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = duration.proto; path = ../src/google/protobuf/duration.proto; sourceTree = "<group>"; };
8B79657814992E3E002FFBFC /* GPBRootObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBRootObject.h; sourceTree = "<group>"; };
8B79657914992E3E002FFBFC /* GPBRootObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBRootObject.m; sourceTree = "<group>"; };
8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_custom_options.proto; path = ../../src/google/protobuf/unittest_custom_options.proto; sourceTree = "<group>"; };
8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_embed_optimize_for.proto; path = ../../src/google/protobuf/unittest_embed_optimize_for.proto; sourceTree = "<group>"; };
8B7E6A7614893DBA00F8884A /* unittest_empty.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_empty.proto; path = ../../src/google/protobuf/unittest_empty.proto; sourceTree = "<group>"; };
8B7E6A7814893DBB00F8884A /* unittest_import.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_import.proto; path = ../../src/google/protobuf/unittest_import.proto; sourceTree = "<group>"; };
8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_mset.proto; path = ../../src/google/protobuf/unittest_mset.proto; sourceTree = "<group>"; };
8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_no_generic_services.proto; path = ../../src/google/protobuf/unittest_no_generic_services.proto; sourceTree = "<group>"; };
8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_optimize_for.proto; path = ../../src/google/protobuf/unittest_optimize_for.proto; sourceTree = "<group>"; };
8B7E6A7E14893DBC00F8884A /* unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest.proto; path = ../../src/google/protobuf/unittest.proto; sourceTree = "<group>"; };
8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBARCUnittestProtos.m; sourceTree = "<group>"; };
8B96157214C8B06000A2AC0B /* GPBDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBDescriptor.h; sourceTree = "<group>"; };
8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDescriptor.m; sourceTree = "<group>"; };
8B9742421A8AAA7800DCE92C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
8B9A5E9F1831913D00A9D33B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_lite.proto; path = ../../src/google/protobuf/unittest_lite.proto; sourceTree = "<group>"; };
8BBEA4A6147C727100C4ADB7 /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8BCF338814ED799900BC5317 /* GPBProtocolBuffers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GPBProtocolBuffers.m; sourceTree = "<group>"; };
8BD3981D14BE54220081D629 /* unittest_enormous_descriptor.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_enormous_descriptor.proto; path = ../../src/google/protobuf/unittest_enormous_descriptor.proto; sourceTree = "<group>"; };
8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnittestProtos.m; sourceTree = "<group>"; };
8BEB5AE01498033E0078BF9D /* GPBRuntimeTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRuntimeTypes.h; sourceTree = "<group>"; };
8BFF9D1D23AD599400E63E32 /* GPBMessageTests+ClassNames.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+ClassNames.m"; sourceTree = "<group>"; };
@@ -194,6 +206,8 @@
F40EE4D6206BF9190071091A /* GPBCompileTest03.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest03.m; sourceTree = "<group>"; };
F40EE4D7206BF9190071091A /* GPBCompileTest06.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest06.m; sourceTree = "<group>"; };
F40EE4D8206BF9190071091A /* GPBCompileTest11.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest11.m; sourceTree = "<group>"; };
F40EE50D206C06880071091A /* GPBCompileTest25.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest25.m; sourceTree = "<group>"; };
F40EE50E206C06880071091A /* GPBCompileTest24.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest24.m; sourceTree = "<group>"; };
F41C175C1833D3310064ED4D /* GPBPerfTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBPerfTests.m; sourceTree = "<group>"; };
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDescriptorTests.m; sourceTree = "<group>"; };
F4353D241ABB156F005A6198 /* GPBDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBDictionary.h; sourceTree = "<group>"; };
@@ -218,23 +232,6 @@
F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Serialization.m"; sourceTree = "<group>"; };
F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = "<group>"; };
F44929021C866B3B00C2548A /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBCodedOutputStream_PackagePrivate.h; sourceTree = "<group>"; };
F44FEAE528B5471300EC57B3 /* unittest_extension_chain_a.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_a.proto; sourceTree = "<group>"; };
F44FEAE728B5471300EC57B3 /* unittest_extension_chain_c.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_c.proto; sourceTree = "<group>"; };
F44FEAE828B5471300EC57B3 /* unittest_extension_chain_g.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_g.proto; sourceTree = "<group>"; };
F44FEAE928B5471300EC57B3 /* unittest_import.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_import.proto; sourceTree = "<group>"; };
F44FEAEA28B5471300EC57B3 /* unittest_deprecated_file.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_deprecated_file.proto; sourceTree = "<group>"; };
F44FEAEB28B5471300EC57B3 /* unittest_import_public.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_import_public.proto; sourceTree = "<group>"; };
F44FEAEC28B5471300EC57B3 /* unittest_extension_chain_f.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_f.proto; sourceTree = "<group>"; };
F44FEAED28B5471300EC57B3 /* unittest_deprecated.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_deprecated.proto; sourceTree = "<group>"; };
F44FEAEE28B5471300EC57B3 /* unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest.proto; sourceTree = "<group>"; };
F44FEAEF28B5471300EC57B3 /* any_test.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = any_test.proto; sourceTree = "<group>"; };
F44FEAF028B5471300EC57B3 /* unittest_extension_chain_b.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_b.proto; sourceTree = "<group>"; };
F44FEAF128B5471300EC57B3 /* unittest_mset.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_mset.proto; sourceTree = "<group>"; };
F44FEAF228B5471300EC57B3 /* unittest_preserve_unknown_enum.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_preserve_unknown_enum.proto; sourceTree = "<group>"; };
F44FEAF328B5471300EC57B3 /* unittest_extension_chain_d.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_d.proto; sourceTree = "<group>"; };
F44FEAF428B5471300EC57B3 /* unittest_extension_chain_e.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = unittest_extension_chain_e.proto; sourceTree = "<group>"; };
F44FEAF528B5472700EC57B3 /* map_proto2_unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = map_proto2_unittest.proto; sourceTree = "<group>"; };
F44FEAF628B5472700EC57B3 /* map_unittest.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = map_unittest.proto; sourceTree = "<group>"; };
F451D3F61A8AAEA600B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = "<group>"; };
F4584D801ECCB39E00803AB6 /* GPBExtensionRegistryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPBExtensionRegistryTest.m; path = Tests/GPBExtensionRegistryTest.m; sourceTree = SOURCE_ROOT; };
F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = "<group>"; };
@@ -451,13 +448,12 @@
7461B6940F94FDDD00A0C422 /* Tests */ = {
isa = PBXGroup;
children = (
F44FEAEF28B5471300EC57B3 /* any_test.proto */,
8B210CCD159383D60032D72D /* golden_message */,
8B210CCF159386920032D72D /* golden_packed_fields_message */,
8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */,
F401DC341A8E5C6F00FCC765 /* GPBArrayTests.m */,
7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */,
7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */,
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */,
F40EE4CD206BF9170071091A /* GPBCompileTest01.m */,
F40EE4C6206BF9170071091A /* GPBCompileTest02.m */,
F40EE4D6206BF9190071091A /* GPBCompileTest03.m */,
@@ -481,6 +477,8 @@
F40EE4CB206BF9170071091A /* GPBCompileTest21.m */,
F40EE4CF206BF9170071091A /* GPBCompileTest22.m */,
F40EE4CC206BF9170071091A /* GPBCompileTest23.m */,
F40EE50E206C06880071091A /* GPBCompileTest24.m */,
F40EE50D206C06880071091A /* GPBCompileTest25.m */,
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */,
F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */,
@@ -493,9 +491,9 @@
F4353D401AC06F31005A6198 /* GPBDictionaryTests+UInt64.m */,
F4584D801ECCB39E00803AB6 /* GPBExtensionRegistryTest.m */,
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */,
8BFF9D1D23AD599400E63E32 /* GPBMessageTests+ClassNames.m */,
F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */,
F4487C761AADF84900531423 /* GPBMessageTests+Runtime.m */,
8BFF9D1D23AD599400E63E32 /* GPBMessageTests+ClassNames.m */,
F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */,
F4B51B1B1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm */,
F41C175C1833D3310064ED4D /* GPBPerfTests.m */,
@@ -508,31 +506,25 @@
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */,
8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */,
7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */,
F44FEAF528B5472700EC57B3 /* map_proto2_unittest.proto */,
F44FEAF628B5472700EC57B3 /* map_unittest.proto */,
F4F53F8B219CC5DF001EABF4 /* text_format_extensions_unittest_data.txt */,
F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */,
F43C88CF191D77FC009E917D /* text_format_unittest_data.txt */,
8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */,
F4AC9E1C1A8BEB1000BD6E83 /* unittest_cycle.proto */,
F44FEAEA28B5471300EC57B3 /* unittest_deprecated_file.proto */,
F44FEAED28B5471300EC57B3 /* unittest_deprecated.proto */,
F44FEAE528B5471300EC57B3 /* unittest_extension_chain_a.proto */,
F44FEAF028B5471300EC57B3 /* unittest_extension_chain_b.proto */,
F44FEAE728B5471300EC57B3 /* unittest_extension_chain_c.proto */,
F44FEAF328B5471300EC57B3 /* unittest_extension_chain_d.proto */,
F44FEAF428B5471300EC57B3 /* unittest_extension_chain_e.proto */,
F44FEAEC28B5471300EC57B3 /* unittest_extension_chain_f.proto */,
F44FEAE828B5471300EC57B3 /* unittest_extension_chain_g.proto */,
F44FEAEB28B5471300EC57B3 /* unittest_import_public.proto */,
F44FEAE928B5471300EC57B3 /* unittest_import.proto */,
F44FEAF128B5471300EC57B3 /* unittest_mset.proto */,
8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */,
8B7E6A7614893DBA00F8884A /* unittest_empty.proto */,
8BD3981D14BE54220081D629 /* unittest_enormous_descriptor.proto */,
8B7E6A7814893DBB00F8884A /* unittest_import.proto */,
8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */,
8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */,
8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */,
8B35468621A61EB2000BD30D /* unittest_objc_options.proto */,
F4CF31711B162EF500BD9B06 /* unittest_objc_startup.proto */,
8B09AAF614B663A7007B4184 /* unittest_objc.proto */,
F44FEAF228B5471300EC57B3 /* unittest_preserve_unknown_enum.proto */,
8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */,
F4487C7A1AADFB5500531423 /* unittest_runtime_proto2.proto */,
F4487C7B1AADFB5500531423 /* unittest_runtime_proto3.proto */,
F44FEAEE28B5471300EC57B3 /* unittest.proto */,
8B7E6A7E14893DBC00F8884A /* unittest.proto */,
8B4248B21A8BD96D00BC1EC6 /* UnitTests-Bridging-Header.h */,
7401C1A90F950347006D8281 /* UnitTests-Info.plist */,
);
@@ -670,7 +662,7 @@
};
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ProtocolBuffers_tvOS" */;
compatibilityVersion = "Xcode 13.0";
compatibilityVersion = "Xcode 6.3";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -759,6 +751,7 @@
buildActionMask = 2147483647;
files = (
8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */,
F40EE511206C068D0071091A /* GPBCompileTest24.m in Sources */,
F40EE503206BF91E0071091A /* GPBCompileTest20.m in Sources */,
F401DC351A8E5C6F00FCC765 /* GPBArrayTests.m in Sources */,
F40EE4F9206BF91E0071091A /* GPBCompileTest10.m in Sources */,
@@ -767,7 +760,7 @@
F40EE4F7206BF91E0071091A /* GPBCompileTest08.m in Sources */,
F40EE500206BF91E0071091A /* GPBCompileTest17.m in Sources */,
F4353D471AC06F31005A6198 /* GPBDictionaryTests+UInt64.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOutputStreamTests.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */,
F40EE506206BF91E0071091A /* GPBCompileTest23.m in Sources */,
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */,
F4487C811AAF62FC00531423 /* GPBMessageTests+Serialization.m in Sources */,
@@ -786,6 +779,7 @@
F4F8D8861D78A193002CE128 /* GPBUnittestProtos2.m in Sources */,
F4B51B1C1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */,
8B4248B41A8BD96E00BC1EC6 /* GPBSwiftTests.swift in Sources */,
F40EE512206C068D0071091A /* GPBCompileTest25.m in Sources */,
F4584D831ECCB53600803AB6 /* GPBExtensionRegistryTest.m in Sources */,
8BFF9D1E23AD599400E63E32 /* GPBMessageTests+ClassNames.m in Sources */,
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
@@ -865,11 +859,7 @@
"$(inherited)",
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/usr/lib\"",
@@ -879,10 +869,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
USER_HEADER_SEARCH_PATHS = (
"${PROJECT_DERIVED_FILE_DIR}/protos",
"$(SRCROOT)",
);
USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/protos $(SRCROOT)";
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-documentation-unknown-command",
@@ -902,11 +889,7 @@
"$(inherited)",
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/usr/lib\"",
@@ -915,10 +898,7 @@
PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_VERSION = 4.0;
USER_HEADER_SEARCH_PATHS = (
"${PROJECT_DERIVED_FILE_DIR}/protos",
"$(SRCROOT)",
);
USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/protos $(SRCROOT)";
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-documentation-unknown-command",
@@ -987,7 +967,7 @@
ONLY_ACTIVE_ARCH = YES;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = appletvos;
TVOS_DEPLOYMENT_TARGET = 12.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
WARNING_CFLAGS = (
"-Wdocumentation-unknown-command",
"-Wundef",
@@ -1055,9 +1035,8 @@
GENERATE_PROFILING_CODE = NO;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = appletvos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TVOS_DEPLOYMENT_TARGET = 12.0;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TVOS_DEPLOYMENT_TARGET = 9.0;
WARNING_CFLAGS = (
"-Wdocumentation-unknown-command",
"-Wundef",

View File

@@ -11,7 +11,7 @@ Requirements
The Objective C implementation requires:
- Objective C 2.0 Runtime (32bit & 64bit iOS, 64bit OS X).
- Xcode 13.3.1 (or later).
- Xcode 10.3 (or later).
- The library code does *not* use ARC (for performance reasons), but it all can
be called from ARC code.
@@ -25,7 +25,7 @@ to build the compiler and run the runtime tests, you can use:
$ objectivec/DevTools/full_mac_build.sh
This will generate the `protoc` binary.
This will generate the `src/protoc` binary.
Building
--------
@@ -200,13 +200,12 @@ supported keys are:
entry can be made as "no_package:PATH=prefix", where PATH is the
path for the .proto file.
* `use_package_as_prefix`, `package_as_prefix_forced_prefix` and
`proto_package_prefix_exceptions_path`: The `value` for
`use_package_as_prefix` can be `yes` or `no`, and indicates if a prefix
should be derived from the proto package for all the symbols for files that
don't have the `objc_class_prefix` file option (mentioned above). This helps
ensure the symbols are more unique and means there is less chance of ObjC
class name collisions.
* `use_package_as_prefix` and `proto_package_prefix_exceptions_path`: The
`value` for `use_package_as_prefix` can be `yes` or `no`, and indicates
if a prefix should be derived from the proto package for all the symbols
for files that don't have the `objc_class_prefix` file option (mentioned
above). This helps ensure the symbols are more unique and means there is
less chance of ObjC class name collisions.
To help in migrating code to using this support,
`proto_package_prefix_exceptions_path` can be used to provide the path
@@ -214,16 +213,10 @@ supported keys are:
if prefixed with `#`). These package won't get the derived prefix, allowing
migrations to the behavior one proto package at a time across a code base.
`package_as_prefix_forced_prefix` can be used to provide a value that will
be used before all prefixes derived from the packages to help group all of
these types with a common prefix. Thus it only makes sense to use it when
`use_package_as_prefix` is also enabled. For example, setting this to
"XYZ\_" and generating a file with the package "something" defining
"MyMessage", would have Objective-C class be `XYZ_Something_MyMessage`.
`use_package_as_prefix` currently defaults to `no` (existing behavior), but
that could change in the future as it helps avoid collisions when more
protos get added to the build. Note that this would be a breaking change.
in the future (as a breaking change), that is likely to change since it
helps prepare folks before they end up using a lot of protos and getting a
lot of collisions.
* `headers_use_forward_declarations`: The `value` for this can be `yes` or
`no`, and indicates if the generated headers use forward declarations for

View File

@@ -34,16 +34,30 @@
// Makes sure all the generated headers compile with ARC on.
#import "objectivec/Tests/Unittest.pbobjc.h"
#import "objectivec/Tests/UnittestCycle.pbobjc.h"
#import "objectivec/Tests/UnittestDeprecated.pbobjc.h"
#import "objectivec/Tests/UnittestDeprecatedFile.pbobjc.h"
#import "objectivec/Tests/UnittestImport.pbobjc.h"
#import "objectivec/Tests/UnittestImportPublic.pbobjc.h"
#import "objectivec/Tests/UnittestMset.pbobjc.h"
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
#import "objectivec/Tests/UnittestObjcOptions.pbobjc.h"
#import "objectivec/Tests/UnittestObjcStartup.pbobjc.h"
#import "objectivec/Tests/UnittestPreserveUnknownEnum.pbobjc.h"
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
#import "objectivec/Tests/UnittestRuntimeProto3.pbobjc.h"
// The unittest_custom_options.proto extends the messages in descriptor.proto
// so we build it in to test extending in general. The library doesn't provide
// a descriptor as it doesn't use the classes/enums.
#import "google/protobuf/Descriptor.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestCustomOptions.pbobjc.h"
#import "google/protobuf/UnittestCycle.pbobjc.h"
#import "google/protobuf/UnittestDeprecated.pbobjc.h"
#import "google/protobuf/UnittestDeprecatedFile.pbobjc.h"
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.h"
#import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.h"
#import "google/protobuf/UnittestEmpty.pbobjc.h"
#import "google/protobuf/UnittestEnormousDescriptor.pbobjc.h"
#import "google/protobuf/UnittestImport.pbobjc.h"
#import "google/protobuf/UnittestImportLite.pbobjc.h"
#import "google/protobuf/UnittestImportPublic.pbobjc.h"
#import "google/protobuf/UnittestImportPublicLite.pbobjc.h"
#import "google/protobuf/UnittestLite.pbobjc.h"
#import "google/protobuf/UnittestMset.pbobjc.h"
#import "google/protobuf/UnittestNoGenericServices.pbobjc.h"
#import "google/protobuf/UnittestObjc.pbobjc.h"
#import "google/protobuf/UnittestObjcStartup.pbobjc.h"
#import "google/protobuf/UnittestOptimizeFor.pbobjc.h"
#import "google/protobuf/UnittestPreserveUnknownEnum.pbobjc.h"
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"

View File

@@ -40,7 +40,8 @@
@interface GPBEnumArray (TestingTweak)
+ (instancetype)arrayWithValue:(int32_t)value;
+ (instancetype)arrayWithCapacity:(NSUInteger)count;
- (instancetype)initWithValues:(const int32_t[])values count:(NSUInteger)count;
- (instancetype)initWithValues:(const int32_t [])values
count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -76,16 +77,16 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
return [[[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
capacity:count] autorelease];
}
- (instancetype)initWithValues:(const int32_t[])values count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue rawValues:values count:count];
- (instancetype)initWithValues:(const int32_t [])values
count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
count:count];
}
@end
#pragma mark - PDDM Macros
// Disable clang-format for the macros.
// clang-format off
//%PDDM-DEFINE ARRAY_TESTS(NAME, TYPE, VAL1, VAL2, VAL3, VAL4)
//%ARRAY_TESTS2(NAME, TYPE, VAL1, VAL2, VAL3, VAL4, )
//%PDDM-DEFINE ARRAY_TESTS2(NAME, TYPE, VAL1, VAL2, VAL3, VAL4, HELPER)
@@ -101,11 +102,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% XCTAssertNotNil(array);
//% XCTAssertEqual(array.count, 0U);
//% XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
//% [array enumerateValuesWithBlock:^(__unused TYPE value, __unused NSUInteger idx, __unused BOOL *stop) {
//% [array enumerateValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) {
//% #pragma unused(value, idx, stop)
//% XCTFail(@"Shouldn't get here!");
//% }];
//% [array enumerateValuesWithOptions:NSEnumerationReverse
//% usingBlock:^(__unused TYPE value, __unused NSUInteger idx, __unused BOOL *stop) {
//% usingBlock:^(TYPE value, NSUInteger idx, BOOL *stop) {
//% #pragma unused(value, idx, stop)
//% XCTFail(@"Shouldn't get here!");
//% }];
//% [array release];
@@ -430,6 +433,7 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//%
//%PDDM-EXPAND ARRAY_TESTS(Int32, int32_t, 1, 2, 3, 4)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Int32
@@ -443,11 +447,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 0U);
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
[array enumerateValuesWithBlock:^(__unused int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[array enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array enumerateValuesWithOptions:NSEnumerationReverse
usingBlock:^(__unused int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array release];
@@ -770,8 +776,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_TESTS(UInt32, uint32_t, 11U, 12U, 13U, 14U)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - UInt32
@@ -785,11 +793,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 0U);
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
[array enumerateValuesWithBlock:^(__unused uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[array enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array enumerateValuesWithOptions:NSEnumerationReverse
usingBlock:^(__unused uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
usingBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array release];
@@ -1112,8 +1122,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_TESTS(Int64, int64_t, 31LL, 32LL, 33LL, 34LL)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Int64
@@ -1127,11 +1139,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 0U);
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
[array enumerateValuesWithBlock:^(__unused int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[array enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array enumerateValuesWithOptions:NSEnumerationReverse
usingBlock:^(__unused int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
usingBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array release];
@@ -1454,8 +1468,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_TESTS(UInt64, uint64_t, 41ULL, 42ULL, 43ULL, 44ULL)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - UInt64
@@ -1469,11 +1485,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 0U);
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
[array enumerateValuesWithBlock:^(__unused uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[array enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array enumerateValuesWithOptions:NSEnumerationReverse
usingBlock:^(__unused uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
usingBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array release];
@@ -1796,8 +1814,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_TESTS(Float, float, 51.f, 52.f, 53.f, 54.f)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Float
@@ -1811,11 +1831,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 0U);
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
[array enumerateValuesWithBlock:^(__unused float value, __unused NSUInteger idx, __unused BOOL *stop) {
[array enumerateValuesWithBlock:^(float value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array enumerateValuesWithOptions:NSEnumerationReverse
usingBlock:^(__unused float value, __unused NSUInteger idx, __unused BOOL *stop) {
usingBlock:^(float value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array release];
@@ -2138,8 +2160,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_TESTS(Double, double, 61., 62., 63., 64.)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Double
@@ -2153,11 +2177,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 0U);
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
[array enumerateValuesWithBlock:^(__unused double value, __unused NSUInteger idx, __unused BOOL *stop) {
[array enumerateValuesWithBlock:^(double value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array enumerateValuesWithOptions:NSEnumerationReverse
usingBlock:^(__unused double value, __unused NSUInteger idx, __unused BOOL *stop) {
usingBlock:^(double value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array release];
@@ -2480,8 +2506,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_TESTS(Bool, BOOL, TRUE, TRUE, FALSE, FALSE)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool
@@ -2495,11 +2523,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 0U);
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
[array enumerateValuesWithBlock:^(__unused BOOL value, __unused NSUInteger idx, __unused BOOL *stop) {
[array enumerateValuesWithBlock:^(BOOL value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array enumerateValuesWithOptions:NSEnumerationReverse
usingBlock:^(__unused BOOL value, __unused NSUInteger idx, __unused BOOL *stop) {
usingBlock:^(BOOL value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array release];
@@ -2822,8 +2852,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND ARRAY_TESTS2(Enum, int32_t, 71, 72, 73, 74, Raw)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Enum
@@ -2837,11 +2869,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 0U);
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
[array enumerateValuesWithBlock:^(__unused int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
[array enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array enumerateValuesWithOptions:NSEnumerationReverse
usingBlock:^(__unused int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(value, idx, stop)
XCTFail(@"Shouldn't get here!");
}];
[array release];
@@ -3164,9 +3198,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
@end
//%PDDM-EXPAND-END (8 expansions)
// clang-format on
//%PDDM-EXPAND-END (8 expansions)
#pragma mark - Non macro-based Enum tests
@@ -3178,13 +3211,15 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
@implementation GPBEnumArrayCustomTests
- (void)testRawBasics {
static const int32_t kValues[] = {71, 272, 73, 374};
static const int32_t kValuesFiltered[] = {71, kGPBUnrecognizedEnumeratorValue, 73,
kGPBUnrecognizedEnumeratorValue};
static const int32_t kValues[] = { 71, 272, 73, 374 };
static const int32_t kValuesFiltered[] = {
71, kGPBUnrecognizedEnumeratorValue, 73, kGPBUnrecognizedEnumeratorValue
};
XCTAssertEqual(GPBARRAYSIZE(kValues), GPBARRAYSIZE(kValuesFiltered));
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 4U);
GPBEnumValidationFunc func = TestingEnum_IsValidValue;
@@ -3213,19 +3248,19 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
idx2 = 0;
[array enumerateRawValuesWithOptions:NSEnumerationReverse
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
XCTAssertEqual(idx, (3 - idx2));
XCTAssertEqual(value, kValues[idx]);
XCTAssertNotEqual(stop, NULL);
++idx2;
}];
XCTAssertEqual(idx, (3 - idx2));
XCTAssertEqual(value, kValues[idx]);
XCTAssertNotEqual(stop, NULL);
++idx2;
}];
idx2 = 0;
[array enumerateValuesWithOptions:NSEnumerationReverse
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
XCTAssertEqual(idx, (3 - idx2));
XCTAssertEqual(value, kValuesFiltered[idx]);
XCTAssertNotEqual(stop, NULL);
++idx2;
}];
XCTAssertEqual(idx, (3 - idx2));
XCTAssertEqual(value, kValuesFiltered[idx]);
XCTAssertNotEqual(stop, NULL);
++idx2;
}];
// Stopping the enumeration.
idx2 = 0;
[array enumerateRawValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
@@ -3240,35 +3275,38 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
idx2 = 0;
[array enumerateRawValuesWithOptions:NSEnumerationReverse
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
XCTAssertEqual(idx, (3 - idx2));
XCTAssertEqual(value, kValues[idx]);
XCTAssertNotEqual(stop, NULL);
if (idx2 == 1) *stop = YES;
XCTAssertNotEqual(idx, 1U);
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
XCTAssertEqual(idx, (3 - idx2));
XCTAssertEqual(value, kValues[idx]);
XCTAssertNotEqual(stop, NULL);
if (idx2 == 1) *stop = YES;
XCTAssertNotEqual(idx, 1U);
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
[array release];
}
- (void)testEquality {
const int32_t kValues1[] = {71, 72, 173}; // With unknown value
const int32_t kValues2[] = {71, 74, 173}; // With unknown value
const int32_t kValues3[] = {71, 72, 173, 74}; // With unknown value
GPBEnumArray *array1 = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues1
count:GPBARRAYSIZE(kValues1)];
const int32_t kValues1[] = { 71, 72, 173 }; // With unknown value
const int32_t kValues2[] = { 71, 74, 173 }; // With unknown value
const int32_t kValues3[] = { 71, 72, 173, 74 }; // With unknown value
GPBEnumArray *array1 =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(array1);
GPBEnumArray *array1prime =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue2
rawValues:kValues1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(array1prime);
GPBEnumArray *array2 = [[GPBEnumArray alloc] initWithValues:kValues2
count:GPBARRAYSIZE(kValues2)];
GPBEnumArray *array2 =
[[GPBEnumArray alloc] initWithValues:kValues2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(array2);
GPBEnumArray *array3 = [[GPBEnumArray alloc] initWithValues:kValues3
count:GPBARRAYSIZE(kValues3)];
GPBEnumArray *array3 =
[[GPBEnumArray alloc] initWithValues:kValues3
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
// 1/1Prime should be different objects, but equal.
@@ -3291,11 +3329,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
}
- (void)testCopy {
const int32_t kValues[] = {71, 72};
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValues:kValues count:GPBARRAYSIZE(kValues)];
const int32_t kValues[] = { 71, 72 };
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValues:kValues
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
[array addRawValue:1000]; // Unknown
[array addRawValue:1000]; // Unknown
XCTAssertEqual(array.count, 3U);
XCTAssertEqual([array rawValueAtIndex:0], 71);
XCTAssertEqual([array rawValueAtIndex:1], 72);
@@ -3320,10 +3360,11 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
}
- (void)testArrayFromArray {
const int32_t kValues[] = {71, 172, 173, 74}; // Unknowns
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
const int32_t kValues[] = { 71, 172, 173, 74 }; // Unknowns
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
GPBEnumArray *array2 = [GPBEnumArray arrayWithValueArray:array];
@@ -3337,34 +3378,38 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
}
- (void)testUnknownAdds {
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue];
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(array);
XCTAssertThrowsSpecificNamed([array addValue:172], NSException, NSInvalidArgumentException);
XCTAssertThrowsSpecificNamed([array addValue:172],
NSException, NSInvalidArgumentException);
XCTAssertEqual(array.count, 0U);
const int32_t kValues1[] = {172, 173}; // Unknown
XCTAssertThrowsSpecificNamed([array addValues:kValues1 count:GPBARRAYSIZE(kValues1)], NSException,
NSInvalidArgumentException);
const int32_t kValues1[] = { 172, 173 }; // Unknown
XCTAssertThrowsSpecificNamed([array addValues:kValues1 count:GPBARRAYSIZE(kValues1)],
NSException, NSInvalidArgumentException);
XCTAssertEqual(array.count, 0U);
[array release];
}
- (void)testRawAdds {
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue];
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 0U);
[array addRawValue:71]; // Valid
XCTAssertEqual(array.count, 1U);
const int32_t kValues1[] = {172, 173}; // Unknown
const int32_t kValues1[] = { 172, 173 }; // Unknown
[array addRawValues:kValues1 count:GPBARRAYSIZE(kValues1)];
XCTAssertEqual(array.count, 3U);
const int32_t kValues2[] = {74, 71};
GPBEnumArray *array2 = [[GPBEnumArray alloc] initWithValues:kValues2
count:GPBARRAYSIZE(kValues2)];
const int32_t kValues2[] = { 74, 71 };
GPBEnumArray *array2 =
[[GPBEnumArray alloc] initWithValues:kValues2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(array2);
[array addRawValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
@@ -3380,35 +3425,37 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
}
- (void)testUnknownInserts {
const int32_t kValues[] = {71, 72, 73};
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
const int32_t kValues[] = { 71, 72, 73 };
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 3U);
// First
XCTAssertThrowsSpecificNamed([array insertValue:174 atIndex:0], NSException,
NSInvalidArgumentException);
XCTAssertThrowsSpecificNamed([array insertValue:174 atIndex:0],
NSException, NSInvalidArgumentException);
XCTAssertEqual(array.count, 3U);
// Middle
XCTAssertThrowsSpecificNamed([array insertValue:274 atIndex:1], NSException,
NSInvalidArgumentException);
XCTAssertThrowsSpecificNamed([array insertValue:274 atIndex:1],
NSException, NSInvalidArgumentException);
XCTAssertEqual(array.count, 3U);
// End
XCTAssertThrowsSpecificNamed([array insertValue:374 atIndex:3], NSException,
NSInvalidArgumentException);
XCTAssertThrowsSpecificNamed([array insertValue:374 atIndex:3],
NSException, NSInvalidArgumentException);
XCTAssertEqual(array.count, 3U);
[array release];
}
- (void)testRawInsert {
const int32_t kValues[] = {71, 72, 73};
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
const int32_t kValues[] = { 71, 72, 73 };
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
XCTAssertEqual(array.count, 3U);
@@ -3425,7 +3472,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 6U);
// Too far.
XCTAssertThrowsSpecificNamed([array insertRawValue:74 atIndex:7], NSException, NSRangeException);
XCTAssertThrowsSpecificNamed([array insertRawValue:74 atIndex:7],
NSException, NSRangeException);
XCTAssertEqual([array rawValueAtIndex:0], 174);
XCTAssertEqual([array valueAtIndex:0], kGPBUnrecognizedEnumeratorValue);
@@ -3440,16 +3488,17 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
}
- (void)testUnknownInplaceMutation {
const int32_t kValues[] = {71, 72, 73, 74};
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
const int32_t kValues[] = { 71, 72, 73, 74 };
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:1 withValue:172], NSException,
NSInvalidArgumentException);
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:3 withValue:274], NSException,
NSInvalidArgumentException);
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:1 withValue:172],
NSException, NSInvalidArgumentException);
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:3 withValue:274],
NSException, NSInvalidArgumentException);
XCTAssertEqual(array.count, 4U);
XCTAssertEqual([array valueAtIndex:0], 71);
XCTAssertEqual([array valueAtIndex:1], 72);
@@ -3458,11 +3507,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array release];
}
- (void)testRawInplaceMutation {
const int32_t kValues[] = {71, 72, 73, 74};
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
const int32_t kValues[] = { 71, 72, 73, 74 };
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:kValues
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
[array replaceValueAtIndex:1 withRawValue:172]; // Unknown
@@ -3475,14 +3526,16 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual([array rawValueAtIndex:3], 274);
XCTAssertEqual([array valueAtIndex:3], kGPBUnrecognizedEnumeratorValue);
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:4 withRawValue:74], NSException,
NSRangeException);
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:4 withRawValue:74],
NSException, NSRangeException);
[array release];
}
- (void)testRawInternalResizing {
const int32_t kValues[] = {71, 172, 173, 74}; // Unknown
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValues:kValues count:GPBARRAYSIZE(kValues)];
const int32_t kValues[] = { 71, 172, 173, 74 }; // Unknown
GPBEnumArray *array =
[[GPBEnumArray alloc] initWithValues:kValues
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
// Add/remove to trigger the intneral buffer to grow/shrink.
@@ -3558,13 +3611,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
NSArray *cpy = [array copy];
XCTAssertTrue(cpy != array); // Ptr compare
XCTAssertTrue(cpy != array); // Ptr compare
XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
XCTAssertEqual(cpy.count, (NSUInteger)0);
NSArray *cpy2 = [array copy];
XCTAssertTrue(cpy2 != array); // Ptr compare
XCTAssertTrue(cpy2 != array); // Ptr compare
// Can't compare cpy and cpy2 because NSArray has a singleton empty
// array it uses, so the ptrs are the same.
XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
@@ -3580,14 +3633,14 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
NSMutableArray *cpy = [array mutableCopy];
XCTAssertTrue(cpy != array); // Ptr compare
XCTAssertTrue(cpy != array); // Ptr compare
XCTAssertTrue([cpy isKindOfClass:[NSMutableArray class]]);
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
XCTAssertEqual(cpy.count, (NSUInteger)0);
NSMutableArray *cpy2 = [array mutableCopy];
XCTAssertTrue(cpy2 != array); // Ptr compare
XCTAssertTrue(cpy2 != cpy); // Ptr compare
XCTAssertTrue(cpy2 != array); // Ptr compare
XCTAssertTrue(cpy2 != cpy); // Ptr compare
XCTAssertTrue([cpy2 isKindOfClass:[NSMutableArray class]]);
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
XCTAssertEqual(cpy2.count, (NSUInteger)0);
@@ -3603,7 +3656,7 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addObject:@"bar"];
NSArray *cpy = [array copy];
XCTAssertTrue(cpy != array); // Ptr compare
XCTAssertTrue(cpy != array); // Ptr compare
XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
XCTAssertEqual(cpy.count, (NSUInteger)2);
@@ -3611,8 +3664,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqualObjects(cpy[1], @"bar");
NSArray *cpy2 = [array copy];
XCTAssertTrue(cpy2 != array); // Ptr compare
XCTAssertTrue(cpy2 != cpy); // Ptr compare
XCTAssertTrue(cpy2 != array); // Ptr compare
XCTAssertTrue(cpy2 != cpy); // Ptr compare
XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
XCTAssertEqual(cpy2.count, (NSUInteger)2);
@@ -3630,7 +3683,7 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addObject:@"bar"];
NSMutableArray *cpy = [array mutableCopy];
XCTAssertTrue(cpy != array); // Ptr compare
XCTAssertTrue(cpy != array); // Ptr compare
XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
XCTAssertEqual(cpy.count, (NSUInteger)2);
@@ -3638,8 +3691,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqualObjects(cpy[1], @"bar");
NSMutableArray *cpy2 = [array mutableCopy];
XCTAssertTrue(cpy2 != array); // Ptr compare
XCTAssertTrue(cpy2 != cpy); // Ptr compare
XCTAssertTrue(cpy2 != array); // Ptr compare
XCTAssertTrue(cpy2 != cpy); // Ptr compare
XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
XCTAssertEqual(cpy2.count, (NSUInteger)2);

View File

@@ -34,7 +34,7 @@
#import "GPBCodedOutputStream.h"
#import "GPBUnknownFieldSet_PackagePrivate.h"
#import "GPBUtilities_PackagePrivate.h"
#import "objectivec/Tests/Unittest.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
@interface CodedInputStreamTests : GPBTestCase
@end
@@ -82,10 +82,8 @@
[self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x7FFFFFFF];
[self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x80000000];
[self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01)
value:0x7FFFFFFFFFFFFFFFL];
[self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01)
value:0x8000000000000000L];
[self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01) value:0x7FFFFFFFFFFFFFFFL];
[self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01) value:0x8000000000000000L];
}
- (void)assertReadVarint:(NSData*)data value:(int64_t)value {
@@ -203,25 +201,30 @@
value:(0x22 << 0) | (0x22 << 7) | (0x22 << 14) | (0x74 << 21)];
// 2961488830
[self assertReadVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b)
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x0bLL << 28)];
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) |
(0x04 << 21) | (0x0bLL << 28)];
// 64-bit
// 7256456126
[self assertReadVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b)
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x1bLL << 28)];
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) |
(0x04 << 21) | (0x1bLL << 28)];
// 41256202580718336
[self assertReadVarint:bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49)
value:(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | (0x43LL << 28) |
(0x49LL << 35) | (0x24LL << 42) | (0x49LL << 49)];
value:(0x00 << 0) | (0x66 << 7) | (0x6b << 14) |
(0x1c << 21) | (0x43LL << 28) | (0x49LL << 35) |
(0x24LL << 42) | (0x49LL << 49)];
// 11964378330978735131
[self assertReadVarint:bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01)
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | (0x3bLL << 28) |
(0x56LL << 35) | (0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
(0x01ULL << 63)];
[self
assertReadVarint:bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85,
0xa6, 0x01)
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
(0x3bLL << 28) | (0x56LL << 35) | (0x00LL << 42) |
(0x05LL << 49) | (0x26LL << 56) | (0x01ULL << 63)];
// Failures
[self assertReadVarintFailure:bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x00)];
[self assertReadVarintFailure:bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x00)];
[self assertReadVarintFailure:bytes(0x80)];
}
@@ -265,12 +268,16 @@
}
- (void)testReadLittleEndian {
[self assertReadLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12) value:0x12345678];
[self assertReadLittleEndian32:bytes(0xf0, 0xde, 0xbc, 0x9a) value:0x9abcdef0];
[self assertReadLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12)
value:0x12345678];
[self assertReadLittleEndian32:bytes(0xf0, 0xde, 0xbc, 0x9a)
value:0x9abcdef0];
[self assertReadLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12)
[self assertReadLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34,
0x12)
value:0x123456789abcdef0LL];
[self assertReadLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a)
[self assertReadLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc,
0x9a)
value:0x9abcdef012345678LL];
}
@@ -280,7 +287,8 @@
NSData* rawBytes = message.data;
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes extensionRegistry:nil error:NULL];
TestAllTypes* message2 =
[TestAllTypes parseFromData:rawBytes extensionRegistry:nil error:NULL];
[self assertAllFieldsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
}
@@ -292,7 +300,8 @@
// skipField() to skip each field on the other. Expect the same tags.
GPBCodedInputStream* input1 = [GPBCodedInputStream streamWithData:rawBytes];
GPBCodedInputStream* input2 = [GPBCodedInputStream streamWithData:rawBytes];
GPBUnknownFieldSet* unknownFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
GPBUnknownFieldSet* unknownFields =
[[[GPBUnknownFieldSet alloc] init] autorelease];
while (YES) {
int32_t tag = [input1 readTag];
@@ -320,9 +329,10 @@
// Serialize and parse it. Make sure to parse from an InputStream, not
// directly from a ByteString, so that CodedInputStream uses buffered
// reading.
NSData* messageData = message.data;
NSData *messageData = message.data;
XCTAssertNotNil(messageData);
GPBCodedInputStream* stream = [GPBCodedInputStream streamWithData:messageData];
GPBCodedInputStream* stream =
[GPBCodedInputStream streamWithData:messageData];
TestAllTypes* message2 = [TestAllTypes parseFromCodedInputStream:stream
extensionRegistry:nil
error:NULL];
@@ -340,7 +350,8 @@
- (void)testReadMaliciouslyLargeBlob {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
int32_t tag = GPBWireFormatMakeTag(1, GPBWireFormatLengthDelimited);
[output writeRawVarint32:tag];
@@ -349,7 +360,8 @@
[output writeRawData:[NSData dataWithBytes:bytes length:32]];
[output flush];
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* data =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
GPBCodedInputStream* input =
[GPBCodedInputStream streamWithData:[NSMutableData dataWithData:data]];
XCTAssertEqual(tag, [input readTag]);
@@ -358,21 +370,23 @@
}
- (void)testReadEmptyString {
NSData* data = bytes(0x00);
NSData *data = bytes(0x00);
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
XCTAssertEqualObjects(@"", [input readString]);
}
- (void)testInvalidGroupEndTagThrows {
NSData* data = bytes(0x0B, 0x1A, 0x02, 0x4B, 0x50, 0x14);
NSData *data = bytes(0x0B, 0x1A, 0x02, 0x4B, 0x50, 0x14);
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
XCTAssertThrowsSpecificNamed([input skipMessage], NSException, GPBCodedInputStreamException,
XCTAssertThrowsSpecificNamed([input skipMessage],
NSException,
GPBCodedInputStreamException,
@"should throw a GPBCodedInputStreamException exception ");
}
- (void)testBytesWithNegativeSize {
NSData* data = bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F);
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
NSData *data = bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F);
GPBCodedInputStream *input = [GPBCodedInputStream streamWithData:data];
XCTAssertNil([input readBytes]);
}
@@ -382,10 +396,11 @@
// again, it will help validate that class' handing of bad utf8.
- (void)testReadMalformedString {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
int32_t tag =
GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString, GPBWireFormatLengthDelimited);
int32_t tag = GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString,
GPBWireFormatLengthDelimited);
[output writeRawVarint32:tag];
[output writeRawVarint32:5];
// Create an invalid utf-8 byte array.
@@ -393,9 +408,10 @@
[output writeRawData:[NSData dataWithBytes:bytes length:sizeof(bytes)]];
[output flush];
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData *data =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
NSError* error = nil;
NSError *error = nil;
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
extensionRegistry:nil
error:&error];
@@ -409,25 +425,27 @@
// correctly. (Again, this is inpart in case a custom string class is ever
// used again.)
const char* strs[] = {
"\xEF\xBB\xBF String with BOM",
"String with \xEF\xBB\xBF in middle",
"String with end bom \xEF\xBB\xBF",
"\xEF\xBB\xBF\xe2\x99\xa1", // BOM White Heart
"\xEF\xBB\xBF\xEF\xBB\xBF String with Two BOM",
"\xEF\xBB\xBF String with BOM",
"String with \xEF\xBB\xBF in middle",
"String with end bom \xEF\xBB\xBF",
"\xEF\xBB\xBF\xe2\x99\xa1", // BOM White Heart
"\xEF\xBB\xBF\xEF\xBB\xBF String with Two BOM",
};
for (size_t i = 0; i < GPBARRAYSIZE(strs); ++i) {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
int32_t tag =
GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString, GPBWireFormatLengthDelimited);
int32_t tag = GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString,
GPBWireFormatLengthDelimited);
[output writeRawVarint32:tag];
size_t length = strlen(strs[i]);
[output writeRawVarint32:(int32_t)length];
[output writeRawData:[NSData dataWithBytes:strs[i] length:length]];
[output flush];
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* data =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
extensionRegistry:nil

View File

@@ -30,23 +30,26 @@
#import "GPBTestUtilities.h"
#import "GPBCodedInputStream.h"
#import "GPBCodedOutputStream_PackagePrivate.h"
#import "GPBCodedInputStream.h"
#import "GPBUtilities_PackagePrivate.h"
#import "objectivec/Tests/Unittest.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
@interface GPBCodedOutputStream (InternalMethods)
// Declared in the .m file, expose for testing.
- (instancetype)initWithOutputStream:(NSOutputStream*)output data:(NSMutableData*)data;
- (instancetype)initWithOutputStream:(NSOutputStream *)output
data:(NSMutableData *)data;
@end
@interface GPBCodedOutputStream (Helper)
+ (instancetype)streamWithOutputStream:(NSOutputStream*)output bufferSize:(size_t)bufferSize;
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output
bufferSize:(size_t)bufferSize;
@end
@implementation GPBCodedOutputStream (Helper)
+ (instancetype)streamWithOutputStream:(NSOutputStream*)output bufferSize:(size_t)bufferSize {
NSMutableData* data = [NSMutableData dataWithLength:bufferSize];
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output
bufferSize:(size_t)bufferSize {
NSMutableData *data = [NSMutableData dataWithLength:bufferSize];
return [[[self alloc] initWithOutputStream:output data:data] autorelease];
}
@end
@@ -78,17 +81,20 @@
- (void)assertWriteLittleEndian32:(NSData*)data value:(int32_t)value {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
[output writeRawLittleEndian32:(int32_t)value];
[output flush];
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* actual =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
XCTAssertEqualObjects(data, actual);
// Try different block sizes.
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
rawOutput = [NSOutputStream outputStreamToMemory];
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput bufferSize:blockSize];
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
bufferSize:blockSize];
[output writeRawLittleEndian32:(int32_t)value];
[output flush];
@@ -99,17 +105,20 @@
- (void)assertWriteLittleEndian64:(NSData*)data value:(int64_t)value {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
[output writeRawLittleEndian64:value];
[output flush];
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* actual =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
XCTAssertEqualObjects(data, actual);
// Try different block sizes.
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
rawOutput = [NSOutputStream outputStreamToMemory];
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput bufferSize:blockSize];
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
bufferSize:blockSize];
[output writeRawLittleEndian64:value];
[output flush];
@@ -122,24 +131,29 @@
// Only do 32-bit write if the value fits in 32 bits.
if (GPBLogicalRightShift64(value, 32) == 0) {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
[output writeRawVarint32:(int32_t)value];
[output flush];
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* actual =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
XCTAssertEqualObjects(data, actual);
// Also try computing size.
XCTAssertEqual(GPBComputeRawVarint32Size((int32_t)value), (size_t)data.length);
XCTAssertEqual(GPBComputeRawVarint32Size((int32_t)value),
(size_t)data.length);
}
{
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
[output writeRawVarint64:value];
[output flush];
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* actual =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
XCTAssertEqualObjects(data, actual);
// Also try computing size.
@@ -151,45 +165,52 @@
// Only do 32-bit write if the value fits in 32 bits.
if (GPBLogicalRightShift64(value, 32) == 0) {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
bufferSize:blockSize];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput
bufferSize:blockSize];
[output writeRawVarint32:(int32_t)value];
[output flush];
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* actual =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
XCTAssertEqualObjects(data, actual);
}
{
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
bufferSize:blockSize];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput
bufferSize:blockSize];
[output writeRawVarint64:value];
[output flush];
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* actual =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
XCTAssertEqualObjects(data, actual);
}
}
}
- (void)assertWriteStringNoTag:(NSData*)data
value:(NSString*)value
context:(NSString*)contextMessage {
value:(NSString *)value
context:(NSString *)contextMessage {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
[output writeStringNoTag:value];
[output flush];
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* actual =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
XCTAssertEqualObjects(data, actual, @"%@", contextMessage);
// Try different block sizes.
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
rawOutput = [NSOutputStream outputStreamToMemory];
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput bufferSize:blockSize];
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
bufferSize:blockSize];
[output writeStringNoTag:value];
[output flush];
@@ -222,41 +243,51 @@
// 1887747006 (no sign bit)
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x07)
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x07LL << 28)];
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) |
(0x04 << 21) | (0x07LL << 28)];
// 2961488830 (sign bit)
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b)
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x0bLL << 28)];
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) |
(0x04 << 21) | (0x0bLL << 28)];
}
- (void)testWriteVarint6 {
// 64-bit
// 7256456126
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b)
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x1bLL << 28)];
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) |
(0x04 << 21) | (0x1bLL << 28)];
}
- (void)testWriteVarint7 {
// 41256202580718336
[self assertWriteVarint:bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49)
value:(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | (0x43LL << 28) |
(0x49LL << 35) | (0x24LL << 42) | (0x49LL << 49)];
value:(0x00 << 0) | (0x66 << 7) | (0x6b << 14) |
(0x1c << 21) | (0x43LL << 28) | (0x49LL << 35) |
(0x24LL << 42) | (0x49LL << 49)];
}
- (void)testWriteVarint8 {
// 11964378330978735131
[self assertWriteVarint:bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01)
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | (0x3bLL << 28) |
(0x56LL << 35) | (0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
[self assertWriteVarint:bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85,
0xa6, 0x01)
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) |
(0x42 << 21) | (0x3bLL << 28) | (0x56LL << 35) |
(0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
(0x01ULL << 63)];
}
- (void)testWriteLittleEndian {
[self assertWriteLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12) value:0x12345678];
[self assertWriteLittleEndian32:bytes(0xf0, 0xde, 0xbc, 0x9a) value:0x9abcdef0];
[self assertWriteLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12)
value:0x12345678];
[self assertWriteLittleEndian32:bytes(0xf0, 0xde, 0xbc, 0x9a)
value:0x9abcdef0];
[self assertWriteLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12)
[self assertWriteLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56,
0x34, 0x12)
value:0x123456789abcdef0LL];
[self assertWriteLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a)
[self assertWriteLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde,
0xbc, 0x9a)
value:0x9abcdef012345678LL];
}
@@ -274,12 +305,18 @@
XCTAssertEqual(1ULL, GPBEncodeZigZag64(-1));
XCTAssertEqual(2ULL, GPBEncodeZigZag64(1));
XCTAssertEqual(3ULL, GPBEncodeZigZag64(-2));
XCTAssertEqual(0x000000007FFFFFFEULL, GPBEncodeZigZag64(0x000000003FFFFFFFLL));
XCTAssertEqual(0x000000007FFFFFFFULL, GPBEncodeZigZag64(0xFFFFFFFFC0000000LL));
XCTAssertEqual(0x00000000FFFFFFFEULL, GPBEncodeZigZag64(0x000000007FFFFFFFLL));
XCTAssertEqual(0x00000000FFFFFFFFULL, GPBEncodeZigZag64(0xFFFFFFFF80000000LL));
XCTAssertEqual(0xFFFFFFFFFFFFFFFEULL, GPBEncodeZigZag64(0x7FFFFFFFFFFFFFFFLL));
XCTAssertEqual(0xFFFFFFFFFFFFFFFFULL, GPBEncodeZigZag64(0x8000000000000000LL));
XCTAssertEqual(0x000000007FFFFFFEULL,
GPBEncodeZigZag64(0x000000003FFFFFFFLL));
XCTAssertEqual(0x000000007FFFFFFFULL,
GPBEncodeZigZag64(0xFFFFFFFFC0000000LL));
XCTAssertEqual(0x00000000FFFFFFFEULL,
GPBEncodeZigZag64(0x000000007FFFFFFFLL));
XCTAssertEqual(0x00000000FFFFFFFFULL,
GPBEncodeZigZag64(0xFFFFFFFF80000000LL));
XCTAssertEqual(0xFFFFFFFFFFFFFFFEULL,
GPBEncodeZigZag64(0x7FFFFFFFFFFFFFFFLL));
XCTAssertEqual(0xFFFFFFFFFFFFFFFFULL,
GPBEncodeZigZag64(0x8000000000000000LL));
// Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1)
// were chosen semi-randomly via keyboard bashing.
@@ -295,8 +332,10 @@
XCTAssertEqual(14927ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(14927)));
XCTAssertEqual(-3612ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-3612)));
XCTAssertEqual(856912304801416ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(856912304801416LL)));
XCTAssertEqual(-75123905439571256ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-75123905439571256LL)));
XCTAssertEqual(856912304801416ULL,
GPBEncodeZigZag64(GPBDecodeZigZag64(856912304801416LL)));
XCTAssertEqual(-75123905439571256ULL,
GPBEncodeZigZag64(GPBDecodeZigZag64(-75123905439571256LL)));
}
- (void)testWriteWholeMessage {
@@ -305,18 +344,21 @@
TestAllTypes* message = [self allSetRepeatedCount:2];
NSData* rawBytes = message.data;
NSData* goldenData = [self getDataFileNamed:@"golden_message" dataToWrite:rawBytes];
NSData* goldenData =
[self getDataFileNamed:@"golden_message" dataToWrite:rawBytes];
XCTAssertEqualObjects(rawBytes, goldenData);
// Try different block sizes.
for (int blockSize = 1; blockSize < 256; blockSize *= 2) {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
bufferSize:blockSize];
GPBCodedOutputStream* output =
[GPBCodedOutputStream streamWithOutputStream:rawOutput
bufferSize:blockSize];
[message writeToCodedOutputStream:output];
[output flush];
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSData* actual =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
XCTAssertEqualObjects(rawBytes, actual);
}
@@ -324,7 +366,8 @@
// that was generated with 2.
TestAllExtensions* extensions = [self allExtensionsSetRepeatedCount:2];
rawBytes = extensions.data;
goldenData = [self getDataFileNamed:@"golden_packed_fields_message" dataToWrite:rawBytes];
goldenData = [self getDataFileNamed:@"golden_packed_fields_message"
dataToWrite:rawBytes];
XCTAssertEqualObjects(rawBytes, goldenData);
}
@@ -337,10 +380,11 @@
char zeroTest[] = "\0Test\0String";
// Note: there is a \0 at the end of this since it is a c-string.
NSString* asNSString = [[NSString alloc] initWithBytes:zeroTest
NSString *asNSString = [[NSString alloc] initWithBytes:zeroTest
length:sizeof(zeroTest)
encoding:NSUTF8StringEncoding];
const char* cString = CFStringGetCStringPtr((CFStringRef)asNSString, kCFStringEncodingUTF8);
const char *cString =
CFStringGetCStringPtr((CFStringRef)asNSString, kCFStringEncodingUTF8);
XCTAssertTrue(cString != NULL);
// Again, if the above assert fails, then it means NSString no longer exposes
// the raw utf8 storage of a string created from utf8 input, so the code using
@@ -348,7 +392,8 @@
// a different code path); but the optimizations for when
// CFStringGetCStringPtr does work could possibly go away.
XCTAssertEqual(sizeof(zeroTest), [asNSString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
XCTAssertEqual(sizeof(zeroTest),
[asNSString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
XCTAssertTrue(0 == memcmp(cString, zeroTest, sizeof(zeroTest)));
[asNSString release];
}
@@ -360,25 +405,25 @@
// strings built via the NSString apis. So this round trips them to ensure
// they are acting as expected.
NSArray<NSString*>* strs = @[
NSArray<NSString *> *strs = @[
@"\0at start",
@"in\0middle",
@"at end\0",
];
int i = 0;
for (NSString* str in strs) {
NSData* asUTF8 = [str dataUsingEncoding:NSUTF8StringEncoding];
NSMutableData* expected = [NSMutableData data];
for (NSString *str in strs) {
NSData *asUTF8 = [str dataUsingEncoding:NSUTF8StringEncoding];
NSMutableData *expected = [NSMutableData data];
uint8_t lengthByte = (uint8_t)asUTF8.length;
[expected appendBytes:&lengthByte length:1];
[expected appendData:asUTF8];
NSString* context = [NSString stringWithFormat:@"Loop %d - Literal", i];
NSString *context = [NSString stringWithFormat:@"Loop %d - Literal", i];
[self assertWriteStringNoTag:expected value:str context:context];
// Force a new string to be built which gets a different class from the
// NSString class cluster than the literal did.
NSString* str2 = [NSString stringWithFormat:@"%@", str];
NSString *str2 = [NSString stringWithFormat:@"%@", str];
context = [NSString stringWithFormat:@"Loop %d - Built", i];
[self assertWriteStringNoTag:expected value:str2 context:context];
@@ -387,11 +432,11 @@
}
- (void)testThatItThrowsWhenWriteRawPtrFails {
NSOutputStream* output = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* codedOutput =
NSOutputStream *output = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream *codedOutput =
[GPBCodedOutputStream streamWithOutputStream:output bufferSize:0]; // Skip buffering.
[output close]; // Close the output stream to force failure on write.
const char* cString = "raw";
const char *cString = "raw";
XCTAssertThrowsSpecificNamed([codedOutput writeRawPtr:cString offset:0 length:strlen(cString)],
NSException, GPBCodedOutputStreamException_WriteFailed);
}

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBArray.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_1 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBCodedInputStream.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_2 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBCodedOutputStream.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_3 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBDescriptor.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_4 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBDictionary.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_5 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBExtensionRegistry.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_6 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBMessage.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_7 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBRootObject.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_8 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBUnknownField.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_9 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBUnknownFieldSet.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_10 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBUtilities.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_11 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBWellKnownTypes.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_12 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBWireFormat.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_13 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBAny.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_14 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBApi.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_15 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBDuration.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_16 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBEmpty.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_17 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBFieldMask.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_18 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBSourceContext.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_19 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBStruct.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_20 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBTimestamp.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_21 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBType.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_22 = 0;

View File

@@ -28,11 +28,13 @@
// (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 is a test including a single public header to ensure things build.
// It helps test that imports are complete/ordered correctly.
#import "GPBWrappers.pbobjc.h"
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_23 = 0;

View File

@@ -28,31 +28,15 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A proto file which is imported by unittest.proto to test importing.
syntax = "proto2";
// This is a test including a single header to ensure things build. This
// is NOT a public header of the library, but uses a file that defines
// proto2 syntax messages that are extendable, so it can need more things
// that the proto3 syntax WKTs bundled with the library.
package objc.protobuf.tests.import;
// Test public import
import public "objectivec/Tests/unittest_import_public.proto";
option objc_class_prefix = "Import";
message Message {
optional int32 d = 1;
}
enum Enum {
IMPORT_FOO = 7;
IMPORT_BAR = 8;
IMPORT_BAZ = 9;
}
#import "google/protobuf/Descriptor.pbobjc.h"
// To use an enum in a map, it must has the first value as 0.
enum EnumForMap {
UNKNOWN = 0;
FOO = 1;
BAR = 2;
}
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_24 = 0;

View File

@@ -28,17 +28,15 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto3";
package objc.protobuf.tests.any;
// This is a test including a single header to ensure things build. This
// is NOT a public header of the library, but uses a file that defines
// extensions to proto2 syntax messages, so it can need more things
// that the proto3 syntax WKTs bundled with the library.
import "google/protobuf/any.proto";
#import "google/protobuf/UnittestCustomOptions.pbobjc.h"
option objc_class_prefix = "Any";
message TestMessage {
int32 int32_value = 1;
google.protobuf.Any any_value = 2;
repeated google.protobuf.Any repeated_any_value = 3;
string text = 4;
}
// Something in the body of this file so the compiler/linker won't complain
// about an empty .o file.
__attribute__((visibility("default"))) char dummy_symbol_25 = 0;

View File

@@ -30,8 +30,8 @@
#import "GPBTestUtilities.h"
#import "objectivec/Tests/Unittest.pbobjc.h"
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestObjc.pbobjc.h"
static const int kNumThreads = 100;
static const int kNumMessages = 100;
@@ -49,7 +49,8 @@ static const int kNumMessages = 100;
- (NSArray *)createThreadsWithSelector:(SEL)selector object:(id)object {
NSMutableArray *array = [NSMutableArray array];
for (NSUInteger i = 0; i < kNumThreads; i++) {
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:selector object:object];
NSThread *thread =
[[NSThread alloc] initWithTarget:self selector:selector object:object];
[array addObject:thread];
[thread release];
}
@@ -87,8 +88,9 @@ static const int kNumMessages = 100;
- (void)testConcurrentReadOfUnsetMessageField {
NSArray *messages = [self createMessagesWithType:[TestAllTypes class]];
NSArray *threads = [self createThreadsWithSelector:@selector(readForeignMessage:)
object:messages];
NSArray *threads =
[self createThreadsWithSelector:@selector(readForeignMessage:)
object:messages];
[self startThreads:threads];
[self joinThreads:threads];
for (TestAllTypes *message in messages) {
@@ -106,7 +108,9 @@ static const int kNumMessages = 100;
- (void)testConcurrentReadOfUnsetRepeatedIntField {
NSArray *messages = [self createMessagesWithType:[TestAllTypes class]];
NSArray *threads = [self createThreadsWithSelector:@selector(readRepeatedInt32:) object:messages];
NSArray *threads =
[self createThreadsWithSelector:@selector(readRepeatedInt32:)
object:messages];
[self startThreads:threads];
[self joinThreads:threads];
for (TestAllTypes *message in messages) {
@@ -124,8 +128,9 @@ static const int kNumMessages = 100;
- (void)testConcurrentReadOfUnsetRepeatedStringField {
NSArray *messages = [self createMessagesWithType:[TestAllTypes class]];
NSArray *threads = [self createThreadsWithSelector:@selector(readRepeatedString:)
object:messages];
NSArray *threads =
[self createThreadsWithSelector:@selector(readRepeatedString:)
object:messages];
[self startThreads:threads];
[self joinThreads:threads];
for (TestAllTypes *message in messages) {
@@ -142,8 +147,11 @@ static const int kNumMessages = 100;
}
- (void)testConcurrentReadOfUnsetInt32Int32MapField {
NSArray *messages = [self createMessagesWithType:[TestRecursiveMessageWithRepeatedField class]];
NSArray *threads = [self createThreadsWithSelector:@selector(readInt32Int32Map:) object:messages];
NSArray *messages =
[self createMessagesWithType:[TestRecursiveMessageWithRepeatedField class]];
NSArray *threads =
[self createThreadsWithSelector:@selector(readInt32Int32Map:)
object:messages];
[self startThreads:threads];
[self joinThreads:threads];
for (TestRecursiveMessageWithRepeatedField *message in messages) {
@@ -160,9 +168,11 @@ static const int kNumMessages = 100;
}
- (void)testConcurrentReadOfUnsetStringStringMapField {
NSArray *messages = [self createMessagesWithType:[TestRecursiveMessageWithRepeatedField class]];
NSArray *threads = [self createThreadsWithSelector:@selector(readStringStringMap:)
object:messages];
NSArray *messages =
[self createMessagesWithType:[TestRecursiveMessageWithRepeatedField class]];
NSArray *threads =
[self createThreadsWithSelector:@selector(readStringStringMap:)
object:messages];
[self startThreads:threads];
[self joinThreads:threads];
for (TestRecursiveMessageWithRepeatedField *message in messages) {
@@ -186,7 +196,8 @@ static const int kNumMessages = 100;
NSArray *threads = [self createThreadsWithSelector:sel object:messages];
[self startThreads:threads];
[self joinThreads:threads];
GPBExtensionDescriptor *extension = [UnittestRoot optionalForeignMessageExtension];
GPBExtensionDescriptor *extension =
[UnittestRoot optionalForeignMessageExtension];
for (TestAllExtensions *message in messages) {
XCTAssertFalse([message hasExtension:extension]);
}

View File

@@ -33,9 +33,9 @@
#import <objc/runtime.h>
#import "GPBDescriptor_PackagePrivate.h"
#import "objectivec/Tests/Unittest.pbobjc.h"
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
#import "objectivec/Tests/UnittestObjcOptions.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestObjc.pbobjc.h"
#import "google/protobuf/Descriptor.pbobjc.h"
@interface DescriptorTests : GPBTestCase
@end
@@ -52,36 +52,37 @@
- (void)testDescriptor_fullName {
GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
XCTAssertEqualObjects(testAllTypesDesc.fullName, @"objc.protobuf.tests.TestAllTypes");
XCTAssertEqualObjects(testAllTypesDesc.fullName, @"protobuf_unittest.TestAllTypes");
GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
XCTAssertEqualObjects(nestedMessageDesc.fullName,
@"objc.protobuf.tests.TestAllTypes.NestedMessage");
XCTAssertEqualObjects(nestedMessageDesc.fullName, @"protobuf_unittest.TestAllTypes.NestedMessage");
// Prefixes removed.
GPBDescriptor *descDesc = [GPBTESTPrefixedParentMessage descriptor];
XCTAssertEqualObjects(descDesc.fullName, @"objc.protobuf.tests.options.PrefixedParentMessage");
GPBDescriptor *descExtRngDesc = [GPBTESTPrefixedParentMessage_Child descriptor];
XCTAssertEqualObjects(descExtRngDesc.fullName,
@"objc.protobuf.tests.options.PrefixedParentMessage.Child");
GPBDescriptor *descDesc = [GPBDescriptorProto descriptor];
XCTAssertEqualObjects(descDesc.fullName, @"google.protobuf.DescriptorProto");
GPBDescriptor *descExtRngDesc = [GPBDescriptorProto_ExtensionRange descriptor];
XCTAssertEqualObjects(descExtRngDesc.fullName, @"google.protobuf.DescriptorProto.ExtensionRange");
// Things that get "_Class" added.
GPBDescriptor *pointDesc = [Point_Class descriptor];
XCTAssertEqualObjects(pointDesc.fullName, @"objc.protobuf.tests.Point");
XCTAssertEqualObjects(pointDesc.fullName, @"protobuf_unittest.Point");
GPBDescriptor *pointRectDesc = [Point_Rect descriptor];
XCTAssertEqualObjects(pointRectDesc.fullName, @"objc.protobuf.tests.Point.Rect");
XCTAssertEqualObjects(pointRectDesc.fullName, @"protobuf_unittest.Point.Rect");
}
- (void)testFieldDescriptor {
GPBDescriptor *descriptor = [TestAllTypes descriptor];
// Nested Enum
GPBFieldDescriptor *fieldDescriptorWithName = [descriptor fieldWithName:@"optionalNestedEnum"];
GPBFieldDescriptor *fieldDescriptorWithName =
[descriptor fieldWithName:@"optionalNestedEnum"];
XCTAssertNotNil(fieldDescriptorWithName);
GPBFieldDescriptor *fieldDescriptorWithNumber = [descriptor fieldWithNumber:21];
GPBFieldDescriptor *fieldDescriptorWithNumber =
[descriptor fieldWithNumber:21];
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, @"TestAllTypes_NestedEnum");
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"TestAllTypes_NestedEnum");
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
@@ -92,7 +93,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, @"ForeignEnum");
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"ForeignEnum");
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
@@ -103,7 +105,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, @"ImportEnum");
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"ImportEnum");
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
@@ -118,7 +121,8 @@
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
// Foreign Message
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalForeignMessage"];
fieldDescriptorWithName =
[descriptor fieldWithName:@"optionalForeignMessage"];
XCTAssertNotNil(fieldDescriptorWithName);
fieldDescriptorWithNumber = [descriptor fieldWithNumber:19];
XCTAssertNotNil(fieldDescriptorWithNumber);
@@ -148,18 +152,22 @@
NSString *enumName = [descriptor enumNameForValue:1];
XCTAssertNotNil(enumName);
int32_t value;
XCTAssertTrue([descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Foo"]);
XCTAssertTrue([descriptor getValue:NULL forEnumName:@"TestAllTypes_NestedEnum_Foo"]);
XCTAssertTrue(
[descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Foo"]);
XCTAssertTrue(
[descriptor getValue:NULL forEnumName:@"TestAllTypes_NestedEnum_Foo"]);
XCTAssertEqual(value, TestAllTypes_NestedEnum_Foo);
enumName = [descriptor enumNameForValue:2];
XCTAssertNotNil(enumName);
XCTAssertTrue([descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Bar"]);
XCTAssertTrue(
[descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Bar"]);
XCTAssertEqual(value, TestAllTypes_NestedEnum_Bar);
enumName = [descriptor enumNameForValue:3];
XCTAssertNotNil(enumName);
XCTAssertTrue([descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Baz"]);
XCTAssertTrue(
[descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Baz"]);
XCTAssertEqual(value, TestAllTypes_NestedEnum_Baz);
// TextFormat
@@ -174,8 +182,10 @@
XCTAssertNil(enumName);
XCTAssertFalse([descriptor getValue:&value forEnumName:@"Unknown"]);
XCTAssertFalse([descriptor getValue:NULL forEnumName:@"Unknown"]);
XCTAssertFalse([descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
XCTAssertFalse([descriptor getValue:NULL forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
XCTAssertFalse([descriptor getValue:&value
forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
XCTAssertFalse([descriptor getValue:NULL
forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
XCTAssertFalse([descriptor getValue:NULL forEnumTextFormatName:@"Unknown"]);
XCTAssertFalse([descriptor getValue:&value forEnumTextFormatName:@"Unknown"]);
}
@@ -184,13 +194,17 @@
GPBEnumDescriptor *descriptor = TestAllTypes_NestedEnum_EnumDescriptor();
XCTAssertEqual(descriptor.enumNameCount, 4U);
XCTAssertEqualObjects([descriptor getEnumNameForIndex:0], @"TestAllTypes_NestedEnum_Foo");
XCTAssertEqualObjects([descriptor getEnumNameForIndex:0],
@"TestAllTypes_NestedEnum_Foo");
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:0], @"FOO");
XCTAssertEqualObjects([descriptor getEnumNameForIndex:1], @"TestAllTypes_NestedEnum_Bar");
XCTAssertEqualObjects([descriptor getEnumNameForIndex:1],
@"TestAllTypes_NestedEnum_Bar");
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:1], @"BAR");
XCTAssertEqualObjects([descriptor getEnumNameForIndex:2], @"TestAllTypes_NestedEnum_Baz");
XCTAssertEqualObjects([descriptor getEnumNameForIndex:2],
@"TestAllTypes_NestedEnum_Baz");
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:2], @"BAZ");
XCTAssertEqualObjects([descriptor getEnumNameForIndex:3], @"TestAllTypes_NestedEnum_Neg");
XCTAssertEqualObjects([descriptor getEnumNameForIndex:3],
@"TestAllTypes_NestedEnum_Neg");
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:3], @"NEG");
}
@@ -272,7 +286,8 @@
- (void)testEnumValueValidator {
GPBDescriptor *descriptor = [TestAllTypes descriptor];
GPBFieldDescriptor *fieldDescriptor = [descriptor fieldWithName:@"optionalNestedEnum"];
GPBFieldDescriptor *fieldDescriptor =
[descriptor fieldWithName:@"optionalNestedEnum"];
// Valid values
XCTAssertTrue([fieldDescriptor isValidEnumValue:1]);
@@ -310,10 +325,12 @@
// Pointer comparisons against lookups from message.
XCTAssertEqual([oneofFoo fieldWithNumber:TestOneof2_FieldNumber_FooString], fooStringField);
XCTAssertEqual([oneofFoo fieldWithNumber:TestOneof2_FieldNumber_FooString],
fooStringField);
XCTAssertEqual([oneofFoo fieldWithName:@"fooString"], fooStringField);
XCTAssertEqual([oneofBar fieldWithNumber:TestOneof2_FieldNumber_BarString], barStringField);
XCTAssertEqual([oneofBar fieldWithNumber:TestOneof2_FieldNumber_BarString],
barStringField);
XCTAssertEqual([oneofBar fieldWithName:@"barString"], barStringField);
// Unknown oneof not found.
@@ -337,7 +354,8 @@
// (pointer comparisons)
XCTAssertEqual(fooStringField.containingOneof, oneofFoo);
XCTAssertEqual(barStringField.containingOneof, oneofBar);
GPBFieldDescriptor *bazString = [descriptor fieldWithNumber:TestOneof2_FieldNumber_BazString];
GPBFieldDescriptor *bazString =
[descriptor fieldWithNumber:TestOneof2_FieldNumber_BazString];
XCTAssertNotNil(bazString);
XCTAssertNil(bazString.containingOneof);
}

View File

@@ -34,10 +34,7 @@
#import "GPBDictionary.h"
#import "GPBTestUtilities.h"
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
// Disable clang-format for the macros.
// clang-format off
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
// Pull in the macros (using an external file because expanding all tests
// in a single file makes a file that is failing to work with within Xcode.
@@ -45,6 +42,7 @@
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(UInt32, uint32_t, 100U, 101U)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool -> UInt32
@@ -58,7 +56,8 @@
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getUInt32:NULL forKey:YES]);
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused BOOL aKey, __unused uint32_t aValue, __unused BOOL *stop) {
[dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -124,7 +123,8 @@
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused BOOL aKey, __unused uint32_t aValue, BOOL *stop) {
[dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -346,8 +346,10 @@
@end
// clang-format on
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Int32, int32_t, 200, 201)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool -> Int32
@@ -361,7 +363,8 @@
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getInt32:NULL forKey:YES]);
[dict enumerateKeysAndInt32sUsingBlock:^(__unused BOOL aKey, __unused int32_t aValue, __unused BOOL *stop) {
[dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -427,7 +430,8 @@
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndInt32sUsingBlock:^(__unused BOOL aKey, __unused int32_t aValue, BOOL *stop) {
[dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -649,8 +653,10 @@
@end
// clang-format on
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(UInt64, uint64_t, 300U, 301U)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool -> UInt64
@@ -664,7 +670,8 @@
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getUInt64:NULL forKey:YES]);
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused BOOL aKey, __unused uint64_t aValue, __unused BOOL *stop) {
[dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -730,7 +737,8 @@
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused BOOL aKey, __unused uint64_t aValue, BOOL *stop) {
[dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -952,8 +960,10 @@
@end
// clang-format on
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Int64, int64_t, 400, 401)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool -> Int64
@@ -967,7 +977,8 @@
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getInt64:NULL forKey:YES]);
[dict enumerateKeysAndInt64sUsingBlock:^(__unused BOOL aKey, __unused int64_t aValue, __unused BOOL *stop) {
[dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -1033,7 +1044,8 @@
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndInt64sUsingBlock:^(__unused BOOL aKey, __unused int64_t aValue, BOOL *stop) {
[dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -1255,8 +1267,10 @@
@end
// clang-format on
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Bool, BOOL, NO, YES)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool -> Bool
@@ -1270,7 +1284,8 @@
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getBool:NULL forKey:YES]);
[dict enumerateKeysAndBoolsUsingBlock:^(__unused BOOL aKey, __unused BOOL aValue, __unused BOOL *stop) {
[dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -1336,7 +1351,8 @@
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndBoolsUsingBlock:^(__unused BOOL aKey, __unused BOOL aValue, BOOL *stop) {
[dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -1558,8 +1574,10 @@
@end
// clang-format on
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Float, float, 500.f, 501.f)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool -> Float
@@ -1573,7 +1591,8 @@
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getFloat:NULL forKey:YES]);
[dict enumerateKeysAndFloatsUsingBlock:^(__unused BOOL aKey, __unused float aValue, __unused BOOL *stop) {
[dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -1639,7 +1658,8 @@
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndFloatsUsingBlock:^(__unused BOOL aKey, __unused float aValue, BOOL *stop) {
[dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -1861,8 +1881,10 @@
@end
// clang-format on
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Double, double, 600., 601.)
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool -> Double
@@ -1876,7 +1898,8 @@
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getDouble:NULL forKey:YES]);
[dict enumerateKeysAndDoublesUsingBlock:^(__unused BOOL aKey, __unused double aValue, __unused BOOL *stop) {
[dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -1942,7 +1965,8 @@
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndDoublesUsingBlock:^(__unused BOOL aKey, __unused double aValue, BOOL *stop) {
[dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -2164,8 +2188,10 @@
@end
// clang-format on
//%PDDM-EXPAND TESTS_FOR_BOOL_KEY_OBJECT_VALUE(Object, NSString*, @"abc", @"def")
// This block of code is generated, do not edit it directly.
// clang-format off
#pragma mark - Bool -> Object
@@ -2179,7 +2205,8 @@
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:YES]);
[dict enumerateKeysAndObjectsUsingBlock:^(__unused BOOL aKey, __unused NSString* aObject, __unused BOOL *stop) {
[dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -2237,7 +2264,8 @@
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndObjectsUsingBlock:^(__unused BOOL aKey, __unused NSString* aObject, BOOL *stop) {
[dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -2432,6 +2460,7 @@
@end
// clang-format on
//%PDDM-EXPAND-END (8 expansions)

View File

@@ -34,10 +34,7 @@
#import "GPBDictionary.h"
#import "GPBTestUtilities.h"
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
// Disable clang-format for the macros.
// clang-format off
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
// Pull in the macros (using an external file because expanding all tests
// in a single file makes a file that is failing to work with within Xcode.
@@ -45,6 +42,7 @@
//%PDDM-EXPAND TEST_FOR_POD_KEY(Int32, int32_t, 11, 12, 13, 14)
// This block of code is generated, do not edit it directly.
// clang-format off
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBInt32EnumDictionary (TestingTweak)
@@ -89,7 +87,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getUInt32:NULL forKey:11]);
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused int32_t aKey, __unused uint32_t aValue, __unused BOOL *stop) {
[dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -159,7 +158,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused int32_t aKey, __unused uint32_t aValue, BOOL *stop) {
[dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -448,7 +448,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getInt32:NULL forKey:11]);
[dict enumerateKeysAndInt32sUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
[dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -518,7 +519,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndInt32sUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, BOOL *stop) {
[dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -807,7 +809,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getUInt64:NULL forKey:11]);
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused int32_t aKey, __unused uint64_t aValue, __unused BOOL *stop) {
[dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -877,7 +880,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused int32_t aKey, __unused uint64_t aValue, BOOL *stop) {
[dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -1166,7 +1170,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getInt64:NULL forKey:11]);
[dict enumerateKeysAndInt64sUsingBlock:^(__unused int32_t aKey, __unused int64_t aValue, __unused BOOL *stop) {
[dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -1236,7 +1241,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndInt64sUsingBlock:^(__unused int32_t aKey, __unused int64_t aValue, BOOL *stop) {
[dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -1525,7 +1531,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getBool:NULL forKey:11]);
[dict enumerateKeysAndBoolsUsingBlock:^(__unused int32_t aKey, __unused BOOL aValue, __unused BOOL *stop) {
[dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -1595,7 +1602,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndBoolsUsingBlock:^(__unused int32_t aKey, __unused BOOL aValue, BOOL *stop) {
[dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -1884,7 +1892,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getFloat:NULL forKey:11]);
[dict enumerateKeysAndFloatsUsingBlock:^(__unused int32_t aKey, __unused float aValue, __unused BOOL *stop) {
[dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -1954,7 +1963,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndFloatsUsingBlock:^(__unused int32_t aKey, __unused float aValue, BOOL *stop) {
[dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -2243,7 +2253,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getDouble:NULL forKey:11]);
[dict enumerateKeysAndDoublesUsingBlock:^(__unused int32_t aKey, __unused double aValue, __unused BOOL *stop) {
[dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -2313,7 +2324,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndDoublesUsingBlock:^(__unused int32_t aKey, __unused double aValue, BOOL *stop) {
[dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -2602,7 +2614,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertFalse([dict getEnum:NULL forKey:11]);
[dict enumerateKeysAndEnumsUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
[dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -2672,7 +2685,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndEnumsUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, BOOL *stop) {
[dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -3029,7 +3043,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndRawValuesUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, BOOL *stop) {
[dict enumerateKeysAndRawValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -3378,7 +3393,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:11]);
[dict enumerateKeysAndObjectsUsingBlock:^(__unused int32_t aKey, __unused NSString* aObject, __unused BOOL *stop) {
[dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
[dict release];
@@ -3438,7 +3454,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
[dict enumerateKeysAndObjectsUsingBlock:^(__unused int32_t aKey, __unused NSString* aObject, BOOL *stop) {
[dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
++idx;
@@ -3656,5 +3673,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
@end
// clang-format on
//%PDDM-EXPAND-END TEST_FOR_POD_KEY(Int32, int32_t, 11, 12, 13, 14)

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