aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec
diff options
context:
space:
mode:
Diffstat (limited to 'objectivec')
-rw-r--r--objectivec/.gitignore23
-rwxr-xr-xobjectivec/DevTools/check_version_stamps.sh67
-rwxr-xr-xobjectivec/DevTools/compile_testing_protos.sh124
-rwxr-xr-xobjectivec/DevTools/full_mac_build.sh169
-rwxr-xr-xobjectivec/DevTools/pddm.py24
-rwxr-xr-xobjectivec/DevTools/pddm_tests.py6
-rw-r--r--objectivec/GPBArray.h1526
-rw-r--r--objectivec/GPBArray.m220
-rw-r--r--objectivec/GPBBootstrap.h77
-rw-r--r--objectivec/GPBCodedInputStream.h198
-rw-r--r--objectivec/GPBCodedInputStream.m161
-rw-r--r--objectivec/GPBCodedInputStream_PackagePrivate.h2
-rw-r--r--objectivec/GPBCodedOutputStream.h642
-rw-r--r--objectivec/GPBCodedOutputStream.m80
-rw-r--r--objectivec/GPBCodedOutputStream_PackagePrivate.h126
-rw-r--r--objectivec/GPBDescriptor.h216
-rw-r--r--objectivec/GPBDescriptor.m536
-rw-r--r--objectivec/GPBDescriptor_PackagePrivate.h203
-rw-r--r--objectivec/GPBDictionary.h5659
-rw-r--r--objectivec/GPBDictionary.m5869
-rw-r--r--objectivec/GPBExtensionInternals.m13
-rw-r--r--objectivec/GPBExtensionRegistry.h58
-rw-r--r--objectivec/GPBExtensionRegistry.m80
-rw-r--r--objectivec/GPBMessage.h455
-rw-r--r--objectivec/GPBMessage.m316
-rw-r--r--objectivec/GPBMessage_PackagePrivate.h23
-rw-r--r--objectivec/GPBProtocolBuffers.h39
-rw-r--r--objectivec/GPBProtocolBuffers.m16
-rw-r--r--objectivec/GPBProtocolBuffers_RuntimeSupport.h2
-rw-r--r--objectivec/GPBRootObject.h12
-rw-r--r--objectivec/GPBRootObject.m29
-rw-r--r--objectivec/GPBRuntimeTypes.h76
-rw-r--r--objectivec/GPBUnknownField.h49
-rw-r--r--objectivec/GPBUnknownField.m22
-rw-r--r--objectivec/GPBUnknownFieldSet.h36
-rw-r--r--objectivec/GPBUnknownFieldSet.m54
-rw-r--r--objectivec/GPBUnknownField_PackagePrivate.h2
-rw-r--r--objectivec/GPBUtilities.h458
-rw-r--r--objectivec/GPBUtilities.m724
-rw-r--r--objectivec/GPBUtilities_PackagePrivate.h34
-rw-r--r--objectivec/GPBWellKnownTypes.h205
-rw-r--r--objectivec/GPBWellKnownTypes.m189
-rw-r--r--objectivec/GPBWireFormat.h1
-rw-r--r--objectivec/GPBWireFormat.m7
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj228
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist8
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme11
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme3
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj384
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist8
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/FFE465CA-0E74-40E8-9F09-500B66B7DCB2.plist62
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/Info.plist21
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme11
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme14
-rw-r--r--objectivec/README.md59
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj290
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme91
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h37
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m48
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json58
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib680
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist34
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m35
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework10
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static8
-rw-r--r--objectivec/Tests/CocoaPods/README.md9
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework10
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static8
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj309
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme91
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h39
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m67
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json (renamed from objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json)54
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard27
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard26
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist (renamed from objectivec/Tests/iOSTestHarness/Info.plist)16
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h37
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m49
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m39
-rwxr-xr-xobjectivec/Tests/CocoaPods/run_tests.sh150
-rw-r--r--objectivec/Tests/GPBARCUnittestProtos.m7
-rw-r--r--objectivec/Tests/GPBArrayTests.m331
-rw-r--r--objectivec/Tests/GPBCodedInputStreamTests.m236
-rw-r--r--objectivec/Tests/GPBCodedOuputStreamTests.m119
-rw-r--r--objectivec/Tests/GPBCompileTest01.m40
-rw-r--r--objectivec/Tests/GPBCompileTest02.m40
-rw-r--r--objectivec/Tests/GPBCompileTest03.m40
-rw-r--r--objectivec/Tests/GPBCompileTest04.m40
-rw-r--r--objectivec/Tests/GPBCompileTest05.m40
-rw-r--r--objectivec/Tests/GPBCompileTest06.m40
-rw-r--r--objectivec/Tests/GPBCompileTest07.m40
-rw-r--r--objectivec/Tests/GPBCompileTest08.m40
-rw-r--r--objectivec/Tests/GPBCompileTest09.m40
-rw-r--r--objectivec/Tests/GPBCompileTest10.m40
-rw-r--r--objectivec/Tests/GPBCompileTest11.m40
-rw-r--r--objectivec/Tests/GPBCompileTest12.m40
-rw-r--r--objectivec/Tests/GPBCompileTest13.m40
-rw-r--r--objectivec/Tests/GPBCompileTest14.m40
-rw-r--r--objectivec/Tests/GPBCompileTest15.m40
-rw-r--r--objectivec/Tests/GPBCompileTest16.m40
-rw-r--r--objectivec/Tests/GPBCompileTest17.m40
-rw-r--r--objectivec/Tests/GPBCompileTest18.m40
-rw-r--r--objectivec/Tests/GPBCompileTest19.m40
-rw-r--r--objectivec/Tests/GPBCompileTest20.m40
-rw-r--r--objectivec/Tests/GPBCompileTest21.m40
-rw-r--r--objectivec/Tests/GPBCompileTest22.m40
-rw-r--r--objectivec/Tests/GPBCompileTest23.m40
-rw-r--r--objectivec/Tests/GPBCompileTest24.m42
-rw-r--r--objectivec/Tests/GPBCompileTest25.m42
-rw-r--r--objectivec/Tests/GPBDescriptorTests.m224
-rw-r--r--objectivec/Tests/GPBDictionaryTests+Bool.m1148
-rw-r--r--objectivec/Tests/GPBDictionaryTests+Int32.m2189
-rw-r--r--objectivec/Tests/GPBDictionaryTests+Int64.m2189
-rw-r--r--objectivec/Tests/GPBDictionaryTests+String.m2111
-rw-r--r--objectivec/Tests/GPBDictionaryTests+UInt32.m2189
-rw-r--r--objectivec/Tests/GPBDictionaryTests+UInt64.m2189
-rw-r--r--objectivec/Tests/GPBDictionaryTests.m186
-rw-r--r--objectivec/Tests/GPBDictionaryTests.pddm558
-rw-r--r--objectivec/Tests/GPBExtensionRegistryTest.m138
-rw-r--r--objectivec/Tests/GPBMessageTests+Runtime.m439
-rw-r--r--objectivec/Tests/GPBMessageTests+Serialization.m288
-rw-r--r--objectivec/Tests/GPBMessageTests.m182
-rw-r--r--objectivec/Tests/GPBPerfTests.m106
-rw-r--r--objectivec/Tests/GPBSwiftTests.swift314
-rw-r--r--objectivec/Tests/GPBTestUtilities.h3
-rw-r--r--objectivec/Tests/GPBTestUtilities.m30
-rw-r--r--objectivec/Tests/GPBUnittestProtos.m16
-rw-r--r--objectivec/Tests/GPBUnittestProtos2.m34
-rw-r--r--objectivec/Tests/GPBUnknownFieldSetTest.m271
-rw-r--r--objectivec/Tests/GPBUtilitiesTests.m235
-rw-r--r--objectivec/Tests/GPBWellKnownTypesTest.m216
-rw-r--r--objectivec/Tests/GPBWireFormatTests.m8
-rw-r--r--objectivec/Tests/iOSTestHarness/AppDelegate.m35
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.pngbin8583 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.pngbin17744 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.pngbin8969 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.pngbin18788 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.pngbin7021 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.pngbin13348 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.pngbin11128 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.pngbin21792 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json49
-rw-r--r--objectivec/Tests/iOSTestHarness/LaunchScreen.xib33
-rw-r--r--objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings2
-rw-r--r--objectivec/Tests/unittest_cycle.proto6
-rw-r--r--objectivec/Tests/unittest_deprecated.proto95
-rw-r--r--objectivec/Tests/unittest_deprecated_file.proto76
-rw-r--r--objectivec/Tests/unittest_extension_chain_a.proto51
-rw-r--r--objectivec/Tests/unittest_extension_chain_b.proto47
-rw-r--r--objectivec/Tests/unittest_extension_chain_c.proto45
-rw-r--r--objectivec/Tests/unittest_extension_chain_d.proto49
-rw-r--r--objectivec/Tests/unittest_extension_chain_e.proto40
-rw-r--r--objectivec/Tests/unittest_extension_chain_f.proto44
-rw-r--r--objectivec/Tests/unittest_extension_chain_g.proto41
-rw-r--r--objectivec/Tests/unittest_objc.proto97
-rwxr-xr-xobjectivec/generate_well_known_types.sh (renamed from objectivec/generate_descriptors_proto.sh)36
-rw-r--r--objectivec/google/protobuf/Any.pbobjc.h205
-rw-r--r--objectivec/google/protobuf/Any.pbobjc.m65
-rw-r--r--objectivec/google/protobuf/Api.pbobjc.h340
-rw-r--r--objectivec/google/protobuf/Api.pbobjc.m206
-rw-r--r--objectivec/google/protobuf/Descriptor.pbobjc.h1212
-rw-r--r--objectivec/google/protobuf/Descriptor.pbobjc.m2594
-rw-r--r--objectivec/google/protobuf/Duration.pbobjc.h165
-rw-r--r--objectivec/google/protobuf/Duration.pbobjc.m52
-rw-r--r--objectivec/google/protobuf/Empty.pbobjc.h64
-rw-r--r--objectivec/google/protobuf/Empty.pbobjc.m40
-rw-r--r--objectivec/google/protobuf/FieldMask.pbobjc.h381
-rw-r--r--objectivec/google/protobuf/FieldMask.pbobjc.m46
-rw-r--r--objectivec/google/protobuf/SourceContext.pbobjc.h56
-rw-r--r--objectivec/google/protobuf/SourceContext.pbobjc.m46
-rw-r--r--objectivec/google/protobuf/Struct.pbobjc.h144
-rw-r--r--objectivec/google/protobuf/Struct.pbobjc.m152
-rw-r--r--objectivec/google/protobuf/Timestamp.pbobjc.h195
-rw-r--r--objectivec/google/protobuf/Timestamp.pbobjc.m52
-rw-r--r--objectivec/google/protobuf/Type.pbobjc.h295
-rw-r--r--objectivec/google/protobuf/Type.pbobjc.m405
-rw-r--r--objectivec/google/protobuf/Wrappers.pbobjc.h134
-rw-r--r--objectivec/google/protobuf/Wrappers.pbobjc.m175
180 files changed, 28200 insertions, 18403 deletions
diff --git a/objectivec/.gitignore b/objectivec/.gitignore
new file mode 100644
index 00000000..f786ffce
--- /dev/null
+++ b/objectivec/.gitignore
@@ -0,0 +1,23 @@
+## Build generated
+build/
+DerivedData/
+
+## Various settings
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+xcuserdata/
+
+## Other
+*.moved-aside
+*.xccheckout
+*.xcscmblueprint
+
+## Obj-C/Swift specific
+*.hmap
+*.ipa
diff --git a/objectivec/DevTools/check_version_stamps.sh b/objectivec/DevTools/check_version_stamps.sh
index 325b71dd..1acbe2a2 100755
--- a/objectivec/DevTools/check_version_stamps.sh
+++ b/objectivec/DevTools/check_version_stamps.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -eu
# This script checks that the runtime version number constant in the compiler
# source and in the runtime source is the same.
@@ -8,8 +8,6 @@
# builds would break. At the same time, we don't want the runtime source
# depending on the compiler sources; so two copies of the constant are needed.
-set -eu
-
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/../.."
@@ -18,39 +16,40 @@ die() {
exit 1
}
-readonly ConstantName=GOOGLE_PROTOBUF_OBJC_GEN_VERSION
-
-# Collect version from plugin sources.
-
-readonly PluginSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc"
-readonly PluginVersion=$( \
- cat "${PluginSrc}" \
- | sed -n -e "s:const int32 ${ConstantName} = \([0-9]*\);:\1:p"
-)
-
-if [[ -z "${PluginVersion}" ]] ; then
- die "Failed to find ${ConstantName} in the plugin source (${PluginSrc})."
-fi
-
-# Collect version from runtime sources.
-
+readonly GeneratorSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc"
readonly RuntimeSrc="${ProtoRootDir}/objectivec/GPBBootstrap.h"
-readonly RuntimeVersion=$( \
- cat "${RuntimeSrc}" \
- | sed -n -e "s:#define ${ConstantName} \([0-9]*\):\1:p"
-)
-
-if [[ -z "${RuntimeVersion}" ]] ; then
- die "Failed to find ${ConstantName} in the runtime source (${RuntimeSrc})."
-fi
-
-# Compare them.
-if [[ "${PluginVersion}" != "${RuntimeVersion}" ]] ; then
- die "Versions don't match!
- Plugin: ${PluginVersion} from ${PluginSrc}
- Runtime: ${RuntimeVersion} from ${RuntimeSrc}
+check_constant() {
+ local ConstantName="$1"
+
+ # Collect version from generator sources.
+ local GeneratorVersion=$( \
+ cat "${GeneratorSrc}" \
+ | sed -n -e "s:const int32 ${ConstantName} = \([0-9]*\);:\1:p"
+ )
+ if [[ -z "${GeneratorVersion}" ]] ; then
+ die "Failed to find ${ConstantName} in the generator source (${GeneratorSrc})."
+ fi
+
+ # Collect version from runtime sources.
+ local RuntimeVersion=$( \
+ cat "${RuntimeSrc}" \
+ | sed -n -e "s:#define ${ConstantName} \([0-9]*\):\1:p"
+ )
+ if [[ -z "${RuntimeVersion}" ]] ; then
+ die "Failed to find ${ConstantName} in the runtime source (${RuntimeSrc})."
+ fi
+
+ # Compare them.
+ if [[ "${GeneratorVersion}" != "${RuntimeVersion}" ]] ; then
+ die "${ConstantName} values don't match!
+ Generator: ${GeneratorVersion} from ${GeneratorSrc}
+ Runtime: ${RuntimeVersion} from ${RuntimeSrc}
"
-fi
+ fi
+}
+
+# Do the check.
+check_constant GOOGLE_PROTOBUF_OBJC_VERSION
# Success
diff --git a/objectivec/DevTools/compile_testing_protos.sh b/objectivec/DevTools/compile_testing_protos.sh
index e9c5fe61..d7f3f605 100755
--- a/objectivec/DevTools/compile_testing_protos.sh
+++ b/objectivec/DevTools/compile_testing_protos.sh
@@ -1,17 +1,16 @@
-#!/bin/bash
-
+#!/bin/bash -eu
# Invoked by the Xcode projects to build the protos needed for the unittests.
-set -eu
-
readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/protos"
+# -----------------------------------------------------------------------------
# Helper for bailing.
die() {
echo "Error: $1"
exit 2
}
+# -----------------------------------------------------------------------------
# What to do.
case "${ACTION}" in
"")
@@ -26,12 +25,19 @@ case "${ACTION}" in
;;
esac
-# Move to the top of the protobuf directories.
-cd "${SRCROOT}/.."
+# -----------------------------------------------------------------------------
+# Ensure the output dir exists
+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}/.."
[[ -x src/protoc ]] || \
die "Could not find the protoc binary; make sure you have built it (objectivec/DevTools/full_mac_build.sh -h)."
+# -----------------------------------------------------------------------------
+# See the compiler or proto files have changed.
RUN_PROTOC=no
if [[ ! -d "${OUTPUT_DIR}" ]] ; then
RUN_PROTOC=yes
@@ -50,7 +56,7 @@ else
# Find the oldest output file.
readonly OldestOutput=$(find \
"${OUTPUT_DIR}" \
- -type f -print0 \
+ -type f -name "*pbobjc.[hm]" -print0 \
| xargs -0 stat -f "%m %N" \
| sort -n -r | tail -n1 | cut -f2- -d" ")
# If the newest input is newer than the oldest output, regenerate.
@@ -64,54 +70,80 @@ if [[ "${RUN_PROTOC}" != "yes" ]] ; then
exit 0
fi
-# Ensure the output dir exists
-mkdir -p "${OUTPUT_DIR}/google/protobuf"
+# -----------------------------------------------------------------------------
+# Prune out all the files from previous generations to ensure we only have
+# current ones.
+find "${OUTPUT_DIR}" \
+ -type f -name "*pbobjc.[hm]" -print0 \
+ | xargs -0 rm -rf
-CORE_PROTO_FILES=( \
- 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_arena.proto \
- src/google/protobuf/unittest_no_arena_import.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 \
-)
-
-compile_proto() {
+# -----------------------------------------------------------------------------
+# Helper to invoke protoc
+compile_protos() {
src/protoc \
--objc_out="${OUTPUT_DIR}/google/protobuf" \
--proto_path=src/google/protobuf/ \
--proto_path=src \
- $*
+ "$@"
}
+# -----------------------------------------------------------------------------
+# Generate most of the proto files that exist in the C++ src tree. Several
+# are used in the tests, but the extra don't hurt in that they ensure ObjC
+# sources can be generated from them.
+
+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_arena.proto
+ src/google/protobuf/unittest_no_arena_import.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
+)
+
+# 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_proto "${a_proto}"
+ compile_protos "${a_proto}"
done
-OBJC_PROTO_FILES=( \
- objectivec/Tests/unittest_cycle.proto \
+# -----------------------------------------------------------------------------
+# Generate the Objective C specific testing protos.
+compile_protos \
+ --proto_path="objectivec/Tests" \
+ objectivec/Tests/unittest_cycle.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 \
+ objectivec/Tests/unittest_extension_chain_d.proto \
+ objectivec/Tests/unittest_extension_chain_e.proto \
+ objectivec/Tests/unittest_extension_chain_f.proto \
+ objectivec/Tests/unittest_extension_chain_g.proto \
objectivec/Tests/unittest_runtime_proto2.proto \
objectivec/Tests/unittest_runtime_proto3.proto \
- objectivec/Tests/unittest_objc.proto \
- objectivec/Tests/unittest_objc_startup.proto \
-)
-
-for a_proto in "${OBJC_PROTO_FILES[@]}" ; do
- compile_proto --proto_path="objectivec/Tests" "${a_proto}"
-done
+ objectivec/Tests/unittest_objc.proto \
+ objectivec/Tests/unittest_objc_startup.proto
diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh
index c8681e26..c673fcba 100755
--- a/objectivec/DevTools/full_mac_build.sh
+++ b/objectivec/DevTools/full_mac_build.sh
@@ -26,8 +26,9 @@ OPTIONS:
Issue a clean before the normal build.
-a, --autogen
Start by rerunning autogen & configure.
- -r, --regenerate-cpp-descriptors
- The descriptor.proto is checked in generated, cause it to regenerate.
+ -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
@@ -36,10 +37,16 @@ OPTIONS:
Skip the invoke of Xcode to test the runtime on both iOS and OS X.
--skip-xcode-ios
Skip the invoke of Xcode to test the runtime on iOS.
+ --skip-xcode-debug
+ Skip the Xcode Debug configuration.
+ --skip-xcode-release
+ Skip the Xcode Release configuration.
--skip-xcode-osx
Skip the invoke of Xcode to test the runtime on OS X.
--skip-objc-conformance
Skip the Objective C conformance tests (run on OS X).
+ --xcode-quiet
+ Pass -quiet to xcodebuild.
EOF
}
@@ -65,17 +72,20 @@ wrapped_make() {
}
NUM_MAKE_JOBS=$(/usr/sbin/sysctl -n hw.ncpu)
-if [[ "${NUM_MAKE_JOBS}" -lt 4 ]] ; then
- NUM_MAKE_JOBS=4
+if [[ "${NUM_MAKE_JOBS}" -lt 2 ]] ; then
+ NUM_MAKE_JOBS=2
fi
DO_AUTOGEN=no
DO_CLEAN=no
-REGEN_CPP_DESCRIPTORS=no
+REGEN_DESCRIPTORS=no
CORE_ONLY=no
DO_XCODE_IOS_TESTS=yes
DO_XCODE_OSX_TESTS=yes
+DO_XCODE_DEBUG=yes
+DO_XCODE_RELEASE=yes
DO_OBJC_CONFORMANCE_TESTS=yes
+XCODE_QUIET=no
while [[ $# != 0 ]]; do
case "${1}" in
-h | --help )
@@ -88,8 +98,8 @@ while [[ $# != 0 ]]; do
-a | --autogen )
DO_AUTOGEN=yes
;;
- -r | --regenerate-cpp-descriptors )
- REGEN_CPP_DESCRIPTORS=yes
+ -r | --regenerate-descriptors )
+ REGEN_DESCRIPTORS=yes
;;
-j | --jobs )
shift
@@ -108,9 +118,18 @@ while [[ $# != 0 ]]; do
--skip-xcode-osx )
DO_XCODE_OSX_TESTS=no
;;
+ --skip-xcode-debug )
+ DO_XCODE_DEBUG=no
+ ;;
+ --skip-xcode-release )
+ DO_XCODE_RELEASE=no
+ ;;
--skip-objc-conformance )
DO_OBJC_CONFORMANCE_TESTS=no
;;
+ --xcode-quiet )
+ XCODE_QUIET=yes
+ ;;
-*)
echo "ERROR: Unknown option: ${1}" 1>&2
printUsage
@@ -150,8 +169,12 @@ if [[ "${DO_CLEAN}" == "yes" ]] ; then
-project objectivec/ProtocolBuffers_iOS.xcodeproj
-scheme ProtocolBuffers
)
- "${XCODEBUILD_CLEAN_BASE_IOS[@]}" -configuration Debug clean
- "${XCODEBUILD_CLEAN_BASE_IOS[@]}" -configuration Release clean
+ if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then
+ "${XCODEBUILD_CLEAN_BASE_IOS[@]}" -configuration Debug clean
+ fi
+ if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then
+ "${XCODEBUILD_CLEAN_BASE_IOS[@]}" -configuration Release clean
+ fi
fi
if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
XCODEBUILD_CLEAN_BASE_OSX=(
@@ -159,13 +182,17 @@ if [[ "${DO_CLEAN}" == "yes" ]] ; then
-project objectivec/ProtocolBuffers_OSX.xcodeproj
-scheme ProtocolBuffers
)
- "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Debug clean
- "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Release clean
+ if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then
+ "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Debug clean
+ fi
+ if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then
+ "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Release clean
+ fi
fi
fi
-if [[ "${REGEN_CPP_DESCRIPTORS}" == "yes" ]] ; then
- header "Regenerating the C++ descriptor sources."
+if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then
+ header "Regenerating the descriptor sources."
./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}"
fi
@@ -184,29 +211,8 @@ else
cd ..
fi
-header "Ensuring the ObjC descriptors are current."
-# Find the newest input file (protos, compiler, and the generator script).
-# (these patterns catch some extra stuff, but better to over sample than under)
-readonly NewestInput=$(find \
- src/google/protobuf/*.proto \
- src/.libs src/*.la src/protoc \
- objectivec/generate_descriptors_proto.sh \
- -type f -print0 \
- | xargs -0 stat -f "%m %N" \
- | sort -n | tail -n1 | cut -f2- -d" ")
-# Find the oldest output file.
-readonly OldestOutput=$(find \
- "${ProtoRootDir}/objectivec/google" \
- -type f -print0 \
- | xargs -0 stat -f "%m %N" \
- | sort -n -r | tail -n1 | cut -f2- -d" ")
-# If the newest input is newer than the oldest output, regenerate.
-if [[ "${NewestInput}" -nt "${OldestOutput}" ]] ; then
- echo ">> Newest input is newer than oldest output, regenerating."
- objectivec/generate_descriptors_proto.sh -j "${NUM_MAKE_JOBS}"
-else
- echo ">> Newest input is older than oldest output, no need to regenerating."
-fi
+# Ensure the WKT sources checked in are current.
+objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}"
header "Checking on the ObjC Runtime Code"
objectivec/DevTools/pddm_tests.py
@@ -217,50 +223,78 @@ if ! objectivec/DevTools/pddm.py --dry-run objectivec/*.[hm] objectivec/Tests/*.
exit 1
fi
+readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )"
+readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix.
+
if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
XCODEBUILD_TEST_BASE_IOS=(
xcodebuild
-project objectivec/ProtocolBuffers_iOS.xcodeproj
-scheme ProtocolBuffers
)
+ if [[ "${XCODE_QUIET}" == "yes" ]] ; then
+ XCODEBUILD_TEST_BASE_IOS+=( -quiet )
+ fi
# Don't need to worry about form factors or retina/non retina;
# just pick a mix of OS Versions and 32/64 bit.
# NOTE: Different Xcode have different simulated hardware/os support.
- readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )"
- readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix.
- IOS_SIMULATOR_NAME="Simulator"
case "${XCODE_VERSION}" in
6.* )
- echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 7.0 or higher." 1>&2
+ echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 8.0 or higher." 1>&2
exit 10
;;
- 7.1* )
+ 7.* )
+ echo "ERROR: Xcode 7.x no longer supported for building, please use 8.0 or higher." 1>&2
+ exit 11
+ ;;
+ 8.0* )
+ # The 8.* device seem to hang and never start under Xcode 8.
+ XCODEBUILD_TEST_BASE_IOS+=(
+ -destination "platform=iOS Simulator,name=iPhone 4s,OS=9.0" # 32bit
+ -destination "platform=iOS Simulator,name=iPhone 7,OS=10.0" # 64bit
+ )
+ ;;
+ 8.[1-3]* )
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPhone 6,OS=9.0" # 64bit
- -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPad Air,OS=9.0" # 64bit
+ -destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
)
;;
- 7.* )
+ 9.[0-2]* )
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit
- -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit
+ -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* )
+ 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
)
;;
* )
- echo "Time to update the simulator targets for Xcode ${XCODE_VERSION}"
+ echo ""
+ echo "ATTENTION: Time to update the simulator targets for Xcode ${XCODE_VERSION}"
+ echo ""
+ echo "Build aborted!"
exit 2
;;
esac
- header "Doing Xcode iOS build/tests - Debug"
- "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Debug test
- header "Doing Xcode iOS build/tests - Release"
- "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test
+ if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then
+ header "Doing Xcode iOS build/tests - Debug"
+ "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Debug test
+ fi
+ if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then
+ header "Doing Xcode iOS build/tests - Release"
+ "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test
+ fi
# Don't leave the simulator in the developer's face.
- killall "${IOS_SIMULATOR_NAME}"
+ killall Simulator 2> /dev/null || true
fi
if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
XCODEBUILD_TEST_BASE_OSX=(
@@ -270,13 +304,32 @@ if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
# Since the ObjC 2.0 Runtime is required, 32bit OS X isn't supported.
-destination "platform=OS X,arch=x86_64" # 64bit
)
- header "Doing Xcode OS X build/tests - Debug"
- "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Debug test
- header "Doing Xcode OS X build/tests - Release"
- "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Release test
+ if [[ "${XCODE_QUIET}" == "yes" ]] ; then
+ XCODEBUILD_TEST_BASE_OSX+=( -quiet )
+ fi
+ case "${XCODE_VERSION}" in
+ 6.* )
+ echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 8.0 or higher." 1>&2
+ exit 10
+ ;;
+ 7.* )
+ echo "ERROR: The unittests include Swift code that is now Swift 3.0." 1>&2
+ echo "ERROR: Xcode 8.0 or higher is required to build the test suite, but the library works with Xcode 7.x." 1>&2
+ exit 11
+ ;;
+ esac
+ if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then
+ header "Doing Xcode OS X build/tests - Debug"
+ "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Debug test
+ fi
+ if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then
+ header "Doing Xcode OS X build/tests - Release"
+ "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Release test
+ fi
fi
if [[ "${DO_OBJC_CONFORMANCE_TESTS}" == "yes" ]] ; then
+ header "Running ObjC Conformance Tests"
cd conformance
wrapped_make -j "${NUM_MAKE_JOBS}" test_objc
cd ..
diff --git a/objectivec/DevTools/pddm.py b/objectivec/DevTools/pddm.py
index 9a11fec4..0b5b7b40 100755
--- a/objectivec/DevTools/pddm.py
+++ b/objectivec/DevTools/pddm.py
@@ -124,6 +124,7 @@ def _MacroRefRe(macro_names):
return re.compile(r'\b(?P<macro_ref>(?P<name>(%s))\((?P<args>.*?)\))' %
'|'.join(macro_names))
+
def _MacroArgRefRe(macro_arg_names):
# Takes in a list of macro arg names and makes a regex that will match
# uses of those args.
@@ -318,25 +319,26 @@ class MacroCollection(object):
return macro.body
assert len(arg_values) == len(macro.args)
args = dict(zip(macro.args, arg_values))
+
def _lookupArg(match):
val = args[match.group('name')]
opt = match.group('option')
if opt:
- if opt == 'S': # Spaces for the length
+ if opt == 'S': # Spaces for the length
return ' ' * len(val)
- elif opt == 'l': # Lowercase first character
+ elif opt == 'l': # Lowercase first character
if val:
return val[0].lower() + val[1:]
else:
return val
- elif opt == 'L': # All Lowercase
+ elif opt == 'L': # All Lowercase
return val.lower()
- elif opt == 'u': # Uppercase first character
+ elif opt == 'u': # Uppercase first character
if val:
return val[0].upper() + val[1:]
else:
return val
- elif opt == 'U': # All Uppercase
+ elif opt == 'U': # All Uppercase
return val.upper()
else:
raise PDDMError('Unknown arg option "%s$%s" while expanding "%s".%s'
@@ -350,6 +352,7 @@ class MacroCollection(object):
def _EvalMacrosRefs(self, text, macro_stack):
macro_ref_re = _MacroRefRe(self._macros.keys())
+
def _resolveMacro(match):
return self._Expand(match, macro_stack)
return macro_ref_re.sub(_resolveMacro, text)
@@ -496,9 +499,10 @@ class SourceFile(object):
# Add the ending marker.
if len(captured_lines) == 1:
result.append('//%%PDDM-EXPAND-END %s' %
- captured_lines[0][directive_len:].strip())
+ captured_lines[0][directive_len:].strip())
else:
- result.append('//%%PDDM-EXPAND-END (%s expansions)' % len(captured_lines))
+ result.append('//%%PDDM-EXPAND-END (%s expansions)' %
+ len(captured_lines))
return result
@@ -669,15 +673,15 @@ def main(args):
if src_file.processed_content != src_file.original_content:
if not opts.dry_run:
- print 'Updating for "%s".' % a_path
+ print('Updating for "%s".' % a_path)
with open(a_path, 'w') as f:
f.write(src_file.processed_content)
else:
# Special result to indicate things need updating.
- print 'Update needed for "%s".' % a_path
+ print('Update needed for "%s".' % a_path)
result = 1
elif opts.verbose:
- print 'No update for "%s".' % a_path
+ print('No update for "%s".' % a_path)
return result
diff --git a/objectivec/DevTools/pddm_tests.py b/objectivec/DevTools/pddm_tests.py
index 8a73b842..9ac6a855 100755
--- a/objectivec/DevTools/pddm_tests.py
+++ b/objectivec/DevTools/pddm_tests.py
@@ -311,7 +311,7 @@ foo(x, y)
mc = pddm.MacroCollection(f)
try:
result = mc.Expand('foo(A,B)')
- self.fail('Should throw exception, entry %d' % idx)
+ self.fail('Should throw exception! Test failed to catch recursion.')
except pddm.PDDMError as e:
self.assertEqual(e.message,
'Found macro recusion, invoking "foo(1, A)":\n...while expanding "bar(1, A)".\n...while expanding "foo(A,B)".')
@@ -483,7 +483,7 @@ foo
sf = pddm.SourceFile(f)
try:
sf.ProcessContent()
- self.fail('Should throw exception, entry %d' % idx)
+ self.fail('Should throw exception! Test failed to catch macro parsing error.')
except pddm.PDDMError as e:
self.assertEqual(e.message,
'Attempt to redefine macro: "PDDM-DEFINE mumble(x_)"\n'
@@ -503,7 +503,7 @@ foo
sf = pddm.SourceFile(f)
try:
sf.ProcessContent()
- self.fail('Should throw exception, entry %d' % idx)
+ self.fail('Should throw exception! Test failed to catch expand error.')
except pddm.PDDMError as e:
self.assertEqual(e.message,
'No macro named "foobar".\n'
diff --git a/objectivec/GPBArray.h b/objectivec/GPBArray.h
index 8c6396a9..638b2882 100644
--- a/objectivec/GPBArray.h
+++ b/objectivec/GPBArray.h
@@ -32,11 +32,6 @@
#import "GPBRuntimeTypes.h"
-// These classes are used for repeated fields of basic data types. They are used because
-// they perform better than boxing into NSNumbers in NSArrays.
-
-// Note: These are not meant to be subclassed.
-
NS_ASSUME_NONNULL_BEGIN
//%PDDM-EXPAND DECLARE_ARRAYS()
@@ -44,38 +39,171 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Int32
+/**
+ * Class used for repeated fields of int32_t values. This performs better than
+ * boxing into NSNumbers in NSArrays.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt32Array : NSObject <NSCopying>
+/** The number of elements contained in the array. */
@property(nonatomic, readonly) NSUInteger count;
+/**
+ * @return A newly instanced and empty GPBInt32Array.
+ **/
+ (instancetype)array;
+
+/**
+ * Creates and initializes a GPBInt32Array with the single element given.
+ *
+ * @param value The value to be placed in the array.
+ *
+ * @return A newly instanced GPBInt32Array with value in it.
+ **/
+ (instancetype)arrayWithValue:(int32_t)value;
+
+/**
+ * Creates and initializes a GPBInt32Array with the contents of the given
+ * array.
+ *
+ * @param array Array with the contents to be put into the new array.
+ *
+ * @return A newly instanced GPBInt32Array with the contents of array.
+ **/
+ (instancetype)arrayWithValueArray:(GPBInt32Array *)array;
+
+/**
+ * Creates and initializes a GPBInt32Array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly instanced GPBInt32Array with a capacity of count.
+ **/
+ (instancetype)arrayWithCapacity:(NSUInteger)count;
-// Initializes the array, copying the values.
-- (instancetype)initWithValues:(const int32_t [])values
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * @return A newly initialized and empty GPBInt32Array.
+ **/
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param values An array with the values to put inside this array.
+ * @param count The number of elements to copy into the array.
+ *
+ * @return A newly initialized GPBInt32Array with a copy of the values.
+ **/
+- (instancetype)initWithValues:(const int32_t [__nullable])values
+ count:(NSUInteger)count;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param array An array with the values to put inside this array.
+ *
+ * @return A newly initialized GPBInt32Array with a copy of the values.
+ **/
- (instancetype)initWithValueArray:(GPBInt32Array *)array;
+
+/**
+ * Initializes the array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly initialized GPBInt32Array with a capacity of count.
+ **/
- (instancetype)initWithCapacity:(NSUInteger)count;
+/**
+ * Gets the value at the given index.
+ *
+ * @param index The index of the value to get.
+ *
+ * @return The value at the given index.
+ **/
- (int32_t)valueAtIndex:(NSUInteger)index;
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param opts Options to control the enumeration.
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+/**
+ * Adds a value to this array.
+ *
+ * @param value The value to add to this array.
+ **/
- (void)addValue:(int32_t)value;
-- (void)addValues:(const int32_t [])values count:(NSUInteger)count;
+
+/**
+ * Adds values to this array.
+ *
+ * @param values The values to add to this array.
+ * @param count The number of elements to add.
+ **/
+- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count;
+
+/**
+ * Adds the values from the given array to this array.
+ *
+ * @param array The array containing the elements to add to this array.
+ **/
- (void)addValuesFromArray:(GPBInt32Array *)array;
+/**
+ * Inserts a value into the given position.
+ *
+ * @param value The value to add to this array.
+ * @param index The index into which to insert the value.
+ **/
- (void)insertValue:(int32_t)value atIndex:(NSUInteger)index;
+/**
+ * Replaces the value at the given index with the given value.
+ *
+ * @param index The index for which to replace the value.
+ * @param value The value to replace with.
+ **/
- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value;
+/**
+ * Removes the value at the given index.
+ *
+ * @param index The index of the value to remove.
+ **/
- (void)removeValueAtIndex:(NSUInteger)index;
+
+/**
+ * Removes all the values from this array.
+ **/
- (void)removeAll;
+/**
+ * Exchanges the values between the given indexes.
+ *
+ * @param idx1 The index of the first element to exchange.
+ * @param idx2 The index of the second element to exchange.
+ **/
- (void)exchangeValueAtIndex:(NSUInteger)idx1
withValueAtIndex:(NSUInteger)idx2;
@@ -83,38 +211,171 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - UInt32
+/**
+ * Class used for repeated fields of uint32_t values. This performs better than
+ * boxing into NSNumbers in NSArrays.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt32Array : NSObject <NSCopying>
+/** The number of elements contained in the array. */
@property(nonatomic, readonly) NSUInteger count;
+/**
+ * @return A newly instanced and empty GPBUInt32Array.
+ **/
+ (instancetype)array;
+
+/**
+ * Creates and initializes a GPBUInt32Array with the single element given.
+ *
+ * @param value The value to be placed in the array.
+ *
+ * @return A newly instanced GPBUInt32Array with value in it.
+ **/
+ (instancetype)arrayWithValue:(uint32_t)value;
+
+/**
+ * Creates and initializes a GPBUInt32Array with the contents of the given
+ * array.
+ *
+ * @param array Array with the contents to be put into the new array.
+ *
+ * @return A newly instanced GPBUInt32Array with the contents of array.
+ **/
+ (instancetype)arrayWithValueArray:(GPBUInt32Array *)array;
+
+/**
+ * Creates and initializes a GPBUInt32Array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly instanced GPBUInt32Array with a capacity of count.
+ **/
+ (instancetype)arrayWithCapacity:(NSUInteger)count;
-// Initializes the array, copying the values.
-- (instancetype)initWithValues:(const uint32_t [])values
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * @return A newly initialized and empty GPBUInt32Array.
+ **/
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param values An array with the values to put inside this array.
+ * @param count The number of elements to copy into the array.
+ *
+ * @return A newly initialized GPBUInt32Array with a copy of the values.
+ **/
+- (instancetype)initWithValues:(const uint32_t [__nullable])values
+ count:(NSUInteger)count;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param array An array with the values to put inside this array.
+ *
+ * @return A newly initialized GPBUInt32Array with a copy of the values.
+ **/
- (instancetype)initWithValueArray:(GPBUInt32Array *)array;
+
+/**
+ * Initializes the array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly initialized GPBUInt32Array with a capacity of count.
+ **/
- (instancetype)initWithCapacity:(NSUInteger)count;
+/**
+ * Gets the value at the given index.
+ *
+ * @param index The index of the value to get.
+ *
+ * @return The value at the given index.
+ **/
- (uint32_t)valueAtIndex:(NSUInteger)index;
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
+
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param opts Options to control the enumeration.
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
+/**
+ * Adds a value to this array.
+ *
+ * @param value The value to add to this array.
+ **/
- (void)addValue:(uint32_t)value;
-- (void)addValues:(const uint32_t [])values count:(NSUInteger)count;
+
+/**
+ * Adds values to this array.
+ *
+ * @param values The values to add to this array.
+ * @param count The number of elements to add.
+ **/
+- (void)addValues:(const uint32_t [__nullable])values count:(NSUInteger)count;
+
+/**
+ * Adds the values from the given array to this array.
+ *
+ * @param array The array containing the elements to add to this array.
+ **/
- (void)addValuesFromArray:(GPBUInt32Array *)array;
+/**
+ * Inserts a value into the given position.
+ *
+ * @param value The value to add to this array.
+ * @param index The index into which to insert the value.
+ **/
- (void)insertValue:(uint32_t)value atIndex:(NSUInteger)index;
+/**
+ * Replaces the value at the given index with the given value.
+ *
+ * @param index The index for which to replace the value.
+ * @param value The value to replace with.
+ **/
- (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint32_t)value;
+/**
+ * Removes the value at the given index.
+ *
+ * @param index The index of the value to remove.
+ **/
- (void)removeValueAtIndex:(NSUInteger)index;
+
+/**
+ * Removes all the values from this array.
+ **/
- (void)removeAll;
+/**
+ * Exchanges the values between the given indexes.
+ *
+ * @param idx1 The index of the first element to exchange.
+ * @param idx2 The index of the second element to exchange.
+ **/
- (void)exchangeValueAtIndex:(NSUInteger)idx1
withValueAtIndex:(NSUInteger)idx2;
@@ -122,38 +383,171 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Int64
+/**
+ * Class used for repeated fields of int64_t values. This performs better than
+ * boxing into NSNumbers in NSArrays.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt64Array : NSObject <NSCopying>
+/** The number of elements contained in the array. */
@property(nonatomic, readonly) NSUInteger count;
+/**
+ * @return A newly instanced and empty GPBInt64Array.
+ **/
+ (instancetype)array;
+
+/**
+ * Creates and initializes a GPBInt64Array with the single element given.
+ *
+ * @param value The value to be placed in the array.
+ *
+ * @return A newly instanced GPBInt64Array with value in it.
+ **/
+ (instancetype)arrayWithValue:(int64_t)value;
+
+/**
+ * Creates and initializes a GPBInt64Array with the contents of the given
+ * array.
+ *
+ * @param array Array with the contents to be put into the new array.
+ *
+ * @return A newly instanced GPBInt64Array with the contents of array.
+ **/
+ (instancetype)arrayWithValueArray:(GPBInt64Array *)array;
+
+/**
+ * Creates and initializes a GPBInt64Array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly instanced GPBInt64Array with a capacity of count.
+ **/
+ (instancetype)arrayWithCapacity:(NSUInteger)count;
-// Initializes the array, copying the values.
-- (instancetype)initWithValues:(const int64_t [])values
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * @return A newly initialized and empty GPBInt64Array.
+ **/
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param values An array with the values to put inside this array.
+ * @param count The number of elements to copy into the array.
+ *
+ * @return A newly initialized GPBInt64Array with a copy of the values.
+ **/
+- (instancetype)initWithValues:(const int64_t [__nullable])values
+ count:(NSUInteger)count;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param array An array with the values to put inside this array.
+ *
+ * @return A newly initialized GPBInt64Array with a copy of the values.
+ **/
- (instancetype)initWithValueArray:(GPBInt64Array *)array;
+
+/**
+ * Initializes the array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly initialized GPBInt64Array with a capacity of count.
+ **/
- (instancetype)initWithCapacity:(NSUInteger)count;
+/**
+ * Gets the value at the given index.
+ *
+ * @param index The index of the value to get.
+ *
+ * @return The value at the given index.
+ **/
- (int64_t)valueAtIndex:(NSUInteger)index;
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block;
+
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param opts Options to control the enumeration.
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block;
+/**
+ * Adds a value to this array.
+ *
+ * @param value The value to add to this array.
+ **/
- (void)addValue:(int64_t)value;
-- (void)addValues:(const int64_t [])values count:(NSUInteger)count;
+
+/**
+ * Adds values to this array.
+ *
+ * @param values The values to add to this array.
+ * @param count The number of elements to add.
+ **/
+- (void)addValues:(const int64_t [__nullable])values count:(NSUInteger)count;
+
+/**
+ * Adds the values from the given array to this array.
+ *
+ * @param array The array containing the elements to add to this array.
+ **/
- (void)addValuesFromArray:(GPBInt64Array *)array;
+/**
+ * Inserts a value into the given position.
+ *
+ * @param value The value to add to this array.
+ * @param index The index into which to insert the value.
+ **/
- (void)insertValue:(int64_t)value atIndex:(NSUInteger)index;
+/**
+ * Replaces the value at the given index with the given value.
+ *
+ * @param index The index for which to replace the value.
+ * @param value The value to replace with.
+ **/
- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int64_t)value;
+/**
+ * Removes the value at the given index.
+ *
+ * @param index The index of the value to remove.
+ **/
- (void)removeValueAtIndex:(NSUInteger)index;
+
+/**
+ * Removes all the values from this array.
+ **/
- (void)removeAll;
+/**
+ * Exchanges the values between the given indexes.
+ *
+ * @param idx1 The index of the first element to exchange.
+ * @param idx2 The index of the second element to exchange.
+ **/
- (void)exchangeValueAtIndex:(NSUInteger)idx1
withValueAtIndex:(NSUInteger)idx2;
@@ -161,38 +555,171 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - UInt64
+/**
+ * Class used for repeated fields of uint64_t values. This performs better than
+ * boxing into NSNumbers in NSArrays.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt64Array : NSObject <NSCopying>
+/** The number of elements contained in the array. */
@property(nonatomic, readonly) NSUInteger count;
+/**
+ * @return A newly instanced and empty GPBUInt64Array.
+ **/
+ (instancetype)array;
+
+/**
+ * Creates and initializes a GPBUInt64Array with the single element given.
+ *
+ * @param value The value to be placed in the array.
+ *
+ * @return A newly instanced GPBUInt64Array with value in it.
+ **/
+ (instancetype)arrayWithValue:(uint64_t)value;
+
+/**
+ * Creates and initializes a GPBUInt64Array with the contents of the given
+ * array.
+ *
+ * @param array Array with the contents to be put into the new array.
+ *
+ * @return A newly instanced GPBUInt64Array with the contents of array.
+ **/
+ (instancetype)arrayWithValueArray:(GPBUInt64Array *)array;
+
+/**
+ * Creates and initializes a GPBUInt64Array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly instanced GPBUInt64Array with a capacity of count.
+ **/
+ (instancetype)arrayWithCapacity:(NSUInteger)count;
-// Initializes the array, copying the values.
-- (instancetype)initWithValues:(const uint64_t [])values
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * @return A newly initialized and empty GPBUInt64Array.
+ **/
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param values An array with the values to put inside this array.
+ * @param count The number of elements to copy into the array.
+ *
+ * @return A newly initialized GPBUInt64Array with a copy of the values.
+ **/
+- (instancetype)initWithValues:(const uint64_t [__nullable])values
+ count:(NSUInteger)count;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param array An array with the values to put inside this array.
+ *
+ * @return A newly initialized GPBUInt64Array with a copy of the values.
+ **/
- (instancetype)initWithValueArray:(GPBUInt64Array *)array;
+
+/**
+ * Initializes the array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly initialized GPBUInt64Array with a capacity of count.
+ **/
- (instancetype)initWithCapacity:(NSUInteger)count;
+/**
+ * Gets the value at the given index.
+ *
+ * @param index The index of the value to get.
+ *
+ * @return The value at the given index.
+ **/
- (uint64_t)valueAtIndex:(NSUInteger)index;
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
+
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param opts Options to control the enumeration.
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
+/**
+ * Adds a value to this array.
+ *
+ * @param value The value to add to this array.
+ **/
- (void)addValue:(uint64_t)value;
-- (void)addValues:(const uint64_t [])values count:(NSUInteger)count;
+
+/**
+ * Adds values to this array.
+ *
+ * @param values The values to add to this array.
+ * @param count The number of elements to add.
+ **/
+- (void)addValues:(const uint64_t [__nullable])values count:(NSUInteger)count;
+
+/**
+ * Adds the values from the given array to this array.
+ *
+ * @param array The array containing the elements to add to this array.
+ **/
- (void)addValuesFromArray:(GPBUInt64Array *)array;
+/**
+ * Inserts a value into the given position.
+ *
+ * @param value The value to add to this array.
+ * @param index The index into which to insert the value.
+ **/
- (void)insertValue:(uint64_t)value atIndex:(NSUInteger)index;
+/**
+ * Replaces the value at the given index with the given value.
+ *
+ * @param index The index for which to replace the value.
+ * @param value The value to replace with.
+ **/
- (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint64_t)value;
+/**
+ * Removes the value at the given index.
+ *
+ * @param index The index of the value to remove.
+ **/
- (void)removeValueAtIndex:(NSUInteger)index;
+
+/**
+ * Removes all the values from this array.
+ **/
- (void)removeAll;
+/**
+ * Exchanges the values between the given indexes.
+ *
+ * @param idx1 The index of the first element to exchange.
+ * @param idx2 The index of the second element to exchange.
+ **/
- (void)exchangeValueAtIndex:(NSUInteger)idx1
withValueAtIndex:(NSUInteger)idx2;
@@ -200,38 +727,171 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Float
+/**
+ * Class used for repeated fields of float values. This performs better than
+ * boxing into NSNumbers in NSArrays.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBFloatArray : NSObject <NSCopying>
+/** The number of elements contained in the array. */
@property(nonatomic, readonly) NSUInteger count;
+/**
+ * @return A newly instanced and empty GPBFloatArray.
+ **/
+ (instancetype)array;
+
+/**
+ * Creates and initializes a GPBFloatArray with the single element given.
+ *
+ * @param value The value to be placed in the array.
+ *
+ * @return A newly instanced GPBFloatArray with value in it.
+ **/
+ (instancetype)arrayWithValue:(float)value;
+
+/**
+ * Creates and initializes a GPBFloatArray with the contents of the given
+ * array.
+ *
+ * @param array Array with the contents to be put into the new array.
+ *
+ * @return A newly instanced GPBFloatArray with the contents of array.
+ **/
+ (instancetype)arrayWithValueArray:(GPBFloatArray *)array;
+
+/**
+ * Creates and initializes a GPBFloatArray with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly instanced GPBFloatArray with a capacity of count.
+ **/
+ (instancetype)arrayWithCapacity:(NSUInteger)count;
-// Initializes the array, copying the values.
-- (instancetype)initWithValues:(const float [])values
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * @return A newly initialized and empty GPBFloatArray.
+ **/
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param values An array with the values to put inside this array.
+ * @param count The number of elements to copy into the array.
+ *
+ * @return A newly initialized GPBFloatArray with a copy of the values.
+ **/
+- (instancetype)initWithValues:(const float [__nullable])values
+ count:(NSUInteger)count;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param array An array with the values to put inside this array.
+ *
+ * @return A newly initialized GPBFloatArray with a copy of the values.
+ **/
- (instancetype)initWithValueArray:(GPBFloatArray *)array;
+
+/**
+ * Initializes the array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly initialized GPBFloatArray with a capacity of count.
+ **/
- (instancetype)initWithCapacity:(NSUInteger)count;
+/**
+ * Gets the value at the given index.
+ *
+ * @param index The index of the value to get.
+ *
+ * @return The value at the given index.
+ **/
- (float)valueAtIndex:(NSUInteger)index;
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block;
+
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param opts Options to control the enumeration.
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block;
+/**
+ * Adds a value to this array.
+ *
+ * @param value The value to add to this array.
+ **/
- (void)addValue:(float)value;
-- (void)addValues:(const float [])values count:(NSUInteger)count;
+
+/**
+ * Adds values to this array.
+ *
+ * @param values The values to add to this array.
+ * @param count The number of elements to add.
+ **/
+- (void)addValues:(const float [__nullable])values count:(NSUInteger)count;
+
+/**
+ * Adds the values from the given array to this array.
+ *
+ * @param array The array containing the elements to add to this array.
+ **/
- (void)addValuesFromArray:(GPBFloatArray *)array;
+/**
+ * Inserts a value into the given position.
+ *
+ * @param value The value to add to this array.
+ * @param index The index into which to insert the value.
+ **/
- (void)insertValue:(float)value atIndex:(NSUInteger)index;
+/**
+ * Replaces the value at the given index with the given value.
+ *
+ * @param index The index for which to replace the value.
+ * @param value The value to replace with.
+ **/
- (void)replaceValueAtIndex:(NSUInteger)index withValue:(float)value;
+/**
+ * Removes the value at the given index.
+ *
+ * @param index The index of the value to remove.
+ **/
- (void)removeValueAtIndex:(NSUInteger)index;
+
+/**
+ * Removes all the values from this array.
+ **/
- (void)removeAll;
+/**
+ * Exchanges the values between the given indexes.
+ *
+ * @param idx1 The index of the first element to exchange.
+ * @param idx2 The index of the second element to exchange.
+ **/
- (void)exchangeValueAtIndex:(NSUInteger)idx1
withValueAtIndex:(NSUInteger)idx2;
@@ -239,38 +899,171 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Double
+/**
+ * Class used for repeated fields of double values. This performs better than
+ * boxing into NSNumbers in NSArrays.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBDoubleArray : NSObject <NSCopying>
+/** The number of elements contained in the array. */
@property(nonatomic, readonly) NSUInteger count;
+/**
+ * @return A newly instanced and empty GPBDoubleArray.
+ **/
+ (instancetype)array;
+
+/**
+ * Creates and initializes a GPBDoubleArray with the single element given.
+ *
+ * @param value The value to be placed in the array.
+ *
+ * @return A newly instanced GPBDoubleArray with value in it.
+ **/
+ (instancetype)arrayWithValue:(double)value;
+
+/**
+ * Creates and initializes a GPBDoubleArray with the contents of the given
+ * array.
+ *
+ * @param array Array with the contents to be put into the new array.
+ *
+ * @return A newly instanced GPBDoubleArray with the contents of array.
+ **/
+ (instancetype)arrayWithValueArray:(GPBDoubleArray *)array;
+
+/**
+ * Creates and initializes a GPBDoubleArray with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly instanced GPBDoubleArray with a capacity of count.
+ **/
+ (instancetype)arrayWithCapacity:(NSUInteger)count;
-// Initializes the array, copying the values.
-- (instancetype)initWithValues:(const double [])values
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * @return A newly initialized and empty GPBDoubleArray.
+ **/
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param values An array with the values to put inside this array.
+ * @param count The number of elements to copy into the array.
+ *
+ * @return A newly initialized GPBDoubleArray with a copy of the values.
+ **/
+- (instancetype)initWithValues:(const double [__nullable])values
+ count:(NSUInteger)count;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param array An array with the values to put inside this array.
+ *
+ * @return A newly initialized GPBDoubleArray with a copy of the values.
+ **/
- (instancetype)initWithValueArray:(GPBDoubleArray *)array;
+
+/**
+ * Initializes the array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly initialized GPBDoubleArray with a capacity of count.
+ **/
- (instancetype)initWithCapacity:(NSUInteger)count;
+/**
+ * Gets the value at the given index.
+ *
+ * @param index The index of the value to get.
+ *
+ * @return The value at the given index.
+ **/
- (double)valueAtIndex:(NSUInteger)index;
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block;
+
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param opts Options to control the enumeration.
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block;
+/**
+ * Adds a value to this array.
+ *
+ * @param value The value to add to this array.
+ **/
- (void)addValue:(double)value;
-- (void)addValues:(const double [])values count:(NSUInteger)count;
+
+/**
+ * Adds values to this array.
+ *
+ * @param values The values to add to this array.
+ * @param count The number of elements to add.
+ **/
+- (void)addValues:(const double [__nullable])values count:(NSUInteger)count;
+
+/**
+ * Adds the values from the given array to this array.
+ *
+ * @param array The array containing the elements to add to this array.
+ **/
- (void)addValuesFromArray:(GPBDoubleArray *)array;
+/**
+ * Inserts a value into the given position.
+ *
+ * @param value The value to add to this array.
+ * @param index The index into which to insert the value.
+ **/
- (void)insertValue:(double)value atIndex:(NSUInteger)index;
+/**
+ * Replaces the value at the given index with the given value.
+ *
+ * @param index The index for which to replace the value.
+ * @param value The value to replace with.
+ **/
- (void)replaceValueAtIndex:(NSUInteger)index withValue:(double)value;
+/**
+ * Removes the value at the given index.
+ *
+ * @param index The index of the value to remove.
+ **/
- (void)removeValueAtIndex:(NSUInteger)index;
+
+/**
+ * Removes all the values from this array.
+ **/
- (void)removeAll;
+/**
+ * Exchanges the values between the given indexes.
+ *
+ * @param idx1 The index of the first element to exchange.
+ * @param idx2 The index of the second element to exchange.
+ **/
- (void)exchangeValueAtIndex:(NSUInteger)idx1
withValueAtIndex:(NSUInteger)idx2;
@@ -278,38 +1071,171 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Bool
+/**
+ * Class used for repeated fields of BOOL values. This performs better than
+ * boxing into NSNumbers in NSArrays.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBBoolArray : NSObject <NSCopying>
+/** The number of elements contained in the array. */
@property(nonatomic, readonly) NSUInteger count;
+/**
+ * @return A newly instanced and empty GPBBoolArray.
+ **/
+ (instancetype)array;
+
+/**
+ * Creates and initializes a GPBBoolArray with the single element given.
+ *
+ * @param value The value to be placed in the array.
+ *
+ * @return A newly instanced GPBBoolArray with value in it.
+ **/
+ (instancetype)arrayWithValue:(BOOL)value;
+
+/**
+ * Creates and initializes a GPBBoolArray with the contents of the given
+ * array.
+ *
+ * @param array Array with the contents to be put into the new array.
+ *
+ * @return A newly instanced GPBBoolArray with the contents of array.
+ **/
+ (instancetype)arrayWithValueArray:(GPBBoolArray *)array;
+
+/**
+ * Creates and initializes a GPBBoolArray with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly instanced GPBBoolArray with a capacity of count.
+ **/
+ (instancetype)arrayWithCapacity:(NSUInteger)count;
-// Initializes the array, copying the values.
-- (instancetype)initWithValues:(const BOOL [])values
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * @return A newly initialized and empty GPBBoolArray.
+ **/
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param values An array with the values to put inside this array.
+ * @param count The number of elements to copy into the array.
+ *
+ * @return A newly initialized GPBBoolArray with a copy of the values.
+ **/
+- (instancetype)initWithValues:(const BOOL [__nullable])values
+ count:(NSUInteger)count;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param array An array with the values to put inside this array.
+ *
+ * @return A newly initialized GPBBoolArray with a copy of the values.
+ **/
- (instancetype)initWithValueArray:(GPBBoolArray *)array;
+
+/**
+ * Initializes the array with the given capacity.
+ *
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly initialized GPBBoolArray with a capacity of count.
+ **/
- (instancetype)initWithCapacity:(NSUInteger)count;
+/**
+ * Gets the value at the given index.
+ *
+ * @param index The index of the value to get.
+ *
+ * @return The value at the given index.
+ **/
- (BOOL)valueAtIndex:(NSUInteger)index;
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block;
+
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param opts Options to control the enumeration.
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block;
+/**
+ * Adds a value to this array.
+ *
+ * @param value The value to add to this array.
+ **/
- (void)addValue:(BOOL)value;
-- (void)addValues:(const BOOL [])values count:(NSUInteger)count;
+
+/**
+ * Adds values to this array.
+ *
+ * @param values The values to add to this array.
+ * @param count The number of elements to add.
+ **/
+- (void)addValues:(const BOOL [__nullable])values count:(NSUInteger)count;
+
+/**
+ * Adds the values from the given array to this array.
+ *
+ * @param array The array containing the elements to add to this array.
+ **/
- (void)addValuesFromArray:(GPBBoolArray *)array;
+/**
+ * Inserts a value into the given position.
+ *
+ * @param value The value to add to this array.
+ * @param index The index into which to insert the value.
+ **/
- (void)insertValue:(BOOL)value atIndex:(NSUInteger)index;
+/**
+ * Replaces the value at the given index with the given value.
+ *
+ * @param index The index for which to replace the value.
+ * @param value The value to replace with.
+ **/
- (void)replaceValueAtIndex:(NSUInteger)index withValue:(BOOL)value;
+/**
+ * Removes the value at the given index.
+ *
+ * @param index The index of the value to remove.
+ **/
- (void)removeValueAtIndex:(NSUInteger)index;
+
+/**
+ * Removes all the values from this array.
+ **/
- (void)removeAll;
+/**
+ * Exchanges the values between the given indexes.
+ *
+ * @param idx1 The index of the first element to exchange.
+ * @param idx2 The index of the second element to exchange.
+ **/
- (void)exchangeValueAtIndex:(NSUInteger)idx1
withValueAtIndex:(NSUInteger)idx2;
@@ -317,26 +1243,108 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum
+/**
+ * This class is used for repeated fields of int32_t values. This performs
+ * better than boxing into NSNumbers in NSArrays.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBEnumArray : NSObject <NSCopying>
+/** The number of elements contained in the array. */
@property(nonatomic, readonly) NSUInteger count;
+/** The validation function to check if the enums are valid. */
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
+/**
+ * @return A newly instanced and empty GPBEnumArray.
+ **/
+ (instancetype)array;
+
+/**
+ * Creates and initializes a GPBEnumArray with the enum validation function
+ * given.
+ *
+ * @param func The enum validation function for the array.
+ *
+ * @return A newly instanced GPBEnumArray.
+ **/
+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+
+/**
+ * Creates and initializes a GPBEnumArray with the enum validation function
+ * given and the single raw value given.
+ *
+ * @param func The enum validation function for the array.
+ * @param value The raw value to add to this array.
+ *
+ * @return A newly instanced GPBEnumArray.
+ **/
+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
rawValue:(int32_t)value;
+
+/**
+ * Creates and initializes a GPBEnumArray that adds the elements from the
+ * given array.
+ *
+ * @param array Array containing the values to add to the new array.
+ *
+ * @return A newly instanced GPBEnumArray.
+ **/
+ (instancetype)arrayWithValueArray:(GPBEnumArray *)array;
+
+/**
+ * Creates and initializes a GPBEnumArray with the given enum validation
+ * function and with the givencapacity.
+ *
+ * @param func The enum validation function for the array.
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly instanced GPBEnumArray with a capacity of count.
+ **/
+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)count;
-- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
-
-// Initializes the array, copying the values.
+/**
+ * Initializes the array with the given enum validation function.
+ *
+ * @param func The enum validation function for the array.
+ *
+ * @return A newly initialized GPBEnumArray with a copy of the values.
+ **/
+- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
+ NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param func The enum validation function for the array.
+ * @param values An array with the values to put inside this array.
+ * @param count The number of elements to copy into the array.
+ *
+ * @return A newly initialized GPBEnumArray with a copy of the values.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+ rawValues:(const int32_t [__nullable])values
+ count:(NSUInteger)count;
+
+/**
+ * Initializes the array, copying the given values.
+ *
+ * @param array An array with the values to put inside this array.
+ *
+ * @return A newly initialized GPBEnumArray with a copy of the values.
+ **/
- (instancetype)initWithValueArray:(GPBEnumArray *)array;
+
+/**
+ * Initializes the array with the given capacity.
+ *
+ * @param func The enum validation function for the array.
+ * @param count The capacity needed for the array.
+ *
+ * @return A newly initialized GPBEnumArray with a capacity of count.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)count;
@@ -344,18 +1352,68 @@ NS_ASSUME_NONNULL_BEGIN
// valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.
+/**
+ * Gets the value at the given index.
+ *
+ * @param index The index of the value to get.
+ *
+ * @return The value at the given index.
+ **/
- (int32_t)valueAtIndex:(NSUInteger)index;
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param opts Options to control the enumeration.
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(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.
+/**
+ * Gets the raw enum value at the given index.
+ *
+ * @param index The index of the raw enum value to get.
+ *
+ * @return The raw enum value at the given index.
+ **/
- (int32_t)rawValueAtIndex:(NSUInteger)index;
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+
+/**
+ * Enumerates the values on this array with the given block.
+ *
+ * @param opts Options to control the enumeration.
+ * @param block The block to enumerate with.
+ * **value**: The current value being enumerated.
+ * **idx**: The index of the current value.
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
@@ -364,29 +1422,114 @@ NS_ASSUME_NONNULL_BEGIN
// to the default value. Use the rawValue methods below to assign non enumerator
// values.
+/**
+ * Adds a value to this array.
+ *
+ * @param value The value to add to this array.
+ **/
- (void)addValue:(int32_t)value;
-- (void)addValues:(const int32_t [])values count:(NSUInteger)count;
+/**
+ * Adds values to this array.
+ *
+ * @param values The values to add to this array.
+ * @param count The number of elements to add.
+ **/
+- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count;
+
+
+/**
+ * Inserts a value into the given position.
+ *
+ * @param value The value to add to this array.
+ * @param index The index into which to insert the value.
+ **/
- (void)insertValue:(int32_t)value atIndex:(NSUInteger)index;
+/**
+ * Replaces the value at the given index with the given value.
+ *
+ * @param index The index for which to replace the value.
+ * @param value The value to replace with.
+ **/
- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value;
// These methods bypass the validationFunc to provide setting of values that were not
// known at the time the binary was compiled.
+/**
+ * Adds a raw enum value to this array.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param value The raw enum value to add to the array.
+ **/
- (void)addRawValue:(int32_t)value;
+
+/**
+ * Adds raw enum values to this array.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param array Array containing the raw enum values to add to this array.
+ **/
- (void)addRawValuesFromArray:(GPBEnumArray *)array;
-- (void)addRawValues:(const int32_t [])values count:(NSUInteger)count;
+/**
+ * Adds raw enum values to this array.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param values Array containing the raw enum values to add to this array.
+ * @param count The number of raw values to add.
+ **/
+- (void)addRawValues:(const int32_t [__nullable])values count:(NSUInteger)count;
+
+/**
+ * Inserts a raw enum value at the given index.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param value Raw enum value to add.
+ * @param index The index into which to insert the value.
+ **/
- (void)insertRawValue:(int32_t)value atIndex:(NSUInteger)index;
+/**
+ * Replaces the raw enum value at the given index with the given value.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param index The index for which to replace the value.
+ * @param value The raw enum value to replace with.
+ **/
- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(int32_t)value;
// No validation applies to these methods.
+/**
+ * Removes the value at the given index.
+ *
+ * @param index The index of the value to remove.
+ **/
- (void)removeValueAtIndex:(NSUInteger)index;
+
+/**
+ * Removes all the values from this array.
+ **/
- (void)removeAll;
+/**
+ * Exchanges the values between the given indexes.
+ *
+ * @param idx1 The index of the first element to exchange.
+ * @param idx2 The index of the second element to exchange.
+ **/
- (void)exchangeValueAtIndex:(NSUInteger)idx1
withValueAtIndex:(NSUInteger)idx2;
@@ -413,19 +1556,82 @@ NS_ASSUME_NONNULL_END
//%PDDM-DEFINE ARRAY_INTERFACE_SIMPLE(NAME, TYPE)
//%#pragma mark - NAME
//%
+//%/**
+//% * Class used for repeated fields of ##TYPE## values. This performs better than
+//% * boxing into NSNumbers in NSArrays.
+//% *
+//% * @note This class is not meant to be subclassed.
+//% **/
//%@interface GPB##NAME##Array : NSObject <NSCopying>
//%
+//%/** The number of elements contained in the array. */
//%@property(nonatomic, readonly) NSUInteger count;
//%
+//%/**
+//% * @return A newly instanced and empty GPB##NAME##Array.
+//% **/
//%+ (instancetype)array;
+//%
+//%/**
+//% * Creates and initializes a GPB##NAME##Array with the single element given.
+//% *
+//% * @param value The value to be placed in the array.
+//% *
+//% * @return A newly instanced GPB##NAME##Array with value in it.
+//% **/
//%+ (instancetype)arrayWithValue:(TYPE)value;
+//%
+//%/**
+//% * Creates and initializes a GPB##NAME##Array with the contents of the given
+//% * array.
+//% *
+//% * @param array Array with the contents to be put into the new array.
+//% *
+//% * @return A newly instanced GPB##NAME##Array with the contents of array.
+//% **/
//%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array;
+//%
+//%/**
+//% * Creates and initializes a GPB##NAME##Array with the given capacity.
+//% *
+//% * @param count The capacity needed for the array.
+//% *
+//% * @return A newly instanced GPB##NAME##Array with a capacity of count.
+//% **/
//%+ (instancetype)arrayWithCapacity:(NSUInteger)count;
//%
-//%// Initializes the array, copying the values.
-//%- (instancetype)initWithValues:(const TYPE [])values
-//% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+//%/**
+//% * @return A newly initialized and empty GPB##NAME##Array.
+//% **/
+//%- (instancetype)init NS_DESIGNATED_INITIALIZER;
+//%
+//%/**
+//% * Initializes the array, copying the given values.
+//% *
+//% * @param values An array with the values to put inside this array.
+//% * @param count The number of elements to copy into the array.
+//% *
+//% * @return A newly initialized GPB##NAME##Array with a copy of the values.
+//% **/
+//%- (instancetype)initWithValues:(const TYPE [__nullable])values
+//% count:(NSUInteger)count;
+//%
+//%/**
+//% * Initializes the array, copying the given values.
+//% *
+//% * @param array An array with the values to put inside this array.
+//% *
+//% * @return A newly initialized GPB##NAME##Array with a copy of the values.
+//% **/
//%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array;
+//%
+//%/**
+//% * Initializes the array with the given capacity.
+//% *
+//% * @param count The capacity needed for the array.
+//% *
+//% * @return A newly initialized GPB##NAME##Array with a capacity of count.
+//% **/
//%- (instancetype)initWithCapacity:(NSUInteger)count;
//%
//%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, Basic)
@@ -442,26 +1648,108 @@ NS_ASSUME_NONNULL_END
//%PDDM-DEFINE ARRAY_INTERFACE_ENUM(NAME, TYPE)
//%#pragma mark - NAME
//%
+//%/**
+//% * This class is used for repeated fields of ##TYPE## values. This performs
+//% * better than boxing into NSNumbers in NSArrays.
+//% *
+//% * @note This class is not meant to be subclassed.
+//% **/
//%@interface GPB##NAME##Array : NSObject <NSCopying>
//%
+//%/** The number of elements contained in the array. */
//%@property(nonatomic, readonly) NSUInteger count;
+//%/** The validation function to check if the enums are valid. */
//%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
//%
+//%/**
+//% * @return A newly instanced and empty GPB##NAME##Array.
+//% **/
//%+ (instancetype)array;
+//%
+//%/**
+//% * Creates and initializes a GPB##NAME##Array with the enum validation function
+//% * given.
+//% *
+//% * @param func The enum validation function for the array.
+//% *
+//% * @return A newly instanced GPB##NAME##Array.
+//% **/
//%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+//%
+//%/**
+//% * Creates and initializes a GPB##NAME##Array with the enum validation function
+//% * given and the single raw value given.
+//% *
+//% * @param func The enum validation function for the array.
+//% * @param value The raw value to add to this array.
+//% *
+//% * @return A newly instanced GPB##NAME##Array.
+//% **/
//%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
//% rawValue:(TYPE)value;
+//%
+//%/**
+//% * Creates and initializes a GPB##NAME##Array that adds the elements from the
+//% * given array.
+//% *
+//% * @param array Array containing the values to add to the new array.
+//% *
+//% * @return A newly instanced GPB##NAME##Array.
+//% **/
//%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array;
+//%
+//%/**
+//% * Creates and initializes a GPB##NAME##Array with the given enum validation
+//% * function and with the givencapacity.
+//% *
+//% * @param func The enum validation function for the array.
+//% * @param count The capacity needed for the array.
+//% *
+//% * @return A newly instanced GPB##NAME##Array with a capacity of count.
+//% **/
//%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
//% capacity:(NSUInteger)count;
//%
-//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+//%/**
+//% * Initializes the array with the given enum validation function.
+//% *
+//% * @param func The enum validation function for the array.
+//% *
+//% * @return A newly initialized GPB##NAME##Array with a copy of the values.
+//% **/
+//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
+//% NS_DESIGNATED_INITIALIZER;
//%
-//%// Initializes the array, copying the values.
+//%/**
+//% * Initializes the array, copying the given values.
+//% *
+//% * @param func The enum validation function for the array.
+//% * @param values An array with the values to put inside this array.
+//% * @param count The number of elements to copy into the array.
+//% *
+//% * @return A newly initialized GPB##NAME##Array with a copy of the values.
+//% **/
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
-//% rawValues:(const TYPE [])values
-//% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+//% rawValues:(const TYPE [__nullable])values
+//% count:(NSUInteger)count;
+//%
+//%/**
+//% * Initializes the array, copying the given values.
+//% *
+//% * @param array An array with the values to put inside this array.
+//% *
+//% * @return A newly initialized GPB##NAME##Array with a copy of the values.
+//% **/
//%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array;
+//%
+//%/**
+//% * Initializes the array with the given capacity.
+//% *
+//% * @param func The enum validation function for the array.
+//% * @param count The capacity needed for the array.
+//% *
+//% * @return A newly initialized GPB##NAME##Array with a capacity of count.
+//% **/
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
//% capacity:(NSUInteger)count;
//%
@@ -474,9 +1762,34 @@ NS_ASSUME_NONNULL_END
//%// These methods bypass the validationFunc to provide access to values that were not
//%// known at the time the binary was compiled.
//%
+//%/**
+//% * Gets the raw enum value at the given index.
+//% *
+//% * @param index The index of the raw enum value to get.
+//% *
+//% * @return The raw enum value at the given index.
+//% **/
//%- (TYPE)rawValueAtIndex:(NSUInteger)index;
//%
+//%/**
+//% * Enumerates the values on this array with the given block.
+//% *
+//% * @param block The block to enumerate with.
+//% * **value**: The current value being enumerated.
+//% * **idx**: The index of the current value.
+//% * **stop**: A pointer to a boolean that when set stops the enumeration.
+//% **/
//%- (void)enumerateRawValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
+//%
+//%/**
+//% * Enumerates the values on this array with the given block.
+//% *
+//% * @param opts Options to control the enumeration.
+//% * @param block The block to enumerate with.
+//% * **value**: The current value being enumerated.
+//% * **idx**: The index of the current value.
+//% * **stop**: A pointer to a boolean that when set stops the enumeration.
+//% **/
//%- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
//% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%
@@ -491,23 +1804,88 @@ NS_ASSUME_NONNULL_END
//%
//%PDDM-DEFINE ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME)
+//%/**
+//% * Gets the value at the given index.
+//% *
+//% * @param index The index of the value to get.
+//% *
+//% * @return The value at the given index.
+//% **/
//%- (TYPE)valueAtIndex:(NSUInteger)index;
//%
+//%/**
+//% * Enumerates the values on this array with the given block.
+//% *
+//% * @param block The block to enumerate with.
+//% * **value**: The current value being enumerated.
+//% * **idx**: The index of the current value.
+//% * **stop**: A pointer to a boolean that when set stops the enumeration.
+//% **/
//%- (void)enumerateValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
+//%
+//%/**
+//% * Enumerates the values on this array with the given block.
+//% *
+//% * @param opts Options to control the enumeration.
+//% * @param block The block to enumerate with.
+//% * **value**: The current value being enumerated.
+//% * **idx**: The index of the current value.
+//% * **stop**: A pointer to a boolean that when set stops the enumeration.
+//% **/
//%- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
//% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%PDDM-DEFINE ARRAY_MUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME)
+//%/**
+//% * Adds a value to this array.
+//% *
+//% * @param value The value to add to this array.
+//% **/
//%- (void)addValue:(TYPE)value;
-//%- (void)addValues:(const TYPE [])values count:(NSUInteger)count;
+//%
+//%/**
+//% * Adds values to this array.
+//% *
+//% * @param values The values to add to this array.
+//% * @param count The number of elements to add.
+//% **/
+//%- (void)addValues:(const TYPE [__nullable])values count:(NSUInteger)count;
+//%
//%ARRAY_EXTRA_MUTABLE_METHODS1_##HELPER_NAME(NAME, TYPE)
+//%/**
+//% * Inserts a value into the given position.
+//% *
+//% * @param value The value to add to this array.
+//% * @param index The index into which to insert the value.
+//% **/
//%- (void)insertValue:(TYPE)value atIndex:(NSUInteger)index;
//%
+//%/**
+//% * Replaces the value at the given index with the given value.
+//% *
+//% * @param index The index for which to replace the value.
+//% * @param value The value to replace with.
+//% **/
//%- (void)replaceValueAtIndex:(NSUInteger)index withValue:(TYPE)value;
//%ARRAY_EXTRA_MUTABLE_METHODS2_##HELPER_NAME(NAME, TYPE)
+//%/**
+//% * Removes the value at the given index.
+//% *
+//% * @param index The index of the value to remove.
+//% **/
//%- (void)removeValueAtIndex:(NSUInteger)index;
+//%
+//%/**
+//% * Removes all the values from this array.
+//% **/
//%- (void)removeAll;
//%
+//%/**
+//% * Exchanges the values between the given indexes.
+//% *
+//% * @param idx1 The index of the first element to exchange.
+//% * @param idx2 The index of the second element to exchange.
+//% **/
//%- (void)exchangeValueAtIndex:(NSUInteger)idx1
//% withValueAtIndex:(NSUInteger)idx2;
@@ -516,6 +1894,11 @@ NS_ASSUME_NONNULL_END
//
//%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Basic(NAME, TYPE)
+//%/**
+//% * Adds the values from the given array to this array.
+//% *
+//% * @param array The array containing the elements to add to this array.
+//% **/
//%- (void)addValuesFromArray:(GPB##NAME##Array *)array;
//%
//%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Basic(NAME, TYPE)
@@ -527,12 +1910,57 @@ NS_ASSUME_NONNULL_END
//%// These methods bypass the validationFunc to provide setting of values that were not
//%// known at the time the binary was compiled.
//%
+//%/**
+//% * Adds a raw enum value to this array.
+//% *
+//% * @note This method bypass the validationFunc to enable the setting of values that
+//% * were not known at the time the binary was compiled.
+//% *
+//% * @param value The raw enum value to add to the array.
+//% **/
//%- (void)addRawValue:(TYPE)value;
+//%
+//%/**
+//% * Adds raw enum values to this array.
+//% *
+//% * @note This method bypass the validationFunc to enable the setting of values that
+//% * were not known at the time the binary was compiled.
+//% *
+//% * @param array Array containing the raw enum values to add to this array.
+//% **/
//%- (void)addRawValuesFromArray:(GPB##NAME##Array *)array;
-//%- (void)addRawValues:(const TYPE [])values count:(NSUInteger)count;
//%
+//%/**
+//% * Adds raw enum values to this array.
+//% *
+//% * @note This method bypass the validationFunc to enable the setting of values that
+//% * were not known at the time the binary was compiled.
+//% *
+//% * @param values Array containing the raw enum values to add to this array.
+//% * @param count The number of raw values to add.
+//% **/
+//%- (void)addRawValues:(const TYPE [__nullable])values count:(NSUInteger)count;
+//%
+//%/**
+//% * Inserts a raw enum value at the given index.
+//% *
+//% * @note This method bypass the validationFunc to enable the setting of values that
+//% * were not known at the time the binary was compiled.
+//% *
+//% * @param value Raw enum value to add.
+//% * @param index The index into which to insert the value.
+//% **/
//%- (void)insertRawValue:(TYPE)value atIndex:(NSUInteger)index;
//%
+//%/**
+//% * Replaces the raw enum value at the given index with the given value.
+//% *
+//% * @note This method bypass the validationFunc to enable the setting of values that
+//% * were not known at the time the binary was compiled.
+//% *
+//% * @param index The index for which to replace the value.
+//% * @param value The raw enum value to replace with.
+//% **/
//%- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(TYPE)value;
//%
//%// No validation applies to these methods.
diff --git a/objectivec/GPBArray.m b/objectivec/GPBArray.m
index 60b08ad1..122e0304 100644
--- a/objectivec/GPBArray.m
+++ b/objectivec/GPBArray.m
@@ -32,6 +32,12 @@
#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
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
// Mutable arrays use an internal buffer that can always hold a multiple of this elements.
#define kChunkSize 16
#define CapacityFromCount(x) (((x / kChunkSize) + 1) * kChunkSize)
@@ -75,7 +81,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
//%@synthesize count = _count;
//%
//%+ (instancetype)array {
-//% return [[[self alloc] initWithValues:NULL count:0] autorelease];
+//% return [[[self alloc] init] autorelease];
//%}
//%
//%+ (instancetype)arrayWithValue:(TYPE)value {
@@ -93,7 +99,9 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
//%}
//%
//%- (instancetype)init {
-//% return [self initWithValues:NULL count:0];
+//% self = [super init];
+//% // No work needed;
+//% return self;
//%}
//%
//%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array {
@@ -101,11 +109,11 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
//%}
//%
//%- (instancetype)initWithValues:(const TYPE [])values count:(NSUInteger)count {
-//% self = [super init];
+//% self = [self init];
//% if (self) {
//% if (count && values) {
-//% _values = malloc(count * sizeof(TYPE));
-//% if (values != NULL) {
+//% _values = reallocf(_values, count * sizeof(TYPE));
+//% if (_values != NULL) {
//% _capacity = count;
//% memcpy(_values, values, count * sizeof(TYPE));
//% _count = count;
@@ -156,15 +164,16 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
//% [super dealloc];
//%}
//%
-//%- (BOOL)isEqual:(GPB##NAME##Array *)other {
+//%- (BOOL)isEqual:(id)other {
//% if (self == other) {
//% return YES;
//% }
//% if (![other isKindOfClass:[GPB##NAME##Array class]]) {
//% return NO;
//% }
-//% return (_count == other->_count
-//% && memcmp(_values, other->_values, (_count * sizeof(TYPE))) == 0);
+//% GPB##NAME##Array *otherArray = other;
+//% return (_count == otherArray->_count
+//% && memcmp(_values, otherArray->_values, (_count * sizeof(TYPE))) == 0);
//%}
//%
//%- (NSUInteger)hash {
@@ -186,7 +195,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
//%}
//%
//%- (void)enumerate##ACCESSOR_NAME##ValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block {
-//% [self enumerate##ACCESSOR_NAME##ValuesWithOptions:0 usingBlock:block];
+//% [self enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
//%}
//%
//%- (void)enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)opts
@@ -299,7 +308,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@synthesize count = _count;
+ (instancetype)array {
- return [[[self alloc] initWithValues:NULL count:0] autorelease];
+ return [[[self alloc] init] autorelease];
}
+ (instancetype)arrayWithValue:(int32_t)value {
@@ -317,7 +326,9 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)init {
- return [self initWithValues:NULL count:0];
+ self = [super init];
+ // No work needed;
+ return self;
}
- (instancetype)initWithValueArray:(GPBInt32Array *)array {
@@ -325,11 +336,11 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)initWithValues:(const int32_t [])values count:(NSUInteger)count {
- self = [super init];
+ self = [self init];
if (self) {
if (count && values) {
- _values = malloc(count * sizeof(int32_t));
- if (values != NULL) {
+ _values = reallocf(_values, count * sizeof(int32_t));
+ if (_values != NULL) {
_capacity = count;
memcpy(_values, values, count * sizeof(int32_t));
_count = count;
@@ -364,15 +375,16 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
[super dealloc];
}
-- (BOOL)isEqual:(GPBInt32Array *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32Array class]]) {
return NO;
}
- return (_count == other->_count
- && memcmp(_values, other->_values, (_count * sizeof(int32_t))) == 0);
+ GPBInt32Array *otherArray = other;
+ return (_count == otherArray->_count
+ && memcmp(_values, otherArray->_values, (_count * sizeof(int32_t))) == 0);
}
- (NSUInteger)hash {
@@ -394,7 +406,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block {
- [self enumerateValuesWithOptions:0 usingBlock:block];
+ [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
@@ -544,7 +556,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@synthesize count = _count;
+ (instancetype)array {
- return [[[self alloc] initWithValues:NULL count:0] autorelease];
+ return [[[self alloc] init] autorelease];
}
+ (instancetype)arrayWithValue:(uint32_t)value {
@@ -562,7 +574,9 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)init {
- return [self initWithValues:NULL count:0];
+ self = [super init];
+ // No work needed;
+ return self;
}
- (instancetype)initWithValueArray:(GPBUInt32Array *)array {
@@ -570,11 +584,11 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)initWithValues:(const uint32_t [])values count:(NSUInteger)count {
- self = [super init];
+ self = [self init];
if (self) {
if (count && values) {
- _values = malloc(count * sizeof(uint32_t));
- if (values != NULL) {
+ _values = reallocf(_values, count * sizeof(uint32_t));
+ if (_values != NULL) {
_capacity = count;
memcpy(_values, values, count * sizeof(uint32_t));
_count = count;
@@ -609,15 +623,16 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
[super dealloc];
}
-- (BOOL)isEqual:(GPBUInt32Array *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32Array class]]) {
return NO;
}
- return (_count == other->_count
- && memcmp(_values, other->_values, (_count * sizeof(uint32_t))) == 0);
+ GPBUInt32Array *otherArray = other;
+ return (_count == otherArray->_count
+ && memcmp(_values, otherArray->_values, (_count * sizeof(uint32_t))) == 0);
}
- (NSUInteger)hash {
@@ -639,7 +654,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block {
- [self enumerateValuesWithOptions:0 usingBlock:block];
+ [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
@@ -789,7 +804,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@synthesize count = _count;
+ (instancetype)array {
- return [[[self alloc] initWithValues:NULL count:0] autorelease];
+ return [[[self alloc] init] autorelease];
}
+ (instancetype)arrayWithValue:(int64_t)value {
@@ -807,7 +822,9 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)init {
- return [self initWithValues:NULL count:0];
+ self = [super init];
+ // No work needed;
+ return self;
}
- (instancetype)initWithValueArray:(GPBInt64Array *)array {
@@ -815,11 +832,11 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)initWithValues:(const int64_t [])values count:(NSUInteger)count {
- self = [super init];
+ self = [self init];
if (self) {
if (count && values) {
- _values = malloc(count * sizeof(int64_t));
- if (values != NULL) {
+ _values = reallocf(_values, count * sizeof(int64_t));
+ if (_values != NULL) {
_capacity = count;
memcpy(_values, values, count * sizeof(int64_t));
_count = count;
@@ -854,15 +871,16 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
[super dealloc];
}
-- (BOOL)isEqual:(GPBInt64Array *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64Array class]]) {
return NO;
}
- return (_count == other->_count
- && memcmp(_values, other->_values, (_count * sizeof(int64_t))) == 0);
+ GPBInt64Array *otherArray = other;
+ return (_count == otherArray->_count
+ && memcmp(_values, otherArray->_values, (_count * sizeof(int64_t))) == 0);
}
- (NSUInteger)hash {
@@ -884,7 +902,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block {
- [self enumerateValuesWithOptions:0 usingBlock:block];
+ [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
@@ -1034,7 +1052,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@synthesize count = _count;
+ (instancetype)array {
- return [[[self alloc] initWithValues:NULL count:0] autorelease];
+ return [[[self alloc] init] autorelease];
}
+ (instancetype)arrayWithValue:(uint64_t)value {
@@ -1052,7 +1070,9 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)init {
- return [self initWithValues:NULL count:0];
+ self = [super init];
+ // No work needed;
+ return self;
}
- (instancetype)initWithValueArray:(GPBUInt64Array *)array {
@@ -1060,11 +1080,11 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)initWithValues:(const uint64_t [])values count:(NSUInteger)count {
- self = [super init];
+ self = [self init];
if (self) {
if (count && values) {
- _values = malloc(count * sizeof(uint64_t));
- if (values != NULL) {
+ _values = reallocf(_values, count * sizeof(uint64_t));
+ if (_values != NULL) {
_capacity = count;
memcpy(_values, values, count * sizeof(uint64_t));
_count = count;
@@ -1099,15 +1119,16 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
[super dealloc];
}
-- (BOOL)isEqual:(GPBUInt64Array *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64Array class]]) {
return NO;
}
- return (_count == other->_count
- && memcmp(_values, other->_values, (_count * sizeof(uint64_t))) == 0);
+ GPBUInt64Array *otherArray = other;
+ return (_count == otherArray->_count
+ && memcmp(_values, otherArray->_values, (_count * sizeof(uint64_t))) == 0);
}
- (NSUInteger)hash {
@@ -1129,7 +1150,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block {
- [self enumerateValuesWithOptions:0 usingBlock:block];
+ [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
@@ -1279,7 +1300,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@synthesize count = _count;
+ (instancetype)array {
- return [[[self alloc] initWithValues:NULL count:0] autorelease];
+ return [[[self alloc] init] autorelease];
}
+ (instancetype)arrayWithValue:(float)value {
@@ -1297,7 +1318,9 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)init {
- return [self initWithValues:NULL count:0];
+ self = [super init];
+ // No work needed;
+ return self;
}
- (instancetype)initWithValueArray:(GPBFloatArray *)array {
@@ -1305,11 +1328,11 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)initWithValues:(const float [])values count:(NSUInteger)count {
- self = [super init];
+ self = [self init];
if (self) {
if (count && values) {
- _values = malloc(count * sizeof(float));
- if (values != NULL) {
+ _values = reallocf(_values, count * sizeof(float));
+ if (_values != NULL) {
_capacity = count;
memcpy(_values, values, count * sizeof(float));
_count = count;
@@ -1344,15 +1367,16 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
[super dealloc];
}
-- (BOOL)isEqual:(GPBFloatArray *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBFloatArray class]]) {
return NO;
}
- return (_count == other->_count
- && memcmp(_values, other->_values, (_count * sizeof(float))) == 0);
+ GPBFloatArray *otherArray = other;
+ return (_count == otherArray->_count
+ && memcmp(_values, otherArray->_values, (_count * sizeof(float))) == 0);
}
- (NSUInteger)hash {
@@ -1374,7 +1398,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block {
- [self enumerateValuesWithOptions:0 usingBlock:block];
+ [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
@@ -1524,7 +1548,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@synthesize count = _count;
+ (instancetype)array {
- return [[[self alloc] initWithValues:NULL count:0] autorelease];
+ return [[[self alloc] init] autorelease];
}
+ (instancetype)arrayWithValue:(double)value {
@@ -1542,7 +1566,9 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)init {
- return [self initWithValues:NULL count:0];
+ self = [super init];
+ // No work needed;
+ return self;
}
- (instancetype)initWithValueArray:(GPBDoubleArray *)array {
@@ -1550,11 +1576,11 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)initWithValues:(const double [])values count:(NSUInteger)count {
- self = [super init];
+ self = [self init];
if (self) {
if (count && values) {
- _values = malloc(count * sizeof(double));
- if (values != NULL) {
+ _values = reallocf(_values, count * sizeof(double));
+ if (_values != NULL) {
_capacity = count;
memcpy(_values, values, count * sizeof(double));
_count = count;
@@ -1589,15 +1615,16 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
[super dealloc];
}
-- (BOOL)isEqual:(GPBDoubleArray *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBDoubleArray class]]) {
return NO;
}
- return (_count == other->_count
- && memcmp(_values, other->_values, (_count * sizeof(double))) == 0);
+ GPBDoubleArray *otherArray = other;
+ return (_count == otherArray->_count
+ && memcmp(_values, otherArray->_values, (_count * sizeof(double))) == 0);
}
- (NSUInteger)hash {
@@ -1619,7 +1646,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block {
- [self enumerateValuesWithOptions:0 usingBlock:block];
+ [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
@@ -1769,7 +1796,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@synthesize count = _count;
+ (instancetype)array {
- return [[[self alloc] initWithValues:NULL count:0] autorelease];
+ return [[[self alloc] init] autorelease];
}
+ (instancetype)arrayWithValue:(BOOL)value {
@@ -1787,7 +1814,9 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)init {
- return [self initWithValues:NULL count:0];
+ self = [super init];
+ // No work needed;
+ return self;
}
- (instancetype)initWithValueArray:(GPBBoolArray *)array {
@@ -1795,11 +1824,11 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)initWithValues:(const BOOL [])values count:(NSUInteger)count {
- self = [super init];
+ self = [self init];
if (self) {
if (count && values) {
- _values = malloc(count * sizeof(BOOL));
- if (values != NULL) {
+ _values = reallocf(_values, count * sizeof(BOOL));
+ if (_values != NULL) {
_capacity = count;
memcpy(_values, values, count * sizeof(BOOL));
_count = count;
@@ -1834,15 +1863,16 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
[super dealloc];
}
-- (BOOL)isEqual:(GPBBoolArray *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolArray class]]) {
return NO;
}
- return (_count == other->_count
- && memcmp(_values, other->_values, (_count * sizeof(BOOL))) == 0);
+ GPBBoolArray *otherArray = other;
+ return (_count == otherArray->_count
+ && memcmp(_values, otherArray->_values, (_count * sizeof(BOOL))) == 0);
}
- (NSUInteger)hash {
@@ -1864,7 +1894,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block {
- [self enumerateValuesWithOptions:0 usingBlock:block];
+ [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
@@ -2015,15 +2045,11 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
@synthesize validationFunc = _validationFunc;
+ (instancetype)array {
- return [[[self alloc] initWithValidationFunction:NULL
- rawValues:NULL
- count:0] autorelease];
+ return [[[self alloc] initWithValidationFunction:NULL] autorelease];
}
+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func {
- return [[[self alloc] initWithValidationFunction:func
- rawValues:NULL
- count:0] autorelease];
+ return [[[self alloc] initWithValidationFunction:func] autorelease];
}
+ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func
@@ -2043,7 +2069,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)init {
- return [self initWithValidationFunction:NULL rawValues:NULL count:0];
+ return [self initWithValidationFunction:NULL];
}
- (instancetype)initWithValueArray:(GPBEnumArray *)array {
@@ -2053,18 +2079,21 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func {
- return [self initWithValidationFunction:func rawValues:NULL count:0];
+ self = [super init];
+ if (self) {
+ _validationFunc = (func != NULL ? func : ArrayDefault_IsValidValue);
+ }
+ return self;
}
- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func
rawValues:(const int32_t [])values
count:(NSUInteger)count {
- self = [super init];
+ self = [self initWithValidationFunction:func];
if (self) {
- _validationFunc = (func != NULL ? func : ArrayDefault_IsValidValue);
if (count && values) {
- _values = malloc(count * sizeof(int32_t));
- if (values != NULL) {
+ _values = reallocf(_values, count * sizeof(int32_t));
+ if (_values != NULL) {
_capacity = count;
memcpy(_values, values, count * sizeof(int32_t));
_count = count;
@@ -2081,7 +2110,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func
capacity:(NSUInteger)count {
- self = [self initWithValidationFunction:func rawValues:NULL count:0];
+ self = [self initWithValidationFunction:func];
if (self && count) {
[self internalResizeToCapacity:count];
}
@@ -2106,15 +2135,16 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
[super dealloc];
}
-- (BOOL)isEqual:(GPBEnumArray *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBEnumArray class]]) {
return NO;
}
- return (_count == other->_count
- && memcmp(_values, other->_values, (_count * sizeof(int32_t))) == 0);
+ GPBEnumArray *otherArray = other;
+ return (_count == otherArray->_count
+ && memcmp(_values, otherArray->_values, (_count * sizeof(int32_t))) == 0);
}
- (NSUInteger)hash {
@@ -2136,7 +2166,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block {
- [self enumerateRawValuesWithOptions:0 usingBlock:block];
+ [self enumerateRawValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
@@ -2188,7 +2218,7 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
}
- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block {
- [self enumerateValuesWithOptions:0 usingBlock:block];
+ [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
@@ -2489,14 +2519,14 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
- (id)copyWithZone:(NSZone *)zone {
if (_array == nil) {
- _array = [[NSMutableArray alloc] init];
+ return [[NSMutableArray allocWithZone:zone] init];
}
return [_array copyWithZone:zone];
}
- (id)mutableCopyWithZone:(NSZone *)zone {
if (_array == nil) {
- _array = [[NSMutableArray alloc] init];
+ return [[NSMutableArray allocWithZone:zone] init];
}
return [_array mutableCopyWithZone:zone];
}
@@ -2507,13 +2537,15 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
return [_array countByEnumeratingWithState:state objects:buffer count:len];
}
-- (void)enumerateObjectsUsingBlock:(void (^)(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 (^)(id obj, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))block {
[_array enumerateObjectsWithOptions:opts usingBlock:block];
}
@end
+
+#pragma clang diagnostic pop
diff --git a/objectivec/GPBBootstrap.h b/objectivec/GPBBootstrap.h
index c49c7e20..ed53ae7c 100644
--- a/objectivec/GPBBootstrap.h
+++ b/objectivec/GPBBootstrap.h
@@ -28,51 +28,61 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// The Objective C runtime has complete enough info that most protos don’t end
-// up using this, so leaving it on is no cost or very little cost. If you
-// happen to see it causing bloat, this is the way to disable it. If you do
-// need to disable it, try only disabling it for Release builds as having
-// full TextFormat can be useful for debugging.
+/**
+ * The Objective C runtime has complete enough info that most protos don’t end
+ * up using this, so leaving it on is no cost or very little cost. If you
+ * happen to see it causing bloat, this is the way to disable it. If you do
+ * need to disable it, try only disabling it for Release builds as having
+ * full TextFormat can be useful for debugging.
+ **/
#ifndef GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
#define GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS 0
#endif
-// Most uses of protocol buffers don't need field options, by default the
-// static data will be compiled out, define this to 1 to include it. The only
-// time you need this is if you are doing introspection of the protocol buffers.
-#ifndef GPBOBJC_INCLUDE_FIELD_OPTIONS
-#define GPBOBJC_INCLUDE_FIELD_OPTIONS 0
-#endif
-
// Used in the generated code to give sizes to enums. int32_t was chosen based
// on the fact that Protocol Buffers enums are limited to this range.
#if !__has_feature(objc_fixed_enum)
#error All supported Xcode versions should support objc_fixed_enum.
#endif
+
// If the headers are imported into Objective-C++, we can run into an issue
// where the defintion of NS_ENUM (really CF_ENUM) changes based on the C++
// standard that is in effect. If it isn't C++11 or higher, the definition
// doesn't allow us to forward declare. We work around this one case by
// providing a local definition. The default case has to use NS_ENUM for the
// magic that is Swift bridging of enums.
-#if (__cplusplus && __cplusplus < 201103L)
+#if (defined(__cplusplus) && __cplusplus && __cplusplus < 201103L)
#define GPB_ENUM(X) enum X : int32_t X; enum X : int32_t
#else
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
#endif
-// GPB_ENUM_FWD_DECLARE is used for forward declaring enums, ex:
-// GPB_ENUM_FWD_DECLARE(Foo_Enum)
-// @property (nonatomic) Foo_Enum value;
+
+/**
+ * GPB_ENUM_FWD_DECLARE is used for forward declaring enums, for example:
+ *
+ * ```
+ * GPB_ENUM_FWD_DECLARE(Foo_Enum)
+ *
+ * @interface BarClass : NSObject
+ * @property (nonatomic) enum Foo_Enum value;
+ * - (void)bazMethod:(enum Foo_Enum):value;
+ * @end
+ * ```
+ **/
#define GPB_ENUM_FWD_DECLARE(X) enum X : int32_t
-// Based upon CF_INLINE. Forces inlining in release.
+/**
+ * Based upon CF_INLINE. Forces inlining in non DEBUG builds.
+ **/
#if !defined(DEBUG)
#define GPB_INLINE static __inline__ __attribute__((always_inline))
#else
#define GPB_INLINE static __inline__
#endif
-// For use in public headers that might need to deal with ARC.
+/**
+ * For use in public headers that might need to deal with ARC.
+ **/
#ifndef GPB_UNSAFE_UNRETAINED
#if __has_feature(objc_arc)
#define GPB_UNSAFE_UNRETAINED __unsafe_unretained
@@ -83,10 +93,31 @@
// If property name starts with init we need to annotate it to get past ARC.
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
+//
+// Meant to be used internally by generated code.
#define GPB_METHOD_FAMILY_NONE __attribute__((objc_method_family(none)))
-// The protoc-gen-objc version which works with the current version of the
-// generated Objective C sources. In general we don't want to change the
-// runtime interfaces (or this version) as it means everything has to be
-// regenerated.
-#define GOOGLE_PROTOBUF_OBJC_GEN_VERSION 30000
+// ----------------------------------------------------------------------------
+// These version numbers are all internal to the ObjC Protobuf runtime; they
+// are used to ensure compatibility between the generated sources and the
+// headers being compiled against and/or the version of sources being run
+// against.
+//
+// They are all #defines so the values are captured into every .o file they
+// are used in and to allow comparisons in the preprocessor.
+
+// Current library runtime version.
+// - Gets bumped when the runtime makes changes to the interfaces between the
+// generated code and runtime (things added/removed, etc).
+#define GOOGLE_PROTOBUF_OBJC_VERSION 30002
+
+// Minimum runtime version supported for compiling/running against.
+// - Gets changed when support for the older generated code is dropped.
+#define GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION 30001
+
+
+// This is a legacy constant now frozen in time for old generated code. If
+// GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION ever gets moved above 30001 then
+// this should also change to break code compiled with an old runtime that
+// can't be supported any more.
+#define GOOGLE_PROTOBUF_OBJC_GEN_VERSION 30001
diff --git a/objectivec/GPBCodedInputStream.h b/objectivec/GPBCodedInputStream.h
index 42a04941..fbe5009c 100644
--- a/objectivec/GPBCodedInputStream.h
+++ b/objectivec/GPBCodedInputStream.h
@@ -35,52 +35,218 @@
NS_ASSUME_NONNULL_BEGIN
-// Reads and decodes protocol message fields.
-// Subclassing of GPBCodedInputStream is NOT supported.
+CF_EXTERN_C_BEGIN
+
+/**
+ * @c GPBCodedInputStream exception name. Exceptions raised from
+ * @c GPBCodedInputStream contain an underlying error in the userInfo dictionary
+ * under the GPBCodedInputStreamUnderlyingErrorKey key.
+ **/
+extern NSString *const GPBCodedInputStreamException;
+
+/** The key under which the underlying NSError from the exception is stored. */
+extern NSString *const GPBCodedInputStreamUnderlyingErrorKey;
+
+/** NSError domain used for @c GPBCodedInputStream errors. */
+extern NSString *const GPBCodedInputStreamErrorDomain;
+
+/**
+ * Error code for NSError with @c GPBCodedInputStreamErrorDomain.
+ **/
+typedef NS_ENUM(NSInteger, GPBCodedInputStreamErrorCode) {
+ /** The size does not fit in the remaining bytes to be read. */
+ GPBCodedInputStreamErrorInvalidSize = -100,
+ /** Attempted to read beyond the subsection limit. */
+ GPBCodedInputStreamErrorSubsectionLimitReached = -101,
+ /** The requested subsection limit is invalid. */
+ GPBCodedInputStreamErrorInvalidSubsectionLimit = -102,
+ /** Invalid tag read. */
+ GPBCodedInputStreamErrorInvalidTag = -103,
+ /** Invalid UTF-8 character in a string. */
+ GPBCodedInputStreamErrorInvalidUTF8 = -104,
+ /** Invalid VarInt read. */
+ GPBCodedInputStreamErrorInvalidVarInt = -105,
+ /** The maximum recursion depth of messages was exceeded. */
+ GPBCodedInputStreamErrorRecursionDepthExceeded = -106,
+};
+
+CF_EXTERN_C_END
+
+/**
+ * Reads and decodes protocol message fields.
+ *
+ * The common uses of protocol buffers shouldn't need to use this class.
+ * @c GPBMessage's provide a @c +parseFromData:error: and
+ * @c +parseFromData:extensionRegistry:error: method that will decode a
+ * message for you.
+ *
+ * @note Subclassing of @c GPBCodedInputStream is NOT supported.
+ **/
@interface GPBCodedInputStream : NSObject
+/**
+ * Creates a new stream wrapping some data.
+ *
+ * @param data The data to wrap inside the stream.
+ *
+ * @return A newly instanced GPBCodedInputStream.
+ **/
+ (instancetype)streamWithData:(NSData *)data;
+
+/**
+ * Initializes a stream wrapping some data.
+ *
+ * @param data The data to wrap inside the stream.
+ *
+ * @return A newly initialized GPBCodedInputStream.
+ **/
- (instancetype)initWithData:(NSData *)data;
-// Attempt to read a field tag, returning zero if we have reached EOF.
-// Protocol message parsers use this to read tags, since a protocol message
-// may legally end wherever a tag occurs, and zero is not a valid tag number.
+/**
+ * Attempts to read a field tag, returning zero if we have reached EOF.
+ * Protocol message parsers use this to read tags, since a protocol message
+ * may legally end wherever a tag occurs, and zero is not a valid tag number.
+ *
+ * @return The field tag, or zero if EOF was reached.
+ **/
- (int32_t)readTag;
+/**
+ * @return A double read from the stream.
+ **/
- (double)readDouble;
+/**
+ * @return A float read from the stream.
+ **/
- (float)readFloat;
+/**
+ * @return A uint64 read from the stream.
+ **/
- (uint64_t)readUInt64;
+/**
+ * @return A uint32 read from the stream.
+ **/
- (uint32_t)readUInt32;
+/**
+ * @return An int64 read from the stream.
+ **/
- (int64_t)readInt64;
+/**
+ * @return An int32 read from the stream.
+ **/
- (int32_t)readInt32;
+/**
+ * @return A fixed64 read from the stream.
+ **/
- (uint64_t)readFixed64;
+/**
+ * @return A fixed32 read from the stream.
+ **/
- (uint32_t)readFixed32;
+/**
+ * @return An enum read from the stream.
+ **/
- (int32_t)readEnum;
+/**
+ * @return A sfixed32 read from the stream.
+ **/
- (int32_t)readSFixed32;
+/**
+ * @return A fixed64 read from the stream.
+ **/
- (int64_t)readSFixed64;
+/**
+ * @return A sint32 read from the stream.
+ **/
- (int32_t)readSInt32;
+/**
+ * @return A sint64 read from the stream.
+ **/
- (int64_t)readSInt64;
+/**
+ * @return A boolean read from the stream.
+ **/
- (BOOL)readBool;
+/**
+ * @return A string read from the stream.
+ **/
- (NSString *)readString;
+/**
+ * @return Data read from the stream.
+ **/
- (NSData *)readBytes;
-// Read an embedded message field value from the stream.
+/**
+ * Read an embedded message field value from the stream.
+ *
+ * @param message The message to set fields on as they are read.
+ * @param extensionRegistry An optional extension registry to use to lookup
+ * extensions for message.
+ **/
- (void)readMessage:(GPBMessage *)message
- extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
+ extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
-// Reads and discards a single field, given its tag value. Returns NO if the
-// tag is an endgroup tag, in which case nothing is skipped. Otherwise,
-// returns YES.
+/**
+ * Reads and discards a single field, given its tag value.
+ *
+ * @param tag The tag number of the field to skip.
+ *
+ * @return NO if the tag is an endgroup tag (in which case nothing is skipped),
+ * YES in all other cases.
+ **/
- (BOOL)skipField:(int32_t)tag;
-// Reads and discards an entire message. This will read either until EOF
-// or until an endgroup tag, whichever comes first.
+/**
+ * Reads and discards an entire message. This will read either until EOF or
+ * until an endgroup tag, whichever comes first.
+ **/
- (void)skipMessage;
-// Verifies that the last call to readTag() returned the given tag value.
-// This is used to verify that a nested group ended with the correct end tag.
-// Throws NSParseErrorException if value does not match the last tag.
-- (void)checkLastTagWas:(int32_t)value;
+/**
+ * Check to see if the logical end of the stream has been reached.
+ *
+ * @note This can return NO when there is no more data, but the current parsing
+ * expected more data.
+ *
+ * @return YES if the logical end of the stream has been reached, NO otherwise.
+ **/
+- (BOOL)isAtEnd;
+
+/**
+ * @return The offset into the stream.
+ **/
+- (size_t)position;
+
+/**
+ * Moves the limit to the given byte offset starting at the current location.
+ *
+ * @exception GPBCodedInputStreamException If the requested bytes exceeed the
+ * current limit.
+ *
+ * @param byteLimit The number of bytes to move the limit, offset to the current
+ * location.
+ *
+ * @return The limit offset before moving the new limit.
+ */
+- (size_t)pushLimit:(size_t)byteLimit;
+
+/**
+ * Moves the limit back to the offset as it was before calling pushLimit:.
+ *
+ * @param oldLimit The number of bytes to move the current limit. Usually this
+ * is the value returned by the pushLimit: method.
+ */
+- (void)popLimit:(size_t)oldLimit;
+
+/**
+ * Verifies that the last call to -readTag returned the given tag value. This
+ * is used to verify that a nested group ended with the correct end tag.
+ *
+ * @exception NSParseErrorException If the value does not match the last tag.
+ *
+ * @param expected The tag that was expected.
+ **/
+- (void)checkLastTagWas:(int32_t)expected;
@end
diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m
index fd877838..dd05ddb4 100644
--- a/objectivec/GPBCodedInputStream.m
+++ b/objectivec/GPBCodedInputStream.m
@@ -36,17 +36,53 @@
#import "GPBUtilities_PackagePrivate.h"
#import "GPBWireFormat.h"
-static const NSUInteger kDefaultRecursionLimit = 64;
+NSString *const GPBCodedInputStreamException =
+ GPBNSStringifySymbol(GPBCodedInputStreamException);
+
+NSString *const GPBCodedInputStreamUnderlyingErrorKey =
+ GPBNSStringifySymbol(GPBCodedInputStreamUnderlyingErrorKey);
+
+NSString *const GPBCodedInputStreamErrorDomain =
+ GPBNSStringifySymbol(GPBCodedInputStreamErrorDomain);
+
+// Matching:
+// https://github.com/google/protobuf/blob/master/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L62
+// private static final int DEFAULT_RECURSION_LIMIT = 100;
+// https://github.com/google/protobuf/blob/master/src/google/protobuf/io/coded_stream.cc#L86
+// int CodedInputStream::default_recursion_limit_ = 100;
+static const NSUInteger kDefaultRecursionLimit = 100;
+
+static void RaiseException(NSInteger code, NSString *reason) {
+ NSDictionary *errorInfo = nil;
+ if ([reason length]) {
+ errorInfo = @{ GPBErrorReasonKey: reason };
+ }
+ NSError *error = [NSError errorWithDomain:GPBCodedInputStreamErrorDomain
+ code:code
+ userInfo:errorInfo];
+
+ NSDictionary *exceptionInfo =
+ @{ GPBCodedInputStreamUnderlyingErrorKey: error };
+ [[NSException exceptionWithName:GPBCodedInputStreamException
+ reason:reason
+ userInfo:exceptionInfo] raise];
+}
+
+static void CheckRecursionLimit(GPBCodedInputStreamState *state) {
+ if (state->recursionDepth >= kDefaultRecursionLimit) {
+ RaiseException(GPBCodedInputStreamErrorRecursionDepthExceeded, nil);
+ }
+}
static void CheckSize(GPBCodedInputStreamState *state, size_t size) {
size_t newSize = state->bufferPos + size;
if (newSize > state->bufferSize) {
- [NSException raise:NSParseErrorException format:@""];
+ RaiseException(GPBCodedInputStreamErrorInvalidSize, nil);
}
if (newSize > state->currentLimit) {
// Fast forward to end of currentLimit;
state->bufferPos = state->currentLimit;
- [NSException raise:NSParseErrorException format:@""];
+ RaiseException(GPBCodedInputStreamErrorSubsectionLimitReached, nil);
}
}
@@ -69,56 +105,25 @@ static int64_t ReadRawLittleEndian64(GPBCodedInputStreamState *state) {
return value;
}
-static int32_t ReadRawVarint32(GPBCodedInputStreamState *state) {
- int8_t tmp = ReadRawByte(state);
- if (tmp >= 0) {
- return tmp;
- }
- int32_t result = tmp & 0x7f;
- if ((tmp = ReadRawByte(state)) >= 0) {
- result |= tmp << 7;
- } else {
- result |= (tmp & 0x7f) << 7;
- if ((tmp = ReadRawByte(state)) >= 0) {
- result |= tmp << 14;
- } else {
- result |= (tmp & 0x7f) << 14;
- if ((tmp = ReadRawByte(state)) >= 0) {
- result |= tmp << 21;
- } else {
- result |= (tmp & 0x7f) << 21;
- result |= (tmp = ReadRawByte(state)) << 28;
- if (tmp < 0) {
- // Discard upper 32 bits.
- for (int i = 0; i < 5; i++) {
- if (ReadRawByte(state) >= 0) {
- return result;
- }
- }
- [NSException raise:NSParseErrorException
- format:@"Unable to read varint32"];
- }
- }
- }
- }
- return result;
-}
-
static int64_t ReadRawVarint64(GPBCodedInputStreamState *state) {
int32_t shift = 0;
int64_t result = 0;
while (shift < 64) {
int8_t b = ReadRawByte(state);
- result |= (int64_t)(b & 0x7F) << shift;
+ result |= (int64_t)((uint64_t)(b & 0x7F) << shift);
if ((b & 0x80) == 0) {
return result;
}
shift += 7;
}
- [NSException raise:NSParseErrorException format:@"Unable to read varint64"];
+ RaiseException(GPBCodedInputStreamErrorInvalidVarInt, @"Invalid VarInt64");
return 0;
}
+static int32_t ReadRawVarint32(GPBCodedInputStreamState *state) {
+ return (int32_t)ReadRawVarint64(state);
+}
+
static void SkipRawData(GPBCodedInputStreamState *state, size_t size) {
CheckSize(state, size);
state->bufferPos += size;
@@ -200,10 +205,15 @@ int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
}
state->lastTag = ReadRawVarint32(state);
- if (state->lastTag == 0) {
- // If we actually read zero, that's not a valid tag.
- [NSException raise:NSParseErrorException
- format:@"Invalid last tag %d", state->lastTag];
+ // Tags have to include a valid wireformat.
+ if (!GPBWireFormatIsValidTag(state->lastTag)) {
+ RaiseException(GPBCodedInputStreamErrorInvalidTag,
+ @"Invalid wireformat in tag.");
+ }
+ // Zero is not a valid field number.
+ if (GPBWireFormatGetTagFieldNumber(state->lastTag) == 0) {
+ RaiseException(GPBCodedInputStreamErrorInvalidTag,
+ @"A zero field number on the wire is invalid.");
}
return state->lastTag;
}
@@ -219,15 +229,15 @@ NSString *GPBCodedInputStreamReadRetainedString(
result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos]
length:size
encoding:NSUTF8StringEncoding];
+ state->bufferPos += size;
if (!result) {
- result = @"";
#ifdef DEBUG
// https://developers.google.com/protocol-buffers/docs/proto#scalar
- NSLog(@"UTF8 failure, is some field type 'string' when it should be "
+ NSLog(@"UTF-8 failure, is some field type 'string' when it should be "
@"'bytes'?");
#endif
+ RaiseException(GPBCodedInputStreamErrorInvalidUTF8, nil);
}
- state->bufferPos += size;
}
return result;
}
@@ -261,8 +271,7 @@ size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state,
byteLimit += state->bufferPos;
size_t oldLimit = state->currentLimit;
if (byteLimit > oldLimit) {
- [NSException raise:NSInvalidArgumentException
- format:@"byteLimit > oldLimit: %tu > %tu", byteLimit, oldLimit];
+ RaiseException(GPBCodedInputStreamErrorInvalidSubsectionLimit, nil);
}
state->currentLimit = byteLimit;
return oldLimit;
@@ -285,8 +294,7 @@ BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state) {
void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
int32_t value) {
if (state->lastTag != value) {
- [NSException raise:NSParseErrorException
- format:@"Last tag: %d should be %d", state->lastTag, value];
+ RaiseException(GPBCodedInputStreamErrorInvalidTag, @"Unexpected tag read");
}
}
@@ -315,6 +323,12 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
[super dealloc];
}
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
- (int32_t)readTag {
return GPBCodedInputStreamReadTag(&state_);
}
@@ -324,6 +338,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
}
- (BOOL)skipField:(int32_t)tag {
+ NSAssert(GPBWireFormatIsValidTag(tag), @"Invalid tag");
switch (GPBWireFormatGetTagWireType(tag)) {
case GPBWireFormatVarint:
GPBCodedInputStreamReadInt32(&state_);
@@ -346,8 +361,6 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
SkipRawData(&state_, sizeof(int32_t));
return YES;
}
- [NSException raise:NSParseErrorException format:@"Invalid tag %d", tag];
- return NO;
}
- (void)skipMessage {
@@ -359,6 +372,22 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
}
}
+- (BOOL)isAtEnd {
+ return GPBCodedInputStreamIsAtEnd(&state_);
+}
+
+- (size_t)position {
+ return state_.bufferPos;
+}
+
+- (size_t)pushLimit:(size_t)byteLimit {
+ return GPBCodedInputStreamPushLimit(&state_, byteLimit);
+}
+
+- (void)popLimit:(size_t)oldLimit {
+ GPBCodedInputStreamPopLimit(&state_, oldLimit);
+}
+
- (double)readDouble {
return GPBCodedInputStreamReadDouble(&state_);
}
@@ -398,11 +427,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
- (void)readGroup:(int32_t)fieldNumber
message:(GPBMessage *)message
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
- if (state_.recursionDepth >= kDefaultRecursionLimit) {
- [NSException raise:NSParseErrorException
- format:@"recursionDepth(%tu) >= %tu", state_.recursionDepth,
- kDefaultRecursionLimit];
- }
+ CheckRecursionLimit(&state_);
++state_.recursionDepth;
[message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
GPBCodedInputStreamCheckLastTagWas(
@@ -412,11 +437,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
- (void)readUnknownGroup:(int32_t)fieldNumber
message:(GPBUnknownFieldSet *)message {
- if (state_.recursionDepth >= kDefaultRecursionLimit) {
- [NSException raise:NSParseErrorException
- format:@"recursionDepth(%tu) >= %tu", state_.recursionDepth,
- kDefaultRecursionLimit];
- }
+ CheckRecursionLimit(&state_);
++state_.recursionDepth;
[message mergeFromCodedInputStream:self];
GPBCodedInputStreamCheckLastTagWas(
@@ -426,12 +447,8 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
- (void)readMessage:(GPBMessage *)message
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
+ CheckRecursionLimit(&state_);
int32_t length = ReadRawVarint32(&state_);
- if (state_.recursionDepth >= kDefaultRecursionLimit) {
- [NSException raise:NSParseErrorException
- format:@"recursionDepth(%tu) >= %tu", state_.recursionDepth,
- kDefaultRecursionLimit];
- }
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
++state_.recursionDepth;
[message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
@@ -444,12 +461,8 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
field:(GPBFieldDescriptor *)field
parentMessage:(GPBMessage *)parentMessage {
+ CheckRecursionLimit(&state_);
int32_t length = ReadRawVarint32(&state_);
- if (state_.recursionDepth >= kDefaultRecursionLimit) {
- [NSException raise:NSParseErrorException
- format:@"recursionDepth(%tu) >= %tu", state_.recursionDepth,
- kDefaultRecursionLimit];
- }
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
++state_.recursionDepth;
GPBDictionaryReadEntry(mapDictionary, self, extensionRegistry, field,
@@ -487,4 +500,6 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
return GPBCodedInputStreamReadSInt64(&state_);
}
+#pragma clang diagnostic pop
+
@end
diff --git a/objectivec/GPBCodedInputStream_PackagePrivate.h b/objectivec/GPBCodedInputStream_PackagePrivate.h
index 90bd0c92..43ec6e79 100644
--- a/objectivec/GPBCodedInputStream_PackagePrivate.h
+++ b/objectivec/GPBCodedInputStream_PackagePrivate.h
@@ -34,8 +34,6 @@
#import "GPBCodedInputStream.h"
-#import <libkern/OSAtomic.h>
-
@class GPBUnknownFieldSet;
@class GPBFieldDescriptor;
diff --git a/objectivec/GPBCodedOutputStream.h b/objectivec/GPBCodedOutputStream.h
index a5aef170..23c404b8 100644
--- a/objectivec/GPBCodedOutputStream.h
+++ b/objectivec/GPBCodedOutputStream.h
@@ -46,36 +46,131 @@
NS_ASSUME_NONNULL_BEGIN
+/**
+ * @c GPBCodedOutputStream exception names.
+ **/
+extern NSString *const GPBCodedOutputStreamException_OutOfSpace;
+extern NSString *const GPBCodedOutputStreamException_WriteFailed;
+
+/**
+ * Writes out protocol message fields.
+ *
+ * The common uses of protocol buffers shouldn't need to use this class.
+ * GPBMessage's provide a -data method that will serialize the message for you.
+ *
+ * @note Any -write* api can raise the GPBCodedOutputStreamException_*
+ * exceptions.
+ *
+ * @note Subclassing of GPBCodedOutputStream is NOT supported.
+ **/
@interface GPBCodedOutputStream : NSObject
-// Creates a new stream to write into data. Data must be sized to fit or it
-// will error when it runs out of space.
+/**
+ * Creates a stream to fill in the given data. Data must be sized to fit or
+ * an error will be raised when out of space.
+ *
+ * @param data The data where the stream will be written to.
+ *
+ * @return A newly instanced GPBCodedOutputStream.
+ **/
+ (instancetype)streamWithData:(NSMutableData *)data;
+
+/**
+ * Creates a stream to write into the given NSOutputStream.
+ *
+ * @param output The output stream where the stream will be written to.
+ *
+ * @return A newly instanced GPBCodedOutputStream.
+ **/
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output;
-+ (instancetype)streamWithOutputStream:(NSOutputStream *)output
- bufferSize:(size_t)bufferSize;
+/**
+ * Initializes a stream to fill in the given data. Data must be sized to fit
+ * or an error will be raised when out of space.
+ *
+ * @param data The data where the stream will be written to.
+ *
+ * @return A newly initialized GPBCodedOutputStream.
+ **/
- (instancetype)initWithData:(NSMutableData *)data;
+
+/**
+ * Initializes a stream to write into the given @c NSOutputStream.
+ *
+ * @param output The output stream where the stream will be written to.
+ *
+ * @return A newly initialized GPBCodedOutputStream.
+ **/
- (instancetype)initWithOutputStream:(NSOutputStream *)output;
-- (instancetype)initWithOutputStream:(NSOutputStream *)output
- bufferSize:(size_t)bufferSize;
+/**
+ * Flush any buffered data out.
+ **/
- (void)flush;
+/**
+ * Write the raw byte out.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeRawByte:(uint8_t)value;
+/**
+ * Write the tag for the given field number and wire format.
+ *
+ * @param fieldNumber The field number.
+ * @param format The wire format the data for the field will be in.
+ **/
- (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;
+/**
+ * Write a 32bit value out in little endian format.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeRawLittleEndian32:(int32_t)value;
+/**
+ * Write a 64bit value out in little endian format.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeRawLittleEndian64:(int64_t)value;
+/**
+ * Write a 32bit value out in varint format.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeRawVarint32:(int32_t)value;
+/**
+ * Write a 64bit value out in varint format.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeRawVarint64:(int64_t)value;
-// Note that this will truncate 64 bit values to 32.
+/**
+ * Write a size_t out as a 32bit varint value.
+ *
+ * @note This will truncate 64 bit values to 32.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeRawVarintSizeTAs32:(size_t)value;
+/**
+ * Writes the contents of an NSData out.
+ *
+ * @param data The data to write out.
+ **/
- (void)writeRawData:(NSData *)data;
+/**
+ * Writes out the given data.
+ *
+ * @param data The data blob to write out.
+ * @param offset The offset into the blob to start writing out.
+ * @param length The number of bytes from the blob to write out.
+ **/
- (void)writeRawPtr:(const void *)data
offset:(size_t)offset
length:(size_t)length;
@@ -83,240 +178,551 @@ NS_ASSUME_NONNULL_BEGIN
//%PDDM-EXPAND _WRITE_DECLS()
// This block of code is generated, do not edit it directly.
+/**
+ * Write a double for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeDouble:(int32_t)fieldNumber value:(double)value;
+/**
+ * Write a packed array of double for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeDoubleArray:(int32_t)fieldNumber
values:(GPBDoubleArray *)values
tag:(uint32_t)tag;
+/**
+ * Write a double without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeDoubleNoTag:(double)value;
+/**
+ * Write a float for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeFloat:(int32_t)fieldNumber value:(float)value;
+/**
+ * Write a packed array of float for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeFloatArray:(int32_t)fieldNumber
values:(GPBFloatArray *)values
tag:(uint32_t)tag;
+/**
+ * Write a float without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeFloatNoTag:(float)value;
+/**
+ * Write a uint64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
+/**
+ * Write a packed array of uint64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeUInt64Array:(int32_t)fieldNumber
values:(GPBUInt64Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a uint64_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeUInt64NoTag:(uint64_t)value;
+/**
+ * Write a int64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
+/**
+ * Write a packed array of int64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeInt64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a int64_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeInt64NoTag:(int64_t)value;
+/**
+ * Write a int32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
+/**
+ * Write a packed array of int32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeInt32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a int32_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeInt32NoTag:(int32_t)value;
+/**
+ * Write a uint32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
+/**
+ * Write a packed array of uint32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeUInt32Array:(int32_t)fieldNumber
values:(GPBUInt32Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a uint32_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeUInt32NoTag:(uint32_t)value;
+/**
+ * Write a uint64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
+/**
+ * Write a packed array of uint64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeFixed64Array:(int32_t)fieldNumber
values:(GPBUInt64Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a uint64_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeFixed64NoTag:(uint64_t)value;
+/**
+ * Write a uint32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
+/**
+ * Write a packed array of uint32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeFixed32Array:(int32_t)fieldNumber
values:(GPBUInt32Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a uint32_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeFixed32NoTag:(uint32_t)value;
+/**
+ * Write a int32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
+/**
+ * Write a packed array of int32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeSInt32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a int32_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeSInt32NoTag:(int32_t)value;
+/**
+ * Write a int64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
+/**
+ * Write a packed array of int64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeSInt64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a int64_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeSInt64NoTag:(int64_t)value;
+/**
+ * Write a int64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
+/**
+ * Write a packed array of int64_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeSFixed64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a int64_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeSFixed64NoTag:(int64_t)value;
+/**
+ * Write a int32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
+/**
+ * Write a packed array of int32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeSFixed32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
tag:(uint32_t)tag;
+/**
+ * Write a int32_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeSFixed32NoTag:(int32_t)value;
+/**
+ * Write a BOOL for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
+/**
+ * Write a packed array of BOOL for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeBoolArray:(int32_t)fieldNumber
values:(GPBBoolArray *)values
tag:(uint32_t)tag;
+/**
+ * Write a BOOL without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeBoolNoTag:(BOOL)value;
+/**
+ * Write a int32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
+/**
+ * Write a packed array of int32_t for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ * @param tag The tag assigned to the values.
+ **/
- (void)writeEnumArray:(int32_t)fieldNumber
values:(GPBEnumArray *)values
tag:(uint32_t)tag;
+/**
+ * Write a int32_t without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeEnumNoTag:(int32_t)value;
+/**
+ * Write a NSString for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
-- (void)writeStringArray:(int32_t)fieldNumber values:(NSArray *)values;
+/**
+ * Write an array of NSString for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ **/
+- (void)writeStringArray:(int32_t)fieldNumber values:(NSArray<NSString*> *)values;
+/**
+ * Write a NSString without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeStringNoTag:(NSString *)value;
+/**
+ * Write a GPBMessage for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
-- (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray *)values;
+/**
+ * Write an array of GPBMessage for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ **/
+- (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
+/**
+ * Write a GPBMessage without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeMessageNoTag:(GPBMessage *)value;
+/**
+ * Write a NSData for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
-- (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray *)values;
+/**
+ * Write an array of NSData for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ **/
+- (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray<NSData*> *)values;
+/**
+ * Write a NSData without any tag.
+ *
+ * @param value The value to write out.
+ **/
- (void)writeBytesNoTag:(NSData *)value;
+/**
+ * Write a GPBMessage for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeGroup:(int32_t)fieldNumber
value:(GPBMessage *)value;
-- (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray *)values;
+/**
+ * Write an array of GPBMessage for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ **/
+- (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
+/**
+ * Write a GPBMessage without any tag (but does write the endGroup tag).
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeGroupNoTag:(int32_t)fieldNumber
value:(GPBMessage *)value;
+/**
+ * Write a GPBUnknownFieldSet for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeUnknownGroup:(int32_t)fieldNumber
value:(GPBUnknownFieldSet *)value;
-- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray *)values;
+/**
+ * Write an array of GPBUnknownFieldSet for the given field number.
+ *
+ * @param fieldNumber The field number assigned to the values.
+ * @param values The values to write out.
+ **/
+- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray<GPBUnknownFieldSet*> *)values;
+/**
+ * Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
+ *
+ * @param fieldNumber The field number assigned to the value.
+ * @param value The value to write out.
+ **/
- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
value:(GPBUnknownFieldSet *)value;
//%PDDM-EXPAND-END _WRITE_DECLS()
-// Write a MessageSet extension field to the stream. For historical reasons,
-// the wire format differs from normal fields.
+/**
+Write a MessageSet extension field to the stream. For historical reasons,
+the wire format differs from normal fields.
+
+@param fieldNumber The extension field number to write out.
+@param value The message from where to get the extension.
+*/
- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
-// Write an unparsed MessageSet extension field to the stream. For
-// historical reasons, the wire format differs from normal fields.
+/**
+Write an unparsed MessageSet extension field to the stream. For historical
+reasons, the wire format differs from normal fields.
+
+@param fieldNumber The extension field number to write out.
+@param value The raw message from where to get the extension.
+*/
- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
@end
-CF_EXTERN_C_BEGIN
-
-size_t GPBComputeDoubleSize(int32_t fieldNumber, double value)
- __attribute__((const));
-size_t GPBComputeFloatSize(int32_t fieldNumber, float value)
- __attribute__((const));
-size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value)
- __attribute__((const));
-size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value)
- __attribute__((const));
-size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value)
- __attribute__((const));
-size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value)
- __attribute__((const));
-size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value)
- __attribute__((const));
-size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value)
- __attribute__((const));
-size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value)
- __attribute__((const));
-size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value)
- __attribute__((const));
-size_t GPBComputeUnknownGroupSize(int32_t fieldNumber,
- GPBUnknownFieldSet *value)
- __attribute__((const));
-size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value)
- __attribute__((const));
-size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value)
- __attribute__((const));
-size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value)
- __attribute__((const));
-size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value)
- __attribute__((const));
-size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value)
- __attribute__((const));
-size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value)
- __attribute__((const));
-size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value)
- __attribute__((const));
-size_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const));
-size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType)
- __attribute__((const));
-
-size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const));
-size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const));
-size_t GPBComputeUInt64SizeNoTag(uint64_t value) __attribute__((const));
-size_t GPBComputeInt64SizeNoTag(int64_t value) __attribute__((const));
-size_t GPBComputeInt32SizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeFixed64SizeNoTag(uint64_t value) __attribute__((const));
-size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const));
-size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const));
-size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const));
-size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const));
-size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value)
- __attribute__((const));
-size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const));
-size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const));
-size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeEnumSizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeSFixed32SizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeSFixed64SizeNoTag(int64_t value) __attribute__((const));
-size_t GPBComputeSInt32SizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeSInt64SizeNoTag(int64_t value) __attribute__((const));
-
-// Note that this will calculate the size of 64 bit values truncated to 32.
-size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) __attribute__((const));
-
-size_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const));
-size_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const));
-
-// Note that this will calculate the size of 64 bit values truncated to 32.
-size_t GPBComputeRawVarint32SizeForInteger(NSInteger value)
- __attribute__((const));
-
-// Compute the number of bytes that would be needed to encode a
-// MessageSet extension to the stream. For historical reasons,
-// the wire format differs from normal fields.
-size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value)
- __attribute__((const));
-
-// Compute the number of bytes that would be needed to encode an
-// unparsed MessageSet extension field to the stream. For
-// historical reasons, the wire format differs from normal fields.
-size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value)
- __attribute__((const));
-
-size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value)
- __attribute__((const));
-
-CF_EXTERN_C_END
-
NS_ASSUME_NONNULL_END
// Write methods for types that can be in packed arrays.
//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
+//%/**
+//% * Write a TYPE for the given field number.
+//% *
+//% * @param fieldNumber The field number assigned to the value.
+//% * @param value The value to write out.
+//% **/
//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
+//%/**
+//% * Write a packed array of TYPE for the given field number.
+//% *
+//% * @param fieldNumber The field number assigned to the values.
+//% * @param values The values to write out.
+//% * @param tag The tag assigned to the values.
+//% **/
//%- (void)write##NAME##Array:(int32_t)fieldNumber
//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
//% NAME$S tag:(uint32_t)tag;
+//%/**
+//% * Write a TYPE without any tag.
+//% *
+//% * @param value The value to write out.
+//% **/
//%- (void)write##NAME##NoTag:(TYPE)value;
//%
// Write methods for types that aren't in packed arrays.
//%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
-//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
-//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray *)values;
-//%- (void)write##NAME##NoTag:(TYPE)value;
+//%/**
+//% * Write a TYPE for the given field number.
+//% *
+//% * @param fieldNumber The field number assigned to the value.
+//% * @param value The value to write out.
+//% **/
+//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
+//%/**
+//% * Write an array of TYPE for the given field number.
+//% *
+//% * @param fieldNumber The field number assigned to the values.
+//% * @param values The values to write out.
+//% **/
+//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
+//%/**
+//% * Write a TYPE without any tag.
+//% *
+//% * @param value The value to write out.
+//% **/
+//%- (void)write##NAME##NoTag:(TYPE *)value;
//%
// Special write methods for Groups.
//%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
+//%/**
+//% * Write a TYPE for the given field number.
+//% *
+//% * @param fieldNumber The field number assigned to the value.
+//% * @param value The value to write out.
+//% **/
//%- (void)write##NAME:(int32_t)fieldNumber
-//% NAME$S value:(TYPE)value;
-//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray *)values;
+//% NAME$S value:(TYPE *)value;
+//%/**
+//% * Write an array of TYPE for the given field number.
+//% *
+//% * @param fieldNumber The field number assigned to the values.
+//% * @param values The values to write out.
+//% **/
+//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
+//%/**
+//% * Write a TYPE without any tag (but does write the endGroup tag).
+//% *
+//% * @param fieldNumber The field number assigned to the value.
+//% * @param value The value to write out.
+//% **/
//%- (void)write##NAME##NoTag:(int32_t)fieldNumber
-//% NAME$S value:(TYPE)value;
+//% NAME$S value:(TYPE *)value;
//%
// One macro to hide it all up above.
@@ -335,8 +741,8 @@ NS_ASSUME_NONNULL_END
//%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t)
//%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL)
//%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t)
-//%_WRITE_UNPACKABLE_DECLS(String, NSString *)
-//%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage *)
-//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData *)
-//%_WRITE_GROUP_DECLS(Group, GPBMessage *)
-//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet *)
+//%_WRITE_UNPACKABLE_DECLS(String, NSString)
+//%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage)
+//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)
+//%_WRITE_GROUP_DECLS(Group, GPBMessage)
+//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet)
diff --git a/objectivec/GPBCodedOutputStream.m b/objectivec/GPBCodedOutputStream.m
index 70142e6f..b846c2fc 100644
--- a/objectivec/GPBCodedOutputStream.m
+++ b/objectivec/GPBCodedOutputStream.m
@@ -28,7 +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.
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
#import <mach/vm_param.h>
@@ -36,6 +36,11 @@
#import "GPBUnknownFieldSet_PackagePrivate.h"
#import "GPBUtilities_PackagePrivate.h"
+// These values are the existing values so as not to break any code that might
+// have already been inspecting them when they weren't documented/exposed.
+NSString *const GPBCodedOutputStreamException_OutOfSpace = @"OutOfSpace";
+NSString *const GPBCodedOutputStreamException_WriteFailed = @"WriteFailed";
+
// Structure for containing state of a GPBCodedInputStream. Brought out into
// a struct so that we can inline several common functions instead of dealing
// with overhead of ObjC dispatch.
@@ -59,13 +64,13 @@ static const int32_t LITTLE_ENDIAN_64_SIZE = sizeof(uint64_t);
static void GPBRefreshBuffer(GPBOutputBufferState *state) {
if (state->output == nil) {
// We're writing to a single buffer.
- [NSException raise:@"OutOfSpace" format:@""];
+ [NSException raise:GPBCodedOutputStreamException_OutOfSpace format:@""];
}
if (state->position != 0) {
NSInteger written =
[state->output write:state->bytes maxLength:state->position];
if (written != (NSInteger)state->position) {
- [NSException raise:@"WriteFailed" format:@""];
+ [NSException raise:GPBCodedOutputStreamException_WriteFailed format:@""];
}
state->position = 0;
}
@@ -144,22 +149,6 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
GPBWriteRawByte(state, (int32_t)(value >> 56) & 0xFF);
}
-#if DEBUG && !defined(NS_BLOCK_ASSERTIONS)
-+ (void)load {
- // This test exists to verify that CFStrings with embedded NULLs will work
- // for us. If this Assert fails, all code below that depends on
- // CFStringGetCStringPtr will NOT work properly on strings that contain
- // embedded NULLs, and we do get that in some protobufs.
- // Note that this will not be compiled in release.
- // We didn't feel that just keeping it in a unit test was sufficient because
- // the Protobuf unit tests are only run when somebody is actually working
- // on protobufs.
- CFStringRef zeroTest = CFSTR("Test\0String");
- const char *cString = CFStringGetCStringPtr(zeroTest, kCFStringEncodingUTF8);
- NSAssert(cString == NULL, @"Serious Error");
-}
-#endif // DEBUG && !defined(NS_BLOCK_ASSERTIONS)
-
- (void)dealloc {
[self flush];
[state_.output close];
@@ -178,12 +167,6 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
return [self initWithOutputStream:nil data:data];
}
-- (instancetype)initWithOutputStream:(NSOutputStream *)output
- bufferSize:(size_t)bufferSize {
- NSMutableData *data = [NSMutableData dataWithLength:bufferSize];
- return [self initWithOutputStream:output data:data];
-}
-
// 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.
@@ -191,29 +174,30 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
data:(NSMutableData *)data {
if ((self = [super init])) {
buffer_ = [data retain];
- [output open];
state_.bytes = [data mutableBytes];
state_.size = [data length];
state_.output = [output retain];
+ [state_.output open];
}
return self;
}
-+ (instancetype)streamWithOutputStream:(NSOutputStream *)output
- bufferSize:(size_t)bufferSize {
- return [[[self alloc] initWithOutputStream:output
- bufferSize:bufferSize] autorelease];
-}
-
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output {
+ NSMutableData *data = [NSMutableData dataWithLength:PAGE_SIZE];
return [[[self alloc] initWithOutputStream:output
- bufferSize:PAGE_SIZE] autorelease];
+ data:data] autorelease];
}
+ (instancetype)streamWithData:(NSMutableData *)data {
return [[[self alloc] initWithData:data] autorelease];
}
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
- (void)writeDoubleNoTag:(double)value {
GPBWriteRawLittleEndian64(&state_, GPBConvertDoubleToInt64(value));
}
@@ -287,19 +271,15 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
}
- (void)writeStringNoTag:(const NSString *)value {
- // If you are concerned about embedded NULLs see the test in
- // +load above.
- const char *quickString =
- CFStringGetCStringPtr((CFStringRef)value, kCFStringEncodingUTF8);
- size_t length = (quickString != NULL)
- ? strlen(quickString)
- : [value lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
+ size_t length = [value lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
GPBWriteRawVarint32(&state_, (int32_t)length);
-
if (length == 0) {
return;
}
+ const char *quickString =
+ CFStringGetCStringPtr((CFStringRef)value, kCFStringEncodingUTF8);
+
// Fast path: Most strings are short, if the buffer already has space,
// add to it directly.
NSUInteger bufferBytesLeft = state_.size - state_.position;
@@ -315,7 +295,7 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
maxLength:bufferBytesLeft
usedLength:&usedBufferLength
encoding:NSUTF8StringEncoding
- options:0
+ options:(NSStringEncodingConversionOptions)0
range:NSMakeRange(0, [value length])
remainingRange:NULL];
}
@@ -962,7 +942,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
state_.position = length;
} else {
// Write is very big. Let's do it all at once.
- [state_.output write:((uint8_t *)value) + offset maxLength:length];
+ NSInteger written = [state_.output write:((uint8_t *)value) + offset maxLength:length];
+ if (written != (NSInteger)length) {
+ [NSException raise:GPBCodedOutputStreamException_WriteFailed format:@""];
+ }
}
}
}
@@ -992,6 +975,8 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
GPBWriteRawLittleEndian64(&state_, value);
}
+#pragma clang diagnostic pop
+
@end
size_t GPBComputeDoubleSizeNoTag(Float64 value) {
@@ -1041,14 +1026,7 @@ size_t GPBComputeBoolSizeNoTag(BOOL value) {
}
size_t GPBComputeStringSizeNoTag(NSString *value) {
- // If you are concerned about embedded NULLs see the test in
- // +load above.
- const char *quickString =
- CFStringGetCStringPtr((CFStringRef)value, kCFStringEncodingUTF8);
- NSUInteger length =
- (quickString != NULL)
- ? strlen(quickString)
- : [value lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
+ NSUInteger length = [value lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
return GPBComputeRawVarint32SizeForInteger(length) + length;
}
diff --git a/objectivec/GPBCodedOutputStream_PackagePrivate.h b/objectivec/GPBCodedOutputStream_PackagePrivate.h
new file mode 100644
index 00000000..2e7bb4c4
--- /dev/null
+++ b/objectivec/GPBCodedOutputStream_PackagePrivate.h
@@ -0,0 +1,126 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "GPBCodedOutputStream.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+CF_EXTERN_C_BEGIN
+
+size_t GPBComputeDoubleSize(int32_t fieldNumber, double value)
+ __attribute__((const));
+size_t GPBComputeFloatSize(int32_t fieldNumber, float value)
+ __attribute__((const));
+size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value)
+ __attribute__((const));
+size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value)
+ __attribute__((const));
+size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value)
+ __attribute__((const));
+size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value)
+ __attribute__((const));
+size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value)
+ __attribute__((const));
+size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value)
+ __attribute__((const));
+size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value)
+ __attribute__((const));
+size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value)
+ __attribute__((const));
+size_t GPBComputeUnknownGroupSize(int32_t fieldNumber,
+ GPBUnknownFieldSet *value)
+ __attribute__((const));
+size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value)
+ __attribute__((const));
+size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value)
+ __attribute__((const));
+size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value)
+ __attribute__((const));
+size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value)
+ __attribute__((const));
+size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value)
+ __attribute__((const));
+size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value)
+ __attribute__((const));
+size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value)
+ __attribute__((const));
+size_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const));
+size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType)
+ __attribute__((const));
+
+size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const));
+size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const));
+size_t GPBComputeUInt64SizeNoTag(uint64_t value) __attribute__((const));
+size_t GPBComputeInt64SizeNoTag(int64_t value) __attribute__((const));
+size_t GPBComputeInt32SizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeFixed64SizeNoTag(uint64_t value) __attribute__((const));
+size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const));
+size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const));
+size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const));
+size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const));
+size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value)
+ __attribute__((const));
+size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const));
+size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const));
+size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeEnumSizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeSFixed32SizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeSFixed64SizeNoTag(int64_t value) __attribute__((const));
+size_t GPBComputeSInt32SizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeSInt64SizeNoTag(int64_t value) __attribute__((const));
+
+// Note that this will calculate the size of 64 bit values truncated to 32.
+size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) __attribute__((const));
+
+size_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const));
+size_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const));
+
+// Note that this will calculate the size of 64 bit values truncated to 32.
+size_t GPBComputeRawVarint32SizeForInteger(NSInteger value)
+ __attribute__((const));
+
+// Compute the number of bytes that would be needed to encode a
+// MessageSet extension to the stream. For historical reasons,
+// the wire format differs from normal fields.
+size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value)
+ __attribute__((const));
+
+// Compute the number of bytes that would be needed to encode an
+// unparsed MessageSet extension field to the stream. For
+// historical reasons, the wire format differs from normal fields.
+size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value)
+ __attribute__((const));
+
+size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value)
+ __attribute__((const));
+
+CF_EXTERN_C_END
+
+NS_ASSUME_NONNULL_END
diff --git a/objectivec/GPBDescriptor.h b/objectivec/GPBDescriptor.h
index 360afe96..292bce13 100644
--- a/objectivec/GPBDescriptor.h
+++ b/objectivec/GPBDescriptor.h
@@ -34,113 +34,285 @@
@class GPBEnumDescriptor;
@class GPBFieldDescriptor;
-@class GPBFieldOptions;
@class GPBFileDescriptor;
@class GPBOneofDescriptor;
NS_ASSUME_NONNULL_BEGIN
-typedef NS_ENUM(NSInteger, GPBFileSyntax) {
+/** Syntax used in the proto file. */
+typedef NS_ENUM(uint8_t, GPBFileSyntax) {
+ /** Unknown syntax. */
GPBFileSyntaxUnknown = 0,
+ /** Proto2 syntax. */
GPBFileSyntaxProto2 = 2,
+ /** Proto3 syntax. */
GPBFileSyntaxProto3 = 3,
};
-typedef NS_ENUM(NSInteger, GPBFieldType) {
- GPBFieldTypeSingle, // optional/required
- GPBFieldTypeRepeated, // repeated
- GPBFieldTypeMap, // map<K,V>
+/** Type of proto field. */
+typedef NS_ENUM(uint8_t, GPBFieldType) {
+ /** Optional/required field. Only valid for proto2 fields. */
+ GPBFieldTypeSingle,
+ /** Repeated field. */
+ GPBFieldTypeRepeated,
+ /** Map field. */
+ GPBFieldTypeMap,
};
+/**
+ * Describes a proto message.
+ **/
@interface GPBDescriptor : NSObject<NSCopying>
+/** Name of the message. */
@property(nonatomic, readonly, copy) NSString *name;
-@property(nonatomic, readonly, strong, nullable) NSArray *fields;
-@property(nonatomic, readonly, strong, nullable) NSArray *oneofs;
-@property(nonatomic, readonly, strong, nullable) NSArray *enums;
+/** Fields declared in the message. */
+@property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor*> *fields;
+/** Oneofs declared in the message. */
+@property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor*> *oneofs;
+/** Extension range declared for the message. */
@property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges;
-@property(nonatomic, readonly) NSUInteger extensionRangesCount;
+/** Number of extension ranges declared for the message. */
+@property(nonatomic, readonly) uint32_t extensionRangesCount;
+/** Descriptor for the file where the message was defined. */
@property(nonatomic, readonly, assign) GPBFileDescriptor *file;
+/** Whether the message is in wire format or not. */
@property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat;
+/** The class of this message. */
@property(nonatomic, readonly) Class messageClass;
-
+/** Containing message descriptor if this message is nested, or nil otherwise. */
+@property(readonly, nullable) GPBDescriptor *containingType;
+/**
+ * Fully qualified name for this message (package.message). Can be nil if the
+ * value is unable to be computed.
+ */
+@property(readonly, nullable) NSString *fullName;
+
+/**
+ * Gets the field for the given number.
+ *
+ * @param fieldNumber The number for the field to get.
+ *
+ * @return The field descriptor for the given number, or nil if not found.
+ **/
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
+
+/**
+ * Gets the field for the given name.
+ *
+ * @param name The name for the field to get.
+ *
+ * @return The field descriptor for the given name, or nil if not found.
+ **/
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
+
+/**
+ * Gets the oneof for the given name.
+ *
+ * @param name The name for the oneof to get.
+ *
+ * @return The oneof descriptor for the given name, or nil if not found.
+ **/
- (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name;
-- (nullable GPBEnumDescriptor *)enumWithName:(NSString *)name;
@end
+/**
+ * Describes a proto file.
+ **/
@interface GPBFileDescriptor : NSObject
+/** The package declared in the proto file. */
@property(nonatomic, readonly, copy) NSString *package;
+/** The objc prefix declared in the proto file. */
+@property(nonatomic, readonly, copy, nullable) NSString *objcPrefix;
+/** The syntax of the proto file. */
@property(nonatomic, readonly) GPBFileSyntax syntax;
@end
+/**
+ * Describes a oneof field.
+ **/
@interface GPBOneofDescriptor : NSObject
+/** Name of the oneof field. */
@property(nonatomic, readonly) NSString *name;
-@property(nonatomic, readonly) NSArray *fields;
-
+/** Fields declared in the oneof. */
+@property(nonatomic, readonly) NSArray<GPBFieldDescriptor*> *fields;
+
+/**
+ * Gets the field for the given number.
+ *
+ * @param fieldNumber The number for the field to get.
+ *
+ * @return The field descriptor for the given number, or nil if not found.
+ **/
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
+
+/**
+ * Gets the field for the given name.
+ *
+ * @param name The name for the field to get.
+ *
+ * @return The field descriptor for the given name, or nil if not found.
+ **/
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
+
@end
+/**
+ * Describes a proto field.
+ **/
@interface GPBFieldDescriptor : NSObject
+/** Name of the field. */
@property(nonatomic, readonly, copy) NSString *name;
+/** Number associated with the field. */
@property(nonatomic, readonly) uint32_t number;
+/** Data type contained in the field. */
@property(nonatomic, readonly) GPBDataType dataType;
+/** Whether it has a default value or not. */
@property(nonatomic, readonly) BOOL hasDefaultValue;
+/** Default value for the field. */
@property(nonatomic, readonly) GPBGenericValue defaultValue;
+/** Whether this field is required. Only valid for proto2 fields. */
@property(nonatomic, readonly, getter=isRequired) BOOL required;
+/** Whether this field is optional. */
@property(nonatomic, readonly, getter=isOptional) BOOL optional;
+/** Type of field (single, repeated, map). */
@property(nonatomic, readonly) GPBFieldType fieldType;
-// If it is a map, the value type is in -type.
+/** Type of the key if the field is a map. The value's type is -fieldType. */
@property(nonatomic, readonly) GPBDataType mapKeyDataType;
+/** Whether the field is packable. */
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
+/** The containing oneof if this field is part of one, nil otherwise. */
@property(nonatomic, readonly, assign, nullable) GPBOneofDescriptor *containingOneof;
-@property(nonatomic, readonly, nullable) GPBFieldOptions *fieldOptions;
-
-// Message properties
+/** Class of the message if the field is of message type. */
@property(nonatomic, readonly, assign, nullable) Class msgClass;
-// Enum properties
+/** Descriptor for the enum if this field is an enum. */
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
+/**
+ * Checks whether the given enum raw value is a valid enum value.
+ *
+ * @param value The raw enum value to check.
+ *
+ * @return YES if value is a valid enum raw value.
+ **/
- (BOOL)isValidEnumValue:(int32_t)value;
-// For now, this will return nil if it doesn't know the name to use for
-// TextFormat.
+/** @return Name for the text format, or nil if not known. */
- (nullable NSString *)textFormatName;
@end
+/**
+ * Describes a proto enum.
+ **/
@interface GPBEnumDescriptor : NSObject
+/** Name of the enum. */
@property(nonatomic, readonly, copy) NSString *name;
+/** Function that validates that raw values are valid enum values. */
@property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier;
+/**
+ * Returns the enum value name for the given raw enum.
+ *
+ * Note that there can be more than one name corresponding to a given value
+ * if the allow_alias option is used.
+ *
+ * @param number The raw enum value.
+ *
+ * @return The first name that matches the enum value passed, or nil if not valid.
+ **/
- (nullable NSString *)enumNameForValue:(int32_t)number;
+
+/**
+ * Gets the enum raw value for the given enum name.
+ *
+ * @param outValue A pointer where the value will be set.
+ * @param name The enum name for which to get the raw value.
+ *
+ * @return YES if a value was copied into the pointer, NO otherwise.
+ **/
- (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name;
+/**
+ * Returns the text format for the given raw enum value.
+ *
+ * @param number The raw enum value.
+ *
+ * @return The first text format name which matches the enum value, or nil if not valid.
+ **/
- (nullable NSString *)textFormatNameForValue:(int32_t)number;
+/**
+ * Gets the enum raw value for the given text format name.
+ *
+ * @param outValue A pointer where the value will be set.
+ * @param textFormatName The text format name for which to get the raw value.
+ *
+ * @return YES if a value was copied into the pointer, NO otherwise.
+ **/
+- (BOOL)getValue:(nullable int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName;
+
+/**
+ * Gets the number of defined enum names.
+ *
+ * @return Count of the number of enum names, including any aliases.
+ */
+@property(nonatomic, readonly) uint32_t enumNameCount;
+
+/**
+ * Gets the enum name corresponding to the given index.
+ *
+ * @param index Index into the available names. The defined range is from 0
+ * to self.enumNameCount - 1.
+ *
+ * @returns The enum name at the given index, or nil if the index is out of range.
+ */
+- (nullable NSString *)getEnumNameForIndex:(uint32_t)index;
+
+/**
+ * Gets the enum text format name corresponding to the given index.
+ *
+ * @param index Index into the available names. The defined range is from 0
+ * to self.enumNameCount - 1.
+ *
+ * @returns The text format name at the given index, or nil if the index is out of range.
+ */
+- (nullable NSString *)getEnumTextFormatNameForIndex:(uint32_t)index;
+
@end
+/**
+ * Describes a proto extension.
+ **/
@interface GPBExtensionDescriptor : NSObject<NSCopying>
+/** Field number under which the extension is stored. */
@property(nonatomic, readonly) uint32_t fieldNumber;
+/** The containing message class, i.e. the class extended by this extension. */
@property(nonatomic, readonly) Class containingMessageClass;
+/** Data type contained in the extension. */
@property(nonatomic, readonly) GPBDataType dataType;
+/** Whether the extension is repeated. */
@property(nonatomic, readonly, getter=isRepeated) BOOL repeated;
+/** Whether the extension is packable. */
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
+/** The class of the message if the extension is of message type. */
@property(nonatomic, readonly, assign) Class msgClass;
+/** The singleton name for the extension. */
@property(nonatomic, readonly) NSString *singletonName;
+/** The enum descriptor if the extension is of enum type. */
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
-@property(nonatomic, readonly) id defaultValue;
+/** The default value for the extension. */
+@property(nonatomic, readonly, nullable) id defaultValue;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/objectivec/GPBDescriptor.m b/objectivec/GPBDescriptor.m
index bae9187e..ad46ef4f 100644
--- a/objectivec/GPBDescriptor.m
+++ b/objectivec/GPBDescriptor.m
@@ -35,10 +35,17 @@
#import "GPBUtilities_PackagePrivate.h"
#import "GPBWireFormat.h"
#import "GPBMessage_PackagePrivate.h"
-#import "google/protobuf/Descriptor.pbobjc.h"
-// The address of this variable is used as a key for obj_getAssociatedObject.
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
+// The addresses of these variables are used as keys for objc_getAssociatedObject.
static const char kTextFormatExtraValueKey = 0;
+static const char kParentClassNameValueKey = 0;
+static const char kClassNameSuffixKey = 0;
// Utility function to generate selectors on the fly.
static SEL SelFromStrings(const char *prefix, const char *middle,
@@ -92,7 +99,6 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex,
@implementation GPBDescriptor {
Class messageClass_;
- NSArray *enums_;
GPBFileDescriptor *file_;
BOOL wireFormat_;
}
@@ -100,7 +106,6 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex,
@synthesize messageClass = messageClass_;
@synthesize fields = fields_;
@synthesize oneofs = oneofs_;
-@synthesize enums = enums_;
@synthesize extensionRanges = extensionRanges_;
@synthesize extensionRangesCount = extensionRangesCount_;
@synthesize file = file_;
@@ -110,130 +115,58 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex,
allocDescriptorForClass:(Class)messageClass
rootClass:(Class)rootClass
file:(GPBFileDescriptor *)file
- fields:(GPBMessageFieldDescription *)fieldDescriptions
- fieldCount:(NSUInteger)fieldCount
- oneofs:(GPBMessageOneofDescription *)oneofDescriptions
- oneofCount:(NSUInteger)oneofCount
- enums:(GPBMessageEnumDescription *)enumDescriptions
- enumCount:(NSUInteger)enumCount
- ranges:(const GPBExtensionRange *)ranges
- rangeCount:(NSUInteger)rangeCount
- storageSize:(size_t)storageSize
- wireFormat:(BOOL)wireFormat {
+ 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;
- NSMutableArray *oneofs = nil;
- NSMutableArray *enums = nil;
- NSMutableArray *extensionRanges = nil;
GPBFileSyntax syntax = file.syntax;
- for (NSUInteger i = 0; i < fieldCount; ++i) {
+ BOOL fieldsIncludeDefault =
+ (flags & GPBDescriptorInitializationFlag_FieldsWithDefault) != 0;
+
+ void *desc;
+ for (uint32_t i = 0; i < fieldCount; ++i) {
if (fields == nil) {
fields = [[NSMutableArray alloc] initWithCapacity:fieldCount];
}
- GPBFieldDescriptor *fieldDescriptor = [[GPBFieldDescriptor alloc]
- initWithFieldDescription:&fieldDescriptions[i]
- rootClass:rootClass
- syntax:syntax];
+ // Need correctly typed pointer for array indexing below to work.
+ if (fieldsIncludeDefault) {
+ GPBMessageFieldDescriptionWithDefault *fieldDescWithDefault = fieldDescriptions;
+ desc = &(fieldDescWithDefault[i]);
+ } else {
+ GPBMessageFieldDescription *fieldDesc = fieldDescriptions;
+ desc = &(fieldDesc[i]);
+ }
+ GPBFieldDescriptor *fieldDescriptor =
+ [[GPBFieldDescriptor alloc] initWithFieldDescription:desc
+ includesDefault:fieldsIncludeDefault
+ syntax:syntax];
[fields addObject:fieldDescriptor];
[fieldDescriptor release];
}
- for (NSUInteger i = 0; i < oneofCount; ++i) {
- if (oneofs == nil) {
- oneofs = [[NSMutableArray alloc] initWithCapacity:oneofCount];
- }
- GPBMessageOneofDescription *oneofDescription = &oneofDescriptions[i];
- NSArray *fieldsForOneof =
- NewFieldsArrayForHasIndex(oneofDescription->index, fields);
- GPBOneofDescriptor *oneofDescriptor =
- [[GPBOneofDescriptor alloc] initWithOneofDescription:oneofDescription
- fields:fieldsForOneof];
- [oneofs addObject:oneofDescriptor];
- [oneofDescriptor release];
- [fieldsForOneof release];
- }
- for (NSUInteger i = 0; i < enumCount; ++i) {
- if (enums == nil) {
- enums = [[NSMutableArray alloc] initWithCapacity:enumCount];
- }
- GPBEnumDescriptor *enumDescriptor =
- enumDescriptions[i].enumDescriptorFunc();
- [enums addObject:enumDescriptor];
- }
+ BOOL wireFormat = (flags & GPBDescriptorInitializationFlag_WireFormat) != 0;
GPBDescriptor *descriptor = [[self alloc] initWithClass:messageClass
file:file
fields:fields
- oneofs:oneofs
- enums:enums
- extensionRanges:ranges
- extensionRangesCount:rangeCount
storageSize:storageSize
wireFormat:wireFormat];
[fields release];
- [oneofs release];
- [enums release];
- [extensionRanges release];
- return descriptor;
-}
-
-+ (instancetype)
- allocDescriptorForClass:(Class)messageClass
- rootClass:(Class)rootClass
- file:(GPBFileDescriptor *)file
- fields:(GPBMessageFieldDescription *)fieldDescriptions
- fieldCount:(NSUInteger)fieldCount
- oneofs:(GPBMessageOneofDescription *)oneofDescriptions
- oneofCount:(NSUInteger)oneofCount
- enums:(GPBMessageEnumDescription *)enumDescriptions
- enumCount:(NSUInteger)enumCount
- ranges:(const GPBExtensionRange *)ranges
- rangeCount:(NSUInteger)rangeCount
- storageSize:(size_t)storageSize
- wireFormat:(BOOL)wireFormat
- extraTextFormatInfo:(const char *)extraTextFormatInfo {
- GPBDescriptor *descriptor = [self allocDescriptorForClass:messageClass
- rootClass:rootClass
- file:file
- fields:fieldDescriptions
- fieldCount:fieldCount
- oneofs:oneofDescriptions
- oneofCount:oneofCount
- enums:enumDescriptions
- enumCount:enumCount
- ranges:ranges
- rangeCount:rangeCount
- storageSize:storageSize
- wireFormat:wireFormat];
- // Extra info is a compile time option, so skip the work if not needed.
- if (extraTextFormatInfo) {
- NSValue *extraInfoValue = [NSValue valueWithPointer:extraTextFormatInfo];
- for (GPBFieldDescriptor *fieldDescriptor in descriptor->fields_) {
- if (fieldDescriptor->description_->flags & GPBFieldTextFormatNameCustom) {
- objc_setAssociatedObject(fieldDescriptor, &kTextFormatExtraValueKey,
- extraInfoValue,
- OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- }
- }
- }
return descriptor;
}
- (instancetype)initWithClass:(Class)messageClass
file:(GPBFileDescriptor *)file
fields:(NSArray *)fields
- oneofs:(NSArray *)oneofs
- enums:(NSArray *)enums
- extensionRanges:(const GPBExtensionRange *)extensionRanges
- extensionRangesCount:(NSUInteger)extensionRangesCount
- storageSize:(size_t)storageSize
+ storageSize:(uint32_t)storageSize
wireFormat:(BOOL)wireFormat {
if ((self = [super init])) {
messageClass_ = messageClass;
file_ = file;
fields_ = [fields retain];
- oneofs_ = [oneofs retain];
- enums_ = [enums retain];
- extensionRanges_ = extensionRanges;
- extensionRangesCount_ = extensionRangesCount;
storageSize_ = storageSize;
wireFormat_ = wireFormat;
}
@@ -243,14 +176,143 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex,
- (void)dealloc {
[fields_ release];
[oneofs_ release];
- [enums_ release];
[super dealloc];
}
+- (void)setupOneofs:(const char **)oneofNames
+ count:(uint32_t)count
+ firstHasIndex:(int32_t)firstHasIndex {
+ NSCAssert(firstHasIndex < 0, @"Should always be <0");
+ NSMutableArray *oneofs = [[NSMutableArray alloc] initWithCapacity:count];
+ 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];
+ [oneofs addObject:oneofDescriptor];
+ [oneofDescriptor release];
+ [fieldsForOneof release];
+ }
+ oneofs_ = oneofs;
+}
+
+- (void)setupExtraTextInfo:(const char *)extraTextFormatInfo {
+ // Extra info is a compile time option, so skip the work if not needed.
+ if (extraTextFormatInfo) {
+ NSValue *extraInfoValue = [NSValue valueWithPointer:extraTextFormatInfo];
+ for (GPBFieldDescriptor *fieldDescriptor in fields_) {
+ if (fieldDescriptor->description_->flags & GPBFieldTextFormatNameCustom) {
+ objc_setAssociatedObject(fieldDescriptor, &kTextFormatExtraValueKey,
+ extraInfoValue,
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ }
+ }
+}
+
+- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count {
+ extensionRanges_ = ranges;
+ extensionRangesCount_ = count;
+}
+
+- (void)setupContainingMessageClassName:(const char *)msgClassName {
+ // Note: Only fetch the class here, can't send messages to it because
+ // that could cause cycles back to this class within +initialize if
+ // two messages have each other in fields (i.e. - they build a graph).
+ NSAssert(objc_getClass(msgClassName), @"Class %s not defined", msgClassName);
+ NSValue *parentNameValue = [NSValue valueWithPointer:msgClassName];
+ objc_setAssociatedObject(self, &kParentClassNameValueKey,
+ parentNameValue,
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+- (void)setupMessageClassNameSuffix:(NSString *)suffix {
+ if (suffix.length) {
+ objc_setAssociatedObject(self, &kClassNameSuffixKey,
+ suffix,
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+}
+
- (NSString *)name {
return NSStringFromClass(messageClass_);
}
+- (GPBDescriptor *)containingType {
+ NSValue *parentNameValue =
+ objc_getAssociatedObject(self, &kParentClassNameValueKey);
+ if (!parentNameValue) {
+ return nil;
+ }
+ const char *parentName = [parentNameValue pointerValue];
+ Class parentClass = objc_getClass(parentName);
+ NSAssert(parentClass, @"Class %s not defined", parentName);
+ return [parentClass descriptor];
+}
+
+- (NSString *)fullName {
+ NSString *className = NSStringFromClass(self.messageClass);
+ GPBFileDescriptor *file = self.file;
+ NSString *objcPrefix = file.objcPrefix;
+ if (objcPrefix && ![className hasPrefix:objcPrefix]) {
+ NSAssert(0,
+ @"Class didn't have correct prefix? (%@ - %@)",
+ className, objcPrefix);
+ return nil;
+ }
+ GPBDescriptor *parent = self.containingType;
+
+ NSString *name = nil;
+ if (parent) {
+ NSString *parentClassName = NSStringFromClass(parent.messageClass);
+ // The generator will add _Class to avoid reserved words, drop it.
+ NSString *suffix = objc_getAssociatedObject(parent, &kClassNameSuffixKey);
+ if (suffix) {
+ if (![parentClassName hasSuffix:suffix]) {
+ NSAssert(0,
+ @"ParentMessage class didn't have correct suffix? (%@ - %@)",
+ className, suffix);
+ return nil;
+ }
+ 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);
+ return nil;
+ }
+ name = [className substringFromIndex:parentPrefix.length];
+ } else {
+ name = [className substringFromIndex:objcPrefix.length];
+ }
+
+ // The generator will add _Class to avoid reserved words, drop it.
+ NSString *suffix = objc_getAssociatedObject(self, &kClassNameSuffixKey);
+ if (suffix) {
+ if (![name hasSuffix:suffix]) {
+ NSAssert(0,
+ @"Message class didn't have correct suffix? (%@ - %@)",
+ name, suffix);
+ return nil;
+ }
+ name = [name substringToIndex:(name.length - suffix.length)];
+ }
+
+ NSString *prefix = (parent != nil ? parent.fullName : file.package);
+ NSString *result;
+ if (prefix.length > 0) {
+ result = [NSString stringWithFormat:@"%@.%@", prefix, name];
+ } else {
+ result = name;
+ }
+ return result;
+}
+
- (id)copyWithZone:(NSZone *)zone {
#pragma unused(zone)
return [self retain];
@@ -283,26 +345,31 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex,
return nil;
}
-- (GPBEnumDescriptor *)enumWithName:(NSString *)name {
- for (GPBEnumDescriptor *descriptor in enums_) {
- if ([descriptor.name isEqual:name]) {
- return descriptor;
- }
- }
- return nil;
-}
-
@end
@implementation GPBFileDescriptor {
NSString *package_;
+ NSString *objcPrefix_;
GPBFileSyntax syntax_;
}
@synthesize package = package_;
+@synthesize objcPrefix = objcPrefix_;
@synthesize syntax = syntax_;
- (instancetype)initWithPackage:(NSString *)package
+ objcPrefix:(NSString *)objcPrefix
+ syntax:(GPBFileSyntax)syntax {
+ self = [super init];
+ if (self) {
+ package_ = [package copy];
+ objcPrefix_ = [objcPrefix copy];
+ syntax_ = syntax;
+ }
+ return self;
+}
+
+- (instancetype)initWithPackage:(NSString *)package
syntax:(GPBFileSyntax)syntax {
self = [super init];
if (self) {
@@ -312,25 +379,28 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex,
return self;
}
+- (void)dealloc {
+ [package_ release];
+ [objcPrefix_ release];
+ [super dealloc];
+}
+
@end
@implementation GPBOneofDescriptor
@synthesize fields = fields_;
-- (instancetype)initWithOneofDescription:
- (GPBMessageOneofDescription *)oneofDescription
- fields:(NSArray *)fields {
+- (instancetype)initWithName:(const char *)name fields:(NSArray *)fields {
self = [super init];
if (self) {
- NSAssert(oneofDescription->index < 0, @"Should always be <0");
- oneofDescription_ = oneofDescription;
+ name_ = name;
fields_ = [fields retain];
for (GPBFieldDescriptor *fieldDesc in fields) {
fieldDesc->containingOneof_ = self;
}
- caseSel_ = SelFromStrings(NULL, oneofDescription->name, "OneOfCase", NO);
+ caseSel_ = SelFromStrings(NULL, name, "OneOfCase", NO);
}
return self;
}
@@ -341,7 +411,7 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex,
}
- (NSString *)name {
- return @(oneofDescription_->name);
+ return (NSString * _Nonnull)@(name_);
}
- (GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber {
@@ -389,7 +459,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
@implementation GPBFieldDescriptor {
GPBGenericValue defaultValue_;
- GPBFieldOptions *fieldOptions_;
// Message ivars
Class msgClass_;
@@ -403,7 +472,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
} enumHandling_;
}
-@synthesize fieldOptions = fieldOptions_;
@synthesize msgClass = msgClass_;
@synthesize containingOneof = containingOneof_;
@@ -417,16 +485,21 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
return self;
}
-- (instancetype)initWithFieldDescription:
- (GPBMessageFieldDescription *)description
- rootClass:(Class)rootClass
+- (instancetype)initWithFieldDescription:(void *)description
+ includesDefault:(BOOL)includesDefault
syntax:(GPBFileSyntax)syntax {
if ((self = [super init])) {
- description_ = description;
- getSel_ = sel_getUid(description->name);
- setSel_ = SelFromStrings("set", description->name, NULL, YES);
+ GPBMessageFieldDescription *coreDesc;
+ if (includesDefault) {
+ coreDesc = &(((GPBMessageFieldDescriptionWithDefault *)description)->core);
+ } else {
+ coreDesc = description;
+ }
+ description_ = coreDesc;
+ getSel_ = sel_getUid(coreDesc->name);
+ setSel_ = SelFromStrings("set", coreDesc->name, NULL, YES);
- GPBDataType dataType = description->dataType;
+ GPBDataType dataType = coreDesc->dataType;
BOOL isMessage = GPBDataTypeIsMessage(dataType);
BOOL isMapOrArray = GPBFieldIsMapOrArray(self);
@@ -434,45 +507,49 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
// map<>/repeated fields get a *Count property (inplace of a has*) to
// support checking if there are any entries without triggering
// autocreation.
- hasOrCountSel_ = SelFromStrings(NULL, description->name, "_Count", NO);
+ hasOrCountSel_ = SelFromStrings(NULL, coreDesc->name, "_Count", NO);
} else {
// If there is a positive hasIndex, then:
// - All fields types for proto2 messages get has* selectors.
// - Only message fields for proto3 messages get has* selectors.
// Note: the positive check is to handle oneOfs, we can't check
// containingOneof_ because it isn't set until after initialization.
- if ((description->hasIndex >= 0) &&
- (description->hasIndex != GPBNoHasBit) &&
+ if ((coreDesc->hasIndex >= 0) &&
+ (coreDesc->hasIndex != GPBNoHasBit) &&
((syntax != GPBFileSyntaxProto3) || isMessage)) {
- hasOrCountSel_ = SelFromStrings("has", description->name, NULL, NO);
- setHasSel_ = SelFromStrings("setHas", description->name, NULL, YES);
+ hasOrCountSel_ = SelFromStrings("has", coreDesc->name, NULL, NO);
+ setHasSel_ = SelFromStrings("setHas", coreDesc->name, NULL, YES);
}
}
// Extra type specific data.
if (isMessage) {
- const char *className = description->dataTypeSpecific.className;
+ const char *className = coreDesc->dataTypeSpecific.className;
+ // Note: Only fetch the class here, can't send messages to it because
+ // that could cause cycles back to this class within +initialize if
+ // two messages have each other in fields (i.e. - they build a graph).
msgClass_ = objc_getClass(className);
NSAssert(msgClass_, @"Class %s not defined", className);
} else if (dataType == GPBDataTypeEnum) {
- if ((description_->flags & GPBFieldHasEnumDescriptor) != 0) {
+ if ((coreDesc->flags & GPBFieldHasEnumDescriptor) != 0) {
enumHandling_.enumDescriptor_ =
- description->dataTypeSpecific.enumDescFunc();
+ coreDesc->dataTypeSpecific.enumDescFunc();
} else {
enumHandling_.enumVerifier_ =
- description->dataTypeSpecific.enumVerifier;
+ coreDesc->dataTypeSpecific.enumVerifier;
}
}
- // Non map<>/repeated fields can have defaults.
- if (!isMapOrArray) {
- defaultValue_ = description->defaultValue;
+ // Non map<>/repeated fields can have defaults in proto2 syntax.
+ if (!isMapOrArray && includesDefault) {
+ defaultValue_ = ((GPBMessageFieldDescriptionWithDefault *)description)->defaultValue;
if (dataType == GPBDataTypeBytes) {
// Data stored as a length prefixed (network byte order) c-string in
// descriptor structure.
const uint8_t *bytes = (const uint8_t *)defaultValue_.valueData;
if (bytes) {
- uint32_t length = *((uint32_t *)bytes);
+ uint32_t length;
+ memcpy(&length, bytes, sizeof(length));
length = ntohl(length);
bytes += sizeof(length);
defaultValue_.valueData =
@@ -480,24 +557,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
}
}
-
- // FieldOptions stored as a length prefixed (network byte order) c-escaped
- // string in descriptor records.
- if (description->fieldOptions) {
- uint8_t *optionsBytes = (uint8_t *)description->fieldOptions;
- uint32_t optionsLength = *((uint32_t *)optionsBytes);
- optionsLength = ntohl(optionsLength);
- if (optionsLength > 0) {
- optionsBytes += sizeof(optionsLength);
- NSData *optionsData = [NSData dataWithBytesNoCopy:optionsBytes
- length:optionsLength
- freeWhenDone:NO];
- GPBExtensionRegistry *registry = [rootClass extensionRegistry];
- fieldOptions_ = [[GPBFieldOptions parseFromData:optionsData
- extensionRegistry:registry
- error:NULL] retain];
- }
- }
}
return self;
}
@@ -523,7 +582,7 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
- (NSString *)name {
- return @(description_->name);
+ return (NSString * _Nonnull)@(description_->name);
}
- (BOOL)isRequired {
@@ -666,7 +725,7 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
} else {
// Undo the CamelCase.
NSMutableString *result = [NSMutableString stringWithCapacity:len];
- for (NSUInteger i = 0; i < len; i++) {
+ for (uint32_t i = 0; i < len; i++) {
unichar c = [name characterAtIndex:i];
if (c >= 'A' && c <= 'Z') {
if (i > 0) {
@@ -686,10 +745,16 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
@implementation GPBEnumDescriptor {
NSString *name_;
- GPBMessageEnumValueDescription *valueDescriptions_;
- NSUInteger valueDescriptionsCount_;
+ // valueNames_ is a single c string with all of the value names appended
+ // together, each null terminated. -calcValueNameOffsets fills in
+ // nameOffsets_ with the offsets to allow quicker access to the individual
+ // names.
+ const char *valueNames_;
+ const int32_t *values_;
GPBEnumValidationFunc enumVerifier_;
const uint8_t *extraTextFormatInfo_;
+ uint32_t *nameOffsets_;
+ uint32_t valueCount_;
}
@synthesize name = name_;
@@ -697,26 +762,30 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
+ (instancetype)
allocDescriptorForName:(NSString *)name
- values:(GPBMessageEnumValueDescription *)valueDescriptions
- valueCount:(NSUInteger)valueCount
+ valueNames:(const char *)valueNames
+ values:(const int32_t *)values
+ count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier {
GPBEnumDescriptor *descriptor = [[self alloc] initWithName:name
- values:valueDescriptions
- valueCount:valueCount
+ valueNames:valueNames
+ values:values
+ count:valueCount
enumVerifier:enumVerifier];
return descriptor;
}
+ (instancetype)
allocDescriptorForName:(NSString *)name
- values:(GPBMessageEnumValueDescription *)valueDescriptions
- valueCount:(NSUInteger)valueCount
+ 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
- values:valueDescriptions
- valueCount:valueCount
+ valueNames:valueNames
+ values:values
+ count:valueCount
enumVerifier:enumVerifier];
// Set the extra info.
descriptor->extraTextFormatInfo_ = (const uint8_t *)extraTextFormatInfo;
@@ -724,25 +793,46 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
- (instancetype)initWithName:(NSString *)name
- values:(GPBMessageEnumValueDescription *)valueDescriptions
- valueCount:(NSUInteger)valueCount
+ valueNames:(const char *)valueNames
+ values:(const int32_t *)values
+ count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier {
if ((self = [super init])) {
name_ = [name copy];
- valueDescriptions_ = valueDescriptions;
- valueDescriptionsCount_ = valueCount;
+ valueNames_ = valueNames;
+ values_ = values;
+ valueCount_ = valueCount;
enumVerifier_ = enumVerifier;
}
return self;
}
+- (void)dealloc {
+ [name_ release];
+ if (nameOffsets_) free(nameOffsets_);
+ [super dealloc];
+}
+
+- (void)calcValueNameOffsets {
+ @synchronized(self) {
+ if (nameOffsets_ != NULL) {
+ return;
+ }
+ uint32_t *offsets = malloc(valueCount_ * sizeof(uint32_t));
+ const char *scan = valueNames_;
+ for (uint32_t i = 0; i < valueCount_; ++i) {
+ offsets[i] = (uint32_t)(scan - valueNames_);
+ while (*scan != '\0') ++scan;
+ ++scan; // Step over the null.
+ }
+ nameOffsets_ = offsets;
+ }
+}
+
- (NSString *)enumNameForValue:(int32_t)number {
- for (NSUInteger i = 0; i < valueDescriptionsCount_; ++i) {
- GPBMessageEnumValueDescription *scan = &valueDescriptions_[i];
- if ((scan->number == number) && (scan->name != NULL)) {
- NSString *fullName =
- [NSString stringWithFormat:@"%@_%s", name_, scan->name];
- return fullName;
+ for (uint32_t i = 0; i < valueCount_; ++i) {
+ if (values_[i] == number) {
+ return [self getEnumNameForIndex:i];
}
}
return nil;
@@ -760,12 +850,14 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
const char *nameAsCStr = [name UTF8String];
nameAsCStr += prefixLen;
+ if (nameOffsets_ == NULL) [self calcValueNameOffsets];
+
// Find it.
- for (NSUInteger i = 0; i < valueDescriptionsCount_; ++i) {
- GPBMessageEnumValueDescription *scan = &valueDescriptions_[i];
- if ((scan->name != NULL) && (strcmp(nameAsCStr, scan->name) == 0)) {
+ for (uint32_t i = 0; i < valueCount_; ++i) {
+ const char *valueName = valueNames_ + nameOffsets_[i];
+ if (strcmp(nameAsCStr, valueName) == 0) {
if (outValue) {
- *outValue = scan->number;
+ *outValue = values_[i];
}
return YES;
}
@@ -773,39 +865,70 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
return NO;
}
-- (void)dealloc {
- [name_ release];
- [super dealloc];
+- (BOOL)getValue:(int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName {
+ if (nameOffsets_ == NULL) [self calcValueNameOffsets];
+
+ for (uint32_t i = 0; i < valueCount_; ++i) {
+ int32_t value = values_[i];
+ NSString *valueTextFormatName = [self textFormatNameForValue:value];
+ if ([valueTextFormatName isEqual:textFormatName]) {
+ if (outValue) {
+ *outValue = value;
+ }
+ return YES;
+ }
+ }
+ return NO;
}
- (NSString *)textFormatNameForValue:(int32_t)number {
// Find the EnumValue descriptor and its index.
- GPBMessageEnumValueDescription *valueDescriptor = NULL;
- NSUInteger valueDescriptorIndex;
- for (valueDescriptorIndex = 0; valueDescriptorIndex < valueDescriptionsCount_;
+ BOOL foundIt = NO;
+ uint32_t valueDescriptorIndex;
+ for (valueDescriptorIndex = 0; valueDescriptorIndex < valueCount_;
++valueDescriptorIndex) {
- GPBMessageEnumValueDescription *scan =
- &valueDescriptions_[valueDescriptorIndex];
- if (scan->number == number) {
- valueDescriptor = scan;
+ if (values_[valueDescriptorIndex] == number) {
+ foundIt = YES;
break;
}
}
- // If we didn't find it, or names were disable at proto compile time, nothing
- // we can do.
- if (!valueDescriptor || !valueDescriptor->name) {
+ if (!foundIt) {
return nil;
}
+ return [self getEnumTextFormatNameForIndex:valueDescriptorIndex];
+}
+- (uint32_t)enumNameCount {
+ return valueCount_;
+}
+
+- (NSString *)getEnumNameForIndex:(uint32_t)index {
+ if (nameOffsets_ == NULL) [self calcValueNameOffsets];
+
+ if (index >= valueCount_) {
+ return nil;
+ }
+ const char *valueName = valueNames_ + nameOffsets_[index];
+ NSString *fullName = [NSString stringWithFormat:@"%@_%s", name_, valueName];
+ return fullName;
+}
+
+- (NSString *)getEnumTextFormatNameForIndex:(uint32_t)index {
+ if (nameOffsets_ == NULL) [self calcValueNameOffsets];
+
+ if (index >= valueCount_) {
+ return nil;
+ }
NSString *result = nil;
// Naming adds an underscore between enum name and value name, skip that also.
- NSString *shortName = @(valueDescriptor->name);
+ const char *valueName = valueNames_ + nameOffsets_[index];
+ NSString *shortName = @(valueName);
// See if it is in the map of special format handling.
if (extraTextFormatInfo_) {
result = GPBDecodeTextFormatName(extraTextFormatInfo_,
- (int32_t)valueDescriptorIndex, shortName);
+ (int32_t)index, shortName);
}
// Logic here needs to match what objectivec_enum.cc does in the proto
// compiler.
@@ -837,7 +960,7 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
if ((self = [super init])) {
description_ = description;
-#if DEBUG
+#if defined(DEBUG) && DEBUG
const char *className = description->messageOrGroupClassName;
if (className) {
NSAssert(objc_lookUpClass(className) != Nil,
@@ -858,7 +981,8 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
const uint8_t *bytes =
(const uint8_t *)description->defaultValue.valueData;
if (bytes) {
- uint32_t length = *((uint32_t *)bytes);
+ uint32_t length;
+ memcpy(&length, bytes, sizeof(length));
// The length is stored in network byte order.
length = ntohl(length);
bytes += sizeof(length);
@@ -891,7 +1015,7 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
- (NSString *)singletonName {
- return @(description_->singletonName);
+ return (NSString * _Nonnull)@(description_->singletonName);
}
- (const char *)singletonNameC {
@@ -922,10 +1046,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
return GPBExtensionIsRepeated(description_);
}
-- (BOOL)isMap {
- return (description_->options & GPBFieldMapKeyMask) != 0;
-}
-
- (BOOL)isPackable {
return GPBExtensionIsPacked(description_);
}
@@ -995,3 +1115,5 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
}
@end
+
+#pragma clang diagnostic pop
diff --git a/objectivec/GPBDescriptor_PackagePrivate.h b/objectivec/GPBDescriptor_PackagePrivate.h
index 7987d928..452b3f8e 100644
--- a/objectivec/GPBDescriptor_PackagePrivate.h
+++ b/objectivec/GPBDescriptor_PackagePrivate.h
@@ -36,7 +36,8 @@
#import "GPBWireFormat.h"
// Describes attributes of the field.
-typedef NS_OPTIONS(uint32_t, GPBFieldFlags) {
+typedef NS_OPTIONS(uint16_t, GPBFieldFlags) {
+ GPBFieldNone = 0,
// These map to standard protobuf concepts.
GPBFieldRequired = 1 << 0,
GPBFieldRepeated = 1 << 1,
@@ -44,6 +45,12 @@ typedef NS_OPTIONS(uint32_t, GPBFieldFlags) {
GPBFieldOptional = 1 << 3,
GPBFieldHasDefaultValue = 1 << 4,
+ // Indicates the field needs custom handling for the TextFormat name, if not
+ // set, the name can be derived from the ObjC name.
+ GPBFieldTextFormatNameCustom = 1 << 6,
+ // Indicates the field has an enum descriptor.
+ GPBFieldHasEnumDescriptor = 1 << 7,
+
// These are not standard protobuf concepts, they are specific to the
// Objective C runtime.
@@ -62,67 +69,50 @@ typedef NS_OPTIONS(uint32_t, GPBFieldFlags) {
GPBFieldMapKeySFixed64 = 10 << 8,
GPBFieldMapKeyBool = 11 << 8,
GPBFieldMapKeyString = 12 << 8,
-
- // Indicates the field needs custom handling for the TextFormat name, if not
- // set, the name can be derived from the ObjC name.
- GPBFieldTextFormatNameCustom = 1 << 16,
- // Indicates the field has an enum descriptor.
- GPBFieldHasEnumDescriptor = 1 << 17,
};
+// NOTE: The structures defined here have their members ordered to minimize
+// their size. This directly impacts the size of apps since these exist per
+// field/extension.
+
// Describes a single field in a protobuf as it is represented as an ivar.
typedef struct GPBMessageFieldDescription {
// Name of ivar.
const char *name;
+ union {
+ const char *className; // Name for message class.
+ // For enums only: If EnumDescriptors are compiled in, it will be that,
+ // otherwise it will be the verifier.
+ GPBEnumDescriptorFunc enumDescFunc;
+ GPBEnumValidationFunc enumVerifier;
+ } dataTypeSpecific;
// The field number for the ivar.
uint32_t number;
// The index (in bits) into _has_storage_.
- // > 0: the bit to use for a value being set.
- // = 0: no storage used.
+ // >= 0: the bit to use for a value being set.
+ // = GPBNoHasBit(INT32_MAX): no storage used.
// < 0: in a oneOf, use a full int32 to record the field active.
int32_t hasIndex;
+ // Offset of the variable into it's structure struct.
+ uint32_t offset;
// Field flags. Use accessor functions below.
GPBFieldFlags flags;
// Data type of the ivar.
GPBDataType dataType;
- // Offset of the variable into it's structure struct.
- size_t offset;
- // FieldOptions protobuf, serialized as string.
- const char *fieldOptions;
-
- GPBGenericValue defaultValue; // Default value for the ivar.
- union {
- const char *className; // Name for message class.
- // For enums only: If EnumDescriptors are compiled in, it will be that,
- // otherwise it will be the verifier.
- GPBEnumDescriptorFunc enumDescFunc;
- GPBEnumValidationFunc enumVerifier;
- } dataTypeSpecific;
} GPBMessageFieldDescription;
-// Describes a oneof.
-typedef struct GPBMessageOneofDescription {
- // Name of this enum oneof.
- const char *name;
- // The index of this oneof in the has_storage.
- int32_t index;
-} GPBMessageOneofDescription;
-
-// Describes an enum type defined in a .proto file.
-typedef struct GPBMessageEnumDescription {
- GPBEnumDescriptorFunc enumDescriptorFunc;
-} GPBMessageEnumDescription;
+// Fields in messages defined in a 'proto2' syntax file can provide a default
+// value. This struct provides the default along with the field info.
+typedef struct GPBMessageFieldDescriptionWithDefault {
+ // Default value for the ivar.
+ GPBGenericValue defaultValue;
-// Describes an individual enum constant of a particular type.
-typedef struct GPBMessageEnumValueDescription {
- // Name of this enum constant.
- const char *name;
- // Numeric value of this enum constant.
- int32_t number;
-} GPBMessageEnumValueDescription;
+ GPBMessageFieldDescription core;
+} GPBMessageFieldDescriptionWithDefault;
// Describes attributes of the extension.
-typedef NS_OPTIONS(uint32_t, GPBExtensionOptions) {
+typedef NS_OPTIONS(uint8_t, GPBExtensionOptions) {
+ GPBExtensionNone = 0,
// These map to standard protobuf concepts.
GPBExtensionRepeated = 1 << 0,
GPBExtensionPacked = 1 << 1,
@@ -131,82 +121,74 @@ typedef NS_OPTIONS(uint32_t, GPBExtensionOptions) {
// An extension
typedef struct GPBExtensionDescription {
+ GPBGenericValue defaultValue;
const char *singletonName;
- GPBDataType dataType;
const char *extendedClass;
- int32_t fieldNumber;
- GPBGenericValue defaultValue;
const char *messageOrGroupClassName;
- GPBExtensionOptions options;
GPBEnumDescriptorFunc enumDescriptorFunc;
+ int32_t fieldNumber;
+ GPBDataType dataType;
+ GPBExtensionOptions options;
} GPBExtensionDescription;
+typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
+ GPBDescriptorInitializationFlag_None = 0,
+ GPBDescriptorInitializationFlag_FieldsWithDefault = 1 << 0,
+ GPBDescriptorInitializationFlag_WireFormat = 1 << 1,
+};
+
@interface GPBDescriptor () {
@package
NSArray *fields_;
NSArray *oneofs_;
- size_t storageSize_;
+ uint32_t storageSize_;
}
-// fieldDescriptions, enumDescriptions, rangeDescriptions, and
-// extraTextFormatInfo have to be long lived, they are held as raw pointers.
+// fieldDescriptions have to be long lived, they are held as raw pointers.
+ (instancetype)
allocDescriptorForClass:(Class)messageClass
rootClass:(Class)rootClass
file:(GPBFileDescriptor *)file
- fields:(GPBMessageFieldDescription *)fieldDescriptions
- fieldCount:(NSUInteger)fieldCount
- oneofs:(GPBMessageOneofDescription *)oneofDescriptions
- oneofCount:(NSUInteger)oneofCount
- enums:(GPBMessageEnumDescription *)enumDescriptions
- enumCount:(NSUInteger)enumCount
- ranges:(const GPBExtensionRange *)ranges
- rangeCount:(NSUInteger)rangeCount
- storageSize:(size_t)storageSize
- wireFormat:(BOOL)wireFormat;
-+ (instancetype)
- allocDescriptorForClass:(Class)messageClass
- rootClass:(Class)rootClass
- file:(GPBFileDescriptor *)file
- fields:(GPBMessageFieldDescription *)fieldDescriptions
- fieldCount:(NSUInteger)fieldCount
- oneofs:(GPBMessageOneofDescription *)oneofDescriptions
- oneofCount:(NSUInteger)oneofCount
- enums:(GPBMessageEnumDescription *)enumDescriptions
- enumCount:(NSUInteger)enumCount
- ranges:(const GPBExtensionRange *)ranges
- rangeCount:(NSUInteger)rangeCount
- storageSize:(size_t)storageSize
- wireFormat:(BOOL)wireFormat
- extraTextFormatInfo:(const char *)extraTextFormatInfo;
+ fields:(void *)fieldDescriptions
+ fieldCount:(uint32_t)fieldCount
+ storageSize:(uint32_t)storageSize
+ flags:(GPBDescriptorInitializationFlags)flags;
- (instancetype)initWithClass:(Class)messageClass
file:(GPBFileDescriptor *)file
fields:(NSArray *)fields
- oneofs:(NSArray *)oneofs
- enums:(NSArray *)enums
- extensionRanges:(const GPBExtensionRange *)ranges
- extensionRangesCount:(NSUInteger)rangeCount
- storageSize:(size_t)storage
+ storageSize:(uint32_t)storage
wireFormat:(BOOL)wireFormat;
+// Called right after init to provide extra information to avoid init having
+// an explosion of args. These pointers are recorded, so they are expected
+// to live for the lifetime of the app.
+- (void)setupOneofs:(const char **)oneofNames
+ count:(uint32_t)count
+ firstHasIndex:(int32_t)firstHasIndex;
+- (void)setupExtraTextInfo:(const char *)extraTextFormatInfo;
+- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count;
+- (void)setupContainingMessageClassName:(const char *)msgClassName;
+- (void)setupMessageClassNameSuffix:(NSString *)suffix;
+
@end
@interface GPBFileDescriptor ()
- (instancetype)initWithPackage:(NSString *)package
+ objcPrefix:(NSString *)objcPrefix
+ syntax:(GPBFileSyntax)syntax;
+- (instancetype)initWithPackage:(NSString *)package
syntax:(GPBFileSyntax)syntax;
@end
@interface GPBOneofDescriptor () {
@package
- GPBMessageOneofDescription *oneofDescription_;
+ const char *name_;
NSArray *fields_;
-
SEL caseSel_;
}
-- (instancetype)initWithOneofDescription:
- (GPBMessageOneofDescription *)oneofDescription
- fields:(NSArray *)fields;
+// name must be long lived.
+- (instancetype)initWithName:(const char *)name fields:(NSArray *)fields;
@end
@interface GPBFieldDescriptor () {
@@ -222,30 +204,32 @@ typedef struct GPBExtensionDescription {
// Single initializer
// description has to be long lived, it is held as a raw pointer.
-- (instancetype)initWithFieldDescription:
- (GPBMessageFieldDescription *)description
- rootClass:(Class)rootClass
+- (instancetype)initWithFieldDescription:(void *)description
+ includesDefault:(BOOL)includesDefault
syntax:(GPBFileSyntax)syntax;
@end
@interface GPBEnumDescriptor ()
-// valueDescriptions and extraTextFormatInfo have to be long lived, they are
+// valueNames, values and extraTextFormatInfo have to be long lived, they are
// held as raw pointers.
+ (instancetype)
allocDescriptorForName:(NSString *)name
- values:(GPBMessageEnumValueDescription *)valueDescriptions
- valueCount:(NSUInteger)valueCount
+ valueNames:(const char *)valueNames
+ values:(const int32_t *)values
+ count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier;
+ (instancetype)
allocDescriptorForName:(NSString *)name
- values:(GPBMessageEnumValueDescription *)valueDescriptions
- valueCount:(NSUInteger)valueCount
+ valueNames:(const char *)valueNames
+ values:(const int32_t *)values
+ count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier
extraTextFormatInfo:(const char *)extraTextFormatInfo;
- (instancetype)initWithName:(NSString *)name
- values:(GPBMessageEnumValueDescription *)valueDescriptions
- valueCount:(NSUInteger)valueCount
+ valueNames:(const char *)valueNames
+ values:(const int32_t *)values
+ count:(uint32_t)valueCount
enumVerifier:(GPBEnumValidationFunc)enumVerifier;
@end
@@ -269,6 +253,12 @@ typedef struct GPBExtensionDescription {
CF_EXTERN_C_BEGIN
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
GPB_INLINE BOOL GPBFieldIsMapOrArray(GPBFieldDescriptor *field) {
return (field->description_->flags &
(GPBFieldRepeated | GPBFieldMapKeyMask)) != 0;
@@ -286,6 +276,8 @@ GPB_INLINE uint32_t GPBFieldNumber(GPBFieldDescriptor *field) {
return field->description_->number;
}
+#pragma clang diagnostic pop
+
uint32_t GPBFieldTag(GPBFieldDescriptor *self);
// For repeated fields, alternateWireType is the wireType with the opposite
@@ -294,10 +286,6 @@ uint32_t GPBFieldTag(GPBFieldDescriptor *self);
// would be the wire type for packed.
uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self);
-GPB_INLINE BOOL GPBPreserveUnknownFields(GPBFileSyntax syntax) {
- return syntax != GPBFileSyntaxProto3;
-}
-
GPB_INLINE BOOL GPBHasPreservingUnknownEnumSemantics(GPBFileSyntax syntax) {
return syntax == GPBFileSyntaxProto3;
}
@@ -314,5 +302,24 @@ GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) {
return (description->options & GPBExtensionSetWireFormat) != 0;
}
+// Helper for compile time assets.
+#ifndef GPBInternalCompileAssert
+ #if __has_feature(c_static_assert) || __has_extension(c_static_assert)
+ #define GPBInternalCompileAssert(test, msg) _Static_assert((test), #msg)
+ #else
+ // Pre-Xcode 7 support.
+ #define GPBInternalCompileAssertSymbolInner(line, msg) GPBInternalCompileAssert ## line ## __ ## msg
+ #define GPBInternalCompileAssertSymbol(line, msg) GPBInternalCompileAssertSymbolInner(line, msg)
+ #define GPBInternalCompileAssert(test, msg) \
+ typedef char GPBInternalCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
+ #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert)
+#endif // GPBInternalCompileAssert
+
+// Sanity check that there isn't padding between the field description
+// structures with and without a default.
+GPBInternalCompileAssert(sizeof(GPBMessageFieldDescriptionWithDefault) ==
+ (sizeof(GPBGenericValue) +
+ sizeof(GPBMessageFieldDescription)),
+ DescriptionsWithDefault_different_size_than_expected);
CF_EXTERN_C_END
diff --git a/objectivec/GPBDictionary.h b/objectivec/GPBDictionary.h
index 6961cfc3..a81165e8 100644
--- a/objectivec/GPBDictionary.h
+++ b/objectivec/GPBDictionary.h
@@ -32,10 +32,14 @@
#import "GPBRuntimeTypes.h"
-// These classes are used for map fields of basic data types. They are used because
-// they perform better than boxing into NSNumbers in NSDictionaries.
-
-// Note: These are not meant to be subclassed.
+// Note on naming: for the classes holding numeric values, a more natural
+// naming of the method might be things like "-valueForKey:",
+// "-setValue:forKey:"; etc. But those selectors are also defined by Key Value
+// Coding (KVC) as categories on NSObject. So "overloading" the selectors with
+// other meanings can cause warnings (based on compiler settings), but more
+// importantly, some of those selector get called as KVC breaks up keypaths.
+// So if those selectors are used, using KVC will compile cleanly, but could
+// crash as it invokes those selectors with the wrong types of arguments.
NS_ASSUME_NONNULL_BEGIN
@@ -44,275 +48,727 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - UInt32 -> UInt32
+/**
+ * Class used for map fields of <uint32_t, uint32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt32UInt32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(uint32_t)key;
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint32_t)key value:(nullable uint32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(uint32_t key, uint32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary;
-- (void)setValue:(uint32_t)value forKey:(uint32_t)key;
-
-- (void)removeValueForKey:(uint32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt32:(uint32_t)value forKey:(uint32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt32ForKey:(uint32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt32 -> Int32
+/**
+ * Class used for map fields of <uint32_t, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt32Int32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(uint32_t)key;
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32Int32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint32_t)key value:(nullable int32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(uint32_t key, int32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary;
-- (void)setValue:(int32_t)value forKey:(uint32_t)key;
-
-- (void)removeValueForKey:(uint32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt32:(int32_t)value forKey:(uint32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt32ForKey:(uint32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt32 -> UInt64
+/**
+ * Class used for map fields of <uint32_t, uint64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt32UInt64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(uint32_t)key;
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint32_t)key value:(nullable uint64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(uint32_t key, uint64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary;
-- (void)setValue:(uint64_t)value forKey:(uint32_t)key;
-
-- (void)removeValueForKey:(uint32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt64:(uint64_t)value forKey:(uint32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt64ForKey:(uint32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt32 -> Int64
+/**
+ * Class used for map fields of <uint32_t, int64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt32Int64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(uint32_t)key;
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32Int64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int64_t [])values
- forKeys:(const uint32_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint32_t)key value:(nullable int64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(uint32_t key, int64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary;
-- (void)setValue:(int64_t)value forKey:(uint32_t)key;
-
-- (void)removeValueForKey:(uint32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt64:(int64_t)value forKey:(uint32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt64ForKey:(uint32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt32 -> Bool
+/**
+ * Class used for map fields of <uint32_t, BOOL>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt32BoolDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(uint32_t)key;
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32BoolDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint32_t)key value:(nullable BOOL *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(uint32_t key, BOOL value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary;
-- (void)setValue:(BOOL)value forKey:(uint32_t)key;
-
-- (void)removeValueForKey:(uint32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setBool:(BOOL)value forKey:(uint32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeBoolForKey:(uint32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt32 -> Float
+/**
+ * Class used for map fields of <uint32_t, float>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt32FloatDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(uint32_t)key;
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32FloatDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const float [])values
- forKeys:(const uint32_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint32_t)key value:(nullable float *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(uint32_t key, float value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary;
-- (void)setValue:(float)value forKey:(uint32_t)key;
-
-- (void)removeValueForKey:(uint32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setFloat:(float)value forKey:(uint32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeFloatForKey:(uint32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt32 -> Double
+/**
+ * Class used for map fields of <uint32_t, double>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt32DoubleDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(uint32_t)key;
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32DoubleDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint32_t)key value:(nullable double *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(uint32_t key, double value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary;
-- (void)setValue:(double)value forKey:(uint32_t)key;
-
-- (void)removeValueForKey:(uint32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setDouble:(double)value forKey:(uint32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeDoubleForKey:(uint32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt32 -> Enum
+/**
+ * Class used for map fields of <uint32_t, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt32EnumDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
+/** The validation function to check if the enums are valid. */
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(uint32_t)key;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32EnumDictionary *)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems;
-
+/**
+ * Initializes a dictionary with the given validation function.
+ *
+ * @param func The enum validation function for the dictionary.
+ *
+ * @return A newly initialized dictionary.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+
+/**
+ * Initializes a dictionary with the entries given.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param values The raw enum values values to be placed in the dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of entries to store in the dictionary.
+ *
+ * @return A newly initialized dictionary with the keys and values in it.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes a dictionary with the entries from the given.
+ * dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to the dictionary.
+ *
+ * @return A newly initialized dictionary with the entries from the given
+ * dictionary in it.
+ **/
- (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary;
+
+/**
+ * Initializes a dictionary with the given capacity.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param numItems Capacity needed for the dictionary.
+ *
+ * @return A newly initialized dictionary with the given capacity.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)numItems;
@@ -320,19 +776,63 @@ NS_ASSUME_NONNULL_BEGIN
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.
-- (BOOL)valueForKey:(uint32_t)key value:(nullable int32_t *)value;
-
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(uint32_t key, int32_t value, BOOL *stop))block;
-// These methods bypass the validationFunc to provide access to values that were not
-// known at the time the binary was compiled.
-
-- (BOOL)valueForKey:(uint32_t)key rawValue:(nullable int32_t *)rawValue;
-
+/**
+ * Gets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **rawValue**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(uint32_t key, int32_t rawValue, BOOL *stop))block;
+/**
+ * Adds the keys and raw enum values from another dictionary.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary;
// If value is not a valid enumerator as defined by validationFunc, these
@@ -340,325 +840,856 @@ NS_ASSUME_NONNULL_BEGIN
// to the default value. Use the rawValue methods below to assign non enumerator
// values.
-- (void)setValue:(int32_t)value forKey:(uint32_t)key;
-
-// This method bypass the validationFunc to provide setting of values that were not
-// known at the time the binary was compiled.
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setEnum:(int32_t)value forKey:(uint32_t)key;
+
+/**
+ * Sets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue The raw enum value to set.
+ * @param key The key under which to store the raw enum value.
+ **/
- (void)setRawValue:(int32_t)rawValue forKey:(uint32_t)key;
-// No validation applies to these methods.
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeEnumForKey:(uint32_t)aKey;
-- (void)removeValueForKey:(uint32_t)aKey;
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt32 -> Object
-@interface GPBUInt32ObjectDictionary : NSObject <NSCopying>
+/**
+ * Class used for map fields of <uint32_t, ObjectType>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
+@interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(uint32_t)key;
-+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const uint32_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param objects The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (id)objectForKey:(uint32_t)key;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
+/**
+ * Fetches the object stored under the given key.
+ *
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return The object if found, nil otherwise.
+ **/
+- (ObjectType)objectForKey:(uint32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **object**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndObjectsUsingBlock:
- (void (^)(uint32_t key, id object, BOOL *stop))block;
-
+ (void (^)(uint32_t key, ObjectType object, BOOL *stop))block;
+
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary;
-- (void)setObject:(id)object forKey:(uint32_t)key;
-
+/**
+ * Sets the value for the given key.
+ *
+ * @param object The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setObject:(ObjectType)object forKey:(uint32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
- (void)removeObjectForKey:(uint32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int32 -> UInt32
+/**
+ * Class used for map fields of <int32_t, uint32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt32UInt32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(int32_t)key;
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt32UInt32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int32_t)key value:(nullable uint32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(int32_t key, uint32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary;
-- (void)setValue:(uint32_t)value forKey:(int32_t)key;
-
-- (void)removeValueForKey:(int32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt32:(uint32_t)value forKey:(int32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt32ForKey:(int32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int32 -> Int32
+/**
+ * Class used for map fields of <int32_t, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt32Int32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(int32_t)key;
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt32Int32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int32_t)key value:(nullable int32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(int32_t key, int32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary;
-- (void)setValue:(int32_t)value forKey:(int32_t)key;
-
-- (void)removeValueForKey:(int32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt32:(int32_t)value forKey:(int32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt32ForKey:(int32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int32 -> UInt64
+/**
+ * Class used for map fields of <int32_t, uint64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt32UInt64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(int32_t)key;
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt32UInt64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int32_t)key value:(nullable uint64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(int32_t key, uint64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary;
-- (void)setValue:(uint64_t)value forKey:(int32_t)key;
-
-- (void)removeValueForKey:(int32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt64:(uint64_t)value forKey:(int32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt64ForKey:(int32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int32 -> Int64
+/**
+ * Class used for map fields of <int32_t, int64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt32Int64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(int32_t)key;
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt32Int64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int64_t [])values
- forKeys:(const int32_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int32_t)key value:(nullable int64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(int32_t key, int64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary;
-- (void)setValue:(int64_t)value forKey:(int32_t)key;
-
-- (void)removeValueForKey:(int32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt64:(int64_t)value forKey:(int32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt64ForKey:(int32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int32 -> Bool
+/**
+ * Class used for map fields of <int32_t, BOOL>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt32BoolDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(int32_t)key;
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt32BoolDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int32_t)key value:(nullable BOOL *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(int32_t key, BOOL value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary;
-- (void)setValue:(BOOL)value forKey:(int32_t)key;
-
-- (void)removeValueForKey:(int32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setBool:(BOOL)value forKey:(int32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeBoolForKey:(int32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int32 -> Float
+/**
+ * Class used for map fields of <int32_t, float>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt32FloatDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(int32_t)key;
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt32FloatDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const float [])values
- forKeys:(const int32_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int32_t)key value:(nullable float *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(int32_t key, float value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary;
-- (void)setValue:(float)value forKey:(int32_t)key;
-
-- (void)removeValueForKey:(int32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setFloat:(float)value forKey:(int32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeFloatForKey:(int32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int32 -> Double
+/**
+ * Class used for map fields of <int32_t, double>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt32DoubleDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(int32_t)key;
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt32DoubleDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int32_t)key value:(nullable double *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(int32_t key, double value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary;
-- (void)setValue:(double)value forKey:(int32_t)key;
-
-- (void)removeValueForKey:(int32_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setDouble:(double)value forKey:(int32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeDoubleForKey:(int32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int32 -> Enum
+/**
+ * Class used for map fields of <int32_t, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt32EnumDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
+/** The validation function to check if the enums are valid. */
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(int32_t)key;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt32EnumDictionary *)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems;
-
+/**
+ * Initializes a dictionary with the given validation function.
+ *
+ * @param func The enum validation function for the dictionary.
+ *
+ * @return A newly initialized dictionary.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+
+/**
+ * Initializes a dictionary with the entries given.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param values The raw enum values values to be placed in the dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of entries to store in the dictionary.
+ *
+ * @return A newly initialized dictionary with the keys and values in it.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes a dictionary with the entries from the given.
+ * dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to the dictionary.
+ *
+ * @return A newly initialized dictionary with the entries from the given
+ * dictionary in it.
+ **/
- (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary;
+
+/**
+ * Initializes a dictionary with the given capacity.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param numItems Capacity needed for the dictionary.
+ *
+ * @return A newly initialized dictionary with the given capacity.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)numItems;
@@ -666,19 +1697,63 @@ NS_ASSUME_NONNULL_BEGIN
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.
-- (BOOL)valueForKey:(int32_t)key value:(nullable int32_t *)value;
-
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getEnum:(nullable int32_t *)value forKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(int32_t key, int32_t value, BOOL *stop))block;
-// These methods bypass the validationFunc to provide access to values that were not
-// known at the time the binary was compiled.
-
-- (BOOL)valueForKey:(int32_t)key rawValue:(nullable int32_t *)rawValue;
-
+/**
+ * Gets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **rawValue**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(int32_t key, int32_t rawValue, BOOL *stop))block;
+/**
+ * Adds the keys and raw enum values from another dictionary.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary;
// If value is not a valid enumerator as defined by validationFunc, these
@@ -686,325 +1761,856 @@ NS_ASSUME_NONNULL_BEGIN
// to the default value. Use the rawValue methods below to assign non enumerator
// values.
-- (void)setValue:(int32_t)value forKey:(int32_t)key;
-
-// This method bypass the validationFunc to provide setting of values that were not
-// known at the time the binary was compiled.
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setEnum:(int32_t)value forKey:(int32_t)key;
+
+/**
+ * Sets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue The raw enum value to set.
+ * @param key The key under which to store the raw enum value.
+ **/
- (void)setRawValue:(int32_t)rawValue forKey:(int32_t)key;
-// No validation applies to these methods.
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeEnumForKey:(int32_t)aKey;
-- (void)removeValueForKey:(int32_t)aKey;
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int32 -> Object
-@interface GPBInt32ObjectDictionary : NSObject <NSCopying>
+/**
+ * Class used for map fields of <int32_t, ObjectType>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
+@interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(int32_t)key;
-+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const int32_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param objects The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (id)objectForKey:(int32_t)key;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
+/**
+ * Fetches the object stored under the given key.
+ *
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return The object if found, nil otherwise.
+ **/
+- (ObjectType)objectForKey:(int32_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **object**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndObjectsUsingBlock:
- (void (^)(int32_t key, id object, BOOL *stop))block;
-
+ (void (^)(int32_t key, ObjectType object, BOOL *stop))block;
+
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary;
-- (void)setObject:(id)object forKey:(int32_t)key;
-
+/**
+ * Sets the value for the given key.
+ *
+ * @param object The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setObject:(ObjectType)object forKey:(int32_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
- (void)removeObjectForKey:(int32_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt64 -> UInt32
+/**
+ * Class used for map fields of <uint64_t, uint32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt64UInt32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(uint64_t)key;
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint64_t)key value:(nullable uint32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(uint64_t key, uint32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary;
-- (void)setValue:(uint32_t)value forKey:(uint64_t)key;
-
-- (void)removeValueForKey:(uint64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt32:(uint32_t)value forKey:(uint64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt32ForKey:(uint64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt64 -> Int32
+/**
+ * Class used for map fields of <uint64_t, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt64Int32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(uint64_t)key;
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64Int32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint64_t)key value:(nullable int32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(uint64_t key, int32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary;
-- (void)setValue:(int32_t)value forKey:(uint64_t)key;
-
-- (void)removeValueForKey:(uint64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt32:(int32_t)value forKey:(uint64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt32ForKey:(uint64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt64 -> UInt64
+/**
+ * Class used for map fields of <uint64_t, uint64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt64UInt64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(uint64_t)key;
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint64_t)key value:(nullable uint64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(uint64_t key, uint64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary;
-- (void)setValue:(uint64_t)value forKey:(uint64_t)key;
-
-- (void)removeValueForKey:(uint64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt64:(uint64_t)value forKey:(uint64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt64ForKey:(uint64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt64 -> Int64
+/**
+ * Class used for map fields of <uint64_t, int64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt64Int64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(uint64_t)key;
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64Int64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int64_t [])values
- forKeys:(const uint64_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint64_t)key value:(nullable int64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(uint64_t key, int64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary;
-- (void)setValue:(int64_t)value forKey:(uint64_t)key;
-
-- (void)removeValueForKey:(uint64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt64:(int64_t)value forKey:(uint64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt64ForKey:(uint64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt64 -> Bool
+/**
+ * Class used for map fields of <uint64_t, BOOL>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt64BoolDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(uint64_t)key;
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64BoolDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint64_t)key value:(nullable BOOL *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(uint64_t key, BOOL value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary;
-- (void)setValue:(BOOL)value forKey:(uint64_t)key;
-
-- (void)removeValueForKey:(uint64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setBool:(BOOL)value forKey:(uint64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeBoolForKey:(uint64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt64 -> Float
+/**
+ * Class used for map fields of <uint64_t, float>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt64FloatDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(uint64_t)key;
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64FloatDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const float [])values
- forKeys:(const uint64_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint64_t)key value:(nullable float *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(uint64_t key, float value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary;
-- (void)setValue:(float)value forKey:(uint64_t)key;
-
-- (void)removeValueForKey:(uint64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setFloat:(float)value forKey:(uint64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeFloatForKey:(uint64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt64 -> Double
+/**
+ * Class used for map fields of <uint64_t, double>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt64DoubleDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(uint64_t)key;
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64DoubleDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(uint64_t)key value:(nullable double *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(uint64_t key, double value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary;
-- (void)setValue:(double)value forKey:(uint64_t)key;
-
-- (void)removeValueForKey:(uint64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setDouble:(double)value forKey:(uint64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeDoubleForKey:(uint64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt64 -> Enum
+/**
+ * Class used for map fields of <uint64_t, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBUInt64EnumDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
+/** The validation function to check if the enums are valid. */
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(uint64_t)key;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64EnumDictionary *)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems;
-
+/**
+ * Initializes a dictionary with the given validation function.
+ *
+ * @param func The enum validation function for the dictionary.
+ *
+ * @return A newly initialized dictionary.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+
+/**
+ * Initializes a dictionary with the entries given.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param values The raw enum values values to be placed in the dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of entries to store in the dictionary.
+ *
+ * @return A newly initialized dictionary with the keys and values in it.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes a dictionary with the entries from the given.
+ * dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to the dictionary.
+ *
+ * @return A newly initialized dictionary with the entries from the given
+ * dictionary in it.
+ **/
- (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary;
+
+/**
+ * Initializes a dictionary with the given capacity.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param numItems Capacity needed for the dictionary.
+ *
+ * @return A newly initialized dictionary with the given capacity.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)numItems;
@@ -1012,19 +2618,63 @@ NS_ASSUME_NONNULL_BEGIN
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.
-- (BOOL)valueForKey:(uint64_t)key value:(nullable int32_t *)value;
-
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(uint64_t key, int32_t value, BOOL *stop))block;
-// These methods bypass the validationFunc to provide access to values that were not
-// known at the time the binary was compiled.
-
-- (BOOL)valueForKey:(uint64_t)key rawValue:(nullable int32_t *)rawValue;
-
+/**
+ * Gets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **rawValue**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(uint64_t key, int32_t rawValue, BOOL *stop))block;
+/**
+ * Adds the keys and raw enum values from another dictionary.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary;
// If value is not a valid enumerator as defined by validationFunc, these
@@ -1032,325 +2682,856 @@ NS_ASSUME_NONNULL_BEGIN
// to the default value. Use the rawValue methods below to assign non enumerator
// values.
-- (void)setValue:(int32_t)value forKey:(uint64_t)key;
-
-// This method bypass the validationFunc to provide setting of values that were not
-// known at the time the binary was compiled.
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setEnum:(int32_t)value forKey:(uint64_t)key;
+
+/**
+ * Sets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue The raw enum value to set.
+ * @param key The key under which to store the raw enum value.
+ **/
- (void)setRawValue:(int32_t)rawValue forKey:(uint64_t)key;
-// No validation applies to these methods.
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeEnumForKey:(uint64_t)aKey;
-- (void)removeValueForKey:(uint64_t)aKey;
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - UInt64 -> Object
-@interface GPBUInt64ObjectDictionary : NSObject <NSCopying>
+/**
+ * Class used for map fields of <uint64_t, ObjectType>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
+@interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(uint64_t)key;
-+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const uint64_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param objects The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (id)objectForKey:(uint64_t)key;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
+/**
+ * Fetches the object stored under the given key.
+ *
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return The object if found, nil otherwise.
+ **/
+- (ObjectType)objectForKey:(uint64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **object**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndObjectsUsingBlock:
- (void (^)(uint64_t key, id object, BOOL *stop))block;
-
+ (void (^)(uint64_t key, ObjectType object, BOOL *stop))block;
+
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary;
-- (void)setObject:(id)object forKey:(uint64_t)key;
-
+/**
+ * Sets the value for the given key.
+ *
+ * @param object The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setObject:(ObjectType)object forKey:(uint64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
- (void)removeObjectForKey:(uint64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int64 -> UInt32
+/**
+ * Class used for map fields of <int64_t, uint32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt64UInt32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(int64_t)key;
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt64UInt32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int64_t)key value:(nullable uint32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(int64_t key, uint32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary;
-- (void)setValue:(uint32_t)value forKey:(int64_t)key;
-
-- (void)removeValueForKey:(int64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt32:(uint32_t)value forKey:(int64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt32ForKey:(int64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int64 -> Int32
+/**
+ * Class used for map fields of <int64_t, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt64Int32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(int64_t)key;
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt64Int32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int64_t)key value:(nullable int32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(int64_t key, int32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary;
-- (void)setValue:(int32_t)value forKey:(int64_t)key;
-
-- (void)removeValueForKey:(int64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt32:(int32_t)value forKey:(int64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt32ForKey:(int64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int64 -> UInt64
+/**
+ * Class used for map fields of <int64_t, uint64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt64UInt64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(int64_t)key;
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt64UInt64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int64_t)key value:(nullable uint64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(int64_t key, uint64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary;
-- (void)setValue:(uint64_t)value forKey:(int64_t)key;
-
-- (void)removeValueForKey:(int64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt64:(uint64_t)value forKey:(int64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt64ForKey:(int64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int64 -> Int64
+/**
+ * Class used for map fields of <int64_t, int64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt64Int64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(int64_t)key;
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt64Int64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int64_t [])values
- forKeys:(const int64_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int64_t)key value:(nullable int64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(int64_t key, int64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary;
-- (void)setValue:(int64_t)value forKey:(int64_t)key;
-
-- (void)removeValueForKey:(int64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt64:(int64_t)value forKey:(int64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt64ForKey:(int64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int64 -> Bool
+/**
+ * Class used for map fields of <int64_t, BOOL>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt64BoolDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(int64_t)key;
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt64BoolDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int64_t)key value:(nullable BOOL *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(int64_t key, BOOL value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary;
-- (void)setValue:(BOOL)value forKey:(int64_t)key;
-
-- (void)removeValueForKey:(int64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setBool:(BOOL)value forKey:(int64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeBoolForKey:(int64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int64 -> Float
+/**
+ * Class used for map fields of <int64_t, float>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt64FloatDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(int64_t)key;
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt64FloatDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const float [])values
- forKeys:(const int64_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int64_t)key value:(nullable float *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(int64_t key, float value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary;
-- (void)setValue:(float)value forKey:(int64_t)key;
-
-- (void)removeValueForKey:(int64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setFloat:(float)value forKey:(int64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeFloatForKey:(int64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int64 -> Double
+/**
+ * Class used for map fields of <int64_t, double>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt64DoubleDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(int64_t)key;
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt64DoubleDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(int64_t)key value:(nullable double *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(int64_t key, double value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary;
-- (void)setValue:(double)value forKey:(int64_t)key;
-
-- (void)removeValueForKey:(int64_t)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setDouble:(double)value forKey:(int64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeDoubleForKey:(int64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int64 -> Enum
+/**
+ * Class used for map fields of <int64_t, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBInt64EnumDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
+/** The validation function to check if the enums are valid. */
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(int64_t)key;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt64EnumDictionary *)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems;
-
+/**
+ * Initializes a dictionary with the given validation function.
+ *
+ * @param func The enum validation function for the dictionary.
+ *
+ * @return A newly initialized dictionary.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+
+/**
+ * Initializes a dictionary with the entries given.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param values The raw enum values values to be placed in the dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of entries to store in the dictionary.
+ *
+ * @return A newly initialized dictionary with the keys and values in it.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes a dictionary with the entries from the given.
+ * dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to the dictionary.
+ *
+ * @return A newly initialized dictionary with the entries from the given
+ * dictionary in it.
+ **/
- (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary;
+
+/**
+ * Initializes a dictionary with the given capacity.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param numItems Capacity needed for the dictionary.
+ *
+ * @return A newly initialized dictionary with the given capacity.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)numItems;
@@ -1358,19 +3539,63 @@ NS_ASSUME_NONNULL_BEGIN
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.
-- (BOOL)valueForKey:(int64_t)key value:(nullable int32_t *)value;
-
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getEnum:(nullable int32_t *)value forKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(int64_t key, int32_t value, BOOL *stop))block;
-// These methods bypass the validationFunc to provide access to values that were not
-// known at the time the binary was compiled.
-
-- (BOOL)valueForKey:(int64_t)key rawValue:(nullable int32_t *)rawValue;
-
+/**
+ * Gets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **rawValue**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(int64_t key, int32_t rawValue, BOOL *stop))block;
+/**
+ * Adds the keys and raw enum values from another dictionary.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary;
// If value is not a valid enumerator as defined by validationFunc, these
@@ -1378,325 +3603,856 @@ NS_ASSUME_NONNULL_BEGIN
// to the default value. Use the rawValue methods below to assign non enumerator
// values.
-- (void)setValue:(int32_t)value forKey:(int64_t)key;
-
-// This method bypass the validationFunc to provide setting of values that were not
-// known at the time the binary was compiled.
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setEnum:(int32_t)value forKey:(int64_t)key;
+
+/**
+ * Sets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue The raw enum value to set.
+ * @param key The key under which to store the raw enum value.
+ **/
- (void)setRawValue:(int32_t)rawValue forKey:(int64_t)key;
-// No validation applies to these methods.
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeEnumForKey:(int64_t)aKey;
-- (void)removeValueForKey:(int64_t)aKey;
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Int64 -> Object
-@interface GPBInt64ObjectDictionary : NSObject <NSCopying>
+/**
+ * Class used for map fields of <int64_t, ObjectType>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
+@interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(int64_t)key;
-+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const int64_t [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param objects The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (id)objectForKey:(int64_t)key;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
+/**
+ * Fetches the object stored under the given key.
+ *
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return The object if found, nil otherwise.
+ **/
+- (ObjectType)objectForKey:(int64_t)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **object**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndObjectsUsingBlock:
- (void (^)(int64_t key, id object, BOOL *stop))block;
-
+ (void (^)(int64_t key, ObjectType object, BOOL *stop))block;
+
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary;
-- (void)setObject:(id)object forKey:(int64_t)key;
-
+/**
+ * Sets the value for the given key.
+ *
+ * @param object The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setObject:(ObjectType)object forKey:(int64_t)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
- (void)removeObjectForKey:(int64_t)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Bool -> UInt32
+/**
+ * Class used for map fields of <BOOL, uint32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBBoolUInt32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(BOOL)key;
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBBoolUInt32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(BOOL)key value:(nullable uint32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(BOOL key, uint32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary;
-- (void)setValue:(uint32_t)value forKey:(BOOL)key;
-
-- (void)removeValueForKey:(BOOL)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt32:(uint32_t)value forKey:(BOOL)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt32ForKey:(BOOL)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Bool -> Int32
+/**
+ * Class used for map fields of <BOOL, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBBoolInt32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(BOOL)key;
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBBoolInt32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const BOOL [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(BOOL)key value:(nullable int32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(BOOL key, int32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary;
-- (void)setValue:(int32_t)value forKey:(BOOL)key;
-
-- (void)removeValueForKey:(BOOL)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt32:(int32_t)value forKey:(BOOL)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt32ForKey:(BOOL)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Bool -> UInt64
+/**
+ * Class used for map fields of <BOOL, uint64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBBoolUInt64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(BOOL)key;
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBBoolUInt64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(BOOL)key value:(nullable uint64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(BOOL key, uint64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary;
-- (void)setValue:(uint64_t)value forKey:(BOOL)key;
-
-- (void)removeValueForKey:(BOOL)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt64:(uint64_t)value forKey:(BOOL)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt64ForKey:(BOOL)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Bool -> Int64
+/**
+ * Class used for map fields of <BOOL, int64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBBoolInt64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(BOOL)key;
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBBoolInt64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int64_t [])values
- forKeys:(const BOOL [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(BOOL)key value:(nullable int64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(BOOL key, int64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary;
-- (void)setValue:(int64_t)value forKey:(BOOL)key;
-
-- (void)removeValueForKey:(BOOL)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt64:(int64_t)value forKey:(BOOL)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt64ForKey:(BOOL)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Bool -> Bool
+/**
+ * Class used for map fields of <BOOL, BOOL>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBBoolBoolDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(BOOL)key;
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBBoolBoolDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(BOOL)key value:(nullable BOOL *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getBool:(nullable BOOL *)value forKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(BOOL key, BOOL value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary;
-- (void)setValue:(BOOL)value forKey:(BOOL)key;
-
-- (void)removeValueForKey:(BOOL)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setBool:(BOOL)value forKey:(BOOL)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeBoolForKey:(BOOL)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Bool -> Float
+/**
+ * Class used for map fields of <BOOL, float>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBBoolFloatDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(BOOL)key;
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBBoolFloatDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const float [])values
- forKeys:(const BOOL [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(BOOL)key value:(nullable float *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getFloat:(nullable float *)value forKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(BOOL key, float value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary;
-- (void)setValue:(float)value forKey:(BOOL)key;
-
-- (void)removeValueForKey:(BOOL)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setFloat:(float)value forKey:(BOOL)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeFloatForKey:(BOOL)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Bool -> Double
+/**
+ * Class used for map fields of <BOOL, double>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBBoolDoubleDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(BOOL)key;
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBBoolDoubleDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(BOOL)key value:(nullable double *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getDouble:(nullable double *)value forKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(BOOL key, double value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary;
-- (void)setValue:(double)value forKey:(BOOL)key;
-
-- (void)removeValueForKey:(BOOL)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setDouble:(double)value forKey:(BOOL)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeDoubleForKey:(BOOL)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Bool -> Enum
+/**
+ * Class used for map fields of <BOOL, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBBoolEnumDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
+/** The validation function to check if the enums are valid. */
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(BOOL)key;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBBoolEnumDictionary *)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems;
-
+/**
+ * Initializes a dictionary with the given validation function.
+ *
+ * @param func The enum validation function for the dictionary.
+ *
+ * @return A newly initialized dictionary.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+
+/**
+ * Initializes a dictionary with the entries given.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param values The raw enum values values to be placed in the dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of entries to store in the dictionary.
+ *
+ * @return A newly initialized dictionary with the keys and values in it.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const BOOL [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes a dictionary with the entries from the given.
+ * dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to the dictionary.
+ *
+ * @return A newly initialized dictionary with the entries from the given
+ * dictionary in it.
+ **/
- (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary;
+
+/**
+ * Initializes a dictionary with the given capacity.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param numItems Capacity needed for the dictionary.
+ *
+ * @return A newly initialized dictionary with the given capacity.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)numItems;
@@ -1704,19 +4460,63 @@ NS_ASSUME_NONNULL_BEGIN
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.
-- (BOOL)valueForKey:(BOOL)key value:(nullable int32_t *)value;
-
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getEnum:(nullable int32_t *)value forKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(BOOL key, int32_t value, BOOL *stop))block;
-// These methods bypass the validationFunc to provide access to values that were not
-// known at the time the binary was compiled.
-
-- (BOOL)valueForKey:(BOOL)key rawValue:(nullable int32_t *)rawValue;
-
+/**
+ * Gets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **rawValue**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(BOOL key, int32_t rawValue, BOOL *stop))block;
+/**
+ * Adds the keys and raw enum values from another dictionary.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary;
// If value is not a valid enumerator as defined by validationFunc, these
@@ -1724,325 +4524,856 @@ NS_ASSUME_NONNULL_BEGIN
// to the default value. Use the rawValue methods below to assign non enumerator
// values.
-- (void)setValue:(int32_t)value forKey:(BOOL)key;
-
-// This method bypass the validationFunc to provide setting of values that were not
-// known at the time the binary was compiled.
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setEnum:(int32_t)value forKey:(BOOL)key;
+
+/**
+ * Sets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue The raw enum value to set.
+ * @param key The key under which to store the raw enum value.
+ **/
- (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key;
-// No validation applies to these methods.
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeEnumForKey:(BOOL)aKey;
-- (void)removeValueForKey:(BOOL)aKey;
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - Bool -> Object
-@interface GPBBoolObjectDictionary : NSObject <NSCopying>
+/**
+ * Class used for map fields of <BOOL, ObjectType>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
+@interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(BOOL)key;
-+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBBoolObjectDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const BOOL [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param objects The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (id)objectForKey:(BOOL)key;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
+/**
+ * Fetches the object stored under the given key.
+ *
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return The object if found, nil otherwise.
+ **/
+- (ObjectType)objectForKey:(BOOL)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **object**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndObjectsUsingBlock:
- (void (^)(BOOL key, id object, BOOL *stop))block;
-
+ (void (^)(BOOL key, ObjectType object, BOOL *stop))block;
+
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary;
-- (void)setObject:(id)object forKey:(BOOL)key;
-
+/**
+ * Sets the value for the given key.
+ *
+ * @param object The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setObject:(ObjectType)object forKey:(BOOL)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
- (void)removeObjectForKey:(BOOL)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - String -> UInt32
+/**
+ * Class used for map fields of <NSString, uint32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBStringUInt32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(NSString *)key;
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBStringUInt32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(NSString *)key value:(nullable uint32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(NSString *key, uint32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary;
-- (void)setValue:(uint32_t)value forKey:(NSString *)key;
-
-- (void)removeValueForKey:(NSString *)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt32:(uint32_t)value forKey:(NSString *)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt32ForKey:(NSString *)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - String -> Int32
+/**
+ * Class used for map fields of <NSString, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBStringInt32Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(NSString *)key;
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBStringInt32Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(NSString *)key value:(nullable int32_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(NSString *key, int32_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary;
-- (void)setValue:(int32_t)value forKey:(NSString *)key;
-
-- (void)removeValueForKey:(NSString *)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt32:(int32_t)value forKey:(NSString *)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt32ForKey:(NSString *)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - String -> UInt64
+/**
+ * Class used for map fields of <NSString, uint64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBStringUInt64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(NSString *)key;
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBStringUInt64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(NSString *)key value:(nullable uint64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(NSString *key, uint64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary;
-- (void)setValue:(uint64_t)value forKey:(NSString *)key;
-
-- (void)removeValueForKey:(NSString *)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setUInt64:(uint64_t)value forKey:(NSString *)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeUInt64ForKey:(NSString *)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - String -> Int64
+/**
+ * Class used for map fields of <NSString, int64_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBStringInt64Dictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(NSString *)key;
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBStringInt64Dictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const int64_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(NSString *)key value:(nullable int64_t *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(NSString *key, int64_t value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary;
-- (void)setValue:(int64_t)value forKey:(NSString *)key;
-
-- (void)removeValueForKey:(NSString *)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setInt64:(int64_t)value forKey:(NSString *)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeInt64ForKey:(NSString *)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - String -> Bool
+/**
+ * Class used for map fields of <NSString, BOOL>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBStringBoolDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(NSString *)key;
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBStringBoolDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(NSString *)key value:(nullable BOOL *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(NSString *key, BOOL value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary;
-- (void)setValue:(BOOL)value forKey:(NSString *)key;
-
-- (void)removeValueForKey:(NSString *)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setBool:(BOOL)value forKey:(NSString *)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeBoolForKey:(NSString *)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - String -> Float
+/**
+ * Class used for map fields of <NSString, float>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBStringFloatDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(NSString *)key;
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBStringFloatDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const float [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(NSString *)key value:(nullable float *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(NSString *key, float value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary;
-- (void)setValue:(float)value forKey:(NSString *)key;
-
-- (void)removeValueForKey:(NSString *)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setFloat:(float)value forKey:(NSString *)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeFloatForKey:(NSString *)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - String -> Double
+/**
+ * Class used for map fields of <NSString, double>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBStringDoubleDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(NSString *)key;
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBStringDoubleDictionary *)dictionary;
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+/**
+ * Initializes this dictionary, copying the given values and keys.
+ *
+ * @param values The values to be placed in this dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of elements to copy into the dictionary.
+ *
+ * @return A newly initialized dictionary with a copy of the values and keys.
+ **/
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
+ count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes this dictionary, copying the entries from the given dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to this dictionary.
+ *
+ * @return A newly initialized dictionary with the entries of the given dictionary.
+ **/
- (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary;
-- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (BOOL)valueForKey:(NSString *)key value:(nullable double *)value;
+/**
+ * Initializes this dictionary with the requested capacity.
+ *
+ * @param numItems Number of items needed for this dictionary.
+ *
+ * @return A newly initialized dictionary with the requested capacity.
+ **/
+- (instancetype)initWithCapacity:(NSUInteger)numItems;
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(NSString *key, double value, BOOL *stop))block;
+/**
+ * Adds the keys and values from another dictionary.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary;
-- (void)setValue:(double)value forKey:(NSString *)key;
-
-- (void)removeValueForKey:(NSString *)aKey;
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setDouble:(double)value forKey:(NSString *)key;
+
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeDoubleForKey:(NSString *)aKey;
+
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
#pragma mark - String -> Enum
+/**
+ * Class used for map fields of <NSString, int32_t>
+ * values. This performs better than boxing into NSNumbers in NSDictionaries.
+ *
+ * @note This class is not meant to be subclassed.
+ **/
@interface GPBStringEnumDictionary : NSObject <NSCopying>
+/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
+/** The validation function to check if the enums are valid. */
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(NSString *)key;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
- count:(NSUInteger)count;
-+ (instancetype)dictionaryWithDictionary:(GPBStringEnumDictionary *)dictionary;
-+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems;
-
+/**
+ * Initializes a dictionary with the given validation function.
+ *
+ * @param func The enum validation function for the dictionary.
+ *
+ * @return A newly initialized dictionary.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+
+/**
+ * Initializes a dictionary with the entries given.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param values The raw enum values values to be placed in the dictionary.
+ * @param keys The keys under which to store the values.
+ * @param count The number of entries to store in the dictionary.
+ *
+ * @return A newly initialized dictionary with the keys and values in it.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Initializes a dictionary with the entries from the given.
+ * dictionary.
+ *
+ * @param dictionary Dictionary containing the entries to add to the dictionary.
+ *
+ * @return A newly initialized dictionary with the entries from the given
+ * dictionary in it.
+ **/
- (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary;
+
+/**
+ * Initializes a dictionary with the given capacity.
+ *
+ * @param func The enum validation function for the dictionary.
+ * @param numItems Capacity needed for the dictionary.
+ *
+ * @return A newly initialized dictionary with the given capacity.
+ **/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
capacity:(NSUInteger)numItems;
@@ -2050,19 +5381,63 @@ NS_ASSUME_NONNULL_BEGIN
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.
-- (BOOL)valueForKey:(NSString *)key value:(nullable int32_t *)value;
-
-- (void)enumerateKeysAndValuesUsingBlock:
+/**
+ * Gets the value for the given key.
+ *
+ * @param value Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getEnum:(nullable int32_t *)value forKey:(NSString *)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **value**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(NSString *key, int32_t value, BOOL *stop))block;
-// These methods bypass the validationFunc to provide access to values that were not
-// known at the time the binary was compiled.
-
-- (BOOL)valueForKey:(NSString *)key rawValue:(nullable int32_t *)rawValue;
-
+/**
+ * Gets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue Pointer into which the value will be set, if found.
+ * @param key Key under which the value is stored, if present.
+ *
+ * @return YES if the key was found and the value was copied, NO otherwise.
+ **/
+- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(NSString *)key;
+
+/**
+ * Enumerates the keys and values on this dictionary with the given block.
+ *
+ * @note This method bypass the validationFunc to enable the access of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param block The block to enumerate with.
+ * **key**: The key for the current entry.
+ * **rawValue**: The value for the current entry
+ * **stop**: A pointer to a boolean that when set stops the enumeration.
+ **/
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(NSString *key, int32_t rawValue, BOOL *stop))block;
+/**
+ * Adds the keys and raw enum values from another dictionary.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param otherDictionary Dictionary containing entries to be added to this
+ * dictionary.
+ **/
- (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary;
// If value is not a valid enumerator as defined by validationFunc, these
@@ -2070,15 +5445,35 @@ NS_ASSUME_NONNULL_BEGIN
// to the default value. Use the rawValue methods below to assign non enumerator
// values.
-- (void)setValue:(int32_t)value forKey:(NSString *)key;
-
-// This method bypass the validationFunc to provide setting of values that were not
-// known at the time the binary was compiled.
+/**
+ * Sets the value for the given key.
+ *
+ * @param value The value to set.
+ * @param key The key under which to store the value.
+ **/
+- (void)setEnum:(int32_t)value forKey:(NSString *)key;
+
+/**
+ * Sets the raw enum value for the given key.
+ *
+ * @note This method bypass the validationFunc to enable the setting of values that
+ * were not known at the time the binary was compiled.
+ *
+ * @param rawValue The raw enum value to set.
+ * @param key The key under which to store the raw enum value.
+ **/
- (void)setRawValue:(int32_t)rawValue forKey:(NSString *)key;
-// No validation applies to these methods.
+/**
+ * Removes the entry for the given key.
+ *
+ * @param aKey Key to be removed from this dictionary.
+ **/
+- (void)removeEnumForKey:(NSString *)aKey;
-- (void)removeValueForKey:(NSString *)aKey;
+/**
+ * Removes all entries in this dictionary.
+ **/
- (void)removeAll;
@end
@@ -2096,7 +5491,7 @@ NS_ASSUME_NONNULL_END
//%DICTIONARY_POD_INTERFACES_FOR_KEY(String, NSString, *, OBJECT)
//%PDDM-DEFINE DICTIONARY_INTERFACES_FOR_POD_KEY(KEY_NAME, KEY_TYPE)
//%DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, , POD)
-//%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, id)
+//%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, ObjectType)
//%PDDM-DEFINE DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER)
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt32, uint32_t)
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int32, int32_t)
@@ -2107,48 +5502,98 @@ NS_ASSUME_NONNULL_END
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double)
//%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t)
//%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
-//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, value)
+//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value)
//%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE)
-//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, object)
-//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE)
-//%- (BOOL)valueForKey:(KEY_TYPE)key value:(nullable VALUE_TYPE *)value;
-//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE)
+//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, Object, object)
+//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
+//%/**
+//% * Gets the value for the given key.
+//% *
+//% * @param value Pointer into which the value will be set, if found.
+//% * @param key Key under which the value is stored, if present.
+//% *
+//% * @return YES if the key was found and the value was copied, NO otherwise.
+//% **/
+//%- (BOOL)get##VNAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key;
+//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE, VNAME)
+//%/**
+//% * Fetches the object stored under the given key.
+//% *
+//% * @param key Key under which the value is stored, if present.
+//% *
+//% * @return The object if found, nil otherwise.
+//% **/
//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key;
-//%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE)
-//%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE)
+//%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE, VNAME)
+//%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
//%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD()
// Nothing
//%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum()
// Nothing
//%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT()
-//%GPB_UNSAFE_UNRETAINED ##
-//%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
+//%__nonnull GPB_UNSAFE_UNRETAINED ##
+//%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE)
+//%GPB##KEY_NAME##VALUE_NAME##Dictionary
+//%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE)
+//%GPB##KEY_NAME##VALUE_NAME##Dictionary
+//%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE)
+//%GPB##KEY_NAME##VALUE_NAME##Dictionary<__covariant VALUE_TYPE>
+//%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
//%#pragma mark - KEY_NAME -> VALUE_NAME
//%
-//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
+//%/**
+//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
+//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
+//% *
+//% * @note This class is not meant to be subclassed.
+//% **/
+//%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject <NSCopying>
//%
+//%/** Number of entries stored in this dictionary. */
//%@property(nonatomic, readonly) NSUInteger count;
//%
-//%+ (instancetype)dictionary;
-//%+ (instancetype)dictionaryWith##VNAME$u##:(VALUE_TYPE)##VNAME
-//% ##VNAME$S## forKey:(KEY_TYPE##KisP$S##KisP)key;
-//%+ (instancetype)dictionaryWith##VNAME$u##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])##VNAME##s
-//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
-//% ##VNAME$S## count:(NSUInteger)count;
-//%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
-//%+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
-//%
-//%- (instancetype)initWith##VNAME$u##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])##VNAME##s
-//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
+//%/**
+//% * Initializes this dictionary, copying the given values and keys.
+//% *
+//% * @param ##VNAME_VAR##s The values to be placed in this dictionary.
+//% * @param keys ##VNAME_VAR$S## The keys under which to store the values.
+//% * @param count ##VNAME_VAR$S## The number of elements to copy into the dictionary.
+//% *
+//% * @return A newly initialized dictionary with a copy of the values and keys.
+//% **/
+//%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s
+//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
//% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+//%
+//%/**
+//% * Initializes this dictionary, copying the entries from the given dictionary.
+//% *
+//% * @param dictionary Dictionary containing the entries to add to this dictionary.
+//% *
+//% * @return A newly initialized dictionary with the entries of the given dictionary.
+//% **/
//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
+//%
+//%/**
+//% * Initializes this dictionary with the requested capacity.
+//% *
+//% * @param numItems Number of items needed for this dictionary.
+//% *
+//% * @return A newly initialized dictionary with the requested capacity.
+//% **/
//%- (instancetype)initWithCapacity:(NSUInteger)numItems;
//%
-//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
+//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
//%
+//%/**
+//% * Adds the keys and values from another dictionary.
+//% *
+//% * @param otherDictionary Dictionary containing entries to be added to this
+//% * dictionary.
+//% **/
//%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
//%
-//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
+//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
//%
//%@end
//%
@@ -2158,30 +5603,62 @@ NS_ASSUME_NONNULL_END
//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER)
//%#pragma mark - KEY_NAME -> VALUE_NAME
//%
+//%/**
+//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
+//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
+//% *
+//% * @note This class is not meant to be subclassed.
+//% **/
//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
//%
+//%/** Number of entries stored in this dictionary. */
//%@property(nonatomic, readonly) NSUInteger count;
+//%/** The validation function to check if the enums are valid. */
//%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
//%
-//%+ (instancetype)dictionary;
-//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
-//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
-//% rawValue:(VALUE_TYPE)rawValue
-//% forKey:(KEY_TYPE##KisP$S##KisP)key;
-//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
-//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])values
-//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
-//% count:(NSUInteger)count;
-//%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
-//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
-//% capacity:(NSUInteger)numItems;
-//%
+//%/**
+//% * Initializes a dictionary with the given validation function.
+//% *
+//% * @param func The enum validation function for the dictionary.
+//% *
+//% * @return A newly initialized dictionary.
+//% **/
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
+//%
+//%/**
+//% * Initializes a dictionary with the entries given.
+//% *
+//% * @param func The enum validation function for the dictionary.
+//% * @param values The raw enum values values to be placed in the dictionary.
+//% * @param keys The keys under which to store the values.
+//% * @param count The number of entries to store in the dictionary.
+//% *
+//% * @return A newly initialized dictionary with the keys and values in it.
+//% **/
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
-//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])values
-//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
+//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values
+//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
//% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
+//%
+//%/**
+//% * Initializes a dictionary with the entries from the given.
+//% * dictionary.
+//% *
+//% * @param dictionary Dictionary containing the entries to add to the dictionary.
+//% *
+//% * @return A newly initialized dictionary with the entries from the given
+//% * dictionary in it.
+//% **/
//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
+//%
+//%/**
+//% * Initializes a dictionary with the given capacity.
+//% *
+//% * @param func The enum validation function for the dictionary.
+//% * @param numItems Capacity needed for the dictionary.
+//% *
+//% * @return A newly initialized dictionary with the given capacity.
+//% **/
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
//% capacity:(NSUInteger)numItems;
//%
@@ -2189,16 +5666,44 @@ NS_ASSUME_NONNULL_END
//%// is not a valid enumerator as defined by validationFunc. If the actual value is
//%// desired, use "raw" version of the method.
//%
-//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, value)
+//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
//%
-//%// These methods bypass the validationFunc to provide access to values that were not
-//%// known at the time the binary was compiled.
-//%
-//%- (BOOL)valueForKey:(KEY_TYPE##KisP$S##KisP)key rawValue:(nullable VALUE_TYPE *)rawValue;
+//%/**
+//% * Gets the raw enum value for the given key.
+//% *
+//% * @note This method bypass the validationFunc to enable the access of values that
+//% * were not known at the time the binary was compiled.
+//% *
+//% * @param rawValue Pointer into which the value will be set, if found.
+//% * @param key Key under which the value is stored, if present.
+//% *
+//% * @return YES if the key was found and the value was copied, NO otherwise.
+//% **/
+//%- (BOOL)getRawValue:(nullable VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
//%
+//%/**
+//% * Enumerates the keys and values on this dictionary with the given block.
+//% *
+//% * @note This method bypass the validationFunc to enable the access of values that
+//% * were not known at the time the binary was compiled.
+//% *
+//% * @param block The block to enumerate with.
+//% * **key**: The key for the current entry.
+//% * **rawValue**: The value for the current entry
+//% * **stop**: A pointer to a boolean that when set stops the enumeration.
+//% **/
//%- (void)enumerateKeysAndRawValuesUsingBlock:
//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE rawValue, BOOL *stop))block;
//%
+//%/**
+//% * Adds the keys and raw enum values from another dictionary.
+//% *
+//% * @note This method bypass the validationFunc to enable the setting of values that
+//% * were not known at the time the binary was compiled.
+//% *
+//% * @param otherDictionary Dictionary containing entries to be added to this
+//% * dictionary.
+//% **/
//%- (void)addRawEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
//%
//%// If value is not a valid enumerator as defined by validationFunc, these
@@ -2206,21 +5711,44 @@ NS_ASSUME_NONNULL_END
//%// to the default value. Use the rawValue methods below to assign non enumerator
//%// values.
//%
-//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, value)
+//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
//%
//%@end
//%
-//%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
-//%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE)
+//%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
+//%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE, VNAME)
//%
-//%- (void)enumerateKeysAnd##VNAME$u##sUsingBlock:
-//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME, BOOL *stop))block;
-
-//%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
-//%- (void)set##VNAME$u##:(VALUE_TYPE)##VNAME forKey:(KEY_TYPE##KisP$S##KisP)key;
+//%/**
+//% * Enumerates the keys and values on this dictionary with the given block.
+//% *
+//% * @param block The block to enumerate with.
+//% * **key**: ##VNAME_VAR$S## The key for the current entry.
+//% * **VNAME_VAR**: The value for the current entry
+//% * **stop**: ##VNAME_VAR$S## A pointer to a boolean that when set stops the enumeration.
+//% **/
+//%- (void)enumerateKeysAnd##VNAME##sUsingBlock:
+//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block;
+
+//%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
+//%/**
+//% * Sets the value for the given key.
+//% *
+//% * @param ##VNAME_VAR The value to set.
+//% * @param key ##VNAME_VAR$S## The key under which to store the value.
+//% **/
+//%- (void)set##VNAME##:(VALUE_TYPE)##VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key;
//%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
-//%- (void)remove##VNAME$u##ForKey:(KEY_TYPE##KisP$S##KisP)aKey;
+//%/**
+//% * Removes the entry for the given key.
+//% *
+//% * @param aKey Key to be removed from this dictionary.
+//% **/
+//%- (void)remove##VNAME##ForKey:(KEY_TYPE##KisP$S##KisP)aKey;
+//%
+//%/**
+//% * Removes all entries in this dictionary.
+//% **/
//%- (void)removeAll;
//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
@@ -2229,9 +5757,14 @@ NS_ASSUME_NONNULL_END
// Empty
//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_Enum(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
//%
-//%// This method bypass the validationFunc to provide setting of values that were not
-//%// known at the time the binary was compiled.
+//%/**
+//% * Sets the raw enum value for the given key.
+//% *
+//% * @note This method bypass the validationFunc to enable the setting of values that
+//% * were not known at the time the binary was compiled.
+//% *
+//% * @param rawValue The raw enum value to set.
+//% * @param key The key under which to store the raw enum value.
+//% **/
//%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
//%
-//%// No validation applies to these methods.
-//%
diff --git a/objectivec/GPBDictionary.m b/objectivec/GPBDictionary.m
index 6baa2a18..cedf5e54 100644
--- a/objectivec/GPBDictionary.m
+++ b/objectivec/GPBDictionary.m
@@ -31,7 +31,7 @@
#import "GPBDictionary_PackagePrivate.h"
#import "GPBCodedInputStream_PackagePrivate.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
#import "GPBDescriptor_PackagePrivate.h"
#import "GPBMessage_PackagePrivate.h"
#import "GPBUtilities_PackagePrivate.h"
@@ -45,6 +45,12 @@
// directly.
// ------------------------------------------------------------------
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
// Used to include code only visible to specific versions of the static
// analyzer. Useful for wrapping code that only exists to silence the analyzer.
// Determine the values you want to use for BEGIN_APPLE_BUILD_VERSION,
@@ -323,13 +329,15 @@ static void WriteDictObjectField(GPBCodedOutputStream *stream, id value, uint32_
size_t GPBDictionaryComputeSizeInternalHelper(NSDictionary *dict, GPBFieldDescriptor *field) {
GPBDataType mapValueType = GPBGetFieldDataType(field);
- __block size_t result = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSString *key;
+ NSEnumerator *keys = [dict keyEnumerator];
+ while ((key = [keys nextObject])) {
+ id obj = dict[key];
size_t msgSize = GPBComputeStringSize(kMapKeyFieldNumber, key);
msgSize += ComputeDictObjectFieldSize(obj, kMapValueFieldNumber, mapValueType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * dict.count;
return result;
@@ -341,8 +349,10 @@ void GPBDictionaryWriteToStreamInternalHelper(GPBCodedOutputStream *outputStream
NSCAssert(field.mapKeyDataType == GPBDataTypeString, @"Unexpected key type");
GPBDataType mapValueType = GPBGetFieldDataType(field);
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [dict enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {
- #pragma unused(stop)
+ NSString *key;
+ NSEnumerator *keys = [dict keyEnumerator];
+ while ((key = [keys nextObject])) {
+ id obj = dict[key];
// Write the tag.
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
@@ -353,14 +363,16 @@ void GPBDictionaryWriteToStreamInternalHelper(GPBCodedOutputStream *outputStream
[outputStream writeInt32NoTag:(int32_t)msgSize];
[outputStream writeString:kMapKeyFieldNumber value:key];
WriteDictObjectField(outputStream, obj, kMapValueFieldNumber, mapValueType);
- }];
+ }
}
BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict, GPBFieldDescriptor *field) {
NSCAssert(field.mapKeyDataType == GPBDataTypeString, @"Unexpected key type");
NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeMessage, @"Unexpected value type");
#pragma unused(field) // For when asserts are off in release.
- for (GPBMessage *msg in [dict objectEnumerator]) {
+ GPBMessage *msg;
+ NSEnumerator *objects = [dict objectEnumerator];
+ while ((msg = [objects nextObject])) {
if (!msg.initialized) {
return NO;
}
@@ -400,7 +412,7 @@ static void ReadValue(GPBCodedInputStream *stream,
valueToFill->valueInt32 = GPBCodedInputStreamReadInt32(&stream->state_);
break;
case GPBDataTypeInt64:
- valueToFill->valueInt64 = GPBCodedInputStreamReadInt32(&stream->state_);
+ valueToFill->valueInt64 = GPBCodedInputStreamReadInt64(&stream->state_);
break;
case GPBDataTypeSInt32:
valueToFill->valueInt32 = GPBCodedInputStreamReadSInt32(&stream->state_);
@@ -484,6 +496,8 @@ void GPBDictionaryReadEntry(id mapDictionary,
key.valueString = [@"" retain];
}
if (GPBDataTypeIsObject(valueDataType) && value.valueString == nil) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wswitch-enum"
switch (valueDataType) {
case GPBDataTypeString:
value.valueString = [@"" retain];
@@ -505,6 +519,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
// Nothing
break;
}
+#pragma clang diagnostic pop
}
if ((keyDataType == GPBDataTypeString) && GPBDataTypeIsObject(valueDataType)) {
@@ -568,12 +583,12 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%DICTIONARY_KEY_TO_ENUM_IMPL(KEY_NAME, KEY_TYPE, KisP, Enum, int32_t, KHELPER)
//%PDDM-DEFINE DICTIONARY_KEY_TO_POD_IMPL(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER)
-//%DICTIONARY_COMMON_IMPL(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, POD, value)
+//%DICTIONARY_COMMON_IMPL(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, POD, VALUE_NAME, value)
//%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_IMPL(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE)
-//%DICTIONARY_COMMON_IMPL(KEY_NAME, KEY_TYPE, , VALUE_NAME, VALUE_TYPE, POD, OBJECT, object)
+//%DICTIONARY_COMMON_IMPL(KEY_NAME, KEY_TYPE, , VALUE_NAME, VALUE_TYPE, POD, OBJECT, Object, object)
-//%PDDM-DEFINE DICTIONARY_COMMON_IMPL(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME)
+//%PDDM-DEFINE DICTIONARY_COMMON_IMPL(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR)
//%#pragma mark - KEY_NAME -> VALUE_NAME
//%
//%@implementation GPB##KEY_NAME##VALUE_NAME##Dictionary {
@@ -581,52 +596,19 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% NSMutableDictionary *_dictionary;
//%}
//%
-//%+ (instancetype)dictionary {
-//% return [[[self alloc] initWith##VNAME$u##s:NULL forKeys:NULL count:0] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWith##VNAME$u##:(VALUE_TYPE)##VNAME
-//% ##VNAME$S## forKey:(KEY_TYPE##KisP$S##KisP)key {
-//% // Cast is needed so the compiler knows what class we are invoking initWith##VNAME$u##s:forKeys:count:
-//% // on to get the type correct.
-//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWith##VNAME$u##s:&##VNAME
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:&key
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:1] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWith##VNAME$u##s:(const VALUE_TYPE [])##VNAME##s
-//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
-//% ##VNAME$S## count:(NSUInteger)count {
-//% // Cast is needed so the compiler knows what class we are invoking initWith##VNAME$u##s:forKeys:count:
-//% // on to get the type correct.
-//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWith##VNAME$u##s:##VNAME##s
-//% KEY_NAME$S VALUE_NAME$S forKeys:keys
-//% KEY_NAME$S VALUE_NAME$S count:count] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary {
-//% // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
-//% // on to get the type correct.
-//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
-//% return [[[self alloc] initWithCapacity:numItems] autorelease];
-//%}
-//%
//%- (instancetype)init {
-//% return [self initWith##VNAME$u##s:NULL forKeys:NULL count:0];
+//% return [self initWith##VNAME##s:NULL forKeys:NULL count:0];
//%}
//%
-//%- (instancetype)initWith##VNAME$u##s:(const VALUE_TYPE [])##VNAME##s
+//%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE [])##VNAME_VAR##s
//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
//% ##VNAME$S## count:(NSUInteger)count {
//% self = [super init];
//% if (self) {
//% _dictionary = [[NSMutableDictionary alloc] init];
-//% if (count && VNAME##s && keys) {
+//% if (count && VNAME_VAR##s && keys) {
//% for (NSUInteger i = 0; i < count; ++i) {
-//%DICTIONARY_VALIDATE_VALUE_##VHELPER(VNAME##s[i], ______)##DICTIONARY_VALIDATE_KEY_##KHELPER(keys[i], ______) [_dictionary setObject:WRAPPED##VHELPER(VNAME##s[i]) forKey:WRAPPED##KHELPER(keys[i])];
+//%DICTIONARY_VALIDATE_VALUE_##VHELPER(VNAME_VAR##s[i], ______)##DICTIONARY_VALIDATE_KEY_##KHELPER(keys[i], ______) [_dictionary setObject:WRAPPED##VHELPER(VNAME_VAR##s[i]) forKey:WRAPPED##KHELPER(keys[i])];
//% }
//% }
//% }
@@ -634,7 +616,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%}
//%
//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary {
-//% self = [self initWith##VNAME$u##s:NULL forKeys:NULL count:0];
+//% self = [self initWith##VNAME##s:NULL forKeys:NULL count:0];
//% if (self) {
//% if (dictionary) {
//% [_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -645,14 +627,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%
//%- (instancetype)initWithCapacity:(NSUInteger)numItems {
//% #pragma unused(numItems)
-//% return [self initWith##VNAME$u##s:NULL forKeys:NULL count:0];
+//% return [self initWith##VNAME##s:NULL forKeys:NULL count:0];
//%}
//%
-//%DICTIONARY_IMMUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, )
+//%DICTIONARY_IMMUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR, )
//%
//%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_NAME, VALUE_TYPE, KHELPER)
//%
-//%DICTIONARY_MUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, )
+//%DICTIONARY_MUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR, )
//%
//%@end
//%
@@ -670,54 +652,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%
//%@synthesize validationFunc = _validationFunc;
//%
-//%+ (instancetype)dictionary {
-//% return [[[self alloc] initWithValidationFunction:NULL
-//% rawValues:NULL
-//% forKeys:NULL
-//% count:0] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func {
-//% return [[[self alloc] initWithValidationFunction:func
-//% rawValues:NULL
-//% forKeys:NULL
-//% count:0] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
-//% rawValue:(VALUE_TYPE)rawValue
-//% forKey:(KEY_TYPE##KisP$S##KisP)key {
-//% // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
-//% // on to get the type correct.
-//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWithValidationFunction:func
-//% KEY_NAME$S VALUE_NAME$S rawValues:&rawValue
-//% KEY_NAME$S VALUE_NAME$S forKeys:&key
-//% KEY_NAME$S VALUE_NAME$S count:1] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
-//% rawValues:(const VALUE_TYPE [])rawValues
-//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
-//% count:(NSUInteger)count {
-//% // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
-//% // on to get the type correct.
-//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWithValidationFunction:func
-//% KEY_NAME$S VALUE_NAME$S rawValues:rawValues
-//% KEY_NAME$S VALUE_NAME$S forKeys:keys
-//% KEY_NAME$S VALUE_NAME$S count:count] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary {
-//% // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
-//% // on to get the type correct.
-//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
-//% capacity:(NSUInteger)numItems {
-//% return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease];
-//%}
-//%
//%- (instancetype)init {
//% return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0];
//%}
@@ -762,9 +696,9 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0];
//%}
//%
-//%DICTIONARY_IMMUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, value, Raw)
+//%DICTIONARY_IMMUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, Value, value, Raw)
//%
-//%- (BOOL)valueForKey:(KEY_TYPE##KisP$S##KisP)key value:(VALUE_TYPE *)value {
+//%- (BOOL)getEnum:(VALUE_TYPE *)value forKey:(KEY_TYPE##KisP$S##KisP)key {
//% NSNumber *wrapped = [_dictionary objectForKey:WRAPPED##KHELPER(key)];
//% if (wrapped && value) {
//% VALUE_TYPE result = UNWRAP##VALUE_NAME(wrapped);
@@ -776,7 +710,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% return (wrapped != NULL);
//%}
//%
-//%- (BOOL)valueForKey:(KEY_TYPE##KisP$S##KisP)key rawValue:(VALUE_TYPE *)rawValue {
+//%- (BOOL)getRawValue:(VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key {
//% NSNumber *wrapped = [_dictionary objectForKey:WRAPPED##KHELPER(key)];
//% if (wrapped && rawValue) {
//% *rawValue = UNWRAP##VALUE_NAME(wrapped);
@@ -784,23 +718,28 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% return (wrapped != NULL);
//%}
//%
-//%- (void)enumerateKeysAndValuesUsingBlock:
+//%- (void)enumerateKeysAndEnumsUsingBlock:
//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE value, BOOL *stop))block {
//% GPBEnumValidationFunc func = _validationFunc;
-//% [_dictionary enumerateKeysAndObjectsUsingBlock:^(ENUM_TYPE##KHELPER(KEY_TYPE)##aKey,
-//% ENUM_TYPE##VHELPER(VALUE_TYPE)##aValue,
-//% BOOL *stop) {
+//% BOOL stop = NO;
+//% NSEnumerator *keys = [_dictionary keyEnumerator];
+//% ENUM_TYPE##KHELPER(KEY_TYPE)##aKey;
+//% while ((aKey = [keys nextObject])) {
+//% ENUM_TYPE##VHELPER(VALUE_TYPE)##aValue = _dictionary[aKey];
//% VALUE_TYPE unwrapped = UNWRAP##VALUE_NAME(aValue);
//% if (!func(unwrapped)) {
//% unwrapped = kGPBUnrecognizedEnumeratorValue;
//% }
-//% block(UNWRAP##KEY_NAME(aKey), unwrapped, stop);
-//% }];
+//% block(UNWRAP##KEY_NAME(aKey), unwrapped, &stop);
+//% if (stop) {
+//% break;
+//% }
+//% }
//%}
//%
-//%DICTIONARY_MUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, value, Raw)
+//%DICTIONARY_MUTABLE_CORE2(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, Value, Enum, value, Raw)
//%
-//%- (void)setValue:(VALUE_TYPE)value forKey:(KEY_TYPE##KisP$S##KisP)key {
+//%- (void)setEnum:(VALUE_TYPE)value forKey:(KEY_TYPE##KisP$S##KisP)key {
//%DICTIONARY_VALIDATE_KEY_##KHELPER(key, ) if (!_validationFunc(value)) {
//% [NSException raise:NSInvalidArgumentException
//% format:@"GPB##KEY_NAME##VALUE_NAME##Dictionary: Attempt to set an unknown enum value (%d)",
@@ -816,7 +755,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%@end
//%
-//%PDDM-DEFINE DICTIONARY_IMMUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, ACCESSOR_NAME)
+//%PDDM-DEFINE DICTIONARY_IMMUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR, ACCESSOR_NAME)
//%- (void)dealloc {
//% NSAssert(!_autocreator,
//% @"%@: Autocreator must be cleared before release, autocreator: %@",
@@ -829,14 +768,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% return [[GPB##KEY_NAME##VALUE_NAME##Dictionary allocWithZone:zone] initWithDictionary:self];
//%}
//%
-//%- (BOOL)isEqual:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)other {
+//%- (BOOL)isEqual:(id)other {
//% if (self == other) {
//% return YES;
//% }
//% if (![other isKindOfClass:[GPB##KEY_NAME##VALUE_NAME##Dictionary class]]) {
//% return NO;
//% }
-//% return [_dictionary isEqual:other->_dictionary];
+//% GPB##KEY_NAME##VALUE_NAME##Dictionary *otherDictionary = other;
+//% return [_dictionary isEqual:otherDictionary->_dictionary];
//%}
//%
//%- (NSUInteger)hash {
@@ -851,32 +791,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% return _dictionary.count;
//%}
//%
-//%- (void)enumerateKeysAnd##ACCESSOR_NAME##VNAME$u##sUsingBlock:
-//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME, BOOL *stop))block {
-//% [_dictionary enumerateKeysAndObjectsUsingBlock:^(ENUM_TYPE##KHELPER(KEY_TYPE)##aKey,
-//% ENUM_TYPE##VHELPER(VALUE_TYPE)##a##VNAME$u,
-//% BOOL *stop) {
-//% block(UNWRAP##KEY_NAME(aKey), UNWRAP##VALUE_NAME(a##VNAME$u), stop);
-//% }];
+//%- (void)enumerateKeysAnd##ACCESSOR_NAME##VNAME##sUsingBlock:
+//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block {
+//% BOOL stop = NO;
+//% NSDictionary *internal = _dictionary;
+//% NSEnumerator *keys = [internal keyEnumerator];
+//% ENUM_TYPE##KHELPER(KEY_TYPE)##aKey;
+//% while ((aKey = [keys nextObject])) {
+//% ENUM_TYPE##VHELPER(VALUE_TYPE)##a##VNAME_VAR$u = internal[aKey];
+//% block(UNWRAP##KEY_NAME(aKey), UNWRAP##VALUE_NAME(a##VNAME_VAR$u), &stop);
+//% if (stop) {
+//% break;
+//% }
+//% }
//%}
//%
//%EXTRA_METHODS_##VHELPER(KEY_NAME, VALUE_NAME)- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
-//% NSUInteger count = _dictionary.count;
+//% NSDictionary *internal = _dictionary;
+//% NSUInteger count = internal.count;
//% if (count == 0) {
//% return 0;
//% }
//%
//% GPBDataType valueDataType = GPBGetFieldDataType(field);
//% GPBDataType keyDataType = field.mapKeyDataType;
-//% __block size_t result = 0;
-//% [_dictionary enumerateKeysAndObjectsUsingBlock:^(ENUM_TYPE##KHELPER(KEY_TYPE)##aKey,
-//% ENUM_TYPE##VHELPER(VALUE_TYPE)##a##VNAME$u##,
-//% BOOL *stop) {
-//% #pragma unused(stop)
+//% size_t result = 0;
+//% NSEnumerator *keys = [internal keyEnumerator];
+//% ENUM_TYPE##KHELPER(KEY_TYPE)##aKey;
+//% while ((aKey = [keys nextObject])) {
+//% ENUM_TYPE##VHELPER(VALUE_TYPE)##a##VNAME_VAR$u = internal[aKey];
//% size_t msgSize = ComputeDict##KEY_NAME##FieldSize(UNWRAP##KEY_NAME(aKey), kMapKeyFieldNumber, keyDataType);
-//% msgSize += ComputeDict##VALUE_NAME##FieldSize(UNWRAP##VALUE_NAME(a##VNAME$u), kMapValueFieldNumber, valueDataType);
+//% msgSize += ComputeDict##VALUE_NAME##FieldSize(UNWRAP##VALUE_NAME(a##VNAME_VAR$u), kMapValueFieldNumber, valueDataType);
//% result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
-//% }];
+//% }
//% size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
//% result += tagSize * count;
//% return result;
@@ -887,20 +834,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% GPBDataType valueDataType = GPBGetFieldDataType(field);
//% GPBDataType keyDataType = field.mapKeyDataType;
//% uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
-//% [_dictionary enumerateKeysAndObjectsUsingBlock:^(ENUM_TYPE##KHELPER(KEY_TYPE)##aKey,
-//% ENUM_TYPE##VHELPER(VALUE_TYPE)##a##VNAME$u,
-//% BOOL *stop) {
-//% #pragma unused(stop)
-//% // Write the tag.
+//% NSDictionary *internal = _dictionary;
+//% NSEnumerator *keys = [internal keyEnumerator];
+//% ENUM_TYPE##KHELPER(KEY_TYPE)##aKey;
+//% while ((aKey = [keys nextObject])) {
+//% ENUM_TYPE##VHELPER(VALUE_TYPE)##a##VNAME_VAR$u = internal[aKey];
//% [outputStream writeInt32NoTag:tag];
//% // Write the size of the message.
-//% size_t msgSize = ComputeDict##KEY_NAME##FieldSize(UNWRAP##KEY_NAME(aKey), kMapKeyFieldNumber, keyDataType);
-//% msgSize += ComputeDict##VALUE_NAME##FieldSize(UNWRAP##VALUE_NAME(a##VNAME$u), kMapValueFieldNumber, valueDataType);
+//% KEY_TYPE KisP##unwrappedKey = UNWRAP##KEY_NAME(aKey);
+//% VALUE_TYPE unwrappedValue = UNWRAP##VALUE_NAME(a##VNAME_VAR$u);
+//% size_t msgSize = ComputeDict##KEY_NAME##FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+//% msgSize += ComputeDict##VALUE_NAME##FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
//% [outputStream writeInt32NoTag:(int32_t)msgSize];
//% // Write the fields.
-//% WriteDict##KEY_NAME##Field(outputStream, UNWRAP##KEY_NAME(aKey), kMapKeyFieldNumber, keyDataType);
-//% WriteDict##VALUE_NAME##Field(outputStream, UNWRAP##VALUE_NAME(a##VNAME$u), kMapValueFieldNumber, valueDataType);
-//% }];
+//% WriteDict##KEY_NAME##Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+//% WriteDict##VALUE_NAME##Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+//% }
//%}
//%
//%SERIAL_DATA_FOR_ENTRY_##VHELPER(KEY_NAME, VALUE_NAME)- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -909,12 +858,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%}
//%
//%- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
-//% [self enumerateKeysAnd##ACCESSOR_NAME##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##key, VALUE_TYPE VNAME, BOOL *stop) {
+//% [self enumerateKeysAnd##ACCESSOR_NAME##VNAME##sUsingBlock:^(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop) {
//% #pragma unused(stop)
-//% block(TEXT_FORMAT_OBJ##KEY_NAME(key), TEXT_FORMAT_OBJ##VALUE_NAME(VNAME));
+//% block(TEXT_FORMAT_OBJ##KEY_NAME(key), TEXT_FORMAT_OBJ##VALUE_NAME(VNAME_VAR));
//% }];
//%}
-//%PDDM-DEFINE DICTIONARY_MUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, ACCESSOR_NAME)
+//%PDDM-DEFINE DICTIONARY_MUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR, ACCESSOR_NAME)
+//%DICTIONARY_MUTABLE_CORE2(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME, VNAME_VAR, ACCESSOR_NAME)
+//%PDDM-DEFINE DICTIONARY_MUTABLE_CORE2(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_REMOVE, VNAME_VAR, ACCESSOR_NAME)
//%- (void)add##ACCESSOR_NAME##EntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary {
//% if (otherDictionary) {
//% [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary];
@@ -924,14 +875,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% }
//%}
//%
-//%- (void)set##ACCESSOR_NAME##VNAME$u##:(VALUE_TYPE)VNAME forKey:(KEY_TYPE##KisP$S##KisP)key {
-//%DICTIONARY_VALIDATE_VALUE_##VHELPER(VNAME, )##DICTIONARY_VALIDATE_KEY_##KHELPER(key, ) [_dictionary setObject:WRAPPED##VHELPER(VNAME) forKey:WRAPPED##KHELPER(key)];
+//%- (void)set##ACCESSOR_NAME##VNAME##:(VALUE_TYPE)VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key {
+//%DICTIONARY_VALIDATE_VALUE_##VHELPER(VNAME_VAR, )##DICTIONARY_VALIDATE_KEY_##KHELPER(key, ) [_dictionary setObject:WRAPPED##VHELPER(VNAME_VAR) forKey:WRAPPED##KHELPER(key)];
//% if (_autocreator) {
//% GPBAutocreatedDictionaryModified(_autocreator, self);
//% }
//%}
//%
-//%- (void)remove##VNAME$u##ForKey:(KEY_TYPE##KisP$S##KisP)aKey {
+//%- (void)remove##VNAME_REMOVE##ForKey:(KEY_TYPE##KisP$S##KisP)aKey {
//% [_dictionary removeObjectForKey:WRAPPED##KHELPER(aKey)];
//%}
//%
@@ -944,11 +895,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
//
//%PDDM-DEFINE DICTIONARY_BOOL_KEY_TO_POD_IMPL(VALUE_NAME, VALUE_TYPE)
-//%DICTIONARY_BOOL_KEY_TO_VALUE_IMPL(VALUE_NAME, VALUE_TYPE, POD, value)
+//%DICTIONARY_BOOL_KEY_TO_VALUE_IMPL(VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value)
//%PDDM-DEFINE DICTIONARY_BOOL_KEY_TO_OBJECT_IMPL(VALUE_NAME, VALUE_TYPE)
-//%DICTIONARY_BOOL_KEY_TO_VALUE_IMPL(VALUE_NAME, VALUE_TYPE, OBJECT, object)
+//%DICTIONARY_BOOL_KEY_TO_VALUE_IMPL(VALUE_NAME, VALUE_TYPE, OBJECT, Object, object)
-//%PDDM-DEFINE DICTIONARY_BOOL_KEY_TO_VALUE_IMPL(VALUE_NAME, VALUE_TYPE, HELPER, VNAME)
+//%PDDM-DEFINE DICTIONARY_BOOL_KEY_TO_VALUE_IMPL(VALUE_NAME, VALUE_TYPE, HELPER, VNAME, VNAME_VAR)
//%#pragma mark - Bool -> VALUE_NAME
//%
//%@implementation GPBBool##VALUE_NAME##Dictionary {
@@ -956,48 +907,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% VALUE_TYPE _values[2];
//%BOOL_DICT_HAS_STORAGE_##HELPER()}
//%
-//%+ (instancetype)dictionary {
-//% return [[[self alloc] initWith##VNAME$u##s:NULL forKeys:NULL count:0] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWith##VNAME$u##:(VALUE_TYPE)VNAME
-//% ##VNAME$S## forKey:(BOOL)key {
-//% // Cast is needed so the compiler knows what class we are invoking initWith##VNAME$u##s:forKeys:count:
-//% // on to get the type correct.
-//% return [[(GPBBool##VALUE_NAME##Dictionary*)[self alloc] initWith##VNAME$u##s:&##VNAME
-//% VALUE_NAME$S ##VNAME$S## forKeys:&key
-//% VALUE_NAME$S ##VNAME$S## count:1] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWith##VNAME$u##s:(const VALUE_TYPE [])##VNAME##s
-//% ##VNAME$S## forKeys:(const BOOL [])keys
-//% ##VNAME$S## count:(NSUInteger)count {
-//% // Cast is needed so the compiler knows what class we are invoking initWith##VNAME$u##s:forKeys:count:
-//% // on to get the type correct.
-//% return [[(GPBBool##VALUE_NAME##Dictionary*)[self alloc] initWith##VNAME$u##s:##VNAME##s
-//% VALUE_NAME$S ##VNAME$S## forKeys:keys
-//% VALUE_NAME$S ##VNAME$S## count:count] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWithDictionary:(GPBBool##VALUE_NAME##Dictionary *)dictionary {
-//% // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
-//% // on to get the type correct.
-//% return [[(GPBBool##VALUE_NAME##Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-//%}
-//%
-//%+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
-//% return [[[self alloc] initWithCapacity:numItems] autorelease];
-//%}
-//%
//%- (instancetype)init {
-//% return [self initWith##VNAME$u##s:NULL forKeys:NULL count:0];
+//% return [self initWith##VNAME##s:NULL forKeys:NULL count:0];
//%}
//%
//%BOOL_DICT_INITS_##HELPER(VALUE_NAME, VALUE_TYPE)
//%
//%- (instancetype)initWithCapacity:(NSUInteger)numItems {
//% #pragma unused(numItems)
-//% return [self initWith##VNAME$u##s:NULL forKeys:NULL count:0];
+//% return [self initWith##VNAME##s:NULL forKeys:NULL count:0];
//%}
//%
//%BOOL_DICT_DEALLOC##HELPER()
@@ -1006,19 +924,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% return [[GPBBool##VALUE_NAME##Dictionary allocWithZone:zone] initWithDictionary:self];
//%}
//%
-//%- (BOOL)isEqual:(GPBBool##VALUE_NAME##Dictionary *)other {
+//%- (BOOL)isEqual:(id)other {
//% if (self == other) {
//% return YES;
//% }
//% if (![other isKindOfClass:[GPBBool##VALUE_NAME##Dictionary class]]) {
//% return NO;
//% }
-//% if ((BOOL_DICT_W_HAS##HELPER(0, ) != BOOL_DICT_W_HAS##HELPER(0, other->)) ||
-//% (BOOL_DICT_W_HAS##HELPER(1, ) != BOOL_DICT_W_HAS##HELPER(1, other->))) {
+//% GPBBool##VALUE_NAME##Dictionary *otherDictionary = other;
+//% if ((BOOL_DICT_W_HAS##HELPER(0, ) != BOOL_DICT_W_HAS##HELPER(0, otherDictionary->)) ||
+//% (BOOL_DICT_W_HAS##HELPER(1, ) != BOOL_DICT_W_HAS##HELPER(1, otherDictionary->))) {
//% return NO;
//% }
-//% if ((BOOL_DICT_W_HAS##HELPER(0, ) && (NEQ_##HELPER(_values[0], other->_values[0]))) ||
-//% (BOOL_DICT_W_HAS##HELPER(1, ) && (NEQ_##HELPER(_values[1], other->_values[1])))) {
+//% if ((BOOL_DICT_W_HAS##HELPER(0, ) && (NEQ_##HELPER(_values[0], otherDictionary->_values[0]))) ||
+//% (BOOL_DICT_W_HAS##HELPER(1, ) && (NEQ_##HELPER(_values[1], otherDictionary->_values[1])))) {
//% return NO;
//% }
//% return YES;
@@ -1044,7 +963,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% return (BOOL_DICT_W_HAS##HELPER(0, ) ? 1 : 0) + (BOOL_DICT_W_HAS##HELPER(1, ) ? 1 : 0);
//%}
//%
-//%BOOL_VALUE_FOR_KEY_##HELPER(VALUE_TYPE)
+//%BOOL_VALUE_FOR_KEY_##HELPER(VALUE_NAME, VALUE_TYPE)
//%
//%BOOL_SET_GPBVALUE_FOR_KEY_##HELPER(VALUE_NAME, VALUE_TYPE, VisP)
//%
@@ -1057,8 +976,8 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% }
//%}
//%
-//%- (void)enumerateKeysAnd##VNAME$u##sUsingBlock:
-//% (void (^)(BOOL key, VALUE_TYPE VNAME, BOOL *stop))block {
+//%- (void)enumerateKeysAnd##VNAME##sUsingBlock:
+//% (void (^)(BOOL key, VALUE_TYPE VNAME_VAR, BOOL *stop))block {
//% BOOL stop = NO;
//% if (BOOL_DICT_HAS##HELPER(0, )) {
//% block(NO, _values[0], &stop);
@@ -1115,7 +1034,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
//
//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_NAME, VALUE_TYPE, KHELPER)
-//%- (BOOL)valueForKey:(KEY_TYPE)key value:(VALUE_TYPE *)value {
+//%- (BOOL)get##VALUE_NAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key {
//% NSNumber *wrapped = [_dictionary objectForKey:WRAPPED##KHELPER(key)];
//% if (wrapped && value) {
//% *value = UNWRAP##VALUE_NAME(wrapped);
@@ -1205,9 +1124,9 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% BOOL _valueSet[2];
//%
//%PDDM-DEFINE BOOL_DICT_INITS_POD(VALUE_NAME, VALUE_TYPE)
-//%- (instancetype)initWithValues:(const VALUE_TYPE [])values
-//% forKeys:(const BOOL [])keys
-//% count:(NSUInteger)count {
+//%- (instancetype)initWith##VALUE_NAME##s:(const VALUE_TYPE [])values
+//% ##VALUE_NAME$S## forKeys:(const BOOL [])keys
+//% ##VALUE_NAME$S## count:(NSUInteger)count {
//% self = [super init];
//% if (self) {
//% for (NSUInteger i = 0; i < count; ++i) {
@@ -1220,7 +1139,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%}
//%
//%- (instancetype)initWithDictionary:(GPBBool##VALUE_NAME##Dictionary *)dictionary {
-//% self = [self initWithValues:NULL forKeys:NULL count:0];
+//% self = [self initWith##VALUE_NAME##s:NULL forKeys:NULL count:0];
//% if (self) {
//% if (dictionary) {
//% for (int i = 0; i < 2; ++i) {
@@ -1246,8 +1165,8 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%BOOL_DICT_HASPOD(IDX, REF)
//%PDDM-DEFINE BOOL_DICT_HASPOD(IDX, REF)
//%REF##_valueSet[IDX]
-//%PDDM-DEFINE BOOL_VALUE_FOR_KEY_POD(VALUE_TYPE)
-//%- (BOOL)valueForKey:(BOOL)key value:(VALUE_TYPE *)value {
+//%PDDM-DEFINE BOOL_VALUE_FOR_KEY_POD(VALUE_NAME, VALUE_TYPE)
+//%- (BOOL)get##VALUE_NAME##:(VALUE_TYPE *)value forKey:(BOOL)key {
//% int idx = (key ? 1 : 0);
//% if (_valueSet[idx]) {
//% if (value) {
@@ -1279,7 +1198,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% }
//%}
//%
-//%- (void)setValue:(VALUE_TYPE)value forKey:(BOOL)key {
+//%- (void)set##VALUE_NAME:(VALUE_TYPE)value forKey:(BOOL)key {
//% int idx = (key ? 1 : 0);
//% _values[idx] = value;
//% _valueSet[idx] = YES;
@@ -1288,7 +1207,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
//% }
//%}
//%
-//%- (void)removeValueForKey:(BOOL)aKey {
+//%- (void)remove##VALUE_NAME##ForKey:(BOOL)aKey {
//% _valueSet[aKey ? 1 : 0] = NO;
//%}
//%
@@ -1353,14 +1272,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%- (instancetype)deepCopyWithZone:(NSZone *)zone {
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *newDict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
-//% [_dictionary enumerateKeysAndObjectsUsingBlock:^(id aKey,
-//% GPBMessage *msg,
-//% BOOL *stop) {
-//% #pragma unused(stop)
+//% NSEnumerator *keys = [_dictionary keyEnumerator];
+//% id aKey;
+//% NSMutableDictionary *internalDict = newDict->_dictionary;
+//% while ((aKey = [keys nextObject])) {
+//% GPBMessage *msg = _dictionary[aKey];
//% GPBMessage *copiedMsg = [msg copyWithZone:zone];
-//% [newDict->_dictionary setObject:copiedMsg forKey:aKey];
+//% [internalDict setObject:copiedMsg forKey:aKey];
//% [copiedMsg release];
-//% }];
+//% }
//% return newDict;
//%}
//%
@@ -1449,7 +1369,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
//%(BOOL_DICT_HASOBJECT(IDX, REF))
//%PDDM-DEFINE BOOL_DICT_HASOBJECT(IDX, REF)
//%REF##_values[IDX] != nil
-//%PDDM-DEFINE BOOL_VALUE_FOR_KEY_OBJECT(VALUE_TYPE)
+//%PDDM-DEFINE BOOL_VALUE_FOR_KEY_OBJECT(VALUE_NAME, VALUE_TYPE)
//%- (VALUE_TYPE)objectForKey:(BOOL)key {
//% return _values[key ? 1 : 0];
//%}
@@ -1515,46 +1435,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(uint32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32UInt32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32UInt32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt32UInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt32s:(const uint32_t [])values
+ forKeys:(const uint32_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -1568,7 +1455,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -1579,7 +1466,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -1594,14 +1481,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt32UInt32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt32UInt32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32UInt32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt32UInt32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -1616,32 +1504,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(uint32_t key, uint32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedIntValue], [aValue unsignedIntValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedIntValue], [aValue unsignedIntValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -1652,20 +1547,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
+ uint32_t unwrappedKey = [aKey unsignedIntValue];
+ uint32_t unwrappedValue = [aValue unsignedIntValue];
+ size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt32Field(outputStream, [aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- WriteDictUInt32Field(outputStream, [aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -1674,13 +1571,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint32_t key, uint32_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt32sUsingBlock:^(uint32_t key, uint32_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%u", value]);
}];
}
-- (BOOL)valueForKey:(uint32_t)key value:(uint32_t *)value {
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped unsignedIntValue];
@@ -1697,14 +1594,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint32_t)value forKey:(uint32_t)key {
+- (void)setUInt32:(uint32_t)value forKey:(uint32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint32_t)aKey {
+- (void)removeUInt32ForKey:(uint32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -1721,44 +1618,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(uint32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32Int32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32Int32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32Int32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt32Int32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int32_t [])values
+- (instancetype)initWithInt32s:(const int32_t [])values
forKeys:(const uint32_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -1774,7 +1638,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -1785,7 +1649,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -1800,14 +1664,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt32Int32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt32Int32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32Int32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt32Int32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -1822,32 +1687,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(uint32_t key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedIntValue], [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedIntValue], [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -1858,20 +1730,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ uint32_t unwrappedKey = [aKey unsignedIntValue];
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt32Field(outputStream, [aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- WriteDictInt32Field(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -1880,13 +1754,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint32_t key, int32_t value, BOOL *stop) {
+ [self enumerateKeysAndInt32sUsingBlock:^(uint32_t key, int32_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%d", value]);
}];
}
-- (BOOL)valueForKey:(uint32_t)key value:(int32_t *)value {
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped intValue];
@@ -1903,14 +1777,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int32_t)value forKey:(uint32_t)key {
+- (void)setInt32:(int32_t)value forKey:(uint32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint32_t)aKey {
+- (void)removeInt32ForKey:(uint32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -1927,46 +1801,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(uint32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32UInt64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32UInt64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt32UInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt64s:(const uint64_t [])values
+ forKeys:(const uint32_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -1980,7 +1821,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -1991,7 +1832,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -2006,14 +1847,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt32UInt64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt32UInt64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32UInt64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt32UInt64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -2028,32 +1870,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(uint32_t key, uint64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedIntValue], [aValue unsignedLongLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedIntValue], [aValue unsignedLongLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -2064,20 +1913,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
+ uint32_t unwrappedKey = [aKey unsignedIntValue];
+ uint64_t unwrappedValue = [aValue unsignedLongLongValue];
+ size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt32Field(outputStream, [aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- WriteDictUInt64Field(outputStream, [aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -2086,13 +1937,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint32_t key, uint64_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt64sUsingBlock:^(uint32_t key, uint64_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%llu", value]);
}];
}
-- (BOOL)valueForKey:(uint32_t)key value:(uint64_t *)value {
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped unsignedLongLongValue];
@@ -2109,14 +1960,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint64_t)value forKey:(uint32_t)key {
+- (void)setUInt64:(uint64_t)value forKey:(uint32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint32_t)aKey {
+- (void)removeUInt64ForKey:(uint32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -2133,44 +1984,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(uint32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32Int64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32Int64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32Int64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt32Int64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int64_t [])values
+- (instancetype)initWithInt64s:(const int64_t [])values
forKeys:(const uint32_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -2186,7 +2004,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -2197,7 +2015,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -2212,14 +2030,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt32Int64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt32Int64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32Int64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt32Int64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -2234,32 +2053,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(uint32_t key, int64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedIntValue], [aValue longLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedIntValue], [aValue longLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -2270,20 +2096,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
+ uint32_t unwrappedKey = [aKey unsignedIntValue];
+ int64_t unwrappedValue = [aValue longLongValue];
+ size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt32Field(outputStream, [aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- WriteDictInt64Field(outputStream, [aValue longLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -2292,13 +2120,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint32_t key, int64_t value, BOOL *stop) {
+ [self enumerateKeysAndInt64sUsingBlock:^(uint32_t key, int64_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%lld", value]);
}];
}
-- (BOOL)valueForKey:(uint32_t)key value:(int64_t *)value {
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped longLongValue];
@@ -2315,14 +2143,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int64_t)value forKey:(uint32_t)key {
+- (void)setInt64:(int64_t)value forKey:(uint32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint32_t)aKey {
+- (void)removeInt64ForKey:(uint32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -2339,46 +2167,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(uint32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32BoolDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32BoolDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32BoolDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt32BoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithBools:(const BOOL [])values
+ forKeys:(const uint32_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -2392,7 +2187,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithBools:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -2403,7 +2198,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -2418,14 +2213,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt32BoolDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt32BoolDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32BoolDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt32BoolDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -2440,32 +2236,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(uint32_t key, BOOL value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedIntValue], [aValue boolValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedIntValue], [aValue boolValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -2476,20 +2279,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
+ uint32_t unwrappedKey = [aKey unsignedIntValue];
+ BOOL unwrappedValue = [aValue boolValue];
+ size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt32Field(outputStream, [aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- WriteDictBoolField(outputStream, [aValue boolValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -2498,13 +2303,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint32_t key, BOOL value, BOOL *stop) {
+ [self enumerateKeysAndBoolsUsingBlock:^(uint32_t key, BOOL value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%u", key], (value ? @"true" : @"false"));
}];
}
-- (BOOL)valueForKey:(uint32_t)key value:(BOOL *)value {
+- (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped boolValue];
@@ -2521,14 +2326,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(BOOL)value forKey:(uint32_t)key {
+- (void)setBool:(BOOL)value forKey:(uint32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint32_t)aKey {
+- (void)removeBoolForKey:(uint32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -2545,44 +2350,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(uint32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32FloatDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32FloatDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32FloatDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt32FloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const float [])values
+- (instancetype)initWithFloats:(const float [])values
forKeys:(const uint32_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -2598,7 +2370,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithFloats:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -2609,7 +2381,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -2624,14 +2396,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt32FloatDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt32FloatDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32FloatDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt32FloatDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -2646,32 +2419,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(uint32_t key, float value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedIntValue], [aValue floatValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedIntValue], [aValue floatValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -2682,20 +2462,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
+ uint32_t unwrappedKey = [aKey unsignedIntValue];
+ float unwrappedValue = [aValue floatValue];
+ size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt32Field(outputStream, [aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- WriteDictFloatField(outputStream, [aValue floatValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -2704,13 +2486,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint32_t key, float value, BOOL *stop) {
+ [self enumerateKeysAndFloatsUsingBlock:^(uint32_t key, float value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%.*g", FLT_DIG, value]);
}];
}
-- (BOOL)valueForKey:(uint32_t)key value:(float *)value {
+- (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped floatValue];
@@ -2727,14 +2509,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(float)value forKey:(uint32_t)key {
+- (void)setFloat:(float)value forKey:(uint32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint32_t)aKey {
+- (void)removeFloatForKey:(uint32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -2751,46 +2533,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(uint32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32DoubleDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32DoubleDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32DoubleDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt32DoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithDoubles:(const double [])values
+ forKeys:(const uint32_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -2804,7 +2553,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithDoubles:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -2815,7 +2564,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -2830,14 +2579,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt32DoubleDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt32DoubleDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32DoubleDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt32DoubleDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -2852,32 +2602,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(uint32_t key, double value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedIntValue], [aValue doubleValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedIntValue], [aValue doubleValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -2888,20 +2645,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
+ uint32_t unwrappedKey = [aKey unsignedIntValue];
+ double unwrappedValue = [aValue doubleValue];
+ size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt32Field(outputStream, [aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- WriteDictDoubleField(outputStream, [aValue doubleValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -2910,13 +2669,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint32_t key, double value, BOOL *stop) {
+ [self enumerateKeysAndDoublesUsingBlock:^(uint32_t key, double value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]);
}];
}
-- (BOOL)valueForKey:(uint32_t)key value:(double *)value {
+- (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped doubleValue];
@@ -2933,14 +2692,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(double)value forKey:(uint32_t)key {
+- (void)setDouble:(double)value forKey:(uint32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint32_t)aKey {
+- (void)removeDoubleForKey:(uint32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -2960,54 +2719,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
@synthesize validationFunc = _validationFunc;
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValidationFunction:NULL
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func {
- return [[[self alloc] initWithValidationFunction:func
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(uint32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32EnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:&rawValue
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValues:(const int32_t [])rawValues
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32EnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:rawValues
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32EnumDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32EnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems {
- return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0];
}
@@ -3064,14 +2775,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt32EnumDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt32EnumDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32EnumDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt32EnumDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -3088,30 +2800,37 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(uint32_t key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedIntValue], [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedIntValue], [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -3122,20 +2841,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ uint32_t unwrappedKey = [aKey unsignedIntValue];
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt32Field(outputStream, [aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- WriteDictEnumField(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
@@ -3162,7 +2883,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}];
}
-- (BOOL)valueForKey:(uint32_t)key value:(int32_t *)value {
+- (BOOL)getEnum:(int32_t *)value forKey:(uint32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
int32_t result = [wrapped intValue];
@@ -3174,7 +2895,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (BOOL)valueForKey:(uint32_t)key rawValue:(int32_t *)rawValue {
+- (BOOL)getRawValue:(int32_t *)rawValue forKey:(uint32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && rawValue) {
*rawValue = [wrapped intValue];
@@ -3182,18 +2903,23 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(uint32_t key, int32_t value, BOOL *stop))block {
GPBEnumValidationFunc func = _validationFunc;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
+ BOOL stop = NO;
+ NSEnumerator *keys = [_dictionary keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = _dictionary[aKey];
int32_t unwrapped = [aValue intValue];
if (!func(unwrapped)) {
unwrapped = kGPBUnrecognizedEnumeratorValue;
}
- block([aKey unsignedIntValue], unwrapped, stop);
- }];
+ block([aKey unsignedIntValue], unwrapped, &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary {
@@ -3212,7 +2938,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(uint32_t)aKey {
+- (void)removeEnumForKey:(uint32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -3220,7 +2946,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
[_dictionary removeAllObjects];
}
-- (void)setValue:(int32_t)value forKey:(uint32_t)key {
+- (void)setEnum:(int32_t)value forKey:(uint32_t)key {
if (!_validationFunc(value)) {
[NSException raise:NSInvalidArgumentException
format:@"GPBUInt32EnumDictionary: Attempt to set an unknown enum value (%d)",
@@ -3242,39 +2968,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(uint32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32ObjectDictionary*)[self alloc] initWithObjects:&object
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithObjects:(const id [])objects
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt32ObjectDictionary*)[self alloc] initWithObjects:objects
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt32ObjectDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt32ObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithObjects:NULL forKeys:NULL count:0];
}
@@ -3325,14 +3018,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt32ObjectDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt32ObjectDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt32ObjectDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt32ObjectDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -3349,11 +3043,17 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (void)enumerateKeysAndObjectsUsingBlock:
(void (^)(uint32_t key, id object, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- block([aKey unsignedIntValue], aObject, stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
+ block([aKey unsignedIntValue], aObject, &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (BOOL)isInitialized {
@@ -3368,34 +3068,36 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)deepCopyWithZone:(NSZone *)zone {
GPBUInt32ObjectDictionary *newDict =
[[GPBUInt32ObjectDictionary alloc] init];
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(id aKey,
- GPBMessage *msg,
- BOOL *stop) {
- #pragma unused(stop)
+ NSEnumerator *keys = [_dictionary keyEnumerator];
+ id aKey;
+ NSMutableDictionary *internalDict = newDict->_dictionary;
+ while ((aKey = [keys nextObject])) {
+ GPBMessage *msg = _dictionary[aKey];
GPBMessage *copiedMsg = [msg copyWithZone:zone];
- [newDict->_dictionary setObject:copiedMsg forKey:aKey];
+ [internalDict setObject:copiedMsg forKey:aKey];
[copiedMsg release];
- }];
+ }
return newDict;
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -3406,20 +3108,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType);
+ uint32_t unwrappedKey = [aKey unsignedIntValue];
+ id unwrappedValue = aObject;
+ size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictObjectFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt32Field(outputStream, [aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType);
- WriteDictObjectField(outputStream, aObject, kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictObjectField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -3479,46 +3183,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(int32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32UInt32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32UInt32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt32UInt32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt32UInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt32s:(const uint32_t [])values
+ forKeys:(const int32_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -3532,7 +3203,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -3543,7 +3214,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -3558,14 +3229,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt32UInt32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt32UInt32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32UInt32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt32UInt32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -3580,32 +3252,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(int32_t key, uint32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey intValue], [aValue unsignedIntValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey intValue], [aValue unsignedIntValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -3616,20 +3295,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
+ int32_t unwrappedKey = [aKey intValue];
+ uint32_t unwrappedValue = [aValue unsignedIntValue];
+ size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt32Field(outputStream, [aKey intValue], kMapKeyFieldNumber, keyDataType);
- WriteDictUInt32Field(outputStream, [aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -3638,13 +3319,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int32_t key, uint32_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt32sUsingBlock:^(int32_t key, uint32_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%u", value]);
}];
}
-- (BOOL)valueForKey:(int32_t)key value:(uint32_t *)value {
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped unsignedIntValue];
@@ -3661,14 +3342,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint32_t)value forKey:(int32_t)key {
+- (void)setUInt32:(uint32_t)value forKey:(int32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int32_t)aKey {
+- (void)removeUInt32ForKey:(int32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -3685,44 +3366,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(int32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32Int32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32Int32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt32Int32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt32Int32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int32_t [])values
+- (instancetype)initWithInt32s:(const int32_t [])values
forKeys:(const int32_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -3738,7 +3386,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -3749,7 +3397,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -3764,14 +3412,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt32Int32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt32Int32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32Int32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt32Int32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -3786,32 +3435,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(int32_t key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey intValue], [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey intValue], [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -3822,20 +3478,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ int32_t unwrappedKey = [aKey intValue];
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt32Field(outputStream, [aKey intValue], kMapKeyFieldNumber, keyDataType);
- WriteDictInt32Field(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -3844,13 +3502,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int32_t key, int32_t value, BOOL *stop) {
+ [self enumerateKeysAndInt32sUsingBlock:^(int32_t key, int32_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%d", value]);
}];
}
-- (BOOL)valueForKey:(int32_t)key value:(int32_t *)value {
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped intValue];
@@ -3867,14 +3525,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int32_t)value forKey:(int32_t)key {
+- (void)setInt32:(int32_t)value forKey:(int32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int32_t)aKey {
+- (void)removeInt32ForKey:(int32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -3891,46 +3549,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(int32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32UInt64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32UInt64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt32UInt64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt32UInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt64s:(const uint64_t [])values
+ forKeys:(const int32_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -3944,7 +3569,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -3955,7 +3580,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -3970,14 +3595,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt32UInt64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt32UInt64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32UInt64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt32UInt64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -3992,32 +3618,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(int32_t key, uint64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey intValue], [aValue unsignedLongLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey intValue], [aValue unsignedLongLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -4028,20 +3661,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
+ int32_t unwrappedKey = [aKey intValue];
+ uint64_t unwrappedValue = [aValue unsignedLongLongValue];
+ size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt32Field(outputStream, [aKey intValue], kMapKeyFieldNumber, keyDataType);
- WriteDictUInt64Field(outputStream, [aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -4050,13 +3685,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int32_t key, uint64_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt64sUsingBlock:^(int32_t key, uint64_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%llu", value]);
}];
}
-- (BOOL)valueForKey:(int32_t)key value:(uint64_t *)value {
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped unsignedLongLongValue];
@@ -4073,14 +3708,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint64_t)value forKey:(int32_t)key {
+- (void)setUInt64:(uint64_t)value forKey:(int32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int32_t)aKey {
+- (void)removeUInt64ForKey:(int32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -4097,44 +3732,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(int32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32Int64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32Int64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt32Int64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt32Int64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int64_t [])values
+- (instancetype)initWithInt64s:(const int64_t [])values
forKeys:(const int32_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -4150,7 +3752,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -4161,7 +3763,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -4176,14 +3778,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt32Int64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt32Int64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32Int64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt32Int64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -4198,32 +3801,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(int32_t key, int64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey intValue], [aValue longLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey intValue], [aValue longLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -4234,20 +3844,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
+ int32_t unwrappedKey = [aKey intValue];
+ int64_t unwrappedValue = [aValue longLongValue];
+ size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt32Field(outputStream, [aKey intValue], kMapKeyFieldNumber, keyDataType);
- WriteDictInt64Field(outputStream, [aValue longLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -4256,13 +3868,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int32_t key, int64_t value, BOOL *stop) {
+ [self enumerateKeysAndInt64sUsingBlock:^(int32_t key, int64_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%lld", value]);
}];
}
-- (BOOL)valueForKey:(int32_t)key value:(int64_t *)value {
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped longLongValue];
@@ -4279,14 +3891,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int64_t)value forKey:(int32_t)key {
+- (void)setInt64:(int64_t)value forKey:(int32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int32_t)aKey {
+- (void)removeInt64ForKey:(int32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -4303,46 +3915,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(int32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32BoolDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32BoolDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt32BoolDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt32BoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithBools:(const BOOL [])values
+ forKeys:(const int32_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -4356,7 +3935,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithBools:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -4367,7 +3946,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -4382,14 +3961,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt32BoolDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt32BoolDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32BoolDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt32BoolDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -4404,32 +3984,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(int32_t key, BOOL value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey intValue], [aValue boolValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey intValue], [aValue boolValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -4440,20 +4027,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
+ int32_t unwrappedKey = [aKey intValue];
+ BOOL unwrappedValue = [aValue boolValue];
+ size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt32Field(outputStream, [aKey intValue], kMapKeyFieldNumber, keyDataType);
- WriteDictBoolField(outputStream, [aValue boolValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -4462,13 +4051,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int32_t key, BOOL value, BOOL *stop) {
+ [self enumerateKeysAndBoolsUsingBlock:^(int32_t key, BOOL value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%d", key], (value ? @"true" : @"false"));
}];
}
-- (BOOL)valueForKey:(int32_t)key value:(BOOL *)value {
+- (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped boolValue];
@@ -4485,14 +4074,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(BOOL)value forKey:(int32_t)key {
+- (void)setBool:(BOOL)value forKey:(int32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int32_t)aKey {
+- (void)removeBoolForKey:(int32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -4509,44 +4098,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(int32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32FloatDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32FloatDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt32FloatDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt32FloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const float [])values
+- (instancetype)initWithFloats:(const float [])values
forKeys:(const int32_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -4562,7 +4118,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithFloats:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -4573,7 +4129,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -4588,14 +4144,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt32FloatDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt32FloatDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32FloatDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt32FloatDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -4610,32 +4167,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(int32_t key, float value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey intValue], [aValue floatValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey intValue], [aValue floatValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -4646,20 +4210,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
+ int32_t unwrappedKey = [aKey intValue];
+ float unwrappedValue = [aValue floatValue];
+ size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt32Field(outputStream, [aKey intValue], kMapKeyFieldNumber, keyDataType);
- WriteDictFloatField(outputStream, [aValue floatValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -4668,13 +4234,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int32_t key, float value, BOOL *stop) {
+ [self enumerateKeysAndFloatsUsingBlock:^(int32_t key, float value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%.*g", FLT_DIG, value]);
}];
}
-- (BOOL)valueForKey:(int32_t)key value:(float *)value {
+- (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped floatValue];
@@ -4691,14 +4257,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(float)value forKey:(int32_t)key {
+- (void)setFloat:(float)value forKey:(int32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int32_t)aKey {
+- (void)removeFloatForKey:(int32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -4715,46 +4281,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(int32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32DoubleDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32DoubleDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt32DoubleDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt32DoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithDoubles:(const double [])values
+ forKeys:(const int32_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -4768,7 +4301,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithDoubles:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -4779,7 +4312,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -4794,14 +4327,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt32DoubleDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt32DoubleDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32DoubleDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt32DoubleDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -4816,32 +4350,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(int32_t key, double value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey intValue], [aValue doubleValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey intValue], [aValue doubleValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -4852,20 +4393,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
+ int32_t unwrappedKey = [aKey intValue];
+ double unwrappedValue = [aValue doubleValue];
+ size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt32Field(outputStream, [aKey intValue], kMapKeyFieldNumber, keyDataType);
- WriteDictDoubleField(outputStream, [aValue doubleValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -4874,13 +4417,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int32_t key, double value, BOOL *stop) {
+ [self enumerateKeysAndDoublesUsingBlock:^(int32_t key, double value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]);
}];
}
-- (BOOL)valueForKey:(int32_t)key value:(double *)value {
+- (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped doubleValue];
@@ -4897,14 +4440,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(double)value forKey:(int32_t)key {
+- (void)setDouble:(double)value forKey:(int32_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int32_t)aKey {
+- (void)removeDoubleForKey:(int32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -4924,54 +4467,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
@synthesize validationFunc = _validationFunc;
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValidationFunction:NULL
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func {
- return [[[self alloc] initWithValidationFunction:func
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(int32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32EnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:&rawValue
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValues:(const int32_t [])rawValues
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32EnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:rawValues
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt32EnumDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32EnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems {
- return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0];
}
@@ -5028,14 +4523,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt32EnumDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt32EnumDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32EnumDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt32EnumDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -5052,30 +4548,37 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(int32_t key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey intValue], [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey intValue], [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -5086,20 +4589,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ int32_t unwrappedKey = [aKey intValue];
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt32Field(outputStream, [aKey intValue], kMapKeyFieldNumber, keyDataType);
- WriteDictEnumField(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
@@ -5126,7 +4631,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}];
}
-- (BOOL)valueForKey:(int32_t)key value:(int32_t *)value {
+- (BOOL)getEnum:(int32_t *)value forKey:(int32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
int32_t result = [wrapped intValue];
@@ -5138,7 +4643,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (BOOL)valueForKey:(int32_t)key rawValue:(int32_t *)rawValue {
+- (BOOL)getRawValue:(int32_t *)rawValue forKey:(int32_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && rawValue) {
*rawValue = [wrapped intValue];
@@ -5146,18 +4651,23 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(int32_t key, int32_t value, BOOL *stop))block {
GPBEnumValidationFunc func = _validationFunc;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
+ BOOL stop = NO;
+ NSEnumerator *keys = [_dictionary keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = _dictionary[aKey];
int32_t unwrapped = [aValue intValue];
if (!func(unwrapped)) {
unwrapped = kGPBUnrecognizedEnumeratorValue;
}
- block([aKey intValue], unwrapped, stop);
- }];
+ block([aKey intValue], unwrapped, &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary {
@@ -5176,7 +4686,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(int32_t)aKey {
+- (void)removeEnumForKey:(int32_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -5184,7 +4694,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
[_dictionary removeAllObjects];
}
-- (void)setValue:(int32_t)value forKey:(int32_t)key {
+- (void)setEnum:(int32_t)value forKey:(int32_t)key {
if (!_validationFunc(value)) {
[NSException raise:NSInvalidArgumentException
format:@"GPBInt32EnumDictionary: Attempt to set an unknown enum value (%d)",
@@ -5206,39 +4716,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(int32_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32ObjectDictionary*)[self alloc] initWithObjects:&object
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithObjects:(const id [])objects
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt32ObjectDictionary*)[self alloc] initWithObjects:objects
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt32ObjectDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt32ObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithObjects:NULL forKeys:NULL count:0];
}
@@ -5289,14 +4766,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt32ObjectDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt32ObjectDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt32ObjectDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt32ObjectDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -5313,11 +4791,17 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (void)enumerateKeysAndObjectsUsingBlock:
(void (^)(int32_t key, id object, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- block([aKey intValue], aObject, stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
+ block([aKey intValue], aObject, &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (BOOL)isInitialized {
@@ -5332,34 +4816,36 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)deepCopyWithZone:(NSZone *)zone {
GPBInt32ObjectDictionary *newDict =
[[GPBInt32ObjectDictionary alloc] init];
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(id aKey,
- GPBMessage *msg,
- BOOL *stop) {
- #pragma unused(stop)
+ NSEnumerator *keys = [_dictionary keyEnumerator];
+ id aKey;
+ NSMutableDictionary *internalDict = newDict->_dictionary;
+ while ((aKey = [keys nextObject])) {
+ GPBMessage *msg = _dictionary[aKey];
GPBMessage *copiedMsg = [msg copyWithZone:zone];
- [newDict->_dictionary setObject:copiedMsg forKey:aKey];
+ [internalDict setObject:copiedMsg forKey:aKey];
[copiedMsg release];
- }];
+ }
return newDict;
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -5370,20 +4856,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType);
+ int32_t unwrappedKey = [aKey intValue];
+ id unwrappedValue = aObject;
+ size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictObjectFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt32Field(outputStream, [aKey intValue], kMapKeyFieldNumber, keyDataType);
- WriteDictObjectField(outputStream, aObject, kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictObjectField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -5443,46 +4931,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(uint64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64UInt32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64UInt32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt64UInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt32s:(const uint32_t [])values
+ forKeys:(const uint64_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -5496,7 +4951,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -5507,7 +4962,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -5522,14 +4977,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt64UInt32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt64UInt32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64UInt32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt64UInt32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -5544,32 +5000,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(uint64_t key, uint32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedLongLongValue], [aValue unsignedIntValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedLongLongValue], [aValue unsignedIntValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -5580,20 +5043,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
+ uint64_t unwrappedKey = [aKey unsignedLongLongValue];
+ uint32_t unwrappedValue = [aValue unsignedIntValue];
+ size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt64Field(outputStream, [aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictUInt32Field(outputStream, [aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -5602,13 +5067,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint64_t key, uint32_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt32sUsingBlock:^(uint64_t key, uint32_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%u", value]);
}];
}
-- (BOOL)valueForKey:(uint64_t)key value:(uint32_t *)value {
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped unsignedIntValue];
@@ -5625,14 +5090,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint32_t)value forKey:(uint64_t)key {
+- (void)setUInt32:(uint32_t)value forKey:(uint64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint64_t)aKey {
+- (void)removeUInt32ForKey:(uint64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -5649,44 +5114,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(uint64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64Int32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64Int32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64Int32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt64Int32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int32_t [])values
+- (instancetype)initWithInt32s:(const int32_t [])values
forKeys:(const uint64_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -5702,7 +5134,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -5713,7 +5145,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -5728,14 +5160,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt64Int32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt64Int32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64Int32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt64Int32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -5750,32 +5183,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(uint64_t key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedLongLongValue], [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedLongLongValue], [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -5786,20 +5226,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ uint64_t unwrappedKey = [aKey unsignedLongLongValue];
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt64Field(outputStream, [aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictInt32Field(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -5808,13 +5250,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint64_t key, int32_t value, BOOL *stop) {
+ [self enumerateKeysAndInt32sUsingBlock:^(uint64_t key, int32_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%d", value]);
}];
}
-- (BOOL)valueForKey:(uint64_t)key value:(int32_t *)value {
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped intValue];
@@ -5831,14 +5273,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int32_t)value forKey:(uint64_t)key {
+- (void)setInt32:(int32_t)value forKey:(uint64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint64_t)aKey {
+- (void)removeInt32ForKey:(uint64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -5855,46 +5297,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(uint64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64UInt64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64UInt64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt64UInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt64s:(const uint64_t [])values
+ forKeys:(const uint64_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -5908,7 +5317,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -5919,7 +5328,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -5934,14 +5343,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt64UInt64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt64UInt64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64UInt64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt64UInt64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -5956,32 +5366,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(uint64_t key, uint64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedLongLongValue], [aValue unsignedLongLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedLongLongValue], [aValue unsignedLongLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -5992,20 +5409,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
+ uint64_t unwrappedKey = [aKey unsignedLongLongValue];
+ uint64_t unwrappedValue = [aValue unsignedLongLongValue];
+ size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt64Field(outputStream, [aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictUInt64Field(outputStream, [aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -6014,13 +5433,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint64_t key, uint64_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt64sUsingBlock:^(uint64_t key, uint64_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%llu", value]);
}];
}
-- (BOOL)valueForKey:(uint64_t)key value:(uint64_t *)value {
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped unsignedLongLongValue];
@@ -6037,14 +5456,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint64_t)value forKey:(uint64_t)key {
+- (void)setUInt64:(uint64_t)value forKey:(uint64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint64_t)aKey {
+- (void)removeUInt64ForKey:(uint64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -6061,44 +5480,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(uint64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64Int64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64Int64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64Int64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt64Int64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int64_t [])values
+- (instancetype)initWithInt64s:(const int64_t [])values
forKeys:(const uint64_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -6114,7 +5500,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -6125,7 +5511,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -6140,14 +5526,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt64Int64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt64Int64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64Int64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt64Int64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -6162,32 +5549,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(uint64_t key, int64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedLongLongValue], [aValue longLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedLongLongValue], [aValue longLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -6198,20 +5592,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
+ uint64_t unwrappedKey = [aKey unsignedLongLongValue];
+ int64_t unwrappedValue = [aValue longLongValue];
+ size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt64Field(outputStream, [aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictInt64Field(outputStream, [aValue longLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -6220,13 +5616,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint64_t key, int64_t value, BOOL *stop) {
+ [self enumerateKeysAndInt64sUsingBlock:^(uint64_t key, int64_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%lld", value]);
}];
}
-- (BOOL)valueForKey:(uint64_t)key value:(int64_t *)value {
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped longLongValue];
@@ -6243,14 +5639,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int64_t)value forKey:(uint64_t)key {
+- (void)setInt64:(int64_t)value forKey:(uint64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint64_t)aKey {
+- (void)removeInt64ForKey:(uint64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -6267,46 +5663,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(uint64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64BoolDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64BoolDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64BoolDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt64BoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithBools:(const BOOL [])values
+ forKeys:(const uint64_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -6320,7 +5683,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithBools:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -6331,7 +5694,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -6346,14 +5709,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt64BoolDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt64BoolDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64BoolDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt64BoolDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -6368,32 +5732,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(uint64_t key, BOOL value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedLongLongValue], [aValue boolValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedLongLongValue], [aValue boolValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -6404,20 +5775,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
+ uint64_t unwrappedKey = [aKey unsignedLongLongValue];
+ BOOL unwrappedValue = [aValue boolValue];
+ size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt64Field(outputStream, [aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictBoolField(outputStream, [aValue boolValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -6426,13 +5799,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint64_t key, BOOL value, BOOL *stop) {
+ [self enumerateKeysAndBoolsUsingBlock:^(uint64_t key, BOOL value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%llu", key], (value ? @"true" : @"false"));
}];
}
-- (BOOL)valueForKey:(uint64_t)key value:(BOOL *)value {
+- (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped boolValue];
@@ -6449,14 +5822,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(BOOL)value forKey:(uint64_t)key {
+- (void)setBool:(BOOL)value forKey:(uint64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint64_t)aKey {
+- (void)removeBoolForKey:(uint64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -6473,44 +5846,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(uint64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64FloatDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64FloatDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64FloatDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt64FloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const float [])values
+- (instancetype)initWithFloats:(const float [])values
forKeys:(const uint64_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -6526,7 +5866,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithFloats:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -6537,7 +5877,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -6552,14 +5892,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt64FloatDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt64FloatDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64FloatDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt64FloatDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -6574,32 +5915,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(uint64_t key, float value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedLongLongValue], [aValue floatValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedLongLongValue], [aValue floatValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -6610,20 +5958,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
+ uint64_t unwrappedKey = [aKey unsignedLongLongValue];
+ float unwrappedValue = [aValue floatValue];
+ size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt64Field(outputStream, [aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictFloatField(outputStream, [aValue floatValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -6632,13 +5982,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint64_t key, float value, BOOL *stop) {
+ [self enumerateKeysAndFloatsUsingBlock:^(uint64_t key, float value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%.*g", FLT_DIG, value]);
}];
}
-- (BOOL)valueForKey:(uint64_t)key value:(float *)value {
+- (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped floatValue];
@@ -6655,14 +6005,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(float)value forKey:(uint64_t)key {
+- (void)setFloat:(float)value forKey:(uint64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint64_t)aKey {
+- (void)removeFloatForKey:(uint64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -6679,46 +6029,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(uint64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64DoubleDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64DoubleDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64DoubleDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt64DoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithDoubles:(const double [])values
+ forKeys:(const uint64_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -6732,7 +6049,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithDoubles:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -6743,7 +6060,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -6758,14 +6075,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt64DoubleDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt64DoubleDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64DoubleDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt64DoubleDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -6780,32 +6098,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(uint64_t key, double value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedLongLongValue], [aValue doubleValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedLongLongValue], [aValue doubleValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -6816,20 +6141,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
+ uint64_t unwrappedKey = [aKey unsignedLongLongValue];
+ double unwrappedValue = [aValue doubleValue];
+ size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt64Field(outputStream, [aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictDoubleField(outputStream, [aValue doubleValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -6838,13 +6165,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(uint64_t key, double value, BOOL *stop) {
+ [self enumerateKeysAndDoublesUsingBlock:^(uint64_t key, double value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]);
}];
}
-- (BOOL)valueForKey:(uint64_t)key value:(double *)value {
+- (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped doubleValue];
@@ -6861,14 +6188,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(double)value forKey:(uint64_t)key {
+- (void)setDouble:(double)value forKey:(uint64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(uint64_t)aKey {
+- (void)removeDoubleForKey:(uint64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -6888,54 +6215,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
@synthesize validationFunc = _validationFunc;
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValidationFunction:NULL
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func {
- return [[[self alloc] initWithValidationFunction:func
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(uint64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64EnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:&rawValue
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValues:(const int32_t [])rawValues
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64EnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:rawValues
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64EnumDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64EnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems {
- return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0];
}
@@ -6992,14 +6271,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt64EnumDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt64EnumDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64EnumDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt64EnumDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -7016,30 +6296,37 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(uint64_t key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey unsignedLongLongValue], [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey unsignedLongLongValue], [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -7050,20 +6337,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ uint64_t unwrappedKey = [aKey unsignedLongLongValue];
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt64Field(outputStream, [aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictEnumField(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
@@ -7090,7 +6379,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}];
}
-- (BOOL)valueForKey:(uint64_t)key value:(int32_t *)value {
+- (BOOL)getEnum:(int32_t *)value forKey:(uint64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
int32_t result = [wrapped intValue];
@@ -7102,7 +6391,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (BOOL)valueForKey:(uint64_t)key rawValue:(int32_t *)rawValue {
+- (BOOL)getRawValue:(int32_t *)rawValue forKey:(uint64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && rawValue) {
*rawValue = [wrapped intValue];
@@ -7110,18 +6399,23 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(uint64_t key, int32_t value, BOOL *stop))block {
GPBEnumValidationFunc func = _validationFunc;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
+ BOOL stop = NO;
+ NSEnumerator *keys = [_dictionary keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = _dictionary[aKey];
int32_t unwrapped = [aValue intValue];
if (!func(unwrapped)) {
unwrapped = kGPBUnrecognizedEnumeratorValue;
}
- block([aKey unsignedLongLongValue], unwrapped, stop);
- }];
+ block([aKey unsignedLongLongValue], unwrapped, &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary {
@@ -7140,7 +6434,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(uint64_t)aKey {
+- (void)removeEnumForKey:(uint64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -7148,7 +6442,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
[_dictionary removeAllObjects];
}
-- (void)setValue:(int32_t)value forKey:(uint64_t)key {
+- (void)setEnum:(int32_t)value forKey:(uint64_t)key {
if (!_validationFunc(value)) {
[NSException raise:NSInvalidArgumentException
format:@"GPBUInt64EnumDictionary: Attempt to set an unknown enum value (%d)",
@@ -7170,39 +6464,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(uint64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64ObjectDictionary*)[self alloc] initWithObjects:&object
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithObjects:(const id [])objects
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBUInt64ObjectDictionary*)[self alloc] initWithObjects:objects
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBUInt64ObjectDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBUInt64ObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithObjects:NULL forKeys:NULL count:0];
}
@@ -7253,14 +6514,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBUInt64ObjectDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBUInt64ObjectDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBUInt64ObjectDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBUInt64ObjectDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -7277,11 +6539,17 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (void)enumerateKeysAndObjectsUsingBlock:
(void (^)(uint64_t key, id object, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- block([aKey unsignedLongLongValue], aObject, stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
+ block([aKey unsignedLongLongValue], aObject, &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (BOOL)isInitialized {
@@ -7296,34 +6564,36 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)deepCopyWithZone:(NSZone *)zone {
GPBUInt64ObjectDictionary *newDict =
[[GPBUInt64ObjectDictionary alloc] init];
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(id aKey,
- GPBMessage *msg,
- BOOL *stop) {
- #pragma unused(stop)
+ NSEnumerator *keys = [_dictionary keyEnumerator];
+ id aKey;
+ NSMutableDictionary *internalDict = newDict->_dictionary;
+ while ((aKey = [keys nextObject])) {
+ GPBMessage *msg = _dictionary[aKey];
GPBMessage *copiedMsg = [msg copyWithZone:zone];
- [newDict->_dictionary setObject:copiedMsg forKey:aKey];
+ [internalDict setObject:copiedMsg forKey:aKey];
[copiedMsg release];
- }];
+ }
return newDict;
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -7334,20 +6604,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType);
+ uint64_t unwrappedKey = [aKey unsignedLongLongValue];
+ id unwrappedValue = aObject;
+ size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictObjectFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictUInt64Field(outputStream, [aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictObjectField(outputStream, aObject, kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictObjectField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -7407,46 +6679,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(int64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64UInt32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64UInt32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt64UInt32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt64UInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt32s:(const uint32_t [])values
+ forKeys:(const int64_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -7460,7 +6699,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -7471,7 +6710,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -7486,14 +6725,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt64UInt32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt64UInt32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64UInt32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt64UInt32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -7508,32 +6748,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(int64_t key, uint32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey longLongValue], [aValue unsignedIntValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey longLongValue], [aValue unsignedIntValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -7544,20 +6791,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
+ int64_t unwrappedKey = [aKey longLongValue];
+ uint32_t unwrappedValue = [aValue unsignedIntValue];
+ size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt64Field(outputStream, [aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictUInt32Field(outputStream, [aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -7566,13 +6815,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int64_t key, uint32_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt32sUsingBlock:^(int64_t key, uint32_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%u", value]);
}];
}
-- (BOOL)valueForKey:(int64_t)key value:(uint32_t *)value {
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped unsignedIntValue];
@@ -7589,14 +6838,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint32_t)value forKey:(int64_t)key {
+- (void)setUInt32:(uint32_t)value forKey:(int64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int64_t)aKey {
+- (void)removeUInt32ForKey:(int64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -7613,44 +6862,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(int64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64Int32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64Int32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt64Int32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt64Int32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int32_t [])values
+- (instancetype)initWithInt32s:(const int32_t [])values
forKeys:(const int64_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -7666,7 +6882,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -7677,7 +6893,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -7692,14 +6908,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt64Int32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt64Int32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64Int32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt64Int32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -7714,32 +6931,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(int64_t key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey longLongValue], [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey longLongValue], [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -7750,20 +6974,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ int64_t unwrappedKey = [aKey longLongValue];
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt64Field(outputStream, [aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictInt32Field(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -7772,13 +6998,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int64_t key, int32_t value, BOOL *stop) {
+ [self enumerateKeysAndInt32sUsingBlock:^(int64_t key, int32_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%d", value]);
}];
}
-- (BOOL)valueForKey:(int64_t)key value:(int32_t *)value {
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped intValue];
@@ -7795,14 +7021,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int32_t)value forKey:(int64_t)key {
+- (void)setInt32:(int32_t)value forKey:(int64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int64_t)aKey {
+- (void)removeInt32ForKey:(int64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -7819,46 +7045,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(int64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64UInt64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64UInt64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt64UInt64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt64UInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt64s:(const uint64_t [])values
+ forKeys:(const int64_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -7872,7 +7065,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -7883,7 +7076,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -7898,14 +7091,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt64UInt64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt64UInt64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64UInt64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt64UInt64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -7920,32 +7114,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(int64_t key, uint64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey longLongValue], [aValue unsignedLongLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey longLongValue], [aValue unsignedLongLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -7956,20 +7157,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
+ int64_t unwrappedKey = [aKey longLongValue];
+ uint64_t unwrappedValue = [aValue unsignedLongLongValue];
+ size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt64Field(outputStream, [aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictUInt64Field(outputStream, [aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -7978,13 +7181,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int64_t key, uint64_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt64sUsingBlock:^(int64_t key, uint64_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%llu", value]);
}];
}
-- (BOOL)valueForKey:(int64_t)key value:(uint64_t *)value {
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped unsignedLongLongValue];
@@ -8001,14 +7204,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint64_t)value forKey:(int64_t)key {
+- (void)setUInt64:(uint64_t)value forKey:(int64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int64_t)aKey {
+- (void)removeUInt64ForKey:(int64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -8025,44 +7228,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(int64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64Int64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64Int64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt64Int64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt64Int64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int64_t [])values
+- (instancetype)initWithInt64s:(const int64_t [])values
forKeys:(const int64_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -8078,7 +7248,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -8089,7 +7259,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -8104,14 +7274,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt64Int64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt64Int64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64Int64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt64Int64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -8126,32 +7297,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(int64_t key, int64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey longLongValue], [aValue longLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey longLongValue], [aValue longLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -8162,20 +7340,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
+ int64_t unwrappedKey = [aKey longLongValue];
+ int64_t unwrappedValue = [aValue longLongValue];
+ size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt64Field(outputStream, [aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictInt64Field(outputStream, [aValue longLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -8184,13 +7364,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int64_t key, int64_t value, BOOL *stop) {
+ [self enumerateKeysAndInt64sUsingBlock:^(int64_t key, int64_t value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%lld", value]);
}];
}
-- (BOOL)valueForKey:(int64_t)key value:(int64_t *)value {
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped longLongValue];
@@ -8207,14 +7387,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int64_t)value forKey:(int64_t)key {
+- (void)setInt64:(int64_t)value forKey:(int64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int64_t)aKey {
+- (void)removeInt64ForKey:(int64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -8231,46 +7411,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(int64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64BoolDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64BoolDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt64BoolDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt64BoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithBools:(const BOOL [])values
+ forKeys:(const int64_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -8284,7 +7431,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithBools:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -8295,7 +7442,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -8310,14 +7457,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt64BoolDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt64BoolDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64BoolDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt64BoolDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -8332,32 +7480,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(int64_t key, BOOL value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey longLongValue], [aValue boolValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey longLongValue], [aValue boolValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -8368,20 +7523,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
+ int64_t unwrappedKey = [aKey longLongValue];
+ BOOL unwrappedValue = [aValue boolValue];
+ size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt64Field(outputStream, [aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictBoolField(outputStream, [aValue boolValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -8390,13 +7547,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int64_t key, BOOL value, BOOL *stop) {
+ [self enumerateKeysAndBoolsUsingBlock:^(int64_t key, BOOL value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%lld", key], (value ? @"true" : @"false"));
}];
}
-- (BOOL)valueForKey:(int64_t)key value:(BOOL *)value {
+- (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped boolValue];
@@ -8413,14 +7570,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(BOOL)value forKey:(int64_t)key {
+- (void)setBool:(BOOL)value forKey:(int64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int64_t)aKey {
+- (void)removeBoolForKey:(int64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -8437,44 +7594,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(int64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64FloatDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64FloatDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt64FloatDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt64FloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const float [])values
+- (instancetype)initWithFloats:(const float [])values
forKeys:(const int64_t [])keys
count:(NSUInteger)count {
self = [super init];
@@ -8490,7 +7614,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithFloats:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -8501,7 +7625,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -8516,14 +7640,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt64FloatDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt64FloatDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64FloatDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt64FloatDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -8538,32 +7663,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(int64_t key, float value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey longLongValue], [aValue floatValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey longLongValue], [aValue floatValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -8574,20 +7706,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
+ int64_t unwrappedKey = [aKey longLongValue];
+ float unwrappedValue = [aValue floatValue];
+ size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt64Field(outputStream, [aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictFloatField(outputStream, [aValue floatValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -8596,13 +7730,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int64_t key, float value, BOOL *stop) {
+ [self enumerateKeysAndFloatsUsingBlock:^(int64_t key, float value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%.*g", FLT_DIG, value]);
}];
}
-- (BOOL)valueForKey:(int64_t)key value:(float *)value {
+- (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped floatValue];
@@ -8619,14 +7753,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(float)value forKey:(int64_t)key {
+- (void)setFloat:(float)value forKey:(int64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int64_t)aKey {
+- (void)removeFloatForKey:(int64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -8643,46 +7777,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(int64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64DoubleDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64DoubleDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt64DoubleDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt64DoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithDoubles:(const double [])values
+ forKeys:(const int64_t [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -8696,7 +7797,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithDoubles:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -8707,7 +7808,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -8722,14 +7823,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt64DoubleDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt64DoubleDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64DoubleDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt64DoubleDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -8744,32 +7846,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(int64_t key, double value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey longLongValue], [aValue doubleValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey longLongValue], [aValue doubleValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -8780,20 +7889,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
+ int64_t unwrappedKey = [aKey longLongValue];
+ double unwrappedValue = [aValue doubleValue];
+ size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt64Field(outputStream, [aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictDoubleField(outputStream, [aValue doubleValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -8802,13 +7913,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(int64_t key, double value, BOOL *stop) {
+ [self enumerateKeysAndDoublesUsingBlock:^(int64_t key, double value, BOOL *stop) {
#pragma unused(stop)
block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]);
}];
}
-- (BOOL)valueForKey:(int64_t)key value:(double *)value {
+- (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
*value = [wrapped doubleValue];
@@ -8825,14 +7936,14 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(double)value forKey:(int64_t)key {
+- (void)setDouble:(double)value forKey:(int64_t)key {
[_dictionary setObject:@(value) forKey:@(key)];
if (_autocreator) {
GPBAutocreatedDictionaryModified(_autocreator, self);
}
}
-- (void)removeValueForKey:(int64_t)aKey {
+- (void)removeDoubleForKey:(int64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -8852,54 +7963,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
@synthesize validationFunc = _validationFunc;
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValidationFunction:NULL
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func {
- return [[[self alloc] initWithValidationFunction:func
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(int64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64EnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:&rawValue
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValues:(const int32_t [])rawValues
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64EnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:rawValues
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt64EnumDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64EnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems {
- return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0];
}
@@ -8956,14 +8019,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt64EnumDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt64EnumDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64EnumDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt64EnumDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -8980,30 +8044,37 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(int64_t key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block([aKey longLongValue], [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block([aKey longLongValue], [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -9014,20 +8085,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ int64_t unwrappedKey = [aKey longLongValue];
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt64Field(outputStream, [aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictEnumField(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
@@ -9054,7 +8127,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}];
}
-- (BOOL)valueForKey:(int64_t)key value:(int32_t *)value {
+- (BOOL)getEnum:(int32_t *)value forKey:(int64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && value) {
int32_t result = [wrapped intValue];
@@ -9066,7 +8139,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (BOOL)valueForKey:(int64_t)key rawValue:(int32_t *)rawValue {
+- (BOOL)getRawValue:(int32_t *)rawValue forKey:(int64_t)key {
NSNumber *wrapped = [_dictionary objectForKey:@(key)];
if (wrapped && rawValue) {
*rawValue = [wrapped intValue];
@@ -9074,18 +8147,23 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(int64_t key, int32_t value, BOOL *stop))block {
GPBEnumValidationFunc func = _validationFunc;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- NSNumber *aValue,
- BOOL *stop) {
+ BOOL stop = NO;
+ NSEnumerator *keys = [_dictionary keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = _dictionary[aKey];
int32_t unwrapped = [aValue intValue];
if (!func(unwrapped)) {
unwrapped = kGPBUnrecognizedEnumeratorValue;
}
- block([aKey longLongValue], unwrapped, stop);
- }];
+ block([aKey longLongValue], unwrapped, &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary {
@@ -9104,7 +8182,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(int64_t)aKey {
+- (void)removeEnumForKey:(int64_t)aKey {
[_dictionary removeObjectForKey:@(aKey)];
}
@@ -9112,7 +8190,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
[_dictionary removeAllObjects];
}
-- (void)setValue:(int32_t)value forKey:(int64_t)key {
+- (void)setEnum:(int32_t)value forKey:(int64_t)key {
if (!_validationFunc(value)) {
[NSException raise:NSInvalidArgumentException
format:@"GPBInt64EnumDictionary: Attempt to set an unknown enum value (%d)",
@@ -9134,39 +8212,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(int64_t)key {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64ObjectDictionary*)[self alloc] initWithObjects:&object
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithObjects:(const id [])objects
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBInt64ObjectDictionary*)[self alloc] initWithObjects:objects
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBInt64ObjectDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBInt64ObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithObjects:NULL forKeys:NULL count:0];
}
@@ -9217,14 +8262,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBInt64ObjectDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBInt64ObjectDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBInt64ObjectDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBInt64ObjectDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -9241,11 +8287,17 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (void)enumerateKeysAndObjectsUsingBlock:
(void (^)(int64_t key, id object, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- block([aKey longLongValue], aObject, stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
+ block([aKey longLongValue], aObject, &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (BOOL)isInitialized {
@@ -9260,34 +8312,36 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)deepCopyWithZone:(NSZone *)zone {
GPBInt64ObjectDictionary *newDict =
[[GPBInt64ObjectDictionary alloc] init];
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(id aKey,
- GPBMessage *msg,
- BOOL *stop) {
- #pragma unused(stop)
+ NSEnumerator *keys = [_dictionary keyEnumerator];
+ id aKey;
+ NSMutableDictionary *internalDict = newDict->_dictionary;
+ while ((aKey = [keys nextObject])) {
+ GPBMessage *msg = _dictionary[aKey];
GPBMessage *copiedMsg = [msg copyWithZone:zone];
- [newDict->_dictionary setObject:copiedMsg forKey:aKey];
+ [internalDict setObject:copiedMsg forKey:aKey];
[copiedMsg release];
- }];
+ }
return newDict;
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -9298,20 +8352,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSNumber *aKey,
- id aObject,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSNumber *aKey;
+ while ((aKey = [keys nextObject])) {
+ id aObject = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType);
+ int64_t unwrappedKey = [aKey longLongValue];
+ id unwrappedValue = aObject;
+ size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictObjectFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictInt64Field(outputStream, [aKey longLongValue], kMapKeyFieldNumber, keyDataType);
- WriteDictObjectField(outputStream, aObject, kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictObjectField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -9371,46 +8427,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(NSString *)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringUInt32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringUInt32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBStringUInt32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBStringUInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt32s:(const uint32_t [])values
+ forKeys:(const NSString * [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -9428,7 +8451,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -9439,7 +8462,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -9454,14 +8477,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBStringUInt32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBStringUInt32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBStringUInt32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBStringUInt32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -9476,32 +8500,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(NSString *key, uint32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block(aKey, [aValue unsignedIntValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block(aKey, [aValue unsignedIntValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -9512,20 +8543,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
+ NSString *unwrappedKey = aKey;
+ uint32_t unwrappedValue = [aValue unsignedIntValue];
+ size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictStringField(outputStream, aKey, kMapKeyFieldNumber, keyDataType);
- WriteDictUInt32Field(outputStream, [aValue unsignedIntValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -9534,13 +8567,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(NSString *key, uint32_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt32sUsingBlock:^(NSString *key, uint32_t value, BOOL *stop) {
#pragma unused(stop)
block(key, [NSString stringWithFormat:@"%u", value]);
}];
}
-- (BOOL)valueForKey:(NSString *)key value:(uint32_t *)value {
+- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key {
NSNumber *wrapped = [_dictionary objectForKey:key];
if (wrapped && value) {
*value = [wrapped unsignedIntValue];
@@ -9557,7 +8590,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint32_t)value forKey:(NSString *)key {
+- (void)setUInt32:(uint32_t)value forKey:(NSString *)key {
if (!key) {
[NSException raise:NSInvalidArgumentException
format:@"Attempting to add nil key to a Dictionary"];
@@ -9568,7 +8601,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(NSString *)aKey {
+- (void)removeUInt32ForKey:(NSString *)aKey {
[_dictionary removeObjectForKey:aKey];
}
@@ -9585,44 +8618,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(NSString *)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringInt32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringInt32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBStringInt32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBStringInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int32_t [])values
+- (instancetype)initWithInt32s:(const int32_t [])values
forKeys:(const NSString * [])keys
count:(NSUInteger)count {
self = [super init];
@@ -9642,7 +8642,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -9653,7 +8653,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -9668,14 +8668,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBStringInt32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBStringInt32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBStringInt32Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBStringInt32Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -9690,32 +8691,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(NSString *key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block(aKey, [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block(aKey, [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -9726,20 +8734,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ NSString *unwrappedKey = aKey;
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictStringField(outputStream, aKey, kMapKeyFieldNumber, keyDataType);
- WriteDictInt32Field(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -9748,13 +8758,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(NSString *key, int32_t value, BOOL *stop) {
+ [self enumerateKeysAndInt32sUsingBlock:^(NSString *key, int32_t value, BOOL *stop) {
#pragma unused(stop)
block(key, [NSString stringWithFormat:@"%d", value]);
}];
}
-- (BOOL)valueForKey:(NSString *)key value:(int32_t *)value {
+- (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key {
NSNumber *wrapped = [_dictionary objectForKey:key];
if (wrapped && value) {
*value = [wrapped intValue];
@@ -9771,7 +8781,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int32_t)value forKey:(NSString *)key {
+- (void)setInt32:(int32_t)value forKey:(NSString *)key {
if (!key) {
[NSException raise:NSInvalidArgumentException
format:@"Attempting to add nil key to a Dictionary"];
@@ -9782,7 +8792,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(NSString *)aKey {
+- (void)removeInt32ForKey:(NSString *)aKey {
[_dictionary removeObjectForKey:aKey];
}
@@ -9799,46 +8809,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(NSString *)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringUInt64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringUInt64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBStringUInt64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBStringUInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt64s:(const uint64_t [])values
+ forKeys:(const NSString * [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -9856,7 +8833,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -9867,7 +8844,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -9882,14 +8859,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBStringUInt64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBStringUInt64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBStringUInt64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBStringUInt64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -9904,32 +8882,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(NSString *key, uint64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block(aKey, [aValue unsignedLongLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block(aKey, [aValue unsignedLongLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -9940,20 +8925,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
+ NSString *unwrappedKey = aKey;
+ uint64_t unwrappedValue = [aValue unsignedLongLongValue];
+ size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictStringField(outputStream, aKey, kMapKeyFieldNumber, keyDataType);
- WriteDictUInt64Field(outputStream, [aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -9962,13 +8949,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(NSString *key, uint64_t value, BOOL *stop) {
+ [self enumerateKeysAndUInt64sUsingBlock:^(NSString *key, uint64_t value, BOOL *stop) {
#pragma unused(stop)
block(key, [NSString stringWithFormat:@"%llu", value]);
}];
}
-- (BOOL)valueForKey:(NSString *)key value:(uint64_t *)value {
+- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key {
NSNumber *wrapped = [_dictionary objectForKey:key];
if (wrapped && value) {
*value = [wrapped unsignedLongLongValue];
@@ -9985,7 +8972,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint64_t)value forKey:(NSString *)key {
+- (void)setUInt64:(uint64_t)value forKey:(NSString *)key {
if (!key) {
[NSException raise:NSInvalidArgumentException
format:@"Attempting to add nil key to a Dictionary"];
@@ -9996,7 +8983,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(NSString *)aKey {
+- (void)removeUInt64ForKey:(NSString *)aKey {
[_dictionary removeObjectForKey:aKey];
}
@@ -10013,44 +9000,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(NSString *)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringInt64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringInt64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBStringInt64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBStringInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int64_t [])values
+- (instancetype)initWithInt64s:(const int64_t [])values
forKeys:(const NSString * [])keys
count:(NSUInteger)count {
self = [super init];
@@ -10070,7 +9024,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -10081,7 +9035,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -10096,14 +9050,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBStringInt64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBStringInt64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBStringInt64Dictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBStringInt64Dictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -10118,32 +9073,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(NSString *key, int64_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block(aKey, [aValue longLongValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block(aKey, [aValue longLongValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -10154,20 +9116,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType);
+ NSString *unwrappedKey = aKey;
+ int64_t unwrappedValue = [aValue longLongValue];
+ size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictStringField(outputStream, aKey, kMapKeyFieldNumber, keyDataType);
- WriteDictInt64Field(outputStream, [aValue longLongValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -10176,13 +9140,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(NSString *key, int64_t value, BOOL *stop) {
+ [self enumerateKeysAndInt64sUsingBlock:^(NSString *key, int64_t value, BOOL *stop) {
#pragma unused(stop)
block(key, [NSString stringWithFormat:@"%lld", value]);
}];
}
-- (BOOL)valueForKey:(NSString *)key value:(int64_t *)value {
+- (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key {
NSNumber *wrapped = [_dictionary objectForKey:key];
if (wrapped && value) {
*value = [wrapped longLongValue];
@@ -10199,7 +9163,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int64_t)value forKey:(NSString *)key {
+- (void)setInt64:(int64_t)value forKey:(NSString *)key {
if (!key) {
[NSException raise:NSInvalidArgumentException
format:@"Attempting to add nil key to a Dictionary"];
@@ -10210,7 +9174,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(NSString *)aKey {
+- (void)removeInt64ForKey:(NSString *)aKey {
[_dictionary removeObjectForKey:aKey];
}
@@ -10227,46 +9191,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(NSString *)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringBoolDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringBoolDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBStringBoolDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBStringBoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithBools:(const BOOL [])values
+ forKeys:(const NSString * [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -10284,7 +9215,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithBools:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -10295,7 +9226,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -10310,14 +9241,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBStringBoolDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBStringBoolDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBStringBoolDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBStringBoolDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -10332,32 +9264,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(NSString *key, BOOL value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block(aKey, [aValue boolValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block(aKey, [aValue boolValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -10368,20 +9307,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType);
+ NSString *unwrappedKey = aKey;
+ BOOL unwrappedValue = [aValue boolValue];
+ size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictStringField(outputStream, aKey, kMapKeyFieldNumber, keyDataType);
- WriteDictBoolField(outputStream, [aValue boolValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -10390,13 +9331,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(NSString *key, BOOL value, BOOL *stop) {
+ [self enumerateKeysAndBoolsUsingBlock:^(NSString *key, BOOL value, BOOL *stop) {
#pragma unused(stop)
block(key, (value ? @"true" : @"false"));
}];
}
-- (BOOL)valueForKey:(NSString *)key value:(BOOL *)value {
+- (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key {
NSNumber *wrapped = [_dictionary objectForKey:key];
if (wrapped && value) {
*value = [wrapped boolValue];
@@ -10413,7 +9354,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(BOOL)value forKey:(NSString *)key {
+- (void)setBool:(BOOL)value forKey:(NSString *)key {
if (!key) {
[NSException raise:NSInvalidArgumentException
format:@"Attempting to add nil key to a Dictionary"];
@@ -10424,7 +9365,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(NSString *)aKey {
+- (void)removeBoolForKey:(NSString *)aKey {
[_dictionary removeObjectForKey:aKey];
}
@@ -10441,44 +9382,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(NSString *)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringFloatDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringFloatDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBStringFloatDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBStringFloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const float [])values
+- (instancetype)initWithFloats:(const float [])values
forKeys:(const NSString * [])keys
count:(NSUInteger)count {
self = [super init];
@@ -10498,7 +9406,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithFloats:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -10509,7 +9417,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -10524,14 +9432,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBStringFloatDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBStringFloatDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBStringFloatDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBStringFloatDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -10546,32 +9455,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(NSString *key, float value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block(aKey, [aValue floatValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block(aKey, [aValue floatValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -10582,20 +9498,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType);
+ NSString *unwrappedKey = aKey;
+ float unwrappedValue = [aValue floatValue];
+ size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictStringField(outputStream, aKey, kMapKeyFieldNumber, keyDataType);
- WriteDictFloatField(outputStream, [aValue floatValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -10604,13 +9522,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(NSString *key, float value, BOOL *stop) {
+ [self enumerateKeysAndFloatsUsingBlock:^(NSString *key, float value, BOOL *stop) {
#pragma unused(stop)
block(key, [NSString stringWithFormat:@"%.*g", FLT_DIG, value]);
}];
}
-- (BOOL)valueForKey:(NSString *)key value:(float *)value {
+- (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key {
NSNumber *wrapped = [_dictionary objectForKey:key];
if (wrapped && value) {
*value = [wrapped floatValue];
@@ -10627,7 +9545,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(float)value forKey:(NSString *)key {
+- (void)setFloat:(float)value forKey:(NSString *)key {
if (!key) {
[NSException raise:NSInvalidArgumentException
format:@"Attempting to add nil key to a Dictionary"];
@@ -10638,7 +9556,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(NSString *)aKey {
+- (void)removeFloatForKey:(NSString *)aKey {
[_dictionary removeObjectForKey:aKey];
}
@@ -10655,46 +9573,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
NSMutableDictionary *_dictionary;
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(NSString *)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringDoubleDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringDoubleDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBStringDoubleDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBStringDoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithDoubles:(const double [])values
+ forKeys:(const NSString * [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -10712,7 +9597,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithDoubles:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
[_dictionary addEntriesFromDictionary:dictionary->_dictionary];
@@ -10723,7 +9608,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
- (void)dealloc {
@@ -10738,14 +9623,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBStringDoubleDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBStringDoubleDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBStringDoubleDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBStringDoubleDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -10760,32 +9646,39 @@ void GPBDictionaryReadEntry(id mapDictionary,
return _dictionary.count;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(NSString *key, double value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block(aKey, [aValue doubleValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block(aKey, [aValue doubleValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -10796,20 +9689,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType);
+ NSString *unwrappedKey = aKey;
+ double unwrappedValue = [aValue doubleValue];
+ size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictStringField(outputStream, aKey, kMapKeyFieldNumber, keyDataType);
- WriteDictDoubleField(outputStream, [aValue doubleValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (void)setGPBGenericValue:(GPBGenericValue *)value
@@ -10818,13 +9713,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block {
- [self enumerateKeysAndValuesUsingBlock:^(NSString *key, double value, BOOL *stop) {
+ [self enumerateKeysAndDoublesUsingBlock:^(NSString *key, double value, BOOL *stop) {
#pragma unused(stop)
block(key, [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]);
}];
}
-- (BOOL)valueForKey:(NSString *)key value:(double *)value {
+- (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key {
NSNumber *wrapped = [_dictionary objectForKey:key];
if (wrapped && value) {
*value = [wrapped doubleValue];
@@ -10841,7 +9736,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(double)value forKey:(NSString *)key {
+- (void)setDouble:(double)value forKey:(NSString *)key {
if (!key) {
[NSException raise:NSInvalidArgumentException
format:@"Attempting to add nil key to a Dictionary"];
@@ -10852,7 +9747,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(NSString *)aKey {
+- (void)removeDoubleForKey:(NSString *)aKey {
[_dictionary removeObjectForKey:aKey];
}
@@ -10872,54 +9767,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
@synthesize validationFunc = _validationFunc;
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValidationFunction:NULL
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func {
- return [[[self alloc] initWithValidationFunction:func
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(NSString *)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringEnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:&rawValue
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValues:(const int32_t [])rawValues
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringEnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:rawValues
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBStringEnumDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBStringEnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems {
- return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0];
}
@@ -10980,14 +9827,15 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBStringEnumDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBStringEnumDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBStringEnumDictionary class]]) {
return NO;
}
- return [_dictionary isEqual:other->_dictionary];
+ GPBStringEnumDictionary *otherDictionary = other;
+ return [_dictionary isEqual:otherDictionary->_dictionary];
}
- (NSUInteger)hash {
@@ -11004,30 +9852,37 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(NSString *key, int32_t value, BOOL *stop))block {
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- block(aKey, [aValue intValue], stop);
- }];
+ BOOL stop = NO;
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
+ block(aKey, [aValue intValue], &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field {
- NSUInteger count = _dictionary.count;
+ NSDictionary *internal = _dictionary;
+ NSUInteger count = internal.count;
if (count == 0) {
return 0;
}
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
- __block size_t result = 0;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
+ size_t result = 0;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize;
- }];
+ }
size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage);
result += tagSize * count;
return result;
@@ -11038,20 +9893,22 @@ void GPBDictionaryReadEntry(id mapDictionary,
GPBDataType valueDataType = GPBGetFieldDataType(field);
GPBDataType keyDataType = field.mapKeyDataType;
uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited);
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
- #pragma unused(stop)
- // Write the tag.
+ NSDictionary *internal = _dictionary;
+ NSEnumerator *keys = [internal keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = internal[aKey];
[outputStream writeInt32NoTag:tag];
// Write the size of the message.
- size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType);
- msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType);
+ NSString *unwrappedKey = aKey;
+ int32_t unwrappedValue = [aValue intValue];
+ size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType);
[outputStream writeInt32NoTag:(int32_t)msgSize];
// Write the fields.
- WriteDictStringField(outputStream, aKey, kMapKeyFieldNumber, keyDataType);
- WriteDictEnumField(outputStream, [aValue intValue], kMapValueFieldNumber, valueDataType);
- }];
+ WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType);
+ WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType);
+ }
}
- (NSData *)serializedDataForUnknownValue:(int32_t)value
@@ -11078,7 +9935,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}];
}
-- (BOOL)valueForKey:(NSString *)key value:(int32_t *)value {
+- (BOOL)getEnum:(int32_t *)value forKey:(NSString *)key {
NSNumber *wrapped = [_dictionary objectForKey:key];
if (wrapped && value) {
int32_t result = [wrapped intValue];
@@ -11090,7 +9947,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (BOOL)valueForKey:(NSString *)key rawValue:(int32_t *)rawValue {
+- (BOOL)getRawValue:(int32_t *)rawValue forKey:(NSString *)key {
NSNumber *wrapped = [_dictionary objectForKey:key];
if (wrapped && rawValue) {
*rawValue = [wrapped intValue];
@@ -11098,18 +9955,23 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (wrapped != NULL);
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(NSString *key, int32_t value, BOOL *stop))block {
GPBEnumValidationFunc func = _validationFunc;
- [_dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *aKey,
- NSNumber *aValue,
- BOOL *stop) {
+ BOOL stop = NO;
+ NSEnumerator *keys = [_dictionary keyEnumerator];
+ NSString *aKey;
+ while ((aKey = [keys nextObject])) {
+ NSNumber *aValue = _dictionary[aKey];
int32_t unwrapped = [aValue intValue];
if (!func(unwrapped)) {
unwrapped = kGPBUnrecognizedEnumeratorValue;
}
- block(aKey, unwrapped, stop);
- }];
+ block(aKey, unwrapped, &stop);
+ if (stop) {
+ break;
+ }
+ }
}
- (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary {
@@ -11132,7 +9994,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(NSString *)aKey {
+- (void)removeEnumForKey:(NSString *)aKey {
[_dictionary removeObjectForKey:aKey];
}
@@ -11140,7 +10002,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
[_dictionary removeAllObjects];
}
-- (void)setValue:(int32_t)value forKey:(NSString *)key {
+- (void)setEnum:(int32_t)value forKey:(NSString *)key {
if (!key) {
[NSException raise:NSInvalidArgumentException
format:@"Attempting to add nil key to a Dictionary"];
@@ -11173,46 +10035,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
BOOL _valueSet[2];
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint32_t)value
- forKey:(BOOL)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolUInt32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint32_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolUInt32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBBoolUInt32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBBoolUInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint32_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt32s:(const uint32_t [])values
+ forKeys:(const BOOL [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
for (NSUInteger i = 0; i < count; ++i) {
@@ -11225,7 +10054,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
for (int i = 0; i < 2; ++i) {
@@ -11241,7 +10070,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt32s:NULL forKeys:NULL count:0];
}
#if !defined(NS_BLOCK_ASSERTIONS)
@@ -11257,19 +10086,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBBoolUInt32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBBoolUInt32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolUInt32Dictionary class]]) {
return NO;
}
- if ((_valueSet[0] != other->_valueSet[0]) ||
- (_valueSet[1] != other->_valueSet[1])) {
+ GPBBoolUInt32Dictionary *otherDictionary = other;
+ if ((_valueSet[0] != otherDictionary->_valueSet[0]) ||
+ (_valueSet[1] != otherDictionary->_valueSet[1])) {
return NO;
}
- if ((_valueSet[0] && (_values[0] != other->_values[0])) ||
- (_valueSet[1] && (_values[1] != other->_values[1]))) {
+ if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) ||
+ (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) {
return NO;
}
return YES;
@@ -11295,7 +10125,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0);
}
-- (BOOL)valueForKey:(BOOL)key value:(uint32_t *)value {
+- (BOOL)getUInt32:(uint32_t *)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
if (_valueSet[idx]) {
if (value) {
@@ -11322,7 +10152,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt32sUsingBlock:
(void (^)(BOOL key, uint32_t value, BOOL *stop))block {
BOOL stop = NO;
if (_valueSet[0]) {
@@ -11383,7 +10213,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint32_t)value forKey:(BOOL)key {
+- (void)setUInt32:(uint32_t)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
_values[idx] = value;
_valueSet[idx] = YES;
@@ -11392,7 +10222,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(BOOL)aKey {
+- (void)removeUInt32ForKey:(BOOL)aKey {
_valueSet[aKey ? 1 : 0] = NO;
}
@@ -11414,44 +10244,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
BOOL _valueSet[2];
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int32_t)value
- forKey:(BOOL)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolInt32Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int32_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolInt32Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBBoolInt32Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBBoolInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int32_t [])values
+- (instancetype)initWithInt32s:(const int32_t [])values
forKeys:(const BOOL [])keys
count:(NSUInteger)count {
self = [super init];
@@ -11466,7 +10263,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt32s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
for (int i = 0; i < 2; ++i) {
@@ -11482,7 +10279,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt32s:NULL forKeys:NULL count:0];
}
#if !defined(NS_BLOCK_ASSERTIONS)
@@ -11498,19 +10295,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBBoolInt32Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBBoolInt32Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolInt32Dictionary class]]) {
return NO;
}
- if ((_valueSet[0] != other->_valueSet[0]) ||
- (_valueSet[1] != other->_valueSet[1])) {
+ GPBBoolInt32Dictionary *otherDictionary = other;
+ if ((_valueSet[0] != otherDictionary->_valueSet[0]) ||
+ (_valueSet[1] != otherDictionary->_valueSet[1])) {
return NO;
}
- if ((_valueSet[0] && (_values[0] != other->_values[0])) ||
- (_valueSet[1] && (_values[1] != other->_values[1]))) {
+ if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) ||
+ (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) {
return NO;
}
return YES;
@@ -11536,7 +10334,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0);
}
-- (BOOL)valueForKey:(BOOL)key value:(int32_t *)value {
+- (BOOL)getInt32:(int32_t *)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
if (_valueSet[idx]) {
if (value) {
@@ -11563,7 +10361,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt32sUsingBlock:
(void (^)(BOOL key, int32_t value, BOOL *stop))block {
BOOL stop = NO;
if (_valueSet[0]) {
@@ -11624,7 +10422,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int32_t)value forKey:(BOOL)key {
+- (void)setInt32:(int32_t)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
_values[idx] = value;
_valueSet[idx] = YES;
@@ -11633,7 +10431,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(BOOL)aKey {
+- (void)removeInt32ForKey:(BOOL)aKey {
_valueSet[aKey ? 1 : 0] = NO;
}
@@ -11655,46 +10453,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
BOOL _valueSet[2];
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(uint64_t)value
- forKey:(BOOL)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolUInt64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const uint64_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolUInt64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBBoolUInt64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBBoolUInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const uint64_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithUInt64s:(const uint64_t [])values
+ forKeys:(const BOOL [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
for (NSUInteger i = 0; i < count; ++i) {
@@ -11707,7 +10472,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithUInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
for (int i = 0; i < 2; ++i) {
@@ -11723,7 +10488,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithUInt64s:NULL forKeys:NULL count:0];
}
#if !defined(NS_BLOCK_ASSERTIONS)
@@ -11739,19 +10504,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBBoolUInt64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBBoolUInt64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolUInt64Dictionary class]]) {
return NO;
}
- if ((_valueSet[0] != other->_valueSet[0]) ||
- (_valueSet[1] != other->_valueSet[1])) {
+ GPBBoolUInt64Dictionary *otherDictionary = other;
+ if ((_valueSet[0] != otherDictionary->_valueSet[0]) ||
+ (_valueSet[1] != otherDictionary->_valueSet[1])) {
return NO;
}
- if ((_valueSet[0] && (_values[0] != other->_values[0])) ||
- (_valueSet[1] && (_values[1] != other->_values[1]))) {
+ if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) ||
+ (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) {
return NO;
}
return YES;
@@ -11777,7 +10543,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0);
}
-- (BOOL)valueForKey:(BOOL)key value:(uint64_t *)value {
+- (BOOL)getUInt64:(uint64_t *)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
if (_valueSet[idx]) {
if (value) {
@@ -11804,7 +10570,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndUInt64sUsingBlock:
(void (^)(BOOL key, uint64_t value, BOOL *stop))block {
BOOL stop = NO;
if (_valueSet[0]) {
@@ -11865,7 +10631,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(uint64_t)value forKey:(BOOL)key {
+- (void)setUInt64:(uint64_t)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
_values[idx] = value;
_valueSet[idx] = YES;
@@ -11874,7 +10640,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(BOOL)aKey {
+- (void)removeUInt64ForKey:(BOOL)aKey {
_valueSet[aKey ? 1 : 0] = NO;
}
@@ -11896,44 +10662,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
BOOL _valueSet[2];
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(int64_t)value
- forKey:(BOOL)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolInt64Dictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const int64_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolInt64Dictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBBoolInt64Dictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBBoolInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const int64_t [])values
+- (instancetype)initWithInt64s:(const int64_t [])values
forKeys:(const BOOL [])keys
count:(NSUInteger)count {
self = [super init];
@@ -11948,7 +10681,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithInt64s:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
for (int i = 0; i < 2; ++i) {
@@ -11964,7 +10697,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithInt64s:NULL forKeys:NULL count:0];
}
#if !defined(NS_BLOCK_ASSERTIONS)
@@ -11980,19 +10713,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBBoolInt64Dictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBBoolInt64Dictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolInt64Dictionary class]]) {
return NO;
}
- if ((_valueSet[0] != other->_valueSet[0]) ||
- (_valueSet[1] != other->_valueSet[1])) {
+ GPBBoolInt64Dictionary *otherDictionary = other;
+ if ((_valueSet[0] != otherDictionary->_valueSet[0]) ||
+ (_valueSet[1] != otherDictionary->_valueSet[1])) {
return NO;
}
- if ((_valueSet[0] && (_values[0] != other->_values[0])) ||
- (_valueSet[1] && (_values[1] != other->_values[1]))) {
+ if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) ||
+ (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) {
return NO;
}
return YES;
@@ -12018,7 +10752,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0);
}
-- (BOOL)valueForKey:(BOOL)key value:(int64_t *)value {
+- (BOOL)getInt64:(int64_t *)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
if (_valueSet[idx]) {
if (value) {
@@ -12045,7 +10779,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndInt64sUsingBlock:
(void (^)(BOOL key, int64_t value, BOOL *stop))block {
BOOL stop = NO;
if (_valueSet[0]) {
@@ -12106,7 +10840,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int64_t)value forKey:(BOOL)key {
+- (void)setInt64:(int64_t)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
_values[idx] = value;
_valueSet[idx] = YES;
@@ -12115,7 +10849,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(BOOL)aKey {
+- (void)removeInt64ForKey:(BOOL)aKey {
_valueSet[aKey ? 1 : 0] = NO;
}
@@ -12137,46 +10871,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
BOOL _valueSet[2];
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(BOOL)value
- forKey:(BOOL)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolBoolDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const BOOL [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolBoolDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBBoolBoolDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBBoolBoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const BOOL [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithBools:(const BOOL [])values
+ forKeys:(const BOOL [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
for (NSUInteger i = 0; i < count; ++i) {
@@ -12189,7 +10890,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithBools:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
for (int i = 0; i < 2; ++i) {
@@ -12205,7 +10906,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithBools:NULL forKeys:NULL count:0];
}
#if !defined(NS_BLOCK_ASSERTIONS)
@@ -12221,19 +10922,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBBoolBoolDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBBoolBoolDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolBoolDictionary class]]) {
return NO;
}
- if ((_valueSet[0] != other->_valueSet[0]) ||
- (_valueSet[1] != other->_valueSet[1])) {
+ GPBBoolBoolDictionary *otherDictionary = other;
+ if ((_valueSet[0] != otherDictionary->_valueSet[0]) ||
+ (_valueSet[1] != otherDictionary->_valueSet[1])) {
return NO;
}
- if ((_valueSet[0] && (_values[0] != other->_values[0])) ||
- (_valueSet[1] && (_values[1] != other->_values[1]))) {
+ if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) ||
+ (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) {
return NO;
}
return YES;
@@ -12259,7 +10961,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0);
}
-- (BOOL)valueForKey:(BOOL)key value:(BOOL *)value {
+- (BOOL)getBool:(BOOL *)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
if (_valueSet[idx]) {
if (value) {
@@ -12286,7 +10988,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndBoolsUsingBlock:
(void (^)(BOOL key, BOOL value, BOOL *stop))block {
BOOL stop = NO;
if (_valueSet[0]) {
@@ -12347,7 +11049,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(BOOL)value forKey:(BOOL)key {
+- (void)setBool:(BOOL)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
_values[idx] = value;
_valueSet[idx] = YES;
@@ -12356,7 +11058,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(BOOL)aKey {
+- (void)removeBoolForKey:(BOOL)aKey {
_valueSet[aKey ? 1 : 0] = NO;
}
@@ -12378,44 +11080,11 @@ void GPBDictionaryReadEntry(id mapDictionary,
BOOL _valueSet[2];
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(float)value
- forKey:(BOOL)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolFloatDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const float [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolFloatDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBBoolFloatDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBBoolFloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const float [])values
+- (instancetype)initWithFloats:(const float [])values
forKeys:(const BOOL [])keys
count:(NSUInteger)count {
self = [super init];
@@ -12430,7 +11099,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithFloats:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
for (int i = 0; i < 2; ++i) {
@@ -12446,7 +11115,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithFloats:NULL forKeys:NULL count:0];
}
#if !defined(NS_BLOCK_ASSERTIONS)
@@ -12462,19 +11131,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBBoolFloatDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBBoolFloatDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolFloatDictionary class]]) {
return NO;
}
- if ((_valueSet[0] != other->_valueSet[0]) ||
- (_valueSet[1] != other->_valueSet[1])) {
+ GPBBoolFloatDictionary *otherDictionary = other;
+ if ((_valueSet[0] != otherDictionary->_valueSet[0]) ||
+ (_valueSet[1] != otherDictionary->_valueSet[1])) {
return NO;
}
- if ((_valueSet[0] && (_values[0] != other->_values[0])) ||
- (_valueSet[1] && (_values[1] != other->_values[1]))) {
+ if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) ||
+ (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) {
return NO;
}
return YES;
@@ -12500,7 +11170,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0);
}
-- (BOOL)valueForKey:(BOOL)key value:(float *)value {
+- (BOOL)getFloat:(float *)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
if (_valueSet[idx]) {
if (value) {
@@ -12527,7 +11197,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndFloatsUsingBlock:
(void (^)(BOOL key, float value, BOOL *stop))block {
BOOL stop = NO;
if (_valueSet[0]) {
@@ -12588,7 +11258,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(float)value forKey:(BOOL)key {
+- (void)setFloat:(float)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
_values[idx] = value;
_valueSet[idx] = YES;
@@ -12597,7 +11267,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(BOOL)aKey {
+- (void)removeFloatForKey:(BOOL)aKey {
_valueSet[aKey ? 1 : 0] = NO;
}
@@ -12619,46 +11289,13 @@ void GPBDictionaryReadEntry(id mapDictionary,
BOOL _valueSet[2];
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValues:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValue:(double)value
- forKey:(BOOL)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolDoubleDictionary*)[self alloc] initWithValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValues:(const double [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolDoubleDictionary*)[self alloc] initWithValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBBoolDoubleDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBBoolDoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
-- (instancetype)initWithValues:(const double [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithDoubles:(const double [])values
+ forKeys:(const BOOL [])keys
+ count:(NSUInteger)count {
self = [super init];
if (self) {
for (NSUInteger i = 0; i < count; ++i) {
@@ -12671,7 +11308,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
- (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary {
- self = [self initWithValues:NULL forKeys:NULL count:0];
+ self = [self initWithDoubles:NULL forKeys:NULL count:0];
if (self) {
if (dictionary) {
for (int i = 0; i < 2; ++i) {
@@ -12687,7 +11324,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (instancetype)initWithCapacity:(NSUInteger)numItems {
#pragma unused(numItems)
- return [self initWithValues:NULL forKeys:NULL count:0];
+ return [self initWithDoubles:NULL forKeys:NULL count:0];
}
#if !defined(NS_BLOCK_ASSERTIONS)
@@ -12703,19 +11340,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBBoolDoubleDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBBoolDoubleDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolDoubleDictionary class]]) {
return NO;
}
- if ((_valueSet[0] != other->_valueSet[0]) ||
- (_valueSet[1] != other->_valueSet[1])) {
+ GPBBoolDoubleDictionary *otherDictionary = other;
+ if ((_valueSet[0] != otherDictionary->_valueSet[0]) ||
+ (_valueSet[1] != otherDictionary->_valueSet[1])) {
return NO;
}
- if ((_valueSet[0] && (_values[0] != other->_values[0])) ||
- (_valueSet[1] && (_values[1] != other->_values[1]))) {
+ if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) ||
+ (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) {
return NO;
}
return YES;
@@ -12741,7 +11379,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0);
}
-- (BOOL)valueForKey:(BOOL)key value:(double *)value {
+- (BOOL)getDouble:(double *)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
if (_valueSet[idx]) {
if (value) {
@@ -12768,7 +11406,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndDoublesUsingBlock:
(void (^)(BOOL key, double value, BOOL *stop))block {
BOOL stop = NO;
if (_valueSet[0]) {
@@ -12829,7 +11467,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(double)value forKey:(BOOL)key {
+- (void)setDouble:(double)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
_values[idx] = value;
_valueSet[idx] = YES;
@@ -12838,7 +11476,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(BOOL)aKey {
+- (void)removeDoubleForKey:(BOOL)aKey {
_valueSet[aKey ? 1 : 0] = NO;
}
@@ -12859,39 +11497,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
id _values[2];
}
-+ (instancetype)dictionary {
- return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithObject:(id)object
- forKey:(BOOL)key {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolObjectDictionary*)[self alloc] initWithObjects:&object
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithObjects:(const id [])objects
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolObjectDictionary*)[self alloc] initWithObjects:objects
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBBoolObjectDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithDictionary:
- // on to get the type correct.
- return [[(GPBBoolObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems {
- return [[[self alloc] initWithCapacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithObjects:NULL forKeys:NULL count:0];
}
@@ -12943,19 +11548,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBBoolObjectDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBBoolObjectDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolObjectDictionary class]]) {
return NO;
}
- if (((_values[0] != nil) != (other->_values[0] != nil)) ||
- ((_values[1] != nil) != (other->_values[1] != nil))) {
+ GPBBoolObjectDictionary *otherDictionary = other;
+ if (((_values[0] != nil) != (otherDictionary->_values[0] != nil)) ||
+ ((_values[1] != nil) != (otherDictionary->_values[1] != nil))) {
return NO;
}
- if (((_values[0] != nil) && (![_values[0] isEqual:other->_values[0]])) ||
- ((_values[1] != nil) && (![_values[1] isEqual:other->_values[1]]))) {
+ if (((_values[0] != nil) && (![_values[0] isEqual:otherDictionary->_values[0]])) ||
+ ((_values[1] != nil) && (![_values[1] isEqual:otherDictionary->_values[1]]))) {
return NO;
}
return YES;
@@ -13124,54 +11730,6 @@ void GPBDictionaryReadEntry(id mapDictionary,
@synthesize validationFunc = _validationFunc;
-+ (instancetype)dictionary {
- return [[[self alloc] initWithValidationFunction:NULL
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func {
- return [[[self alloc] initWithValidationFunction:func
- rawValues:NULL
- forKeys:NULL
- count:0] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValue:(int32_t)rawValue
- forKey:(BOOL)key {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolEnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:&rawValue
- forKeys:&key
- count:1] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const BOOL [])keys
- count:(NSUInteger)count {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolEnumDictionary*)[self alloc] initWithValidationFunction:func
- rawValues:values
- forKeys:keys
- count:count] autorelease];
-}
-
-+ (instancetype)dictionaryWithDictionary:(GPBBoolEnumDictionary *)dictionary {
- // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count:
- // on to get the type correct.
- return [[(GPBBoolEnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease];
-}
-
-+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func
- capacity:(NSUInteger)numItems {
- return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease];
-}
-
- (instancetype)init {
return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0];
}
@@ -13233,19 +11791,20 @@ void GPBDictionaryReadEntry(id mapDictionary,
return [[GPBBoolEnumDictionary allocWithZone:zone] initWithDictionary:self];
}
-- (BOOL)isEqual:(GPBBoolEnumDictionary *)other {
+- (BOOL)isEqual:(id)other {
if (self == other) {
return YES;
}
if (![other isKindOfClass:[GPBBoolEnumDictionary class]]) {
return NO;
}
- if ((_valueSet[0] != other->_valueSet[0]) ||
- (_valueSet[1] != other->_valueSet[1])) {
+ GPBBoolEnumDictionary *otherDictionary = other;
+ if ((_valueSet[0] != otherDictionary->_valueSet[0]) ||
+ (_valueSet[1] != otherDictionary->_valueSet[1])) {
return NO;
}
- if ((_valueSet[0] && (_values[0] != other->_values[0])) ||
- (_valueSet[1] && (_values[1] != other->_values[1]))) {
+ if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) ||
+ (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) {
return NO;
}
return YES;
@@ -13271,7 +11830,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0);
}
-- (BOOL)valueForKey:(BOOL)key value:(int32_t*)value {
+- (BOOL)getEnum:(int32_t*)value forKey:(BOOL)key {
int idx = (key ? 1 : 0);
if (_valueSet[idx]) {
if (value) {
@@ -13286,7 +11845,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return NO;
}
-- (BOOL)valueForKey:(BOOL)key rawValue:(int32_t*)rawValue {
+- (BOOL)getRawValue:(int32_t*)rawValue forKey:(BOOL)key {
int idx = (key ? 1 : 0);
if (_valueSet[idx]) {
if (rawValue) {
@@ -13297,7 +11856,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
return NO;
}
-- (void)enumerateKeysAndValuesUsingBlock:
+- (void)enumerateKeysAndRawValuesUsingBlock:
(void (^)(BOOL key, int32_t value, BOOL *stop))block {
BOOL stop = NO;
if (_valueSet[0]) {
@@ -13308,7 +11867,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)enumerateKeysAndRawValuesUsingBlock:
+- (void)enumerateKeysAndEnumsUsingBlock:
(void (^)(BOOL key, int32_t rawValue, BOOL *stop))block {
BOOL stop = NO;
GPBEnumValidationFunc func = _validationFunc;
@@ -13413,7 +11972,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)setValue:(int32_t)value forKey:(BOOL)key {
+- (void)setEnum:(int32_t)value forKey:(BOOL)key {
if (!_validationFunc(value)) {
[NSException raise:NSInvalidArgumentException
format:@"GPBBoolEnumDictionary: Attempt to set an unknown enum value (%d)",
@@ -13436,7 +11995,7 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)removeValueForKey:(BOOL)aKey {
+- (void)removeEnumForKey:(BOOL)aKey {
_valueSet[aKey ? 1 : 0] = NO;
}
@@ -13513,22 +12072,26 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (id)copyWithZone:(NSZone *)zone {
if (_dictionary == nil) {
- _dictionary = [[NSMutableDictionary alloc] init];
+ return [[NSMutableDictionary allocWithZone:zone] init];
}
return [_dictionary copyWithZone:zone];
}
- (id)mutableCopyWithZone:(NSZone *)zone {
if (_dictionary == nil) {
- _dictionary = [[NSMutableDictionary alloc] init];
+ return [[NSMutableDictionary allocWithZone:zone] init];
}
return [_dictionary mutableCopyWithZone:zone];
}
+// Not really needed, but subscripting is likely common enough it doesn't hurt
+// to ensure it goes directly to the real NSMutableDictionary.
- (id)objectForKeyedSubscript:(id)key {
return [_dictionary objectForKeyedSubscript:key];
}
+// Not really needed, but subscripting is likely common enough it doesn't hurt
+// to ensure it goes directly to the real NSMutableDictionary.
- (void)setObject:(id)obj forKeyedSubscript:(id<NSCopying>)key {
if (_dictionary == nil) {
_dictionary = [[NSMutableDictionary alloc] init];
@@ -13539,17 +12102,19 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
}
-- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(id key,
+- (void)enumerateKeysAndObjectsUsingBlock:(void (NS_NOESCAPE ^)(id key,
id obj,
BOOL *stop))block {
[_dictionary enumerateKeysAndObjectsUsingBlock:block];
}
- (void)enumerateKeysAndObjectsWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(id key,
+ usingBlock:(void (NS_NOESCAPE ^)(id key,
id obj,
BOOL *stop))block {
[_dictionary enumerateKeysAndObjectsWithOptions:opts usingBlock:block];
}
@end
+
+#pragma clang diagnostic pop
diff --git a/objectivec/GPBExtensionInternals.m b/objectivec/GPBExtensionInternals.m
index 634c3369..290c82a1 100644
--- a/objectivec/GPBExtensionInternals.m
+++ b/objectivec/GPBExtensionInternals.m
@@ -33,7 +33,7 @@
#import <objc/runtime.h>
#import "GPBCodedInputStream_PackagePrivate.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
#import "GPBDescriptor_PackagePrivate.h"
#import "GPBMessage_PackagePrivate.h"
#import "GPBUtilities_PackagePrivate.h"
@@ -45,6 +45,8 @@ static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
__attribute__((ns_returns_retained));
GPB_INLINE size_t DataTypeSize(GPBDataType dataType) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wswitch-enum"
switch (dataType) {
case GPBDataTypeBool:
return 1;
@@ -59,6 +61,7 @@ GPB_INLINE size_t DataTypeSize(GPBDataType dataType) {
default:
return 0;
}
+#pragma clang diagnostic pop
}
static size_t ComputePBSerializedSizeNoTagOfObject(GPBDataType dataType, id object) {
@@ -261,6 +264,12 @@ static void WriteArrayIncludingTagsToCodedOutputStream(
}
}
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension,
BOOL isPackedOnStream,
GPBCodedInputStream *input,
@@ -378,3 +387,5 @@ static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
return nil;
}
+
+#pragma clang diagnostic pop
diff --git a/objectivec/GPBExtensionRegistry.h b/objectivec/GPBExtensionRegistry.h
index 0363c70a..d79632d2 100644
--- a/objectivec/GPBExtensionRegistry.h
+++ b/objectivec/GPBExtensionRegistry.h
@@ -35,30 +35,50 @@
NS_ASSUME_NONNULL_BEGIN
-// A table of known extensions, searchable by name or field number. When
-// parsing a protocol message that might have extensions, you must provide an
-// ExtensionRegistry in which you have registered any extensions that you want
-// to be able to parse. Otherwise, those extensions will just be treated like
-// unknown fields.
-//
-// The *Root classes provide +extensionRegistry for the extensions defined in a
-// given file *and* all files it imports. You can also create a
-// GPBExtensionRegistry, and merge those registries to handle parsing extensions
-// defined from non overlapping files.
-//
-// GPBExtensionRegistry *registry =
-// [[[MyProtoFileRoot extensionRegistry] copy] autorelease];
-// [registry addExtension:[OtherMessage neededExtension]; // Not in MyProtoFile
-// NSError *parseError = nil;
-// MyMessage *msg = [MyMessage parseData:data
-// extensionRegistry:registry
-// error:&parseError];
-//
+/**
+ * A table of known extensions, searchable by name or field number. When
+ * parsing a protocol message that might have extensions, you must provide a
+ * GPBExtensionRegistry in which you have registered any extensions that you
+ * want to be able to parse. Otherwise, those extensions will just be treated
+ * like unknown fields.
+ *
+ * The *Root classes provide `+extensionRegistry` for the extensions defined
+ * in a given file *and* all files it imports. You can also create a
+ * GPBExtensionRegistry, and merge those registries to handle parsing
+ * extensions defined from non overlapping files.
+ *
+ * ```
+ * GPBExtensionRegistry *registry = [[MyProtoFileRoot extensionRegistry] copy];
+ * [registry addExtension:[OtherMessage neededExtension]]; // Not in MyProtoFile
+ * NSError *parseError;
+ * MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError];
+ * ```
+ **/
@interface GPBExtensionRegistry : NSObject<NSCopying>
+/**
+ * Adds the given GPBExtensionDescriptor to this registry.
+ *
+ * @param extension The extension description to add.
+ **/
- (void)addExtension:(GPBExtensionDescriptor *)extension;
+
+/**
+ * Adds all the extensions from another registry to this registry.
+ *
+ * @param registry The registry to merge into this registry.
+ **/
- (void)addExtensions:(GPBExtensionRegistry *)registry;
+/**
+ * Looks for the extension registered for the given field number on a given
+ * GPBDescriptor.
+ *
+ * @param descriptor The descriptor to look for a registered extension on.
+ * @param fieldNumber The field number of the extension to look for.
+ *
+ * @return The registered GPBExtensionDescriptor or nil if none was found.
+ **/
- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
fieldNumber:(NSInteger)fieldNumber;
diff --git a/objectivec/GPBExtensionRegistry.m b/objectivec/GPBExtensionRegistry.m
index df61a17b..b056a52d 100644
--- a/objectivec/GPBExtensionRegistry.m
+++ b/objectivec/GPBExtensionRegistry.m
@@ -34,8 +34,6 @@
#import "GPBDescriptor.h"
@implementation GPBExtensionRegistry {
- // TODO(dmaclach): Reimplement with CFDictionaries that don't use
- // objects as keys.
NSMutableDictionary *mutableClassMap_;
}
@@ -51,43 +49,56 @@
[super dealloc];
}
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
- (instancetype)copyWithZone:(NSZone *)zone {
GPBExtensionRegistry *result = [[[self class] allocWithZone:zone] init];
- if (result && mutableClassMap_.count) {
- [result->mutableClassMap_ addEntriesFromDictionary:mutableClassMap_];
- }
+ [result addExtensions:self];
return result;
}
-- (NSMutableDictionary *)extensionMapForContainingMessageClass:
- (Class)containingMessageClass {
- NSMutableDictionary *extensionMap =
- [mutableClassMap_ objectForKey:containingMessageClass];
- if (extensionMap == nil) {
- extensionMap = [NSMutableDictionary dictionary];
- [mutableClassMap_ setObject:extensionMap
- forKey:(id<NSCopying>)containingMessageClass];
- }
- return extensionMap;
-}
-
- (void)addExtension:(GPBExtensionDescriptor *)extension {
if (extension == nil) {
return;
}
Class containingMessageClass = extension.containingMessageClass;
- NSMutableDictionary *extensionMap =
- [self extensionMapForContainingMessageClass:containingMessageClass];
- [extensionMap setObject:extension forKey:@(extension.fieldNumber)];
+ CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
+ [mutableClassMap_ objectForKey: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);
+ [mutableClassMap_ setObject:(id)extensionMap
+ forKey:(id<NSCopying>)containingMessageClass];
+ CFRelease(extensionMap);
+ }
+
+ ssize_t key = extension.fieldNumber;
+ CFDictionarySetValue(extensionMap, (const void *)key, extension);
}
- (GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
fieldNumber:(NSInteger)fieldNumber {
Class messageClass = descriptor.messageClass;
- NSDictionary *extensionMap =
+ CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
[mutableClassMap_ objectForKey:messageClass];
- return [extensionMap objectForKey:@(fieldNumber)];
+ ssize_t key = fieldNumber;
+ GPBExtensionDescriptor *result =
+ (extensionMap
+ ? CFDictionaryGetValue(extensionMap, (const void *)key)
+ : nil);
+ return result;
+}
+
+static void CopyKeyValue(const void *key, const void *value, void *context) {
+ CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)context;
+ CFDictionarySetValue(extensionMap, key, value);
}
- (void)addExtensions:(GPBExtensionRegistry *)registry {
@@ -96,13 +107,24 @@
return;
}
NSMutableDictionary *otherClassMap = registry->mutableClassMap_;
- for (Class containingMessageClass in otherClassMap) {
- NSMutableDictionary *extensionMap =
- [self extensionMapForContainingMessageClass:containingMessageClass];
- NSMutableDictionary *otherExtensionMap =
- [registry extensionMapForContainingMessageClass:containingMessageClass];
- [extensionMap addEntriesFromDictionary:otherExtensionMap];
- }
+ [otherClassMap enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL * stop) {
+#pragma unused(stop)
+ Class containingMessageClass = key;
+ CFMutableDictionaryRef otherExtensionMap = (CFMutableDictionaryRef)value;
+
+ CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)
+ [mutableClassMap_ objectForKey:containingMessageClass];
+ if (extensionMap == nil) {
+ extensionMap = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, otherExtensionMap);
+ [mutableClassMap_ setObject:(id)extensionMap
+ forKey:(id<NSCopying>)containingMessageClass];
+ CFRelease(extensionMap);
+ } else {
+ CFDictionaryApplyFunction(otherExtensionMap, CopyKeyValue, extensionMap);
+ }
+ }];
}
+#pragma clang diagnostic pop
+
@end
diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h
index 332393ed..276740d2 100644
--- a/objectivec/GPBMessage.h
+++ b/objectivec/GPBMessage.h
@@ -44,134 +44,427 @@ NS_ASSUME_NONNULL_BEGIN
CF_EXTERN_C_BEGIN
-// NSError domain used for errors.
+/** NSError domain used for errors. */
extern NSString *const GPBMessageErrorDomain;
+/** Error codes for NSErrors originated in GPBMessage. */
typedef NS_ENUM(NSInteger, GPBMessageErrorCode) {
- GPBMessageErrorCodeMalformedData = -100,
+ /** Uncategorized error. */
+ GPBMessageErrorCodeOther = -100,
+ /** Message couldn't be serialized because it is missing required fields. */
GPBMessageErrorCodeMissingRequiredField = -101,
};
-// In DEBUG ONLY, an NSException is thrown when a parsed message doesn't
-// contain required fields. This key allows you to retrieve the parsed message
-// from the exception's |userInfo| dictionary.
-#ifdef DEBUG
-extern NSString *const GPBExceptionMessageKey;
-#endif // DEBUG
+/**
+ * Key under which the GPBMessage error's reason is stored inside the userInfo
+ * dictionary.
+ **/
+extern NSString *const GPBErrorReasonKey;
CF_EXTERN_C_END
+/**
+ * Base class that each generated message subclasses from.
+ *
+ * @note @c NSCopying support is a "deep copy", in that all sub objects are
+ * copied. Just like you wouldn't want a UIView/NSView trying to
+ * exist in two places, you don't want a sub message to be a property
+ * property of two other messages.
+ *
+ * @note While the class support NSSecureCoding, if the message has any
+ * extensions, they will end up reloaded in @c unknownFields as there is
+ * no way for the @c NSCoding plumbing to pass through a
+ * @c GPBExtensionRegistry. To support extensions, instead of passing the
+ * calls off to the Message, simple store the result of @c data, and then
+ * when loading, fetch the data and use
+ * @c +parseFromData:extensionRegistry:error: to provide an extension
+ * registry.
+ **/
@interface GPBMessage : NSObject<NSSecureCoding, NSCopying>
-// NOTE: If you add a instance method/property to this class that may conflict
-// with methods declared in protos, you need to update objective_helpers.cc.
-// The main cases are methods that take no arguments, or setFoo:/hasFoo: type
-// methods.
+// If you add an instance method/property to this class that may conflict with
+// fields declared in protos, you need to update objective_helpers.cc. The main
+// cases are methods that take no arguments, or setFoo:/hasFoo: type methods.
+/**
+ * The set of unknown fields for this message.
+ *
+ * Only messages from proto files declared with "proto2" syntax support unknown
+ * fields. For "proto3" syntax, any unknown fields found while parsing are
+ * dropped.
+ **/
@property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields;
-// Are all required fields in the message and all embedded messages set.
+/**
+ * Whether the message, along with all submessages, have the required fields
+ * set. This is only applicable for files declared with "proto2" syntax, as
+ * there are no required fields for "proto3" syntax.
+ **/
@property(nonatomic, readonly, getter=isInitialized) BOOL initialized;
-// Returns an autoreleased instance.
+/**
+ * @return An autoreleased message with the default values set.
+ **/
+ (instancetype)message;
-// Create a message based on a variety of inputs. If there is a data parse
-// error, nil is returned and if not NULL, errorPtr is filled in.
-// NOTE: In DEBUG ONLY, the message is also checked for all required field,
-// if one is missing, the parse will fail (returning nil, filling in errorPtr).
-+ (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr;
-+ (instancetype)parseFromData:(NSData *)data
- extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
- error:(NSError **)errorPtr;
-+ (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
- extensionRegistry:
- (nullable GPBExtensionRegistry *)extensionRegistry
- error:(NSError **)errorPtr;
-
-// Create a message based on delimited input. If there is a data parse
-// error, nil is returned and if not NULL, errorPtr is filled in.
-+ (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
+/**
+ * Creates a new instance by parsing the provided data. This method should be
+ * sent to the generated message class that the data should be interpreted as.
+ * If there is an error the method returns nil and the error is returned in
+ * errorPtr (when provided).
+ *
+ * @note In DEBUG builds, the parsed message is checked to be sure all required
+ * fields were provided, and the parse will fail if some are missing.
+ *
+ * @note The errors returned are likely coming from the domain and codes listed
+ * at the top of this file and GPBCodedInputStream.h.
+ *
+ * @param data The data to parse.
+ * @param errorPtr An optional error pointer to fill in with a failure reason if
+ * the data can not be parsed.
+ *
+ * @return A new instance of the generated class.
+ **/
++ (nullable instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr;
+
+/**
+ * Creates a new instance by parsing the data. This method should be sent to
+ * the generated message class that the data should be interpreted as. If
+ * there is an error the method returns nil and the error is returned in
+ * errorPtr (when provided).
+ *
+ * @note In DEBUG builds, the parsed message is checked to be sure all required
+ * fields were provided, and the parse will fail if some are missing.
+ *
+ * @note The errors returned are likely coming from the domain and codes listed
+ * at the top of this file and GPBCodedInputStream.h.
+ *
+ * @param data The data to parse.
+ * @param extensionRegistry The extension registry to use to look up extensions.
+ * @param errorPtr An optional error pointer to fill in with a failure
+ * reason if the data can not be parsed.
+ *
+ * @return A new instance of the generated class.
+ **/
++ (nullable instancetype)parseFromData:(NSData *)data
+ extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
+ error:(NSError **)errorPtr;
+
+/**
+ * Creates a new instance by parsing the data from the given input stream. This
+ * method should be sent to the generated message class that the data should
+ * be interpreted as. If there is an error the method returns nil and the error
+ * is returned in errorPtr (when provided).
+ *
+ * @note In DEBUG builds, the parsed message is checked to be sure all required
+ * fields were provided, and the parse will fail if some are missing.
+ *
+ * @note The errors returned are likely coming from the domain and codes listed
+ * at the top of this file and GPBCodedInputStream.h.
+ *
+ * @param input The stream to read data from.
+ * @param extensionRegistry The extension registry to use to look up extensions.
+ * @param errorPtr An optional error pointer to fill in with a failure
+ * reason if the data can not be parsed.
+ *
+ * @return A new instance of the generated class.
+ **/
++ (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
error:(NSError **)errorPtr;
-// If there is a data parse error, nil is returned and if not NULL, errorPtr is
-// filled in.
-// NOTE: In DEBUG ONLY, the message is also checked for all required field,
-// if one is missing, the parse will fail (returning nil, filling in errorPtr).
-- (instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr;
-- (instancetype)initWithData:(NSData *)data
- extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
- error:(NSError **)errorPtr;
-- (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
- extensionRegistry:
- (nullable GPBExtensionRegistry *)extensionRegistry
- error:(NSError **)errorPtr;
-
-// Serializes the message and writes it to output.
+/**
+ * Creates a new instance by parsing the data from the given input stream. This
+ * method should be sent to the generated message class that the data should
+ * be interpreted as. If there is an error the method returns nil and the error
+ * is returned in errorPtr (when provided).
+ *
+ * @note Unlike the parseFrom... methods, this never checks to see if all of
+ * the required fields are set. So this method can be used to reload
+ * messages that may not be complete.
+ *
+ * @note The errors returned are likely coming from the domain and codes listed
+ * at the top of this file and GPBCodedInputStream.h.
+ *
+ * @param input The stream to read data from.
+ * @param extensionRegistry The extension registry to use to look up extensions.
+ * @param errorPtr An optional error pointer to fill in with a failure
+ * reason if the data can not be parsed.
+ *
+ * @return A new instance of the generated class.
+ **/
++ (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
+ extensionRegistry:
+ (nullable GPBExtensionRegistry *)extensionRegistry
+ error:(NSError **)errorPtr;
+
+/**
+ * Initializes an instance by parsing the data. This method should be sent to
+ * the generated message class that the data should be interpreted as. If
+ * there is an error the method returns nil and the error is returned in
+ * errorPtr (when provided).
+ *
+ * @note In DEBUG builds, the parsed message is checked to be sure all required
+ * fields were provided, and the parse will fail if some are missing.
+ *
+ * @note The errors returned are likely coming from the domain and codes listed
+ * at the top of this file and GPBCodedInputStream.h.
+ *
+ * @param data The data to parse.
+ * @param errorPtr An optional error pointer to fill in with a failure reason if
+ * the data can not be parsed.
+ *
+ * @return An initialized instance of the generated class.
+ **/
+- (nullable instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr;
+
+/**
+ * Initializes an instance by parsing the data. This method should be sent to
+ * the generated message class that the data should be interpreted as. If
+ * there is an error the method returns nil and the error is returned in
+ * errorPtr (when provided).
+ *
+ * @note In DEBUG builds, the parsed message is checked to be sure all required
+ * fields were provided, and the parse will fail if some are missing.
+ *
+ * @note The errors returned are likely coming from the domain and codes listed
+ * at the top of this file and GPBCodedInputStream.h.
+ *
+ * @param data The data to parse.
+ * @param extensionRegistry The extension registry to use to look up extensions.
+ * @param errorPtr An optional error pointer to fill in with a failure
+ * reason if the data can not be parsed.
+ *
+ * @return An initialized instance of the generated class.
+ **/
+- (nullable instancetype)initWithData:(NSData *)data
+ extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
+ error:(NSError **)errorPtr;
+
+/**
+ * Initializes an instance by parsing the data from the given input stream. This
+ * method should be sent to the generated message class that the data should
+ * be interpreted as. If there is an error the method returns nil and the error
+ * is returned in errorPtr (when provided).
+ *
+ * @note Unlike the parseFrom... methods, this never checks to see if all of
+ * the required fields are set. So this method can be used to reload
+ * messages that may not be complete.
+ *
+ * @note The errors returned are likely coming from the domain and codes listed
+ * at the top of this file and GPBCodedInputStream.h.
+ *
+ * @param input The stream to read data from.
+ * @param extensionRegistry The extension registry to use to look up extensions.
+ * @param errorPtr An optional error pointer to fill in with a failure
+ * reason if the data can not be parsed.
+ *
+ * @return An initialized instance of the generated class.
+ **/
+- (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
+ extensionRegistry:
+ (nullable GPBExtensionRegistry *)extensionRegistry
+ error:(NSError **)errorPtr;
+
+/**
+ * Parses the given data as this message's class, and merges those values into
+ * this message.
+ *
+ * @param data The binary representation of the message to merge.
+ * @param extensionRegistry The extension registry to use to look up extensions.
+ *
+ * @exception GPBCodedInputStreamException Exception thrown when parsing was
+ * unsuccessful.
+ **/
+- (void)mergeFromData:(NSData *)data
+ extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
+
+/**
+ * Merges the fields from another message (of the same type) into this
+ * message.
+ *
+ * @param other Message to merge into this message.
+ **/
+- (void)mergeFrom:(GPBMessage *)other;
+
+/**
+ * Writes out the message to the given coded output stream.
+ *
+ * @param output The coded output stream into which to write the message.
+ *
+ * @note This can raise the GPBCodedOutputStreamException_* exceptions.
+ *
+ **/
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output;
+
+/**
+ * Writes out the message to the given output stream.
+ *
+ * @param output The output stream into which to write the message.
+ *
+ * @note This can raise the GPBCodedOutputStreamException_* exceptions.
+ **/
- (void)writeToOutputStream:(NSOutputStream *)output;
-// Serializes the message and writes it to output, but writes the size of the
-// message as a variant before writing the message.
+/**
+ * Writes out a varint for the message size followed by the the message to
+ * the given output stream.
+ *
+ * @param output The coded output stream into which to write the message.
+ *
+ * @note This can raise the GPBCodedOutputStreamException_* exceptions.
+ **/
- (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output;
+
+/**
+ * Writes out a varint for the message size followed by the the message to
+ * the given output stream.
+ *
+ * @param output The output stream into which to write the message.
+ *
+ * @note This can raise the GPBCodedOutputStreamException_* exceptions.
+ **/
- (void)writeDelimitedToOutputStream:(NSOutputStream *)output;
-// Serializes the message to an NSData. Note that this value is not cached, so
-// if you are using it repeatedly, cache it yourself. If there is an error
-// while generating the data, nil is returned.
-// NOTE: In DEBUG ONLY, the message is also checked for all required field,
-// if one is missing, nil will be returned.
+/**
+ * Serializes the message to an NSData.
+ *
+ * If there is an error while generating the data, nil is returned.
+ *
+ * @note This value is not cached, so if you are using it repeatedly, cache
+ * it yourself.
+ *
+ * @note In DEBUG ONLY, the message is also checked for all required field,
+ * if one is missing, nil will be returned.
+ *
+ * @return The binary representation of the message.
+ **/
- (nullable NSData *)data;
-// Same as -[data], except a delimiter is added to the start of the data
-// indicating the size of the message data that follows.
+/**
+ * Serializes a varint with the message size followed by the message data,
+ * returning that as an NSData.
+ *
+ * @note This value is not cached, so if you are using it repeatedly, it is
+ * recommended to keep a local copy.
+ *
+ * @return The binary representation of the size along with the message.
+ **/
- (NSData *)delimitedData;
-// Returns the size of the object if it were serialized.
-// This is not a cached value. If you are following a pattern like this:
-// size_t size = [aMsg serializedSize];
-// NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
-// [foo writeSize:size];
-// [foo appendData:[aMsg data]];
-// you would be better doing:
-// NSData *data = [aMsg data];
-// NSUInteger size = [aMsg length];
-// NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
-// [foo writeSize:size];
-// [foo appendData:data];
+/**
+ * Calculates the size of the object if it were serialized.
+ *
+ * This is not a cached value. If you are following a pattern like this:
+ *
+ * ```
+ * size_t size = [aMsg serializedSize];
+ * NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
+ * [foo writeSize:size];
+ * [foo appendData:[aMsg data]];
+ * ```
+ *
+ * you would be better doing:
+ *
+ * ```
+ * NSData *data = [aMsg data];
+ * NSUInteger size = [aMsg length];
+ * NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
+ * [foo writeSize:size];
+ * [foo appendData:data];
+ * ```
+ *
+ * @return The size of the message in it's binary representation.
+ **/
- (size_t)serializedSize;
-// Return the descriptor for the message
+/**
+ * @return The descriptor for the message class.
+ **/
+ (GPBDescriptor *)descriptor;
+
+/**
+ * Return the descriptor for the message.
+ **/
- (GPBDescriptor *)descriptor;
-// Extensions use boxed values (NSNumbers) for PODs, NSMutableArrays for
-// repeated. If the extension is a Message one will be auto created for you
-// and returned similar to fields.
+/**
+ * @return An array with the extension descriptors that are currently set on the
+ * message.
+ **/
+- (NSArray *)extensionsCurrentlySet;
+
+/**
+ * Checks whether there is an extension set on the message which matches the
+ * given extension descriptor.
+ *
+ * @param extension Extension descriptor to check if it's set on the message.
+ *
+ * @return Whether the extension is currently set on the message.
+ **/
- (BOOL)hasExtension:(GPBExtensionDescriptor *)extension;
+
+/*
+ * Fetches the given extension's value for this message.
+ *
+ * Extensions use boxed values (NSNumbers) for PODs and NSMutableArrays for
+ * repeated fields. If the extension is a Message one will be auto created for
+ * you and returned similar to fields.
+ *
+ * @param extension The extension descriptor of the extension to fetch.
+ *
+ * @return The extension matching the given descriptor, or nil if none found.
+ **/
- (nullable id)getExtension:(GPBExtensionDescriptor *)extension;
-- (void)setExtension:(GPBExtensionDescriptor *)extension value:(nullable id)value;
+
+/**
+ * Sets the given extension's value for this message. This only applies for
+ * single field extensions (i.e. - not repeated fields).
+ *
+ * Extensions use boxed values (NSNumbers).
+ *
+ * @param extension The extension descriptor under which to set the value.
+ * @param value The value to be set as the extension.
+ **/
+- (void)setExtension:(GPBExtensionDescriptor *)extension
+ value:(nullable id)value;
+
+/**
+ * Adds the given value to the extension for this message. This only applies
+ * to repeated field extensions. If the field is a repeated POD type, the value
+ * should be an NSNumber.
+ *
+ * @param extension The extension descriptor under which to add the value.
+ * @param value The value to be added to the repeated extension.
+ **/
- (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value;
+
+/**
+ * Replaces the value at the given index with the given value for the extension
+ * on this message. This only applies to repeated field extensions. If the field
+ * is a repeated POD type, the value is should be an NSNumber.
+ *
+ * @param extension The extension descriptor under which to replace the value.
+ * @param index The index of the extension to be replaced.
+ * @param value The value to be replaced in the repeated extension.
+ **/
- (void)setExtension:(GPBExtensionDescriptor *)extension
index:(NSUInteger)index
value:(id)value;
+
+/**
+ * Clears the given extension for this message.
+ *
+ * @param extension The extension descriptor to be cleared from this message.
+ **/
- (void)clearExtension:(GPBExtensionDescriptor *)extension;
-// Resets all fields to their default values.
+/**
+ * Resets all of the fields of this message to their default values.
+ **/
- (void)clear;
-// Parses a message of this type from the input and merges it with this
-// message.
-// NOTE: This will throw if there is an error parsing the data.
-- (void)mergeFromData:(NSData *)data
- extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
-
-// Merges the fields from another message (of the same type) into this
-// message.
-- (void)mergeFrom:(GPBMessage *)other;
-
@end
NS_ASSUME_NONNULL_END
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m
index fdb695ec..db5d3b60 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -32,10 +32,11 @@
#import <objc/runtime.h>
#import <objc/message.h>
+#import <stdatomic.h>
#import "GPBArray_PackagePrivate.h"
#import "GPBCodedInputStream_PackagePrivate.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
#import "GPBDescriptor_PackagePrivate.h"
#import "GPBDictionary_PackagePrivate.h"
#import "GPBExtensionInternals.h"
@@ -44,28 +45,19 @@
#import "GPBUnknownFieldSet_PackagePrivate.h"
#import "GPBUtilities_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
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
NSString *const GPBMessageErrorDomain =
GPBNSStringifySymbol(GPBMessageErrorDomain);
-#ifdef DEBUG
-NSString *const GPBExceptionMessageKey =
- GPBNSStringifySymbol(GPBExceptionMessage);
-#endif // DEBUG
+NSString *const GPBErrorReasonKey = @"Reason";
static NSString *const kGPBDataCoderKey = @"GPBData";
-#ifndef _GPBCompileAssert
- #if __has_feature(c_static_assert) || __has_extension(c_static_assert)
- #define _GPBCompileAssert(test, msg) _Static_assert((test), #msg)
- #else
- // Pre-Xcode 7 support.
- #define _GPBCompileAssertSymbolInner(line, msg) _GPBCompileAssert ## line ## __ ## msg
- #define _GPBCompileAssertSymbol(line, msg) _GPBCompileAssertSymbolInner(line, msg)
- #define _GPBCompileAssert(test, msg) \
- typedef char _GPBCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
- #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert)
-#endif // _GPBCompileAssert
-
//
// PLEASE REMEMBER:
//
@@ -86,6 +78,20 @@ static NSString *const kGPBDataCoderKey = @"GPBData";
GPBMessage *autocreator_;
GPBFieldDescriptor *autocreatorField_;
GPBExtensionDescriptor *autocreatorExtension_;
+
+ // A lock to provide mutual exclusion from internal data that can be modified
+ // by *read* operations such as getters (autocreation of message fields and
+ // message extensions, not setting of values). Used to guarantee thread safety
+ // for concurrent reads on the message.
+ // 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
+ // 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
@@ -107,24 +113,39 @@ 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];
}
+#endif
-static NSError *MessageErrorWithReason(NSInteger code, NSString *reason) {
- NSDictionary *userInfo = nil;
- if ([reason length]) {
- userInfo = @{ @"Reason" : reason };
+static NSError *ErrorFromException(NSException *exception) {
+ NSError *error = nil;
+
+ if ([exception.name isEqual:GPBCodedInputStreamException]) {
+ NSDictionary *exceptionInfo = exception.userInfo;
+ error = exceptionInfo[GPBCodedInputStreamUnderlyingErrorKey];
}
- return MessageError(code, userInfo);
-}
+ if (!error) {
+ NSString *reason = exception.reason;
+ NSDictionary *userInfo = nil;
+ if ([reason length]) {
+ userInfo = @{ GPBErrorReasonKey : reason };
+ }
+
+ error = [NSError errorWithDomain:GPBMessageErrorDomain
+ code:GPBMessageErrorCodeOther
+ userInfo:userInfo];
+ }
+ return error;
+}
static void CheckExtension(GPBMessage *self,
GPBExtensionDescriptor *extension) {
- if ([self class] != extension.containingMessageClass) {
+ if (![self isKindOfClass:extension.containingMessageClass]) {
[NSException
raise:NSInvalidArgumentException
format:@"Extension %@ used on wrong class (%@ instead of %@)",
@@ -568,6 +589,7 @@ static id GetArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
id array = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!array) {
// Check again after getting the lock.
+ GPBPrepareReadOnlySemaphore(self);
dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
array = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!array) {
@@ -598,6 +620,7 @@ static id GetMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!dict) {
// Check again after getting the lock.
+ GPBPrepareReadOnlySemaphore(self);
dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!dict) {
@@ -704,7 +727,7 @@ void GPBClearMessageAutocreator(GPBMessage *self) {
return;
}
-#if DEBUG && !defined(NS_BLOCK_ASSERTIONS)
+#if defined(DEBUG) && DEBUG && !defined(NS_BLOCK_ASSERTIONS)
// Either the autocreator must have its "has" flag set to YES, or it must be
// NO and not equal to ourselves.
BOOL autocreatorHas =
@@ -730,6 +753,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];
@@ -789,14 +837,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
file:fileDescriptor
fields:NULL
fieldCount:0
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
storageSize:0
- wireFormat:NO];
+ flags:0];
}
return descriptor;
}
@@ -809,8 +851,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if ((self = [super init])) {
messageStorage_ = (GPBMessage_StoragePtr)(
((uint8_t *)self) + class_getInstanceSize([self class]));
-
- readOnlySemaphore_ = dispatch_semaphore_create(1);
}
return self;
@@ -834,8 +874,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
[self release];
self = nil;
if (errorPtr) {
- *errorPtr = MessageErrorWithReason(GPBMessageErrorCodeMalformedData,
- exception.reason);
+ *errorPtr = ErrorFromException(exception);
}
}
#ifdef DEBUG
@@ -866,8 +905,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
[self release];
self = nil;
if (errorPtr) {
- *errorPtr = MessageErrorWithReason(GPBMessageErrorCodeMalformedData,
- exception.reason);
+ *errorPtr = ErrorFromException(exception);
}
}
#ifdef DEBUG
@@ -886,7 +924,9 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
- (void)dealloc {
[self internalClear:NO];
NSCAssert(!autocreator_, @"Autocreator was not cleared before dealloc.");
- dispatch_release(readOnlySemaphore_);
+ if (readOnlySemaphore_) {
+ dispatch_release(readOnlySemaphore_);
+ }
[super dealloc];
}
@@ -950,7 +990,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
newValue = [value copyWithZone:zone];
}
} else {
- if (field.mapKeyDataType == GPBDataTypeString) {
+ if ((field.mapKeyDataType == GPBDataTypeString) &&
+ GPBFieldDataTypeIsObject(field)) {
// NSDictionary
newValue = [value mutableCopyWithZone:zone];
} else {
@@ -1023,9 +1064,11 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if (arrayOrMap) {
if (field.fieldType == GPBFieldTypeRepeated) {
if (GPBFieldDataTypeIsObject(field)) {
- GPBAutocreatedArray *autoArray = arrayOrMap;
- if (autoArray->_autocreator == self) {
- autoArray->_autocreator = nil;
+ if ([arrayOrMap isKindOfClass:[GPBAutocreatedArray class]]) {
+ GPBAutocreatedArray *autoArray = arrayOrMap;
+ if (autoArray->_autocreator == self) {
+ autoArray->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Array.
@@ -1037,9 +1080,11 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
} else {
if ((field.mapKeyDataType == GPBDataTypeString) &&
GPBFieldDataTypeIsObject(field)) {
- GPBAutocreatedDictionary *autoDict = arrayOrMap;
- if (autoDict->_autocreator == self) {
- autoDict->_autocreator = nil;
+ if ([arrayOrMap isKindOfClass:[GPBAutocreatedDictionary class]]) {
+ GPBAutocreatedDictionary *autoDict = arrayOrMap;
+ if (autoDict->_autocreator == self) {
+ autoDict->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Dictionary.
@@ -1724,6 +1769,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
// Check for an autocreated value.
+ GPBPrepareReadOnlySemaphore(self);
dispatch_semaphore_wait(readOnlySemaphore_, DISPATCH_TIME_FOREVER);
value = [autocreatedExtensionMap_ objectForKey:extension];
if (!value) {
@@ -1751,7 +1797,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (BOOL)hasExtension:(GPBExtensionDescriptor *)extension {
-#if DEBUG
+#if defined(DEBUG) && DEBUG
CheckExtension(self, extension);
#endif // DEBUG
return nil != [extensionMap_ objectForKey:extension];
@@ -1776,11 +1822,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
}
-- (NSArray *)sortedExtensionsInUse {
- return [[extensionMap_ allKeys]
- sortedArrayUsingSelector:@selector(compareByFieldNumber:)];
-}
-
- (void)setExtension:(GPBExtensionDescriptor *)extension value:(id)value {
if (!value) {
[self clearExtension:extension];
@@ -1935,16 +1976,13 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
}
@catch (NSException *exception) {
- [message release];
message = nil;
if (errorPtr) {
- *errorPtr = MessageErrorWithReason(GPBMessageErrorCodeMalformedData,
- exception.reason);
+ *errorPtr = ErrorFromException(exception);
}
}
#ifdef DEBUG
if (message && !message.initialized) {
- [message release];
message = nil;
if (errorPtr) {
*errorPtr = MessageError(GPBMessageErrorCodeMissingRequiredField, nil);
@@ -2010,7 +2048,12 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
[newInput release];
} else {
GPBUnknownFieldSet *unknownFields = GetOrMakeUnknownFields(self);
- [unknownFields mergeMessageSetMessage:typeId data:rawBytes];
+ // rawBytes was created via a NoCopy, so it can be reusing a
+ // subrange of another NSData that might go out of scope as things
+ // unwind, so a copy is needed to ensure what is saved in the
+ // unknown fields stays valid.
+ NSData *cloned = [NSData dataWithData:rawBytes];
+ [unknownFields mergeMessageSetMessage:typeId data:cloned];
}
}
}
@@ -2281,6 +2324,9 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
while (YES) {
BOOL merged = NO;
tag = GPBCodedInputStreamReadTag(state);
+ if (tag == 0) {
+ break; // Reached end.
+ }
for (NSUInteger i = 0; i < numFields; ++i) {
if (startingIndex >= numFields) startingIndex = 0;
GPBFieldDescriptor *fieldDescriptor = fields[startingIndex];
@@ -2319,7 +2365,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
}
} // for(i < numFields)
- if (!merged) {
+ if (!merged && (tag != 0)) {
// Primitive, repeated types can be packed on unpacked on the wire, and
// are parsed either way. The above loop covered tag in the preferred
// for, so this need to check the alternate form.
@@ -2353,17 +2399,11 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
// zero signals EOF / limit reached
return;
} else {
- if (GPBPreserveUnknownFields(syntax)) {
- if (![self parseUnknownField:input
- extensionRegistry:extensionRegistry
- tag:tag]) {
- // it's an endgroup tag
- return;
- }
- } else {
- if (![input skipField:tag]) {
- return;
- }
+ if (![self parseUnknownField:input
+ extensionRegistry:extensionRegistry
+ tag:tag]) {
+ // it's an endgroup tag
+ return;
}
}
} // if(!merged)
@@ -2574,18 +2614,20 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
#pragma mark - isEqual: & hash Support
-- (BOOL)isEqual:(GPBMessage *)other {
+- (BOOL)isEqual:(id)other {
if (other == self) {
return YES;
}
- if (![other isKindOfClass:[self class]] &&
- ![self isKindOfClass:[other class]]) {
+ if (![other isKindOfClass:[GPBMessage class]]) {
return NO;
}
-
+ GPBMessage *otherMsg = other;
GPBDescriptor *descriptor = [[self class] descriptor];
+ if ([[otherMsg class] descriptor] != descriptor) {
+ return NO;
+ }
uint8_t *selfStorage = (uint8_t *)messageStorage_;
- uint8_t *otherStorage = (uint8_t *)other->messageStorage_;
+ uint8_t *otherStorage = (uint8_t *)otherMsg->messageStorage_;
for (GPBFieldDescriptor *field in descriptor->fields_) {
if (GPBFieldIsMapOrArray(field)) {
@@ -2620,9 +2662,13 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
size_t fieldOffset = field->description_->offset;
switch (fieldDataType) {
case GPBDataTypeBool: {
- BOOL *selfValPtr = (BOOL *)&selfStorage[fieldOffset];
- BOOL *otherValPtr = (BOOL *)&otherStorage[fieldOffset];
- if (*selfValPtr != *otherValPtr) {
+ // Bools are stored in has_bits to avoid needing explicit space in
+ // the storage structure.
+ // (the field number passed to the HasIvar helper doesn't really
+ // matter since the offset is never negative)
+ BOOL selfValue = GPBGetHasIvar(self, (int32_t)(fieldOffset), 0);
+ BOOL otherValue = GPBGetHasIvar(other, (int32_t)(fieldOffset), 0);
+ if (selfValue != otherValue) {
return NO;
}
break;
@@ -2634,7 +2680,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
case GPBDataTypeFixed32:
case GPBDataTypeUInt32:
case GPBDataTypeFloat: {
- _GPBCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits);
+ GPBInternalCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits);
// These are all 32bit, signed/unsigned doesn't matter for equality.
uint32_t *selfValPtr = (uint32_t *)&selfStorage[fieldOffset];
uint32_t *otherValPtr = (uint32_t *)&otherStorage[fieldOffset];
@@ -2649,7 +2695,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
case GPBDataTypeFixed64:
case GPBDataTypeUInt64:
case GPBDataTypeDouble: {
- _GPBCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits);
+ GPBInternalCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits);
// These are all 64bit, signed/unsigned doesn't matter for equality.
uint64_t *selfValPtr = (uint64_t *)&selfStorage[fieldOffset];
uint64_t *otherValPtr = (uint64_t *)&otherStorage[fieldOffset];
@@ -2675,14 +2721,14 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
} // for(fields)
// nil and empty are equal
- if (extensionMap_.count != 0 || other->extensionMap_.count != 0) {
- if (![extensionMap_ isEqual:other->extensionMap_]) {
+ if (extensionMap_.count != 0 || otherMsg->extensionMap_.count != 0) {
+ if (![extensionMap_ isEqual:otherMsg->extensionMap_]) {
return NO;
}
}
// nil and empty are equal
- GPBUnknownFieldSet *otherUnknowns = other->unknownFields_;
+ GPBUnknownFieldSet *otherUnknowns = otherMsg->unknownFields_;
if ([unknownFields_ countOfFields] != 0 ||
[otherUnknowns countOfFields] != 0) {
if (![unknownFields_ isEqual:otherUnknowns]) {
@@ -2731,8 +2777,12 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
size_t fieldOffset = field->description_->offset;
switch (fieldDataType) {
case GPBDataTypeBool: {
- BOOL *valPtr = (BOOL *)&storage[fieldOffset];
- result = prime * result + *valPtr;
+ // Bools are stored in has_bits to avoid needing explicit space in
+ // the storage structure.
+ // (the field number passed to the HasIvar helper doesn't really
+ // matter since the offset is never negative)
+ BOOL value = GPBGetHasIvar(self, (int32_t)(fieldOffset), 0);
+ result = prime * result + value;
break;
}
case GPBDataTypeSFixed32:
@@ -2742,7 +2792,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
case GPBDataTypeFixed32:
case GPBDataTypeUInt32:
case GPBDataTypeFloat: {
- _GPBCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits);
+ GPBInternalCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits);
// These are all 32bit, just mix it in.
uint32_t *valPtr = (uint32_t *)&storage[fieldOffset];
result = prime * result + *valPtr;
@@ -2754,7 +2804,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
case GPBDataTypeFixed64:
case GPBDataTypeUInt64:
case GPBDataTypeDouble: {
- _GPBCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits);
+ GPBInternalCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits);
// These are all 64bit, just mix what fits into an NSUInteger in.
uint64_t *valPtr = (uint64_t *)&storage[fieldOffset];
result = prime * result + (NSUInteger)(*valPtr);
@@ -2801,7 +2851,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
return description;
}
-#if DEBUG
+#if defined(DEBUG) && DEBUG
// Xcode 5.1 added support for custom quick look info.
// https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/CustomClassDisplay_in_QuickLook/CH01-quick_look_for_custom_objects/CH01-quick_look_for_custom_objects.html#//apple_ref/doc/uid/TP40014001-CH2-SW1
@@ -2975,7 +3025,10 @@ typedef struct ResolveIvarAccessorMethodResult {
SEL encodingSelector;
} ResolveIvarAccessorMethodResult;
-static void ResolveIvarGet(GPBFieldDescriptor *field,
+// |field| can be __unsafe_unretained because they are created at startup
+// and are essentially global. No need to pay for retain/release when
+// they are captured in blocks.
+static void ResolveIvarGet(__unsafe_unretained GPBFieldDescriptor *field,
ResolveIvarAccessorMethodResult *result) {
GPBDataType fieldDataType = GPBGetFieldDataType(field);
switch (fieldDataType) {
@@ -3017,7 +3070,8 @@ static void ResolveIvarGet(GPBFieldDescriptor *field,
}
}
-static void ResolveIvarSet(GPBFieldDescriptor *field,
+// See comment about __unsafe_unretained on ResolveIvarGet.
+static void ResolveIvarSet(__unsafe_unretained GPBFieldDescriptor *field,
GPBFileSyntax syntax,
ResolveIvarAccessorMethodResult *result) {
GPBDataType fieldDataType = GPBGetFieldDataType(field);
@@ -3055,15 +3109,16 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
+ (BOOL)resolveInstanceMethod:(SEL)sel {
const GPBDescriptor *descriptor = [self descriptor];
if (!descriptor) {
- return NO;
+ return [super resolveInstanceMethod:sel];
}
// NOTE: hasOrCountSel_/setHasSel_ will be NULL if the field for the given
// message should not have has support (done in GPBDescriptor.m), so there is
// no need for checks here to see if has*/setHas* are allowed.
-
ResolveIvarAccessorMethodResult result = {NULL, NULL};
- for (GPBFieldDescriptor *field in descriptor->fields_) {
+
+ // See comment about __unsafe_unretained on ResolveIvarGet.
+ for (__unsafe_unretained GPBFieldDescriptor *field in descriptor->fields_) {
BOOL isMapOrArray = GPBFieldIsMapOrArray(field);
if (!isMapOrArray) {
// Single fields.
@@ -3096,7 +3151,7 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
} else {
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof && (sel == oneof->caseSel_)) {
- int32_t index = oneof->oneofDescription_->index;
+ int32_t index = GPBFieldHasIndex(field);
result.impToAdd = imp_implementationWithBlock(^(id obj) {
return GPBGetHasOneof(obj, index);
});
@@ -3143,8 +3198,17 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
if (result.impToAdd) {
const char *encoding =
GPBMessageEncodingForSelector(result.encodingSelector, YES);
- BOOL methodAdded = class_addMethod(descriptor.messageClass, sel,
- result.impToAdd, encoding);
+ Class msgClass = descriptor.messageClass;
+ BOOL methodAdded = class_addMethod(msgClass, sel, result.impToAdd, encoding);
+ // class_addMethod() is documented as also failing if the method was already
+ // added; so we check if the method is already there and return success so
+ // the method dispatch will still happen. Why would it already be added?
+ // Two threads could cause the same method to be bound at the same time,
+ // but only one will actually bind it; the other still needs to return true
+ // so things will dispatch.
+ if (!methodAdded) {
+ methodAdded = GPBClassHasSel(msgClass, sel);
+ }
return methodAdded;
}
return [super resolveInstanceMethod:sel];
@@ -3152,7 +3216,7 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
+ (BOOL)resolveClassMethod:(SEL)sel {
// Extensions scoped to a Message and looked up via class methods.
- if (GPBResolveExtensionClassMethod(self, sel)) {
+ if (GPBResolveExtensionClassMethod([self descriptor].messageClass, sel)) {
return YES;
}
return [super resolveClassMethod:sel];
@@ -3191,3 +3255,63 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
}
@end
+
+#pragma mark - Messages from GPBUtilities.h but defined here for access to helpers.
+
+// Only exists for public api, no core code should use this.
+id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ if (field.fieldType != GPBFieldTypeRepeated) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"%@.%@ is not a repeated field.",
+ [self class], field.name];
+ }
+#endif
+ GPBDescriptor *descriptor = [[self class] descriptor];
+ GPBFileSyntax syntax = descriptor.file.syntax;
+ return GetOrCreateArrayIvarWithField(self, field, syntax);
+}
+
+// Only exists for public api, no core code should use this.
+id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ if (field.fieldType != GPBFieldTypeMap) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"%@.%@ is not a map<> field.",
+ [self class], field.name];
+ }
+#endif
+ GPBDescriptor *descriptor = [[self class] descriptor];
+ GPBFileSyntax syntax = descriptor.file.syntax;
+ return GetOrCreateMapIvarWithField(self, field, syntax);
+}
+
+id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
+ NSCAssert(!GPBFieldIsMapOrArray(field), @"Shouldn't get here");
+ if (GPBGetHasIvarField(self, field)) {
+ uint8_t *storage = (uint8_t *)self->messageStorage_;
+ id *typePtr = (id *)&storage[field->description_->offset];
+ return *typePtr;
+ }
+ // Not set...
+
+ // Non messages (string/data), get their default.
+ if (!GPBFieldDataTypeIsMessage(field)) {
+ return field.defaultValue.valueMessage;
+ }
+
+ GPBPrepareReadOnlySemaphore(self);
+ dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
+ GPBMessage *result = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
+ if (!result) {
+ // For non repeated messages, create the object, set it and return it.
+ // This object will not initially be visible via GPBGetHasIvar, so
+ // we save its creator so it can become visible if it's mutated later.
+ result = GPBCreateMessageWithAutocreator(field.msgClass, self, field);
+ GPBSetAutocreatedRetainedObjectIvarWithField(self, field, result);
+ }
+ dispatch_semaphore_signal(self->readOnlySemaphore_);
+ return result;
+}
+
+#pragma clang diagnostic pop
diff --git a/objectivec/GPBMessage_PackagePrivate.h b/objectivec/GPBMessage_PackagePrivate.h
index b7e24fc9..ca10983b 100644
--- a/objectivec/GPBMessage_PackagePrivate.h
+++ b/objectivec/GPBMessage_PackagePrivate.h
@@ -34,6 +34,10 @@
#import "GPBMessage.h"
+// TODO: Remove this import. Older generated code use the OSAtomic* apis,
+// so anyone that hasn't regenerated says building by having this. After
+// enough time has passed, this likely can be removed as folks should have
+// regenerated.
#import <libkern/OSAtomic.h>
#import "GPBBootstrap.h"
@@ -57,27 +61,12 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
// GPBMessage_Storage with _has_storage__ as the first field.
// Kept public because static functions need to access it.
GPBMessage_StoragePtr messageStorage_;
-
- // A lock to provide mutual exclusion from internal data that can be modified
- // by *read* operations such as getters (autocreation of message fields and
- // message extensions, not setting of values). Used to guarantee thread safety
- // for concurrent reads on the message.
- // 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
- dispatch_semaphore_t readOnlySemaphore_;
}
// Gets an extension value without autocreating the result if not found. (i.e.
// returns nil if the extension is not set)
- (id)getExistingExtension:(GPBExtensionDescriptor *)extension;
-// Returns an array of GPBExtensionDescriptor* for all the extensions currently
-// in use on the message. They are sorted by field number.
-- (NSArray *)sortedExtensionsInUse;
-
// Parses a message of this type from the input and merges it with this
// message.
//
@@ -103,6 +92,10 @@ 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,
diff --git a/objectivec/GPBProtocolBuffers.h b/objectivec/GPBProtocolBuffers.h
index 677903ed..68d8854e 100644
--- a/objectivec/GPBProtocolBuffers.h
+++ b/objectivec/GPBProtocolBuffers.h
@@ -44,14 +44,33 @@
#import "GPBWellKnownTypes.h"
#import "GPBWireFormat.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
// Well-known proto types
-#import "google/protobuf/Any.pbobjc.h"
-#import "google/protobuf/Api.pbobjc.h"
-#import "google/protobuf/Duration.pbobjc.h"
-#import "google/protobuf/Empty.pbobjc.h"
-#import "google/protobuf/FieldMask.pbobjc.h"
-#import "google/protobuf/SourceContext.pbobjc.h"
-#import "google/protobuf/Struct.pbobjc.h"
-#import "google/protobuf/Timestamp.pbobjc.h"
-#import "google/protobuf/Type.pbobjc.h"
-#import "google/protobuf/Wrappers.pbobjc.h"
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Any.pbobjc.h>
+ #import <Protobuf/Api.pbobjc.h>
+ #import <Protobuf/Duration.pbobjc.h>
+ #import <Protobuf/Empty.pbobjc.h>
+ #import <Protobuf/FieldMask.pbobjc.h>
+ #import <Protobuf/SourceContext.pbobjc.h>
+ #import <Protobuf/Struct.pbobjc.h>
+ #import <Protobuf/Timestamp.pbobjc.h>
+ #import <Protobuf/Type.pbobjc.h>
+ #import <Protobuf/Wrappers.pbobjc.h>
+#else
+ #import "google/protobuf/Any.pbobjc.h"
+ #import "google/protobuf/Api.pbobjc.h"
+ #import "google/protobuf/Duration.pbobjc.h"
+ #import "google/protobuf/Empty.pbobjc.h"
+ #import "google/protobuf/FieldMask.pbobjc.h"
+ #import "google/protobuf/SourceContext.pbobjc.h"
+ #import "google/protobuf/Struct.pbobjc.h"
+ #import "google/protobuf/Timestamp.pbobjc.h"
+ #import "google/protobuf/Type.pbobjc.h"
+ #import "google/protobuf/Wrappers.pbobjc.h"
+#endif
diff --git a/objectivec/GPBProtocolBuffers.m b/objectivec/GPBProtocolBuffers.m
index e9cbfb42..d04c8be1 100644
--- a/objectivec/GPBProtocolBuffers.m
+++ b/objectivec/GPBProtocolBuffers.m
@@ -31,6 +31,14 @@
// 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
+// much sense, and don't trigger when compiled directly. So we shut off the
+// warnings here.
+#pragma clang diagnostic ignored "-Wnullability-completeness"
+
#import "GPBArray.m"
#import "GPBCodedInputStream.m"
#import "GPBCodedOutputStream.m"
@@ -46,17 +54,13 @@
#import "GPBWellKnownTypes.m"
#import "GPBWireFormat.m"
-#import "google/protobuf/Descriptor.pbobjc.m"
-
-// Duration and Timestamp are #imported into GPBWellKnownTypes.m to the
-// Objective C categories added will always be linked in with the classes.
#import "google/protobuf/Any.pbobjc.m"
#import "google/protobuf/Api.pbobjc.m"
-// #import "google/protobuf/Duration.pbobjc.m"
+#import "google/protobuf/Duration.pbobjc.m"
#import "google/protobuf/Empty.pbobjc.m"
#import "google/protobuf/FieldMask.pbobjc.m"
#import "google/protobuf/SourceContext.pbobjc.m"
#import "google/protobuf/Struct.pbobjc.m"
-// #import "google/protobuf/Timestamp.pbobjc.m"
+#import "google/protobuf/Timestamp.pbobjc.m"
#import "google/protobuf/Type.pbobjc.m"
#import "google/protobuf/Wrappers.pbobjc.m"
diff --git a/objectivec/GPBProtocolBuffers_RuntimeSupport.h b/objectivec/GPBProtocolBuffers_RuntimeSupport.h
index fea75b93..04dde620 100644
--- a/objectivec/GPBProtocolBuffers_RuntimeSupport.h
+++ b/objectivec/GPBProtocolBuffers_RuntimeSupport.h
@@ -31,7 +31,7 @@
// This header is meant to only be used by the generated source, it should not
// be included in code using protocol buffers.
-#import "GPBProtocolBuffers.h"
+#import "GPBBootstrap.h"
#import "GPBDescriptor_PackagePrivate.h"
#import "GPBExtensionInternals.h"
diff --git a/objectivec/GPBRootObject.h b/objectivec/GPBRootObject.h
index e2af5d97..d2e2aebf 100644
--- a/objectivec/GPBRootObject.h
+++ b/objectivec/GPBRootObject.h
@@ -34,11 +34,17 @@
NS_ASSUME_NONNULL_BEGIN
-// All Root Objects derive from GPBRootObject. It supplies a registry
-// for derived classes to register their extensions to.
+/**
+ * Every generated proto file defines a local "Root" class that exposes a
+ * GPBExtensionRegistry for all the extensions defined by that file and
+ * the files it depends on.
+ **/
@interface GPBRootObject : NSObject
-// Per class registry.
+/**
+ * @return An extension registry for the given file and all the files it depends
+ * on.
+ **/
+ (GPBExtensionRegistry *)extensionRegistry;
@end
diff --git a/objectivec/GPBRootObject.m b/objectivec/GPBRootObject.m
index 4570716f..bad2f9a7 100644
--- a/objectivec/GPBRootObject.m
+++ b/objectivec/GPBRootObject.m
@@ -43,6 +43,14 @@
- (const char *)singletonNameC;
@end
+// We need some object to conform to the MessageSignatureProtocol to make sure
+// the selectors in it are recorded in our Objective C runtime information.
+// GPBMessage is arguably the more "obvious" choice, but given that all messages
+// inherit from GPBMessage, conflicts seem likely, so we are using GPBRootObject
+// instead.
+@interface GPBRootObject () <GPBMessageSignatureProtocol>
+@end
+
@implementation GPBRootObject
// Taken from http://www.burtleburtle.net/bob/hash/doobs.html
@@ -184,11 +192,10 @@ static id ExtensionForName(id self, SEL _cmd) {
dispatch_semaphore_wait(gExtensionSingletonDictionarySemaphore,
DISPATCH_TIME_FOREVER);
id extension = (id)CFDictionaryGetValue(gExtensionSingletonDictionary, key);
- if (extension) {
- // The method is getting wired in to the class, so no need to keep it in
- // the dictionary.
- CFDictionaryRemoveValue(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.
dispatch_semaphore_signal(gExtensionSingletonDictionarySemaphore);
return extension;
}
@@ -212,9 +219,17 @@ BOOL GPBResolveExtensionClassMethod(Class self, SEL sel) {
#pragma unused(obj)
return extension;
});
- if (class_addMethod(metaClass, sel, imp, encoding)) {
- return YES;
+ BOOL methodAdded = class_addMethod(metaClass, sel, imp, encoding);
+ // class_addMethod() is documented as also failing if the method was already
+ // added; so we check if the method is already there and return success so
+ // the method dispatch will still happen. Why would it already be added?
+ // Two threads could cause the same method to be bound at the same time,
+ // but only one will actually bind it; the other still needs to return true
+ // so things will dispatch.
+ if (!methodAdded) {
+ methodAdded = GPBClassHasSel(metaClass, sel);
}
+ return methodAdded;
}
return NO;
}
diff --git a/objectivec/GPBRuntimeTypes.h b/objectivec/GPBRuntimeTypes.h
index e91d86a6..4d552060 100644
--- a/objectivec/GPBRuntimeTypes.h
+++ b/objectivec/GPBRuntimeTypes.h
@@ -36,21 +36,28 @@
@class GPBMessage;
@class GPBInt32Array;
-// Function used to verify that a given value can be represented by an
-// enum type.
+/**
+ * Verifies that a given value can be represented by an enum type.
+ * */
typedef BOOL (*GPBEnumValidationFunc)(int32_t);
-// Function used to fetch an EnumDescriptor.
+/**
+ * Fetches an EnumDescriptor.
+ * */
typedef GPBEnumDescriptor *(*GPBEnumDescriptorFunc)(void);
-// Magic values used for when an the at runtime to indicate an enum value
-// that wasn't know at compile time.
+/**
+ * Magic value used at runtime to indicate an enum value that wasn't know at
+ * compile time.
+ * */
enum {
kGPBUnrecognizedEnumeratorValue = (int32_t)0xFBADBEEF,
};
-// A union for storing all possible Protobuf values.
-// Note that owner is responsible for memory management of object types.
+/**
+ * A union for storing all possible Protobuf values. Note that owner is
+ * responsible for memory management of object types.
+ * */
typedef union {
BOOL valueBool;
int32_t valueInt32;
@@ -65,38 +72,73 @@ typedef union {
int32_t valueEnum;
} GPBGenericValue;
-// Do not change the order of this enum (or add things to it) without thinking
-// about it very carefully. There are several things that depend on the order.
-typedef enum {
+/**
+ * Enum listing the possible data types that a field can contain.
+ *
+ * @note Do not change the order of this enum (or add things to it) without
+ * thinking about it very carefully. There are several things that depend
+ * on the order.
+ * */
+typedef NS_ENUM(uint8_t, GPBDataType) {
+ /** Field contains boolean value(s). */
GPBDataTypeBool = 0,
+ /** Field contains unsigned 4 byte value(s). */
GPBDataTypeFixed32,
+ /** Field contains signed 4 byte value(s). */
GPBDataTypeSFixed32,
+ /** Field contains float value(s). */
GPBDataTypeFloat,
+ /** Field contains unsigned 8 byte value(s). */
GPBDataTypeFixed64,
+ /** Field contains signed 8 byte value(s). */
GPBDataTypeSFixed64,
+ /** Field contains double value(s). */
GPBDataTypeDouble,
+ /**
+ * Field contains variable length value(s). Inefficient for encoding negative
+ * numbers – if your field is likely to have negative values, use
+ * GPBDataTypeSInt32 instead.
+ **/
GPBDataTypeInt32,
+ /**
+ * Field contains variable length value(s). Inefficient for encoding negative
+ * numbers – if your field is likely to have negative values, use
+ * GPBDataTypeSInt64 instead.
+ **/
GPBDataTypeInt64,
+ /** Field contains signed variable length integer value(s). */
GPBDataTypeSInt32,
+ /** Field contains signed variable length integer value(s). */
GPBDataTypeSInt64,
+ /** Field contains unsigned variable length integer value(s). */
GPBDataTypeUInt32,
+ /** Field contains unsigned variable length integer value(s). */
GPBDataTypeUInt64,
+ /** Field contains an arbitrary sequence of bytes. */
GPBDataTypeBytes,
+ /** Field contains UTF-8 encoded or 7-bit ASCII text. */
GPBDataTypeString,
+ /** Field contains message type(s). */
GPBDataTypeMessage,
+ /** Field contains message type(s). */
GPBDataTypeGroup,
+ /** Field contains enum value(s). */
GPBDataTypeEnum,
-} GPBDataType;
+};
enum {
- // A count of the number of types in GPBDataType. Separated out from the
- // GPBDataType enum to avoid warnings regarding not handling
- // GPBDataType_Count in switch statements.
+ /**
+ * A count of the number of types in GPBDataType. Separated out from the
+ * GPBDataType enum to avoid warnings regarding not handling GPBDataType_Count
+ * in switch statements.
+ **/
GPBDataType_Count = GPBDataTypeEnum + 1
};
-// An extension range.
+/** An extension range. */
typedef struct GPBExtensionRange {
- uint32_t start; // inclusive
- uint32_t end; // exclusive
+ /** Inclusive. */
+ uint32_t start;
+ /** Exclusive. */
+ uint32_t end;
} GPBExtensionRange;
diff --git a/objectivec/GPBUnknownField.h b/objectivec/GPBUnknownField.h
index 12d72a9a..5b96023b 100644
--- a/objectivec/GPBUnknownField.h
+++ b/objectivec/GPBUnknownField.h
@@ -36,23 +36,62 @@
@class GPBUnknownFieldSet;
NS_ASSUME_NONNULL_BEGIN
-
+/**
+ * Store an unknown field. These are used in conjunction with
+ * GPBUnknownFieldSet.
+ **/
@interface GPBUnknownField : NSObject<NSCopying>
+/** Initialize a field with the given number. */
+- (instancetype)initWithNumber:(int32_t)number;
+
+/** The field number the data is stored under. */
@property(nonatomic, readonly, assign) int32_t number;
-// Only one of these will be set.
+/** An array of varint values for this field. */
@property(nonatomic, readonly, strong) GPBUInt64Array *varintList;
+
+/** An array of fixed32 values for this field. */
@property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List;
+
+/** An array of fixed64 values for this field. */
@property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List;
-@property(nonatomic, readonly, strong) NSArray *lengthDelimitedList; // NSData
-@property(nonatomic, readonly, strong) NSArray *groupList; // GPBUnknownFieldSet
-// Only one of these should be used per Field.
+/** An array of data values for this field. */
+@property(nonatomic, readonly, strong) NSArray<NSData*> *lengthDelimitedList;
+
+/** An array of groups of values for this field. */
+@property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet*> *groupList;
+
+/**
+ * Add a value to the varintList.
+ *
+ * @param value The value to add.
+ **/
- (void)addVarint:(uint64_t)value;
+/**
+ * Add a value to the fixed32List.
+ *
+ * @param value The value to add.
+ **/
- (void)addFixed32:(uint32_t)value;
+/**
+ * Add a value to the fixed64List.
+ *
+ * @param value The value to add.
+ **/
- (void)addFixed64:(uint64_t)value;
+/**
+ * Add a value to the lengthDelimitedList.
+ *
+ * @param value The value to add.
+ **/
- (void)addLengthDelimited:(NSData *)value;
+/**
+ * Add a value to the groupList.
+ *
+ * @param value The value to add.
+ **/
- (void)addGroup:(GPBUnknownFieldSet *)value;
@end
diff --git a/objectivec/GPBUnknownField.m b/objectivec/GPBUnknownField.m
index c49c0dfc..9d5c97f3 100644
--- a/objectivec/GPBUnknownField.m
+++ b/objectivec/GPBUnknownField.m
@@ -31,7 +31,7 @@
#import "GPBUnknownField_PackagePrivate.h"
#import "GPBArray.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
@implementation GPBUnknownField {
@protected
@@ -39,8 +39,8 @@
GPBUInt64Array *mutableVarintList_;
GPBUInt32Array *mutableFixed32List_;
GPBUInt64Array *mutableFixed64List_;
- NSMutableArray *mutableLengthDelimitedList_;
- NSMutableArray *mutableGroupList_;
+ NSMutableArray<NSData*> *mutableLengthDelimitedList_;
+ NSMutableArray<GPBUnknownFieldSet*> *mutableGroupList_;
}
@synthesize number = number_;
@@ -67,13 +67,19 @@
[super dealloc];
}
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
- (id)copyWithZone:(NSZone *)zone {
GPBUnknownField *result =
[[GPBUnknownField allocWithZone:zone] initWithNumber:number_];
result->mutableFixed32List_ = [mutableFixed32List_ copyWithZone:zone];
result->mutableFixed64List_ = [mutableFixed64List_ copyWithZone:zone];
result->mutableLengthDelimitedList_ =
- [mutableLengthDelimitedList_ copyWithZone:zone];
+ [mutableLengthDelimitedList_ mutableCopyWithZone:zone];
result->mutableVarintList_ = [mutableVarintList_ copyWithZone:zone];
if (mutableGroupList_.count) {
result->mutableGroupList_ = [[NSMutableArray allocWithZone:zone]
@@ -91,6 +97,7 @@
if (self == object) return YES;
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_];
@@ -196,8 +203,9 @@
}
- (NSString *)description {
- NSMutableString *description = [NSMutableString
- stringWithFormat:@"<%@ %p>: Field: %d {\n", [self class], self, number_];
+ NSMutableString *description =
+ [NSMutableString stringWithFormat:@"<%@ %p>: Field: %d {\n",
+ [self class], self, number_];
[mutableVarintList_
enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
@@ -323,4 +331,6 @@
}
}
+#pragma clang diagnostic pop
+
@end
diff --git a/objectivec/GPBUnknownFieldSet.h b/objectivec/GPBUnknownFieldSet.h
index d785ca16..1b5f24f3 100644
--- a/objectivec/GPBUnknownFieldSet.h
+++ b/objectivec/GPBUnknownFieldSet.h
@@ -34,16 +34,48 @@
NS_ASSUME_NONNULL_BEGIN
+/**
+ * A collection of unknown fields. Fields parsed from the binary representation
+ * of a message that are unknown end up in an instance of this set. This only
+ * applies for files declared with the "proto2" syntax. Files declared with the
+ * "proto3" syntax discard the unknown values.
+ **/
@interface GPBUnknownFieldSet : NSObject<NSCopying>
+/**
+ * Tests to see if the given field number has a value.
+ *
+ * @param number The field number to check.
+ *
+ * @return YES if there is an unknown field for the given field number.
+ **/
- (BOOL)hasField:(int32_t)number;
+
+/**
+ * Fetches the GPBUnknownField for the given field number.
+ *
+ * @param number The field number to look up.
+ *
+ * @return The GPBUnknownField or nil if none found.
+ **/
- (nullable GPBUnknownField *)getField:(int32_t)number;
+
+/**
+ * @return The number of fields in this set.
+ **/
- (NSUInteger)countOfFields;
+/**
+ * Adds the given field to the set.
+ *
+ * @param field The field to add to the set.
+ **/
- (void)addField:(GPBUnknownField *)field;
-// Returns an NSArray of the GPBFields sorted by the field numbers.
-- (NSArray *)sortedFields;
+/**
+ * @return An array of the GPBUnknownFields sorted by the field numbers.
+ **/
+- (NSArray<GPBUnknownField *> *)sortedFields;
@end
diff --git a/objectivec/GPBUnknownFieldSet.m b/objectivec/GPBUnknownFieldSet.m
index 4ddc0d2a..a7335f05 100644
--- a/objectivec/GPBUnknownFieldSet.m
+++ b/objectivec/GPBUnknownFieldSet.m
@@ -36,39 +36,6 @@
#import "GPBUtilities.h"
#import "GPBWireFormat.h"
-#pragma mark CFDictionaryKeyCallBacks
-
-// We use a custom dictionary here because our keys are numbers and
-// conversion back and forth from NSNumber was costing us performance.
-// If/when we move to C++ this could be done using a std::map and some
-// careful retain/release calls.
-
-static const void *GPBUnknownFieldSetKeyRetain(CFAllocatorRef allocator,
- const void *value) {
-#pragma unused(allocator)
- return value;
-}
-
-static void GPBUnknownFieldSetKeyRelease(CFAllocatorRef allocator,
- const void *value) {
-#pragma unused(allocator)
-#pragma unused(value)
-}
-
-static CFStringRef GPBUnknownFieldSetCopyKeyDescription(const void *value) {
- return CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%d"),
- (int)value);
-}
-
-static Boolean GPBUnknownFieldSetKeyEqual(const void *value1,
- const void *value2) {
- return value1 == value2;
-}
-
-static CFHashCode GPBUnknownFieldSetKeyHash(const void *value) {
- return (CFHashCode)value;
-}
-
#pragma mark Helpers
static void checkNumber(int32_t number) {
@@ -93,6 +60,12 @@ static void CopyWorker(const void *key, const void *value, void *context) {
[copied release];
}
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
- (id)copyWithZone:(NSZone *)zone {
GPBUnknownFieldSet *result = [[GPBUnknownFieldSet allocWithZone:zone] init];
if (fields_) {
@@ -148,7 +121,7 @@ static void CopyWorker(const void *key, const void *value, void *context) {
}
- (NSArray *)sortedFields {
- if (!fields_) return nil;
+ if (!fields_) return [NSArray array];
size_t count = CFDictionaryGetCount(fields_);
ssize_t keys[count];
GPBUnknownField *values[count];
@@ -285,13 +258,9 @@ static void GPBUnknownFieldSetSerializedSizeAsMessageSet(const void *key,
int32_t number = [field number];
checkNumber(number);
if (!fields_) {
- CFDictionaryKeyCallBacks keyCallBacks = {
- // See description above for reason for using custom dictionary.
- 0, GPBUnknownFieldSetKeyRetain, GPBUnknownFieldSetKeyRelease,
- GPBUnknownFieldSetCopyKeyDescription, GPBUnknownFieldSetKeyEqual,
- GPBUnknownFieldSetKeyHash,
- };
- fields_ = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallBacks,
+ // 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);
}
ssize_t key = number;
@@ -353,6 +322,7 @@ static void GPBUnknownFieldSetMergeUnknownFields(const void *key,
}
- (BOOL)mergeFieldFrom:(int32_t)tag input:(GPBCodedInputStream *)input {
+ NSAssert(GPBWireFormatIsValidTag(tag), @"Got passed an invalid tag");
int32_t number = GPBWireFormatGetTagFieldNumber(tag);
GPBCodedInputStreamState *state = &input->state_;
switch (GPBWireFormatGetTagWireType(tag)) {
@@ -420,4 +390,6 @@ static void GPBUnknownFieldSetMergeUnknownFields(const void *key,
}
}
+#pragma clang diagnostic pop
+
@end
diff --git a/objectivec/GPBUnknownField_PackagePrivate.h b/objectivec/GPBUnknownField_PackagePrivate.h
index 1fbce0f9..2b4c7895 100644
--- a/objectivec/GPBUnknownField_PackagePrivate.h
+++ b/objectivec/GPBUnknownField_PackagePrivate.h
@@ -36,8 +36,6 @@
@interface GPBUnknownField ()
-- (instancetype)initWithNumber:(int32_t)number;
-
- (void)writeToOutput:(GPBCodedOutputStream *)output;
- (size_t)serializedSize;
diff --git a/objectivec/GPBUtilities.h b/objectivec/GPBUtilities.h
index 5b55104b..5464dfb3 100644
--- a/objectivec/GPBUtilities.h
+++ b/objectivec/GPBUtilities.h
@@ -38,24 +38,58 @@ CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
-// Generates a string that should be a valid "Text Format" for the C++ version
-// of Protocol Buffers. lineIndent can be nil if no additional line indent is
-// needed. The comments provide the names according to the ObjC library, they
-// most likely won't exactly match the original .proto file.
+/**
+ * Generates a string that should be a valid "TextFormat" for the C++ version
+ * of Protocol Buffers.
+ *
+ * @param message The message to generate from.
+ * @param lineIndent A string to use as the prefix for all lines generated. Can
+ * be nil if no extra indent is needed.
+ *
+ * @return An NSString with the TextFormat of the message.
+ **/
NSString *GPBTextFormatForMessage(GPBMessage *message,
NSString * __nullable lineIndent);
+
+/**
+ * Generates a string that should be a valid "TextFormat" for the C++ version
+ * of Protocol Buffers.
+ *
+ * @param unknownSet The unknown field set to generate from.
+ * @param lineIndent A string to use as the prefix for all lines generated. Can
+ * be nil if no extra indent is needed.
+ *
+ * @return An NSString with the TextFormat of the unknown field set.
+ **/
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet,
NSString * __nullable lineIndent);
-//
-// Test if the given field is set on a message.
-//
+/**
+ * Checks if the given field number is set on a message.
+ *
+ * @param self The message to check.
+ * @param fieldNumber The field number to check.
+ *
+ * @return YES if the field number is set on the given message.
+ **/
BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber);
+
+/**
+ * Checks if the given field is set on a message.
+ *
+ * @param self The message to check.
+ * @param field The field to check.
+ *
+ * @return YES if the field is set on the given message.
+ **/
BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field);
-//
-// Clear the given field of a message.
-//
+/**
+ * Clears the given field for the given message.
+ *
+ * @param self The message for which to clear the field.
+ * @param field The field to clear.
+ **/
void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field);
//%PDDM-EXPAND GPB_ACCESSORS()
@@ -63,74 +97,306 @@ void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field);
//
-// Get/Set the given field of a message.
+// Get/Set a given field from/to a message.
//
// Single Fields
+/**
+ * Gets the value of a bytes field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
NSData *GPBGetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of a bytes field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field, NSData *value);
+/**
+ * Gets the value of a string field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
NSString *GPBGetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of a string field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field, NSString *value);
+/**
+ * Gets the value of a message field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
GPBMessage *GPBGetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of a message field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
+/**
+ * Gets the value of a group field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
GPBMessage *GPBGetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of a group field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
+/**
+ * Gets the value of a bool field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of a bool field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field, BOOL value);
+/**
+ * Gets the value of an int32 field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
int32_t GPBGetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of an int32 field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
+/**
+ * Gets the value of an uint32 field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
uint32_t GPBGetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of an uint32 field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field, uint32_t value);
+/**
+ * Gets the value of an int64 field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
int64_t GPBGetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of an int64 field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field, int64_t value);
+/**
+ * Gets the value of an uint64 field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
uint64_t GPBGetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of an uint64 field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field, uint64_t value);
+/**
+ * Gets the value of a float field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
float GPBGetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of a float field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field, float value);
+/**
+ * Gets the value of a double field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ **/
double GPBGetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field);
+
+/**
+ * Sets the value of a double field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The to set in the field.
+ **/
void GPBSetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field, double value);
-// Get/Set the given enum field of a message. You can only Set values that are
-// members of the enum. For proto3, when doing a Get, if the value isn't a
-// memeber of the enum, kGPBUnrecognizedEnumeratorValue will be returned. The
-// the functions with "Raw" in the will bypass all checks.
+/**
+ * Gets the given enum field of a message. For proto3, if the value isn't a
+ * member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned.
+ * GPBGetMessageRawEnumField will bypass the check and return whatever value
+ * was set.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ *
+ * @return The enum value for the given field.
+ **/
int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
-void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
+
+/**
+ * Set the given enum field of a message. You can only set values that are
+ * members of the enum.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The enum value to set in the field.
+ **/
+void GPBSetMessageEnumField(GPBMessage *self,
+ GPBFieldDescriptor *field,
+ int32_t value);
+
+/**
+ * Get the given enum field of a message. No check is done to ensure the value
+ * was defined in the enum.
+ *
+ * @param self The message from which to get the field.
+ * @param field The field to get.
+ *
+ * @return The raw enum value for the given field.
+ **/
int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
-void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
+
+/**
+ * Set the given enum field of a message. You can set the value to anything,
+ * even a value that is not a member of the enum.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param value The raw enum value to set in the field.
+ **/
+void GPBSetMessageRawEnumField(GPBMessage *self,
+ GPBFieldDescriptor *field,
+ int32_t value);
// Repeated Fields
-// The object will/should be GPB*Array or NSMutableArray based on the field's
-// type.
+/**
+ * Gets the value of a repeated field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The repeated field to get.
+ *
+ * @return A GPB*Array or an NSMutableArray based on the field's type.
+ **/
id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
-void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array);
+
+/**
+ * Sets the value of a repeated field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param array A GPB*Array or NSMutableArray based on the field's type.
+ **/
+void GPBSetMessageRepeatedField(GPBMessage *self,
+ GPBFieldDescriptor *field,
+ id array);
// Map Fields
-// The object will/should be GPB*Dictionary or NSMutableDictionary based on the
-// field's type.
+/**
+ * Gets the value of a map<> field.
+ *
+ * @param self The message from which to get the field.
+ * @param field The repeated field to get.
+ *
+ * @return A GPB*Dictionary or NSMutableDictionary based on the field's type.
+ **/
id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
-void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary);
+
+/**
+ * Sets the value of a map<> field.
+ *
+ * @param self The message into which to set the field.
+ * @param field The field to set.
+ * @param dictionary A GPB*Dictionary or NSMutableDictionary based on the
+ * field's type.
+ **/
+void GPBSetMessageMapField(GPBMessage *self,
+ GPBFieldDescriptor *field,
+ id dictionary);
//%PDDM-EXPAND-END GPB_ACCESSORS()
-// Returns an empty NSData to assign to byte fields when you wish
-// to assign them to empty. Prevents allocating a lot of little [NSData data]
-// objects.
+/**
+ * Returns an empty NSData to assign to byte fields when you wish to assign them
+ * to empty. Prevents allocating a lot of little [NSData data] objects.
+ **/
NSData *GPBEmptyNSData(void) __attribute__((pure));
+/**
+ * Drops the `unknownFields` from the given message and from all sub message.
+ **/
+void GPBMessageDropUnknownFieldsRecursively(GPBMessage *message);
+
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
@@ -139,49 +405,135 @@ CF_EXTERN_C_END
//%PDDM-DEFINE GPB_ACCESSORS()
//%
//%//
-//%// Get/Set the given field of a message.
+//%// Get/Set a given field from/to a message.
//%//
//%
//%// Single Fields
//%
-//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, *)
-//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, *)
-//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, *)
-//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, *)
-//%GPB_ACCESSOR_SINGLE(Bool, BOOL)
-//%GPB_ACCESSOR_SINGLE(Int32, int32_t)
-//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t)
-//%GPB_ACCESSOR_SINGLE(Int64, int64_t)
-//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t)
-//%GPB_ACCESSOR_SINGLE(Float, float)
-//%GPB_ACCESSOR_SINGLE(Double, double)
-//%// Get/Set the given enum field of a message. You can only Set values that are
-//%// members of the enum. For proto3, when doing a Get, if the value isn't a
-//%// memeber of the enum, kGPBUnrecognizedEnumeratorValue will be returned. The
-//%// the functions with "Raw" in the will bypass all checks.
+//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, , *)
+//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, , *)
+//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, , *)
+//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, , *)
+//%GPB_ACCESSOR_SINGLE(Bool, BOOL, )
+//%GPB_ACCESSOR_SINGLE(Int32, int32_t, n)
+//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t, n)
+//%GPB_ACCESSOR_SINGLE(Int64, int64_t, n)
+//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t, n)
+//%GPB_ACCESSOR_SINGLE(Float, float, )
+//%GPB_ACCESSOR_SINGLE(Double, double, )
+//%/**
+//% * Gets the given enum field of a message. For proto3, if the value isn't a
+//% * member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned.
+//% * GPBGetMessageRawEnumField will bypass the check and return whatever value
+//% * was set.
+//% *
+//% * @param self The message from which to get the field.
+//% * @param field The field to get.
+//% *
+//% * @return The enum value for the given field.
+//% **/
//%int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
-//%void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
+//%
+//%/**
+//% * Set the given enum field of a message. You can only set values that are
+//% * members of the enum.
+//% *
+//% * @param self The message into which to set the field.
+//% * @param field The field to set.
+//% * @param value The enum value to set in the field.
+//% **/
+//%void GPBSetMessageEnumField(GPBMessage *self,
+//% GPBFieldDescriptor *field,
+//% int32_t value);
+//%
+//%/**
+//% * Get the given enum field of a message. No check is done to ensure the value
+//% * was defined in the enum.
+//% *
+//% * @param self The message from which to get the field.
+//% * @param field The field to get.
+//% *
+//% * @return The raw enum value for the given field.
+//% **/
//%int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
-//%void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
+//%
+//%/**
+//% * Set the given enum field of a message. You can set the value to anything,
+//% * even a value that is not a member of the enum.
+//% *
+//% * @param self The message into which to set the field.
+//% * @param field The field to set.
+//% * @param value The raw enum value to set in the field.
+//% **/
+//%void GPBSetMessageRawEnumField(GPBMessage *self,
+//% GPBFieldDescriptor *field,
+//% int32_t value);
//%
//%// Repeated Fields
//%
-//%// The object will/should be GPB*Array or NSMutableArray based on the field's
-//%// type.
+//%/**
+//% * Gets the value of a repeated field.
+//% *
+//% * @param self The message from which to get the field.
+//% * @param field The repeated field to get.
+//% *
+//% * @return A GPB*Array or an NSMutableArray based on the field's type.
+//% **/
//%id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
-//%void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array);
+//%
+//%/**
+//% * Sets the value of a repeated field.
+//% *
+//% * @param self The message into which to set the field.
+//% * @param field The field to set.
+//% * @param array A GPB*Array or NSMutableArray based on the field's type.
+//% **/
+//%void GPBSetMessageRepeatedField(GPBMessage *self,
+//% GPBFieldDescriptor *field,
+//% id array);
//%
//%// Map Fields
//%
-//%// The object will/should be GPB*Dictionary or NSMutableDictionary based on the
-//%// field's type.
+//%/**
+//% * Gets the value of a map<> field.
+//% *
+//% * @param self The message from which to get the field.
+//% * @param field The repeated field to get.
+//% *
+//% * @return A GPB*Dictionary or NSMutableDictionary based on the field's type.
+//% **/
//%id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
-//%void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary);
+//%
+//%/**
+//% * Sets the value of a map<> field.
+//% *
+//% * @param self The message into which to set the field.
+//% * @param field The field to set.
+//% * @param dictionary A GPB*Dictionary or NSMutableDictionary based on the
+//% * field's type.
+//% **/
+//%void GPBSetMessageMapField(GPBMessage *self,
+//% GPBFieldDescriptor *field,
+//% id dictionary);
//%
-//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE)
-//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, )
-//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, TisP)
+//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE, AN)
+//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, )
+//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, TisP)
+//%/**
+//% * Gets the value of a##AN NAME$L field.
+//% *
+//% * @param self The message from which to get the field.
+//% * @param field The field to get.
+//% **/
//%TYPE TisP##GPBGetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field);
+//%
+//%/**
+//% * Sets the value of a##AN NAME$L field.
+//% *
+//% * @param self The message into which to set the field.
+//% * @param field The field to set.
+//% * @param value The to set in the field.
+//% **/
//%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value);
//%
diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m
index d4d6471f..e2a12ca4 100644
--- a/objectivec/GPBUtilities.m
+++ b/objectivec/GPBUtilities.m
@@ -39,10 +39,29 @@
#import "GPBUnknownField.h"
#import "GPBUnknownFieldSet.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
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
static void AppendTextFormatForMessage(GPBMessage *message,
NSMutableString *toStr,
NSString *lineIndent);
+// Are two datatypes the same basic type representation (ex Int32 and SInt32).
+// Marked unused because currently only called from asserts/debug.
+static BOOL DataTypesEquivalent(GPBDataType type1,
+ GPBDataType type2) __attribute__ ((unused));
+
+// Basic type representation for a type (ex: for SInt32 it is Int32).
+// Marked unused because currently only called from asserts/debug.
+static GPBDataType BaseDataType(GPBDataType type) __attribute__ ((unused));
+
+// String name for a data type.
+// Marked unused because currently only called from asserts/debug.
+static NSString *TypeToString(GPBDataType dataType) __attribute__ ((unused));
+
NSData *GPBEmptyNSData(void) {
static dispatch_once_t onceToken;
static NSData *defaultNSData = nil;
@@ -52,8 +71,169 @@ NSData *GPBEmptyNSData(void) {
return defaultNSData;
}
+void GPBMessageDropUnknownFieldsRecursively(GPBMessage *initialMessage) {
+ if (!initialMessage) {
+ return;
+ }
+
+ // Use an array as a list to process to avoid recursion.
+ NSMutableArray *todo = [NSMutableArray arrayWithObject:initialMessage];
+
+ while (todo.count) {
+ GPBMessage *msg = todo.lastObject;
+ [todo removeLastObject];
+
+ // Clear unknowns.
+ msg.unknownFields = nil;
+
+ // Handle the message fields.
+ GPBDescriptor *descriptor = [[msg class] descriptor];
+ for (GPBFieldDescriptor *field in descriptor->fields_) {
+ if (!GPBFieldDataTypeIsMessage(field)) {
+ continue;
+ }
+ switch (field.fieldType) {
+ case GPBFieldTypeSingle:
+ if (GPBGetHasIvarField(msg, field)) {
+ GPBMessage *fieldMessage = GPBGetObjectIvarWithFieldNoAutocreate(msg, field);
+ [todo addObject:fieldMessage];
+ }
+ break;
+
+ case GPBFieldTypeRepeated: {
+ NSArray *fieldMessages = GPBGetObjectIvarWithFieldNoAutocreate(msg, field);
+ if (fieldMessages.count) {
+ [todo addObjectsFromArray:fieldMessages];
+ }
+ break;
+ }
+
+ case GPBFieldTypeMap: {
+ id rawFieldMap = GPBGetObjectIvarWithFieldNoAutocreate(msg, field);
+ switch (field.mapKeyDataType) {
+ case GPBDataTypeBool:
+ [(GPBBoolObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ BOOL key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeFixed32:
+ case GPBDataTypeUInt32:
+ [(GPBUInt32ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ uint32_t key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeInt32:
+ case GPBDataTypeSFixed32:
+ case GPBDataTypeSInt32:
+ [(GPBInt32ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ int32_t key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeFixed64:
+ case GPBDataTypeUInt64:
+ [(GPBUInt64ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ uint64_t key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeInt64:
+ case GPBDataTypeSFixed64:
+ case GPBDataTypeSInt64:
+ [(GPBInt64ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ int64_t key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeString:
+ [(NSDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ NSString * _Nonnull key, GPBMessage * _Nonnull obj, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:obj];
+ }];
+ break;
+ case GPBDataTypeFloat:
+ case GPBDataTypeDouble:
+ case GPBDataTypeEnum:
+ case GPBDataTypeBytes:
+ case GPBDataTypeGroup:
+ case GPBDataTypeMessage:
+ NSCAssert(NO, @"Aren't valid key types.");
+ }
+ break;
+ } // switch(field.mapKeyDataType)
+ } // switch(field.fieldType)
+ } // for(fields)
+
+ // Handle any extensions holding messages.
+ for (GPBExtensionDescriptor *extension in [msg extensionsCurrentlySet]) {
+ if (!GPBDataTypeIsMessage(extension.dataType)) {
+ continue;
+ }
+ if (extension.isRepeated) {
+ NSArray *extMessages = [msg getExtension:extension];
+ [todo addObjectsFromArray:extMessages];
+ } else {
+ GPBMessage *extMessage = [msg getExtension:extension];
+ [todo addObject:extMessage];
+ }
+ } // for(extensionsCurrentlySet)
+
+ } // while(todo.count)
+}
+
+
+// -- About Version Checks --
+// There's actually 3 places these checks all come into play:
+// 1. When the generated source is compile into .o files, the header check
+// happens. This is checking the protoc used matches the library being used
+// when making the .o.
+// 2. Every place a generated proto header is included in a developer's code,
+// the header check comes into play again. But this time it is checking that
+// the current library headers being used still support/match the ones for
+// the generated code.
+// 3. At runtime the final check here (GPBCheckRuntimeVersionsInternal), is
+// called from the generated code passing in values captured when the
+// generated code's .o was made. This checks that at runtime the generated
+// code and runtime library match.
+
+void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion) {
+ // NOTE: This is passing the value captured in the compiled code to check
+ // against the values captured when the runtime support was compiled. This
+ // ensures the library code isn't in a different framework/library that
+ // was generated with a non matching version.
+ if (GOOGLE_PROTOBUF_OBJC_VERSION < objcRuntimeVersion) {
+ // Library is too old for headers.
+ [NSException raise:NSInternalInconsistencyException
+ format:@"Linked to ProtocolBuffer runtime version %d,"
+ @" but code compiled needing atleast %d!",
+ GOOGLE_PROTOBUF_OBJC_VERSION, objcRuntimeVersion];
+ }
+ if (objcRuntimeVersion < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION) {
+ // Headers are too old for library.
+ [NSException raise:NSInternalInconsistencyException
+ format:@"Proto generation source compiled against runtime"
+ @" version %d, but this version of the runtime only"
+ @" supports back to %d!",
+ objcRuntimeVersion,
+ GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION];
+ }
+}
+
+// This api is no longer used for version checks. 30001 is the last version
+// using this old versioning model. When that support is removed, this function
+// can be removed (along with the declaration in GPBUtilities_PackagePrivate.h).
void GPBCheckRuntimeVersionInternal(int32_t version) {
- if (version != GOOGLE_PROTOBUF_OBJC_GEN_VERSION) {
+ GPBInternalCompileAssert(GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION == 30001,
+ time_to_remove_this_old_version_shim);
+ if (version != GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION) {
[NSException raise:NSInternalInconsistencyException
format:@"Linked to ProtocolBuffer runtime version %d,"
@" but code compiled with version %d!",
@@ -111,7 +291,7 @@ BOOL GPBGetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber) {
} else {
NSCAssert(idx != GPBNoHasBit, @"Invalid has bit.");
uint32_t byteIndex = idx / 32;
- uint32_t bitMask = (1 << (idx % 32));
+ uint32_t bitMask = (1U << (idx % 32));
BOOL hasIvar =
(self->messageStorage_->_has_storage_[byteIndex] & bitMask) ? YES : NO;
return hasIvar;
@@ -135,7 +315,7 @@ void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber,
NSCAssert(idx != GPBNoHasBit, @"Invalid has bit.");
uint32_t *has_storage = self->messageStorage_->_has_storage_;
uint32_t byte = idx / 32;
- uint32_t bitMask = (1 << (idx % 32));
+ uint32_t bitMask = (1U << (idx % 32));
if (value) {
has_storage[byte] |= bitMask;
} else {
@@ -145,9 +325,8 @@ void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber,
}
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
- uint32_t fieldNumberNotToClear) {
- int32_t hasIndex = oneof->oneofDescription_->index;
- uint32_t fieldNumberSet = GPBGetHasOneof(self, hasIndex);
+ int32_t oneofHasIndex, uint32_t fieldNumberNotToClear) {
+ uint32_t fieldNumberSet = GPBGetHasOneof(self, oneofHasIndex);
if ((fieldNumberSet == fieldNumberNotToClear) || (fieldNumberSet == 0)) {
// Do nothing/nothing set in the oneof.
return;
@@ -168,7 +347,7 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
// Set to nothing stored in the oneof.
// (field number doesn't matter since setting to nothing).
- GPBSetHasIvar(self, hasIndex, 1, NO);
+ GPBSetHasIvar(self, oneofHasIndex, 1, NO);
}
#pragma mark - IVar accessors
@@ -176,6 +355,14 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
//%PDDM-DEFINE IVAR_POD_ACCESSORS_DEFN(NAME, TYPE)
//%TYPE GPBGetMessage##NAME##Field(GPBMessage *self,
//% TYPE$S NAME$S GPBFieldDescriptor *field) {
+//%#if defined(DEBUG) && DEBUG
+//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+//% GPBDataType##NAME),
+//% @"Attempting to get value of TYPE from field %@ "
+//% @"of %@ which is of type %@.",
+//% [self class], field.name,
+//% TypeToString(GPBGetFieldDataType(field)));
+//%#endif
//% if (GPBGetHasIvarField(self, field)) {
//% uint8_t *storage = (uint8_t *)self->messageStorage_;
//% TYPE *typePtr = (TYPE *)&storage[field->description_->offset];
@@ -198,13 +385,24 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
//% NAME$S GPBFieldDescriptor *field,
//% NAME$S TYPE value,
//% NAME$S GPBFileSyntax syntax) {
+//%#if defined(DEBUG) && DEBUG
+//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+//% GPBDataType##NAME),
+//% @"Attempting to set field %@ of %@ which is of type %@ with "
+//% @"value of type TYPE.",
+//% [self class], field.name,
+//% TypeToString(GPBGetFieldDataType(field)));
+//%#endif
//% GPBOneofDescriptor *oneof = field->containingOneof_;
//% if (oneof) {
-//% GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field));
+//% GPBMessageFieldDescription *fieldDesc = field->description_;
+//% GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
//% }
+//%#if defined(DEBUG) && DEBUG
//% NSCAssert(self->messageStorage_ != NULL,
//% @"%@: All messages should have storage (from init)",
//% [self class]);
+//%#endif
//%#if defined(__clang_analyzer__)
//% if (self->messageStorage_ == NULL) return;
//%#endif
@@ -212,9 +410,10 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
//% TYPE *typePtr = (TYPE *)&storage[field->description_->offset];
//% *typePtr = value;
//% // proto2: any value counts as having been set; proto3, it
-//% // has to be a non zero value.
-//% BOOL hasValue =
-//% (syntax == GPBFileSyntaxProto2) || (value != (TYPE)0);
+//% // has to be a non zero value or be in a oneof.
+//% BOOL hasValue = ((syntax == GPBFileSyntaxProto2)
+//% || (value != (TYPE)0)
+//% || (field->containingOneof_ != NULL));
//% GPBSetHasIvarField(self, field, hasValue);
//% GPBBecomeVisibleToAutocreator(self);
//%}
@@ -223,6 +422,14 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
//%// Only exists for public api, no core code should use this.
//%TYPE *GPBGetMessage##NAME##Field(GPBMessage *self,
//% TYPE$S NAME$S GPBFieldDescriptor *field) {
+//%#if defined(DEBUG) && DEBUG
+//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+//% GPBDataType##NAME),
+//% @"Attempting to get value of TYPE from field %@ "
+//% @"of %@ which is of type %@.",
+//% [self class], field.name,
+//% TypeToString(GPBGetFieldDataType(field)));
+//%#endif
//% return (TYPE *)GPBGetObjectIvarWithField(self, field);
//%}
//%
@@ -230,6 +437,14 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
//%void GPBSetMessage##NAME##Field(GPBMessage *self,
//% NAME$S GPBFieldDescriptor *field,
//% NAME$S TYPE *value) {
+//%#if defined(DEBUG) && DEBUG
+//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+//% GPBDataType##NAME),
+//% @"Attempting to set field %@ of %@ which is of type %@ with "
+//% @"value of type TYPE.",
+//% [self class], field.name,
+//% TypeToString(GPBGetFieldDataType(field)));
+//%#endif
//% GPBSetObjectIvarWithField(self, field, (id)value);
//%}
//%
@@ -287,7 +502,7 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
GPBDataType fieldType = GPBGetFieldDataType(field);
BOOL isMapOrArray = GPBFieldIsMapOrArray(field);
BOOL fieldIsMessage = GPBDataTypeIsMessage(fieldType);
-#ifdef DEBUG
+#if defined(DEBUG) && DEBUG
if (value == nil && !isMapOrArray && !fieldIsMessage &&
field.hasDefaultValue) {
// Setting a message to nil is an obvious way to "clear" the value
@@ -321,7 +536,8 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
// oneof.
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
- GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field));
+ GPBMessageFieldDescription *fieldDesc = field->description_;
+ GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
// Clear "has" if they are being set to nil.
BOOL setHasValue = (value != nil);
@@ -330,8 +546,19 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
// zero, they are being cleared.
if ((syntax == GPBFileSyntaxProto3) && !fieldIsMessage &&
([value length] == 0)) {
- setHasValue = NO;
- value = nil;
+ // Except, if the field was in a oneof, then it still gets recorded as
+ // having been set so the state of the oneof can be serialized back out.
+ if (!oneof) {
+ setHasValue = NO;
+ }
+ if (setHasValue) {
+ NSCAssert(value != nil, @"Should never be setting has for nil");
+ } else {
+ // The value passed in was retained, it must be released since we
+ // aren't saving anything in the field.
+ [value release];
+ value = nil;
+ }
}
GPBSetHasIvarField(self, field, setHasValue);
}
@@ -347,9 +574,11 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
if (field.fieldType == GPBFieldTypeRepeated) {
// If the old array was autocreated by us, then clear it.
if (GPBDataTypeIsObject(fieldType)) {
- GPBAutocreatedArray *autoArray = oldValue;
- if (autoArray->_autocreator == self) {
- autoArray->_autocreator = nil;
+ if ([oldValue isKindOfClass:[GPBAutocreatedArray class]]) {
+ GPBAutocreatedArray *autoArray = oldValue;
+ if (autoArray->_autocreator == self) {
+ autoArray->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Array.
@@ -362,9 +591,11 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
// If the old map was autocreated by us, then clear it.
if ((field.mapKeyDataType == GPBDataTypeString) &&
GPBDataTypeIsObject(fieldType)) {
- GPBAutocreatedDictionary *autoDict = oldValue;
- if (autoDict->_autocreator == self) {
- autoDict->_autocreator = nil;
+ if ([oldValue isKindOfClass:[GPBAutocreatedDictionary class]]) {
+ GPBAutocreatedDictionary *autoDict = oldValue;
+ if (autoDict->_autocreator == self) {
+ autoDict->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Dictionary.
@@ -397,33 +628,6 @@ id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self,
return *typePtr;
}
-id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
- NSCAssert(!GPBFieldIsMapOrArray(field), @"Shouldn't get here");
- if (GPBGetHasIvarField(self, field)) {
- uint8_t *storage = (uint8_t *)self->messageStorage_;
- id *typePtr = (id *)&storage[field->description_->offset];
- return *typePtr;
- }
- // Not set...
-
- // Non messages (string/data), get their default.
- if (!GPBFieldDataTypeIsMessage(field)) {
- return field.defaultValue.valueMessage;
- }
-
- dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
- GPBMessage *result = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
- if (!result) {
- // For non repeated messages, create the object, set it and return it.
- // This object will not initially be visible via GPBGetHasIvar, so
- // we save its creator so it can become visible if it's mutated later.
- result = GPBCreateMessageWithAutocreator(field.msgClass, self, field);
- GPBSetAutocreatedRetainedObjectIvarWithField(self, field, result);
- }
- dispatch_semaphore_signal(self->readOnlySemaphore_);
- return result;
-}
-
// Only exists for public api, no core code should use this.
int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field) {
GPBFileSyntax syntax = [self descriptor].file.syntax;
@@ -433,6 +637,13 @@ int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field) {
int32_t GPBGetEnumIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
GPBFileSyntax syntax) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeEnum,
+ @"Attempting to get value of type Enum from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
int32_t result = GPBGetMessageInt32Field(self, field);
// If this is presevering unknown enums, make sure the value is valid before
// returning it.
@@ -453,6 +664,13 @@ void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field,
void GPBSetEnumIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field, int32_t value,
GPBFileSyntax syntax) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeEnum,
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type Enum.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
// Don't allow in unknown values. Proto3 can use the Raw method.
if (![field isValidEnumValue:value]) {
[NSException raise:NSInvalidArgumentException
@@ -476,15 +694,22 @@ void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field,
GPBSetInt32IvarWithFieldInternal(self, field, value, syntax);
}
-//%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(Bool, BOOL)
-// This block of code is generated, do not edit it directly.
-
BOOL GPBGetMessageBoolField(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), GPBDataTypeBool),
+ @"Attempting to get value of type bool from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
if (GPBGetHasIvarField(self, field)) {
- uint8_t *storage = (uint8_t *)self->messageStorage_;
- BOOL *typePtr = (BOOL *)&storage[field->description_->offset];
- return *typePtr;
+ // Bools are stored in the has bits to avoid needing explicit space in the
+ // storage structure.
+ // (the field number passed to the HasIvar helper doesn't really matter
+ // since the offset is never negative)
+ GPBMessageFieldDescription *fieldDesc = field->description_;
+ return GPBGetHasIvar(self, (int32_t)(fieldDesc->offset), fieldDesc->number);
} else {
return field.defaultValue.valueBool;
}
@@ -503,23 +728,30 @@ void GPBSetBoolIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
BOOL value,
GPBFileSyntax syntax) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), GPBDataTypeBool),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type bool.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
+ GPBMessageFieldDescription *fieldDesc = field->description_;
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
- GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field));
+ GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
- NSCAssert(self->messageStorage_ != NULL,
- @"%@: All messages should have storage (from init)",
- [self class]);
-#if defined(__clang_analyzer__)
- if (self->messageStorage_ == NULL) return;
-#endif
- uint8_t *storage = (uint8_t *)self->messageStorage_;
- BOOL *typePtr = (BOOL *)&storage[field->description_->offset];
- *typePtr = value;
+
+ // Bools are stored in the has bits to avoid needing explicit space in the
+ // storage structure.
+ // (the field number passed to the HasIvar helper doesn't really matter since
+ // the offset is never negative)
+ GPBSetHasIvar(self, (int32_t)(fieldDesc->offset), fieldDesc->number, value);
+
// proto2: any value counts as having been set; proto3, it
- // has to be a non zero value.
- BOOL hasValue =
- (syntax == GPBFileSyntaxProto2) || (value != (BOOL)0);
+ // has to be a non zero value or be in a oneof.
+ BOOL hasValue = ((syntax == GPBFileSyntaxProto2)
+ || (value != (BOOL)0)
+ || (field->containingOneof_ != NULL));
GPBSetHasIvarField(self, field, hasValue);
GPBBecomeVisibleToAutocreator(self);
}
@@ -529,6 +761,14 @@ void GPBSetBoolIvarWithFieldInternal(GPBMessage *self,
int32_t GPBGetMessageInt32Field(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeInt32),
+ @"Attempting to get value of int32_t from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
int32_t *typePtr = (int32_t *)&storage[field->description_->offset];
@@ -551,13 +791,24 @@ void GPBSetInt32IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value,
GPBFileSyntax syntax) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeInt32),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type int32_t.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
- GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field));
+ GPBMessageFieldDescription *fieldDesc = field->description_;
+ GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
+#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
+#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@@ -565,9 +816,10 @@ void GPBSetInt32IvarWithFieldInternal(GPBMessage *self,
int32_t *typePtr = (int32_t *)&storage[field->description_->offset];
*typePtr = value;
// proto2: any value counts as having been set; proto3, it
- // has to be a non zero value.
- BOOL hasValue =
- (syntax == GPBFileSyntaxProto2) || (value != (int32_t)0);
+ // has to be a non zero value or be in a oneof.
+ BOOL hasValue = ((syntax == GPBFileSyntaxProto2)
+ || (value != (int32_t)0)
+ || (field->containingOneof_ != NULL));
GPBSetHasIvarField(self, field, hasValue);
GPBBecomeVisibleToAutocreator(self);
}
@@ -577,6 +829,14 @@ void GPBSetInt32IvarWithFieldInternal(GPBMessage *self,
uint32_t GPBGetMessageUInt32Field(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeUInt32),
+ @"Attempting to get value of uint32_t from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
uint32_t *typePtr = (uint32_t *)&storage[field->description_->offset];
@@ -599,13 +859,24 @@ void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
uint32_t value,
GPBFileSyntax syntax) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeUInt32),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type uint32_t.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
- GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field));
+ GPBMessageFieldDescription *fieldDesc = field->description_;
+ GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
+#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
+#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@@ -613,9 +884,10 @@ void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self,
uint32_t *typePtr = (uint32_t *)&storage[field->description_->offset];
*typePtr = value;
// proto2: any value counts as having been set; proto3, it
- // has to be a non zero value.
- BOOL hasValue =
- (syntax == GPBFileSyntaxProto2) || (value != (uint32_t)0);
+ // has to be a non zero value or be in a oneof.
+ BOOL hasValue = ((syntax == GPBFileSyntaxProto2)
+ || (value != (uint32_t)0)
+ || (field->containingOneof_ != NULL));
GPBSetHasIvarField(self, field, hasValue);
GPBBecomeVisibleToAutocreator(self);
}
@@ -625,6 +897,14 @@ void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self,
int64_t GPBGetMessageInt64Field(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeInt64),
+ @"Attempting to get value of int64_t from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
int64_t *typePtr = (int64_t *)&storage[field->description_->offset];
@@ -647,13 +927,24 @@ void GPBSetInt64IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
int64_t value,
GPBFileSyntax syntax) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeInt64),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type int64_t.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
- GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field));
+ GPBMessageFieldDescription *fieldDesc = field->description_;
+ GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
+#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
+#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@@ -661,9 +952,10 @@ void GPBSetInt64IvarWithFieldInternal(GPBMessage *self,
int64_t *typePtr = (int64_t *)&storage[field->description_->offset];
*typePtr = value;
// proto2: any value counts as having been set; proto3, it
- // has to be a non zero value.
- BOOL hasValue =
- (syntax == GPBFileSyntaxProto2) || (value != (int64_t)0);
+ // has to be a non zero value or be in a oneof.
+ BOOL hasValue = ((syntax == GPBFileSyntaxProto2)
+ || (value != (int64_t)0)
+ || (field->containingOneof_ != NULL));
GPBSetHasIvarField(self, field, hasValue);
GPBBecomeVisibleToAutocreator(self);
}
@@ -673,6 +965,14 @@ void GPBSetInt64IvarWithFieldInternal(GPBMessage *self,
uint64_t GPBGetMessageUInt64Field(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeUInt64),
+ @"Attempting to get value of uint64_t from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
uint64_t *typePtr = (uint64_t *)&storage[field->description_->offset];
@@ -695,13 +995,24 @@ void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
uint64_t value,
GPBFileSyntax syntax) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeUInt64),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type uint64_t.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
- GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field));
+ GPBMessageFieldDescription *fieldDesc = field->description_;
+ GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
+#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
+#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@@ -709,9 +1020,10 @@ void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self,
uint64_t *typePtr = (uint64_t *)&storage[field->description_->offset];
*typePtr = value;
// proto2: any value counts as having been set; proto3, it
- // has to be a non zero value.
- BOOL hasValue =
- (syntax == GPBFileSyntaxProto2) || (value != (uint64_t)0);
+ // has to be a non zero value or be in a oneof.
+ BOOL hasValue = ((syntax == GPBFileSyntaxProto2)
+ || (value != (uint64_t)0)
+ || (field->containingOneof_ != NULL));
GPBSetHasIvarField(self, field, hasValue);
GPBBecomeVisibleToAutocreator(self);
}
@@ -721,6 +1033,14 @@ void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self,
float GPBGetMessageFloatField(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeFloat),
+ @"Attempting to get value of float from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
float *typePtr = (float *)&storage[field->description_->offset];
@@ -743,13 +1063,24 @@ void GPBSetFloatIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
float value,
GPBFileSyntax syntax) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeFloat),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type float.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
- GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field));
+ GPBMessageFieldDescription *fieldDesc = field->description_;
+ GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
+#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
+#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@@ -757,9 +1088,10 @@ void GPBSetFloatIvarWithFieldInternal(GPBMessage *self,
float *typePtr = (float *)&storage[field->description_->offset];
*typePtr = value;
// proto2: any value counts as having been set; proto3, it
- // has to be a non zero value.
- BOOL hasValue =
- (syntax == GPBFileSyntaxProto2) || (value != (float)0);
+ // has to be a non zero value or be in a oneof.
+ BOOL hasValue = ((syntax == GPBFileSyntaxProto2)
+ || (value != (float)0)
+ || (field->containingOneof_ != NULL));
GPBSetHasIvarField(self, field, hasValue);
GPBBecomeVisibleToAutocreator(self);
}
@@ -769,6 +1101,14 @@ void GPBSetFloatIvarWithFieldInternal(GPBMessage *self,
double GPBGetMessageDoubleField(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeDouble),
+ @"Attempting to get value of double from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
double *typePtr = (double *)&storage[field->description_->offset];
@@ -791,13 +1131,24 @@ void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
double value,
GPBFileSyntax syntax) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeDouble),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type double.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
- GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field));
+ GPBMessageFieldDescription *fieldDesc = field->description_;
+ GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
+#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
+#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@@ -805,14 +1156,15 @@ void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self,
double *typePtr = (double *)&storage[field->description_->offset];
*typePtr = value;
// proto2: any value counts as having been set; proto3, it
- // has to be a non zero value.
- BOOL hasValue =
- (syntax == GPBFileSyntaxProto2) || (value != (double)0);
+ // has to be a non zero value or be in a oneof.
+ BOOL hasValue = ((syntax == GPBFileSyntaxProto2)
+ || (value != (double)0)
+ || (field->containingOneof_ != NULL));
GPBSetHasIvarField(self, field, hasValue);
GPBBecomeVisibleToAutocreator(self);
}
-//%PDDM-EXPAND-END (7 expansions)
+//%PDDM-EXPAND-END (6 expansions)
// Aliases are function calls that are virtually the same.
@@ -822,6 +1174,14 @@ void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self,
// Only exists for public api, no core code should use this.
NSString *GPBGetMessageStringField(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeString),
+ @"Attempting to get value of NSString from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
return (NSString *)GPBGetObjectIvarWithField(self, field);
}
@@ -829,6 +1189,14 @@ NSString *GPBGetMessageStringField(GPBMessage *self,
void GPBSetMessageStringField(GPBMessage *self,
GPBFieldDescriptor *field,
NSString *value) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeString),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type NSString.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBSetObjectIvarWithField(self, field, (id)value);
}
@@ -838,6 +1206,14 @@ void GPBSetMessageStringField(GPBMessage *self,
// Only exists for public api, no core code should use this.
NSData *GPBGetMessageBytesField(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeBytes),
+ @"Attempting to get value of NSData from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
return (NSData *)GPBGetObjectIvarWithField(self, field);
}
@@ -845,6 +1221,14 @@ NSData *GPBGetMessageBytesField(GPBMessage *self,
void GPBSetMessageBytesField(GPBMessage *self,
GPBFieldDescriptor *field,
NSData *value) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeBytes),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type NSData.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBSetObjectIvarWithField(self, field, (id)value);
}
@@ -854,6 +1238,14 @@ void GPBSetMessageBytesField(GPBMessage *self,
// Only exists for public api, no core code should use this.
GPBMessage *GPBGetMessageMessageField(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeMessage),
+ @"Attempting to get value of GPBMessage from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
return (GPBMessage *)GPBGetObjectIvarWithField(self, field);
}
@@ -861,6 +1253,14 @@ GPBMessage *GPBGetMessageMessageField(GPBMessage *self,
void GPBSetMessageMessageField(GPBMessage *self,
GPBFieldDescriptor *field,
GPBMessage *value) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeMessage),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type GPBMessage.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBSetObjectIvarWithField(self, field, (id)value);
}
@@ -870,6 +1270,14 @@ void GPBSetMessageMessageField(GPBMessage *self,
// Only exists for public api, no core code should use this.
GPBMessage *GPBGetMessageGroupField(GPBMessage *self,
GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeGroup),
+ @"Attempting to get value of GPBMessage from field %@ "
+ @"of %@ which is of type %@.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
return (GPBMessage *)GPBGetObjectIvarWithField(self, field);
}
@@ -877,26 +1285,24 @@ GPBMessage *GPBGetMessageGroupField(GPBMessage *self,
void GPBSetMessageGroupField(GPBMessage *self,
GPBFieldDescriptor *field,
GPBMessage *value) {
+#if defined(DEBUG) && DEBUG
+ NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
+ GPBDataTypeGroup),
+ @"Attempting to set field %@ of %@ which is of type %@ with "
+ @"value of type GPBMessage.",
+ [self class], field.name,
+ TypeToString(GPBGetFieldDataType(field)));
+#endif
GPBSetObjectIvarWithField(self, field, (id)value);
}
//%PDDM-EXPAND-END (4 expansions)
-// Only exists for public api, no core code should use this.
-id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field) {
-#if DEBUG
- if (field.fieldType != GPBFieldTypeRepeated) {
- [NSException raise:NSInvalidArgumentException
- format:@"%@.%@ is not a repeated field.",
- [self class], field.name];
- }
-#endif
- return GPBGetObjectIvarWithField(self, field);
-}
+// GPBGetMessageRepeatedField is defined in GPBMessage.m
// Only exists for public api, no core code should use this.
void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array) {
-#if DEBUG
+#if defined(DEBUG) && DEBUG
if (field.fieldType != GPBFieldTypeRepeated) {
[NSException raise:NSInvalidArgumentException
format:@"%@.%@ is not a repeated field.",
@@ -935,10 +1341,10 @@ void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id
case GPBDataTypeString:
case GPBDataTypeMessage:
case GPBDataTypeGroup:
- expectedClass = [NSMutableDictionary class];
+ expectedClass = [NSMutableArray class];
break;
case GPBDataTypeEnum:
- expectedClass = [GPBBoolArray class];
+ expectedClass = [GPBEnumArray class];
break;
}
if (array && ![array isKindOfClass:expectedClass]) {
@@ -950,8 +1356,40 @@ void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id
GPBSetObjectIvarWithField(self, field, array);
}
-#if DEBUG
-static NSString *TypeToStr(GPBDataType dataType) {
+static GPBDataType BaseDataType(GPBDataType type) {
+ switch (type) {
+ case GPBDataTypeSFixed32:
+ case GPBDataTypeInt32:
+ case GPBDataTypeSInt32:
+ case GPBDataTypeEnum:
+ return GPBDataTypeInt32;
+ case GPBDataTypeFixed32:
+ case GPBDataTypeUInt32:
+ return GPBDataTypeUInt32;
+ case GPBDataTypeSFixed64:
+ case GPBDataTypeInt64:
+ case GPBDataTypeSInt64:
+ return GPBDataTypeInt64;
+ case GPBDataTypeFixed64:
+ case GPBDataTypeUInt64:
+ return GPBDataTypeUInt64;
+ case GPBDataTypeMessage:
+ case GPBDataTypeGroup:
+ return GPBDataTypeMessage;
+ case GPBDataTypeBool:
+ case GPBDataTypeFloat:
+ case GPBDataTypeDouble:
+ case GPBDataTypeBytes:
+ case GPBDataTypeString:
+ return type;
+ }
+}
+
+static BOOL DataTypesEquivalent(GPBDataType type1, GPBDataType type2) {
+ return BaseDataType(type1) == BaseDataType(type2);
+}
+
+static NSString *TypeToString(GPBDataType dataType) {
switch (dataType) {
case GPBDataTypeBool:
return @"Bool";
@@ -979,27 +1417,16 @@ static NSString *TypeToStr(GPBDataType dataType) {
case GPBDataTypeGroup:
return @"Object";
case GPBDataTypeEnum:
- return @"Bool";
+ return @"Enum";
}
}
-#endif
-// Only exists for public api, no core code should use this.
-id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field) {
-#if DEBUG
- if (field.fieldType != GPBFieldTypeMap) {
- [NSException raise:NSInvalidArgumentException
- format:@"%@.%@ is not a map<> field.",
- [self class], field.name];
- }
-#endif
- return GPBGetObjectIvarWithField(self, field);
-}
+// GPBGetMessageMapField is defined in GPBMessage.m
// Only exists for public api, no core code should use this.
void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field,
id dictionary) {
-#if DEBUG
+#if defined(DEBUG) && DEBUG
if (field.fieldType != GPBFieldTypeMap) {
[NSException raise:NSInvalidArgumentException
format:@"%@.%@ is not a map<> field.",
@@ -1008,8 +1435,8 @@ void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field,
if (dictionary) {
GPBDataType keyDataType = field.mapKeyDataType;
GPBDataType valueDataType = GPBGetFieldDataType(field);
- NSString *keyStr = TypeToStr(keyDataType);
- NSString *valueStr = TypeToStr(valueDataType);
+ NSString *keyStr = TypeToString(keyDataType);
+ NSString *valueStr = TypeToString(valueDataType);
if (keyDataType == GPBDataTypeString) {
keyStr = @"String";
}
@@ -1039,8 +1466,11 @@ void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field,
const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel) {
Protocol *protocol =
objc_getProtocol(GPBStringifySymbol(GPBMessageSignatureProtocol));
+ NSCAssert(protocol, @"Missing GPBMessageSignatureProtocol");
struct objc_method_description description =
protocol_getMethodDescription(protocol, selector, NO, instanceSel);
+ NSCAssert(description.name != Nil && description.types != nil,
+ @"Missing method for selector %@", NSStringFromSelector(selector));
return description.types;
}
@@ -1059,7 +1489,15 @@ static void AppendStringEscaped(NSString *toPrint, NSMutableString *destStr) {
case '\'': [destStr appendString:@"\\\'"]; break;
case '\\': [destStr appendString:@"\\\\"]; break;
default:
- [destStr appendFormat:@"%C", aChar];
+ // This differs slightly from the C++ code in that the C++ doesn't
+ // generate UTF8; it looks at the string in UTF8, but escapes every
+ // byte > 0x7E.
+ if (aChar < 0x20) {
+ [destStr appendFormat:@"\\%d%d%d",
+ (aChar / 64), ((aChar % 64) / 8), (aChar % 8)];
+ } else {
+ [destStr appendFormat:@"%C", aChar];
+ }
break;
}
}
@@ -1126,6 +1564,8 @@ static void AppendTextFormatForMapMessageField(
[toStr appendString:@"\n"];
[toStr appendString:valueLine];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wswitch-enum"
switch (valueDataType) {
case GPBDataTypeString:
AppendStringEscaped(value, toStr);
@@ -1146,6 +1586,7 @@ static void AppendTextFormatForMapMessageField(
NSCAssert(NO, @"Can't happen");
break;
}
+#pragma clang diagnostic pop
[toStr appendString:@"\n"];
[toStr appendString:msgEnd];
@@ -1167,6 +1608,8 @@ static void AppendTextFormatForMapMessageField(
}
[toStr appendString:valueLine];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wswitch-enum"
switch (valueDataType) {
case GPBDataTypeString:
AppendStringEscaped(valueObj, toStr);
@@ -1204,6 +1647,7 @@ static void AppendTextFormatForMapMessageField(
[toStr appendString:valueObj];
break;
}
+#pragma clang diagnostic pop
[toStr appendString:@"\n"];
[toStr appendString:msgEnd];
@@ -1473,7 +1917,8 @@ static void AppendTextFormatForMessage(GPBMessage *message,
NSUInteger fieldCount = fieldsArray.count;
const GPBExtensionRange *extensionRanges = descriptor.extensionRanges;
NSUInteger extensionRangesCount = descriptor.extensionRangesCount;
- NSArray *activeExtensions = [message sortedExtensionsInUse];
+ NSArray *activeExtensions = [[message extensionsCurrentlySet]
+ sortedArrayUsingSelector:@selector(compareByFieldNumber:)];
for (NSUInteger i = 0, j = 0; i < fieldCount || j < extensionRangesCount;) {
if (i == fieldCount) {
AppendTextFormatForMessageExtensionRange(
@@ -1699,12 +2144,23 @@ NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key,
return result;
}
-#pragma mark - GPBMessageSignatureProtocol
+#pragma clang diagnostic pop
-// A series of selectors that are used solely to get @encoding values
-// for them by the dynamic protobuf runtime code. An object using the protocol
-// needs to be declared for the protocol to be valid at runtime.
-@interface GPBMessageSignatureProtocol : NSObject<GPBMessageSignatureProtocol>
-@end
-@implementation GPBMessageSignatureProtocol
-@end
+BOOL GPBClassHasSel(Class aClass, SEL sel) {
+ // NOTE: We have to use class_copyMethodList, all other runtime method
+ // lookups actually also resolve the method implementation and this
+ // is called from within those methods.
+
+ BOOL result = NO;
+ unsigned int methodCount = 0;
+ Method *methodList = class_copyMethodList(aClass, &methodCount);
+ for (unsigned int i = 0; i < methodCount; ++i) {
+ SEL methodSelector = method_getName(methodList[i]);
+ if (methodSelector == sel) {
+ result = YES;
+ break;
+ }
+ }
+ free(methodList);
+ return result;
+}
diff --git a/objectivec/GPBUtilities_PackagePrivate.h b/objectivec/GPBUtilities_PackagePrivate.h
index cac551f6..ed424ce3 100644
--- a/objectivec/GPBUtilities_PackagePrivate.h
+++ b/objectivec/GPBUtilities_PackagePrivate.h
@@ -50,9 +50,20 @@ CF_EXTERN_C_BEGIN
// These two are used to inject a runtime check for version mismatch into the
// generated sources to make sure they are linked with a supporting runtime.
+void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion);
+GPB_INLINE void GPB_DEBUG_CHECK_RUNTIME_VERSIONS() {
+ // NOTE: By being inline here, this captures the value from the library's
+ // headers at the time the generated code was compiled.
+#if defined(DEBUG) && DEBUG
+ GPBCheckRuntimeVersionSupport(GOOGLE_PROTOBUF_OBJC_VERSION);
+#endif
+}
+
+// Legacy version of the checks, remove when GOOGLE_PROTOBUF_OBJC_GEN_VERSION
+// goes away (see more info in GPBBootstrap.h).
void GPBCheckRuntimeVersionInternal(int32_t version);
GPB_INLINE void GPBDebugCheckRuntimeVersion() {
-#if DEBUG
+#if defined(DEBUG) && DEBUG
GPBCheckRuntimeVersionInternal(GOOGLE_PROTOBUF_OBJC_GEN_VERSION);
#endif
}
@@ -96,7 +107,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 GPBLogicalRightShift32(n, 1) ^ -(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
@@ -104,7 +115,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 GPBLogicalRightShift64(n, 1) ^ -(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
@@ -113,7 +124,7 @@ GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) {
// thus always taking 10 bytes on the wire.)
GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) {
// Note: the right-shift must be arithmetic
- return (n << 1) ^ (n >> 31);
+ return ((uint32_t)n << 1) ^ (uint32_t)(n >> 31);
}
// Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
@@ -122,9 +133,13 @@ GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) {
// thus always taking 10 bytes on the wire.)
GPB_INLINE uint64_t GPBEncodeZigZag64(int64_t n) {
// Note: the right-shift must be arithmetic
- return (n << 1) ^ (n >> 63);
+ return ((uint64_t)n << 1) ^ (uint64_t)(n >> 63);
}
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wswitch-enum"
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
GPB_INLINE BOOL GPBDataTypeIsObject(GPBDataType type) {
switch (type) {
case GPBDataTypeBytes:
@@ -185,7 +200,9 @@ GPB_INLINE void GPBSetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field,
}
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
- uint32_t fieldNumberNotToClear);
+ int32_t oneofHasIndex, uint32_t fieldNumberNotToClear);
+
+#pragma clang diagnostic pop
//%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE)
//%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self,
@@ -292,7 +309,8 @@ NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key,
// A series of selectors that are used solely to get @encoding values
// for them by the dynamic protobuf runtime code. See
-// GPBMessageEncodingForSelector for details.
+// GPBMessageEncodingForSelector for details. GPBRootObject conforms to
+// the protocol so that it is encoded in the Objective C runtime.
@protocol GPBMessageSignatureProtocol
@optional
@@ -328,4 +346,6 @@ GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Enum)
+ (id)getClassValue;
@end
+BOOL GPBClassHasSel(Class aClass, SEL sel);
+
CF_EXTERN_C_END
diff --git a/objectivec/GPBWellKnownTypes.h b/objectivec/GPBWellKnownTypes.h
index 28442fbe..04df4178 100644
--- a/objectivec/GPBWellKnownTypes.h
+++ b/objectivec/GPBWellKnownTypes.h
@@ -30,23 +30,216 @@
#import <Foundation/Foundation.h>
-#import "google/protobuf/Duration.pbobjc.h"
-#import "google/protobuf/Timestamp.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Any.pbobjc.h>
+ #import <Protobuf/Duration.pbobjc.h>
+ #import <Protobuf/Timestamp.pbobjc.h>
+#else
+ #import "google/protobuf/Any.pbobjc.h"
+ #import "google/protobuf/Duration.pbobjc.h"
+ #import "google/protobuf/Timestamp.pbobjc.h"
+#endif
NS_ASSUME_NONNULL_BEGIN
-// Extension to GPBTimestamp to work with standard Foundation time/date types.
+#pragma mark - Errors
+
+/** NSError domain used for errors. */
+extern NSString *const GPBWellKnownTypesErrorDomain;
+
+/** Error code for NSError with GPBWellKnownTypesErrorDomain. */
+typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
+ /** The type_url could not be computed for the requested GPBMessage class. */
+ GPBWellKnownTypesErrorCodeFailedToComputeTypeURL = -100,
+ /** type_url in a Any doesn’t match that of the requested GPBMessage class. */
+ GPBWellKnownTypesErrorCodeTypeURLMismatch = -101,
+};
+
+#pragma mark - GPBTimestamp
+
+/**
+ * Category for GPBTimestamp to work with standard Foundation time/date types.
+ **/
@interface GPBTimestamp (GBPWellKnownTypes)
+
+/** The NSDate representation of this GPBTimestamp. */
@property(nonatomic, readwrite, strong) NSDate *date;
+
+/**
+ * The NSTimeInterval representation of this GPBTimestamp.
+ *
+ * @note: Not all second/nanos combinations can be represented in a
+ * NSTimeInterval, so getting this could be a lossy transform.
+ **/
@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970;
+
+/**
+ * Initializes a GPBTimestamp with the given NSDate.
+ *
+ * @param date The date to configure the GPBTimestamp with.
+ *
+ * @return A newly initialized GPBTimestamp.
+ **/
- (instancetype)initWithDate:(NSDate *)date;
+
+/**
+ * Initializes a GPBTimestamp with the given NSTimeInterval.
+ *
+ * @param timeIntervalSince1970 Time interval to configure the GPBTimestamp with.
+ *
+ * @return A newly initialized GPBTimestamp.
+ **/
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970;
+
@end
-// Extension to GPBDuration to work with standard Foundation time type.
+#pragma mark - GPBDuration
+
+/**
+ * Category for GPBDuration to work with standard Foundation time type.
+ **/
@interface GPBDuration (GBPWellKnownTypes)
-@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970;
-- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970;
+
+/**
+ * The NSTimeInterval representation of this GPBDuration.
+ *
+ * @note: Not all second/nanos combinations can be represented in a
+ * NSTimeInterval, so getting this could be a lossy transform.
+ **/
+@property(nonatomic, readwrite) NSTimeInterval timeInterval;
+
+/**
+ * Initializes a GPBDuration with the given NSTimeInterval.
+ *
+ * @param timeInterval Time interval to configure the GPBDuration with.
+ *
+ * @return A newly initialized GPBDuration.
+ **/
+- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval;
+
+// These next two methods are deprecated because GBPDuration has no need of a
+// "base" time. The older methods were about symmetry with GBPTimestamp, but
+// the unix epoch usage is too confusing.
+
+/** Deprecated, use timeInterval instead. */
+@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970
+ __attribute__((deprecated("Use timeInterval")));
+/** Deprecated, use initWithTimeInterval: instead. */
+- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970
+ __attribute__((deprecated("Use initWithTimeInterval:")));
+
+@end
+
+#pragma mark - GPBAny
+
+/**
+ * Category for GPBAny to help work with the message within the object.
+ **/
+@interface GPBAny (GBPWellKnownTypes)
+
+/**
+ * Convenience method to create a GPBAny containing the serialized message.
+ * This uses type.googleapis.com/ as the type_url's prefix.
+ *
+ * @param message The message to be packed into the GPBAny.
+ * @param errorPtr Pointer to an error that will be populated if something goes
+ * wrong.
+ *
+ * @return A newly configured GPBAny with the given message, or nil on failure.
+ */
++ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message
+ error:(NSError **)errorPtr;
+
+/**
+ * Convenience method to create a GPBAny containing the serialized message.
+ *
+ * @param message The message to be packed into the GPBAny.
+ * @param typeURLPrefix The URL prefix to apply for type_url.
+ * @param errorPtr Pointer to an error that will be populated if something
+ * goes wrong.
+ *
+ * @return A newly configured GPBAny with the given message, or nil on failure.
+ */
++ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message
+ typeURLPrefix:(nonnull NSString *)typeURLPrefix
+ error:(NSError **)errorPtr;
+
+/**
+ * Initializes a GPBAny to contain the serialized message. This uses
+ * type.googleapis.com/ as the type_url's prefix.
+ *
+ * @param message The message to be packed into the GPBAny.
+ * @param errorPtr Pointer to an error that will be populated if something goes
+ * wrong.
+ *
+ * @return A newly configured GPBAny with the given message, or nil on failure.
+ */
+- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message
+ error:(NSError **)errorPtr;
+
+/**
+ * Initializes a GPBAny to contain the serialized message.
+ *
+ * @param message The message to be packed into the GPBAny.
+ * @param typeURLPrefix The URL prefix to apply for type_url.
+ * @param errorPtr Pointer to an error that will be populated if something
+ * goes wrong.
+ *
+ * @return A newly configured GPBAny with the given message, or nil on failure.
+ */
+- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message
+ typeURLPrefix:(nonnull NSString *)typeURLPrefix
+ error:(NSError **)errorPtr;
+
+/**
+ * Packs the serialized message into this GPBAny. This uses
+ * type.googleapis.com/ as the type_url's prefix.
+ *
+ * @param message The message to be packed into the GPBAny.
+ * @param errorPtr Pointer to an error that will be populated if something goes
+ * wrong.
+ *
+ * @return Whether the packing was successful or not.
+ */
+- (BOOL)packWithMessage:(nonnull GPBMessage *)message
+ error:(NSError **)errorPtr;
+
+/**
+ * Packs the serialized message into this GPBAny.
+ *
+ * @param message The message to be packed into the GPBAny.
+ * @param typeURLPrefix The URL prefix to apply for type_url.
+ * @param errorPtr Pointer to an error that will be populated if something
+ * goes wrong.
+ *
+ * @return Whether the packing was successful or not.
+ */
+- (BOOL)packWithMessage:(nonnull GPBMessage *)message
+ typeURLPrefix:(nonnull NSString *)typeURLPrefix
+ error:(NSError **)errorPtr;
+
+/**
+ * Unpacks the serialized message as if it was an instance of the given class.
+ *
+ * @note When checking type_url, the base URL is not checked, only the fully
+ * qualified name.
+ *
+ * @param messageClass The class to use to deserialize the contained message.
+ * @param errorPtr Pointer to an error that will be populated if something
+ * goes wrong.
+ *
+ * @return An instance of the given class populated with the contained data, or
+ * nil on failure.
+ */
+- (nullable GPBMessage *)unpackMessageClass:(Class)messageClass
+ error:(NSError **)errorPtr;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/objectivec/GPBWellKnownTypes.m b/objectivec/GPBWellKnownTypes.m
index fe02f5de..2808afeb 100644
--- a/objectivec/GPBWellKnownTypes.m
+++ b/objectivec/GPBWellKnownTypes.m
@@ -32,24 +32,63 @@
// the static library. If these were compiled separately, the category methods
// below would be stripped by the linker.
-#import "google/protobuf/Timestamp.pbobjc.m"
-#import "google/protobuf/Duration.pbobjc.m"
#import "GPBWellKnownTypes.h"
-static NSTimeInterval TimeIntervalSince1970FromSecondsAndNanos(int64_t seconds,
- int32_t nanos) {
+#import "GPBUtilities_PackagePrivate.h"
+
+NSString *const GPBWellKnownTypesErrorDomain =
+ GPBNSStringifySymbol(GPBWellKnownTypesErrorDomain);
+
+static NSString *kTypePrefixGoogleApisCom = @"type.googleapis.com/";
+
+static NSTimeInterval TimeIntervalFromSecondsAndNanos(int64_t seconds,
+ int32_t nanos) {
return seconds + (NSTimeInterval)nanos / 1e9;
}
-static int32_t SecondsAndNanosFromTimeIntervalSince1970(NSTimeInterval time,
- int64_t *outSeconds) {
+static int32_t SecondsAndNanosFromTimeInterval(NSTimeInterval time,
+ int64_t *outSeconds,
+ BOOL nanosMustBePositive) {
NSTimeInterval seconds;
NSTimeInterval nanos = modf(time, &seconds);
+
+ if (nanosMustBePositive && (nanos < 0)) {
+ // Per Timestamp.proto, nanos is non-negative and "Negative second values with
+ // fractions must still have non-negative nanos values that count forward in
+ // time. Must be from 0 to 999,999,999 inclusive."
+ --seconds;
+ nanos = 1.0 + nanos;
+ }
+
nanos *= 1e9;
*outSeconds = (int64_t)seconds;
return (int32_t)nanos;
}
+static NSString *BuildTypeURL(NSString *typeURLPrefix, NSString *fullName) {
+ if (typeURLPrefix.length == 0) {
+ return fullName;
+ }
+
+ if ([typeURLPrefix hasSuffix:@"/"]) {
+ return [typeURLPrefix stringByAppendingString:fullName];
+ }
+
+ return [NSString stringWithFormat:@"%@/%@", typeURLPrefix, fullName];
+}
+
+static NSString *ParseTypeFromURL(NSString *typeURLString) {
+ NSRange range = [typeURLString rangeOfString:@"/" options:NSBackwardsSearch];
+ if ((range.location == NSNotFound) ||
+ (NSMaxRange(range) == typeURLString.length)) {
+ return nil;
+ }
+ NSString *result = [typeURLString substringFromIndex:range.location + 1];
+ return result;
+}
+
+#pragma mark - GPBTimestamp
+
@implementation GPBTimestamp (GBPWellKnownTypes)
- (instancetype)initWithDate:(NSDate *)date {
@@ -59,8 +98,8 @@ static int32_t SecondsAndNanosFromTimeIntervalSince1970(NSTimeInterval time,
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
if ((self = [super init])) {
int64_t seconds;
- int32_t nanos = SecondsAndNanosFromTimeIntervalSince1970(
- timeIntervalSince1970, &seconds);
+ int32_t nanos = SecondsAndNanosFromTimeInterval(
+ timeIntervalSince1970, &seconds, YES);
self.seconds = seconds;
self.nanos = nanos;
}
@@ -76,42 +115,158 @@ static int32_t SecondsAndNanosFromTimeIntervalSince1970(NSTimeInterval time,
}
- (NSTimeInterval)timeIntervalSince1970 {
- return TimeIntervalSince1970FromSecondsAndNanos(self.seconds, self.nanos);
+ return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos);
}
- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
int64_t seconds;
int32_t nanos =
- SecondsAndNanosFromTimeIntervalSince1970(timeIntervalSince1970, &seconds);
+ SecondsAndNanosFromTimeInterval(timeIntervalSince1970, &seconds, YES);
self.seconds = seconds;
self.nanos = nanos;
}
@end
+#pragma mark - GPBDuration
+
@implementation GPBDuration (GBPWellKnownTypes)
-- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
+- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval {
if ((self = [super init])) {
int64_t seconds;
- int32_t nanos = SecondsAndNanosFromTimeIntervalSince1970(
- timeIntervalSince1970, &seconds);
+ int32_t nanos = SecondsAndNanosFromTimeInterval(
+ timeInterval, &seconds, NO);
self.seconds = seconds;
self.nanos = nanos;
}
return self;
}
-- (NSTimeInterval)timeIntervalSince1970 {
- return TimeIntervalSince1970FromSecondsAndNanos(self.seconds, self.nanos);
+- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
+ return [self initWithTimeInterval:timeIntervalSince1970];
}
-- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
+- (NSTimeInterval)timeInterval {
+ return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos);
+}
+
+- (void)setTimeInterval:(NSTimeInterval)timeInterval {
int64_t seconds;
int32_t nanos =
- SecondsAndNanosFromTimeIntervalSince1970(timeIntervalSince1970, &seconds);
+ SecondsAndNanosFromTimeInterval(timeInterval, &seconds, NO);
self.seconds = seconds;
self.nanos = nanos;
}
+- (NSTimeInterval)timeIntervalSince1970 {
+ return self.timeInterval;
+}
+
+- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
+ self.timeInterval = timeIntervalSince1970;
+}
+
+@end
+
+#pragma mark - GPBAny
+
+@implementation GPBAny (GBPWellKnownTypes)
+
++ (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
+ error:errorPtr] autorelease];
+}
+
+- (instancetype)initWithMessage:(GPBMessage *)message
+ error:(NSError **)errorPtr {
+ return [self initWithMessage:message
+ typeURLPrefix:kTypePrefixGoogleApisCom
+ error:errorPtr];
+}
+
+- (instancetype)initWithMessage:(GPBMessage *)message
+ typeURLPrefix:(NSString *)typeURLPrefix
+ error:(NSError **)errorPtr {
+ self = [self init];
+ if (self) {
+ if (![self packWithMessage:message
+ typeURLPrefix:typeURLPrefix
+ error:errorPtr]) {
+ [self release];
+ self = nil;
+ }
+ }
+ return self;
+}
+
+- (BOOL)packWithMessage:(GPBMessage *)message
+ error:(NSError **)errorPtr {
+ return [self packWithMessage:message
+ typeURLPrefix:kTypePrefixGoogleApisCom
+ error:errorPtr];
+}
+
+- (BOOL)packWithMessage:(GPBMessage *)message
+ typeURLPrefix:(NSString *)typeURLPrefix
+ error:(NSError **)errorPtr {
+ NSString *fullName = [message descriptor].fullName;
+ if (fullName.length == 0) {
+ if (errorPtr) {
+ *errorPtr =
+ [NSError errorWithDomain:GPBWellKnownTypesErrorDomain
+ code:GPBWellKnownTypesErrorCodeFailedToComputeTypeURL
+ userInfo:nil];
+ }
+ return NO;
+ }
+ if (errorPtr) {
+ *errorPtr = nil;
+ }
+ self.typeURL = BuildTypeURL(typeURLPrefix, fullName);
+ self.value = message.data;
+ return YES;
+}
+
+- (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];
+ }
+ return nil;
+ }
+
+ NSString *expectedFullName = ParseTypeFromURL(self.typeURL);
+ if ((expectedFullName == nil) || ![expectedFullName isEqual:fullName]) {
+ if (errorPtr) {
+ *errorPtr =
+ [NSError errorWithDomain:GPBWellKnownTypesErrorDomain
+ code:GPBWellKnownTypesErrorCodeTypeURLMismatch
+ userInfo:nil];
+ }
+ return nil;
+ }
+
+ // 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];
+}
+
@end
diff --git a/objectivec/GPBWireFormat.h b/objectivec/GPBWireFormat.h
index 29cf2f0b..c5941a38 100644
--- a/objectivec/GPBWireFormat.h
+++ b/objectivec/GPBWireFormat.h
@@ -53,6 +53,7 @@ uint32_t GPBWireFormatMakeTag(uint32_t fieldNumber, GPBWireFormat wireType)
__attribute__((const));
GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) __attribute__((const));
uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) __attribute__((const));
+BOOL GPBWireFormatIsValidTag(uint32_t tag) __attribute__((const));
GPBWireFormat GPBWireFormatForType(GPBDataType dataType, BOOL isPacked)
__attribute__((const));
diff --git a/objectivec/GPBWireFormat.m b/objectivec/GPBWireFormat.m
index 193235d6..860a339f 100644
--- a/objectivec/GPBWireFormat.m
+++ b/objectivec/GPBWireFormat.m
@@ -49,6 +49,13 @@ uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) {
return GPBLogicalRightShift32(tag, GPBWireFormatTagTypeBits);
}
+BOOL GPBWireFormatIsValidTag(uint32_t tag) {
+ uint32_t formatBits = (tag & GPBWireFormatTagTypeMask);
+ // The valid GPBWireFormat* values are 0-5, anything else is not a valid tag.
+ BOOL result = (formatBits <= 5);
+ return result;
+}
+
GPBWireFormat GPBWireFormatForType(GPBDataType type, BOOL isPacked) {
if (isPacked) {
return GPBWireFormatLengthDelimited;
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
index 6b34b9bf..a41be9f2 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
@@ -7,7 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
- 2CFB390415C718CE00CBF84D /* Descriptor.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */; };
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */; };
7461B5360F94FB4600A0C422 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
7461B53C0F94FB4E00A0C422 /* GPBCodedInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */; };
@@ -24,10 +23,8 @@
8B4248D21A927E1500BC1EC6 /* GPBWellKnownTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D01A927E1500BC1EC6 /* GPBWellKnownTypes.m */; };
8B4248DC1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */; };
8B79657B14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; };
- 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; };
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 */; };
- 8B96157514CA019D00A2AC0B /* Descriptor.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */; };
8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */; };
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */; };
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */; };
@@ -40,6 +37,31 @@
8BF8193514A0DDA600A2C982 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
F401DC2D1A8D444600FCC765 /* GPBArray.m in Sources */ = {isa = PBXBuildFile; fileRef = F401DC2B1A8D444600FCC765 /* GPBArray.m */; };
F401DC331A8E5C0200FCC765 /* GPBArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F401DC321A8E5C0200FCC765 /* GPBArrayTests.m */; };
+ F40EE4AB206BF8B90071091A /* GPBCompileTest01.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE488206BF8B00071091A /* GPBCompileTest01.m */; };
+ F40EE4AC206BF8B90071091A /* GPBCompileTest02.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE481206BF8AE0071091A /* GPBCompileTest02.m */; };
+ F40EE4AD206BF8B90071091A /* GPBCompileTest03.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE491206BF8B10071091A /* GPBCompileTest03.m */; };
+ F40EE4AE206BF8B90071091A /* GPBCompileTest04.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE47E206BF8AE0071091A /* GPBCompileTest04.m */; };
+ F40EE4AF206BF8B90071091A /* GPBCompileTest05.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE47F206BF8AE0071091A /* GPBCompileTest05.m */; };
+ F40EE4B0206BF8B90071091A /* GPBCompileTest06.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE492206BF8B10071091A /* GPBCompileTest06.m */; };
+ F40EE4B1206BF8B90071091A /* GPBCompileTest07.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE480206BF8AE0071091A /* GPBCompileTest07.m */; };
+ F40EE4B2206BF8B90071091A /* GPBCompileTest08.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE47D206BF8AD0071091A /* GPBCompileTest08.m */; };
+ F40EE4B3206BF8B90071091A /* GPBCompileTest09.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE484206BF8AF0071091A /* GPBCompileTest09.m */; };
+ F40EE4B4206BF8B90071091A /* GPBCompileTest10.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48C206BF8B00071091A /* GPBCompileTest10.m */; };
+ F40EE4B5206BF8B90071091A /* GPBCompileTest11.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE493206BF8B20071091A /* GPBCompileTest11.m */; };
+ F40EE4B6206BF8B90071091A /* GPBCompileTest12.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE490206BF8B10071091A /* GPBCompileTest12.m */; };
+ F40EE4B7206BF8B90071091A /* GPBCompileTest13.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE483206BF8AF0071091A /* GPBCompileTest13.m */; };
+ F40EE4B8206BF8B90071091A /* GPBCompileTest14.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48F206BF8B10071091A /* GPBCompileTest14.m */; };
+ F40EE4B9206BF8B90071091A /* GPBCompileTest15.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE489206BF8B00071091A /* GPBCompileTest15.m */; };
+ F40EE4BA206BF8B90071091A /* GPBCompileTest16.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48B206BF8B00071091A /* GPBCompileTest16.m */; };
+ F40EE4BB206BF8B90071091A /* GPBCompileTest17.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48D206BF8B00071091A /* GPBCompileTest17.m */; };
+ F40EE4BC206BF8B90071091A /* GPBCompileTest18.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48E206BF8B10071091A /* GPBCompileTest18.m */; };
+ F40EE4BD206BF8B90071091A /* GPBCompileTest19.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE482206BF8AF0071091A /* GPBCompileTest19.m */; };
+ F40EE4BE206BF8B90071091A /* GPBCompileTest20.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE485206BF8AF0071091A /* GPBCompileTest20.m */; };
+ 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 */; };
@@ -55,9 +77,13 @@
F4487C751AADF7F500531423 /* GPBMessageTests+Runtime.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C741AADF7F500531423 /* GPBMessageTests+Runtime.m */; };
F4487C7F1AAF62CD00531423 /* GPBMessageTests+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C7E1AAF62CD00531423 /* GPBMessageTests+Serialization.m */; };
F4487C831AAF6AB300531423 /* GPBMessageTests+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */; };
+ F4584D821ECCB52A00803AB6 /* GPBExtensionRegistryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F4584D7E1ECCB38900803AB6 /* GPBExtensionRegistryTest.m */; };
F45C69CC16DFD08D0081955B /* GPBExtensionInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */; };
F45E57C71AE6DC6A000B7D99 /* text_format_map_unittest_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */; };
+ F47476E51D21A524007C7B1A /* Duration.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D41A92826400BC1EC6 /* Duration.pbobjc.m */; };
+ F47476E61D21A524007C7B1A /* Timestamp.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D61A92826400BC1EC6 /* Timestamp.pbobjc.m */; };
F4B51B1E1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B51B1D1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm */; };
+ F4C4B9E41E1D976300D3B61D /* GPBDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */; };
F4E675971B21D0000054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675871B21D0000054530B /* Any.pbobjc.m */; };
F4E675991B21D0000054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675891B21D0000054530B /* Api.pbobjc.m */; };
F4E6759B1B21D0000054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E6758B1B21D0000054530B /* Empty.pbobjc.m */; };
@@ -66,14 +92,7 @@
F4E675A11B21D0000054530B /* Struct.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675911B21D0000054530B /* Struct.pbobjc.m */; };
F4E675A31B21D0000054530B /* Type.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675931B21D0000054530B /* Type.pbobjc.m */; };
F4E675A51B21D0000054530B /* Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675951B21D0000054530B /* Wrappers.pbobjc.m */; };
- F4E675AE1B21D0A70054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675871B21D0000054530B /* Any.pbobjc.m */; };
- F4E675AF1B21D0A70054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675891B21D0000054530B /* Api.pbobjc.m */; };
- F4E675B01B21D0A70054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E6758B1B21D0000054530B /* Empty.pbobjc.m */; };
- F4E675B11B21D0A70054530B /* FieldMask.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E6758D1B21D0000054530B /* FieldMask.pbobjc.m */; };
- F4E675B21B21D0A70054530B /* SourceContext.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E6758F1B21D0000054530B /* SourceContext.pbobjc.m */; };
- F4E675B31B21D0A70054530B /* Struct.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675911B21D0000054530B /* Struct.pbobjc.m */; };
- F4E675B41B21D0A70054530B /* Type.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675931B21D0000054530B /* Type.pbobjc.m */; };
- F4E675B51B21D0A70054530B /* Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675951B21D0000054530B /* Wrappers.pbobjc.m */; };
+ F4F8D8831D789FD9002CE128 /* GPBUnittestProtos2.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F8D8811D789FCE002CE128 /* GPBUnittestProtos2.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -140,10 +159,8 @@
8B4248D51A92826400BC1EC6 /* Timestamp.pbobjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Timestamp.pbobjc.h; path = google/protobuf/Timestamp.pbobjc.h; sourceTree = "<group>"; };
8B4248D61A92826400BC1EC6 /* Timestamp.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Timestamp.pbobjc.m; path = google/protobuf/Timestamp.pbobjc.m; sourceTree = "<group>"; };
8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWellKnownTypesTest.m; sourceTree = "<group>"; };
- 8B42494B1A92A16600BC1EC6 /* descriptor.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = descriptor.proto; path = ../src/google/protobuf/descriptor.proto; sourceTree = "<group>"; };
8B42494C1A92A16600BC1EC6 /* duration.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = duration.proto; path = ../src/google/protobuf/duration.proto; sourceTree = "<group>"; };
8B42494D1A92A16600BC1EC6 /* timestamp.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = timestamp.proto; path = ../src/google/protobuf/timestamp.proto; sourceTree = "<group>"; };
- 8B54585814DCC34E003D7338 /* Descriptor.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Descriptor.pbobjc.h; path = google/protobuf/Descriptor.pbobjc.h; sourceTree = SOURCE_ROOT; };
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>"; };
@@ -162,11 +179,35 @@
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>"; };
- 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Descriptor.pbobjc.m; path = google/protobuf/Descriptor.pbobjc.m; sourceTree = SOURCE_ROOT; };
8BEB5AE01498033E0078BF9D /* GPBRuntimeTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRuntimeTypes.h; sourceTree = "<group>"; };
F401DC2A1A8D444600FCC765 /* GPBArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBArray.h; sourceTree = "<group>"; };
F401DC2B1A8D444600FCC765 /* GPBArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBArray.m; sourceTree = "<group>"; };
F401DC321A8E5C0200FCC765 /* GPBArrayTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBArrayTests.m; sourceTree = "<group>"; };
+ F40EE47D206BF8AD0071091A /* GPBCompileTest08.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest08.m; sourceTree = "<group>"; };
+ F40EE47E206BF8AE0071091A /* GPBCompileTest04.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest04.m; sourceTree = "<group>"; };
+ F40EE47F206BF8AE0071091A /* GPBCompileTest05.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest05.m; sourceTree = "<group>"; };
+ F40EE480206BF8AE0071091A /* GPBCompileTest07.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest07.m; sourceTree = "<group>"; };
+ F40EE481206BF8AE0071091A /* GPBCompileTest02.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest02.m; sourceTree = "<group>"; };
+ F40EE482206BF8AF0071091A /* GPBCompileTest19.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest19.m; sourceTree = "<group>"; };
+ F40EE483206BF8AF0071091A /* GPBCompileTest13.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest13.m; sourceTree = "<group>"; };
+ F40EE484206BF8AF0071091A /* GPBCompileTest09.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest09.m; sourceTree = "<group>"; };
+ F40EE485206BF8AF0071091A /* GPBCompileTest20.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest20.m; sourceTree = "<group>"; };
+ F40EE486206BF8AF0071091A /* GPBCompileTest21.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest21.m; sourceTree = "<group>"; };
+ F40EE487206BF8B00071091A /* GPBCompileTest23.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest23.m; sourceTree = "<group>"; };
+ F40EE488206BF8B00071091A /* GPBCompileTest01.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest01.m; sourceTree = "<group>"; };
+ F40EE489206BF8B00071091A /* GPBCompileTest15.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest15.m; sourceTree = "<group>"; };
+ F40EE48A206BF8B00071091A /* GPBCompileTest22.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest22.m; sourceTree = "<group>"; };
+ F40EE48B206BF8B00071091A /* GPBCompileTest16.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest16.m; sourceTree = "<group>"; };
+ F40EE48C206BF8B00071091A /* GPBCompileTest10.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest10.m; sourceTree = "<group>"; };
+ F40EE48D206BF8B00071091A /* GPBCompileTest17.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest17.m; sourceTree = "<group>"; };
+ F40EE48E206BF8B10071091A /* GPBCompileTest18.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest18.m; sourceTree = "<group>"; };
+ F40EE48F206BF8B10071091A /* GPBCompileTest14.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest14.m; sourceTree = "<group>"; };
+ F40EE490206BF8B10071091A /* GPBCompileTest12.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest12.m; sourceTree = "<group>"; };
+ 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>"; };
@@ -188,7 +229,9 @@
F4487C7C1AAE06AC00531423 /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUtilities_PackagePrivate.h; sourceTree = "<group>"; };
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>"; };
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>"; };
F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = "<group>"; };
F4AC9E1D1A8BEB3500BD6E83 /* unittest_cycle.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_cycle.proto; sourceTree = "<group>"; };
@@ -197,6 +240,7 @@
F4B6B8B21A9CCBDA00892426 /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
F4B6B8B61A9CD1DE00892426 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBExtensionInternals.h; sourceTree = "<group>"; };
F4B6B8B81A9CD1DE00892426 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
+ F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionaryTests.m; sourceTree = "<group>"; };
F4CF31701B162ED800BD9B06 /* unittest_objc_startup.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_objc_startup.proto; sourceTree = "<group>"; };
F4E675861B21D0000054530B /* Any.pbobjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Any.pbobjc.h; path = google/protobuf/Any.pbobjc.h; sourceTree = "<group>"; };
F4E675871B21D0000054530B /* Any.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Any.pbobjc.m; path = google/protobuf/Any.pbobjc.m; sourceTree = "<group>"; };
@@ -222,6 +266,7 @@
F4E675AB1B21D05C0054530B /* struct.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = struct.proto; path = ../src/google/protobuf/struct.proto; sourceTree = "<group>"; };
F4E675AC1B21D05C0054530B /* type.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = type.proto; path = ../src/google/protobuf/type.proto; sourceTree = "<group>"; };
F4E675AD1B21D05C0054530B /* wrappers.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = wrappers.proto; path = ../src/google/protobuf/wrappers.proto; sourceTree = "<group>"; };
+ F4F8D8811D789FCE002CE128 /* GPBUnittestProtos2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnittestProtos2.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -299,9 +344,6 @@
F4E675881B21D0000054530B /* Api.pbobjc.h */,
F4E675891B21D0000054530B /* Api.pbobjc.m */,
F4E675A71B21D05C0054530B /* api.proto */,
- 8B54585814DCC34E003D7338 /* Descriptor.pbobjc.h */,
- 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */,
- 8B42494B1A92A16600BC1EC6 /* descriptor.proto */,
8B4248D31A92826400BC1EC6 /* Duration.pbobjc.h */,
8B4248D41A92826400BC1EC6 /* Duration.pbobjc.m */,
8B42494C1A92A16600BC1EC6 /* duration.proto */,
@@ -368,9 +410,10 @@
7461B4860F94F96B00A0C422 /* IO */ = {
isa = PBXGroup;
children = (
- 7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */,
51457B5F18D0B7AF00CCC606 /* GPBCodedInputStream_PackagePrivate.h */,
+ 7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */,
7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */,
+ F44929001C866B1900C2548A /* GPBCodedOutputStream_PackagePrivate.h */,
7461B4900F94F99000A0C422 /* GPBCodedOutputStream.h */,
7461B4910F94F99000A0C422 /* GPBCodedOutputStream.m */,
7461B4E70F94F99000A0C422 /* GPBWireFormat.h */,
@@ -402,8 +445,34 @@
F401DC321A8E5C0200FCC765 /* GPBArrayTests.m */,
7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */,
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */,
+ F40EE488206BF8B00071091A /* GPBCompileTest01.m */,
+ F40EE481206BF8AE0071091A /* GPBCompileTest02.m */,
+ F40EE491206BF8B10071091A /* GPBCompileTest03.m */,
+ F40EE47E206BF8AE0071091A /* GPBCompileTest04.m */,
+ F40EE47F206BF8AE0071091A /* GPBCompileTest05.m */,
+ F40EE492206BF8B10071091A /* GPBCompileTest06.m */,
+ F40EE480206BF8AE0071091A /* GPBCompileTest07.m */,
+ F40EE47D206BF8AD0071091A /* GPBCompileTest08.m */,
+ F40EE484206BF8AF0071091A /* GPBCompileTest09.m */,
+ F40EE48C206BF8B00071091A /* GPBCompileTest10.m */,
+ F40EE493206BF8B20071091A /* GPBCompileTest11.m */,
+ F40EE490206BF8B10071091A /* GPBCompileTest12.m */,
+ F40EE483206BF8AF0071091A /* GPBCompileTest13.m */,
+ F40EE48F206BF8B10071091A /* GPBCompileTest14.m */,
+ F40EE489206BF8B00071091A /* GPBCompileTest15.m */,
+ F40EE48B206BF8B00071091A /* GPBCompileTest16.m */,
+ F40EE48D206BF8B00071091A /* GPBCompileTest17.m */,
+ F40EE48E206BF8B10071091A /* GPBCompileTest18.m */,
+ F40EE482206BF8AF0071091A /* GPBCompileTest19.m */,
+ F40EE485206BF8AF0071091A /* GPBCompileTest20.m */,
+ F40EE486206BF8AF0071091A /* GPBCompileTest21.m */,
+ F40EE48A206BF8B00071091A /* GPBCompileTest22.m */,
+ F40EE487206BF8B00071091A /* GPBCompileTest23.m */,
+ F40EE508206C06440071091A /* GPBCompileTest24.m */,
+ F40EE507206C06440071091A /* GPBCompileTest25.m */,
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */,
+ F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */,
F4353D2C1AC06F10005A6198 /* GPBDictionaryTests.pddm */,
F4353D2D1AC06F10005A6198 /* GPBDictionaryTests+Bool.m */,
F4353D2E1AC06F10005A6198 /* GPBDictionaryTests+Int32.m */,
@@ -411,6 +480,7 @@
F4353D301AC06F10005A6198 /* GPBDictionaryTests+String.m */,
F4353D311AC06F10005A6198 /* GPBDictionaryTests+UInt32.m */,
F4353D321AC06F10005A6198 /* GPBDictionaryTests+UInt64.m */,
+ F4584D7E1ECCB38900803AB6 /* GPBExtensionRegistryTest.m */,
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */,
F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */,
F4487C741AADF7F500531423 /* GPBMessageTests+Runtime.m */,
@@ -421,12 +491,13 @@
7461B6AB0F94FDF800A0C422 /* GPBTestUtilities.h */,
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */,
8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */,
+ F4F8D8811D789FCE002CE128 /* GPBUnittestProtos2.m */,
7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */,
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */,
8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */,
7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */,
- F43C88CF191D77FC009E917D /* text_format_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 */,
8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */,
@@ -436,8 +507,8 @@
8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */,
8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */,
8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */,
- 8B09AAF614B663A7007B4184 /* unittest_objc.proto */,
F4CF31701B162ED800BD9B06 /* unittest_objc_startup.proto */,
+ 8B09AAF614B663A7007B4184 /* unittest_objc.proto */,
8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */,
F4487C781AADFB3100531423 /* unittest_runtime_proto2.proto */,
F4487C791AADFB3200531423 /* unittest_runtime_proto3.proto */,
@@ -566,9 +637,10 @@
attributes = {
LastSwiftUpdateCheck = 0710;
LastTestingUpgradeCheck = 0600;
- LastUpgradeCheck = 0710;
+ LastUpgradeCheck = 0930;
TargetAttributes = {
8BBEA4A5147C727100C4ADB7 = {
+ LastSwiftMigration = 0800;
TestTargetID = 8B9A5EA41831993600A9D33B;
};
F45BBC141B0CE3C6002D064D = {
@@ -632,7 +704,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 2CFB390415C718CE00CBF84D /* Descriptor.pbobjc.m in Sources */,
7461B53C0F94FB4E00A0C422 /* GPBCodedInputStream.m in Sources */,
F4E6759B1B21D0000054530B /* Empty.pbobjc.m in Sources */,
7461B53D0F94FB4E00A0C422 /* GPBCodedOutputStream.m in Sources */,
@@ -641,6 +712,7 @@
F4E6759D1B21D0000054530B /* FieldMask.pbobjc.m in Sources */,
7461B54C0F94FB4E00A0C422 /* GPBUnknownField.m in Sources */,
7461B5530F94FB4E00A0C422 /* GPBMessage.m in Sources */,
+ F47476E51D21A524007C7B1A /* Duration.pbobjc.m in Sources */,
7461B5610F94FB4E00A0C422 /* GPBUnknownFieldSet.m in Sources */,
7461B5630F94FB4E00A0C422 /* GPBUtilities.m in Sources */,
7461B5640F94FB4E00A0C422 /* GPBWireFormat.m in Sources */,
@@ -655,6 +727,7 @@
F4E675A31B21D0000054530B /* Type.pbobjc.m in Sources */,
F4E675A11B21D0000054530B /* Struct.pbobjc.m in Sources */,
F4E675A51B21D0000054530B /* Wrappers.pbobjc.m in Sources */,
+ F47476E61D21A524007C7B1A /* Timestamp.pbobjc.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -663,40 +736,58 @@
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 */,
F4353D361AC06F10005A6198 /* GPBDictionaryTests+Int64.m in Sources */,
+ F40EE4C0206BF8B90071091A /* GPBCompileTest22.m in Sources */,
+ F40EE4B2206BF8B90071091A /* GPBCompileTest08.m in Sources */,
+ F40EE4BB206BF8B90071091A /* GPBCompileTest17.m in Sources */,
F4353D391AC06F10005A6198 /* GPBDictionaryTests+UInt64.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */,
- F4E675B21B21D0A70054530B /* SourceContext.pbobjc.m in Sources */,
+ F40EE4C1206BF8B90071091A /* GPBCompileTest23.m in Sources */,
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */,
F4B51B1E1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */,
+ F40EE4BD206BF8B90071091A /* GPBCompileTest19.m in Sources */,
+ F40EE4B0206BF8B90071091A /* GPBCompileTest06.m in Sources */,
+ F40EE4B6206BF8B90071091A /* GPBCompileTest12.m in Sources */,
F4487C7F1AAF62CD00531423 /* GPBMessageTests+Serialization.m in Sources */,
+ F40EE4AD206BF8B90071091A /* GPBCompileTest03.m in Sources */,
+ F40EE4BC206BF8B90071091A /* GPBCompileTest18.m in Sources */,
+ F40EE4B7206BF8B90071091A /* GPBCompileTest13.m in Sources */,
+ F40EE4B9206BF8B90071091A /* GPBCompileTest15.m in Sources */,
+ F40EE4B1206BF8B90071091A /* GPBCompileTest07.m in Sources */,
8B4248DC1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m in Sources */,
- F4E675B01B21D0A70054530B /* Empty.pbobjc.m in Sources */,
- F4E675B41B21D0A70054530B /* Type.pbobjc.m in Sources */,
+ F40EE4BF206BF8B90071091A /* GPBCompileTest21.m in Sources */,
+ F40EE4B5206BF8B90071091A /* GPBCompileTest11.m in Sources */,
+ F4F8D8831D789FD9002CE128 /* GPBUnittestProtos2.m in Sources */,
F4353D1D1AB8822D005A6198 /* GPBDescriptorTests.m in Sources */,
- F4E675B51B21D0A70054530B /* Wrappers.pbobjc.m in Sources */,
- F4E675AE1B21D0A70054530B /* Any.pbobjc.m in Sources */,
8B4248BB1A8C256A00BC1EC6 /* GPBSwiftTests.swift in Sources */,
+ F40EE50C206C06640071091A /* GPBCompileTest25.m in Sources */,
+ F4584D821ECCB52A00803AB6 /* GPBExtensionRegistryTest.m in Sources */,
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
- F4E675B31B21D0A70054530B /* Struct.pbobjc.m in Sources */,
F4487C751AADF7F500531423 /* GPBMessageTests+Runtime.m in Sources */,
+ F40EE4AC206BF8B90071091A /* GPBCompileTest02.m in Sources */,
F4353D351AC06F10005A6198 /* GPBDictionaryTests+Int32.m in Sources */,
+ F40EE4AF206BF8B90071091A /* GPBCompileTest05.m in Sources */,
+ F40EE4B8206BF8B90071091A /* GPBCompileTest14.m in Sources */,
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */,
+ F40EE4AE206BF8B90071091A /* GPBCompileTest04.m in Sources */,
+ F40EE4BA206BF8B90071091A /* GPBCompileTest16.m in Sources */,
F41C175D1833D3310064ED4D /* GPBPerfTests.m in Sources */,
F4353D341AC06F10005A6198 /* GPBDictionaryTests+Bool.m in Sources */,
F4487C831AAF6AB300531423 /* GPBMessageTests+Merge.m in Sources */,
+ F40EE4AB206BF8B90071091A /* GPBCompileTest01.m in Sources */,
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */,
F4353D371AC06F10005A6198 /* GPBDictionaryTests+String.m in Sources */,
F4353D381AC06F10005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
+ F40EE4B3206BF8B90071091A /* GPBCompileTest09.m in Sources */,
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */,
+ F4C4B9E41E1D976300D3B61D /* GPBDictionaryTests.m in Sources */,
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */,
- 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */,
8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */,
- F4E675B11B21D0A70054530B /* FieldMask.pbobjc.m in Sources */,
- 8B96157514CA019D00A2AC0B /* Descriptor.pbobjc.m in Sources */,
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */,
- F4E675AF1B21D0A70054530B /* Api.pbobjc.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -727,6 +818,7 @@
7461B52F0F94FAFA00A0C422 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
HEADER_SEARCH_PATHS = "$(SRCROOT)";
PRODUCT_NAME = ProtocolBuffers;
@@ -736,6 +828,7 @@
7461B5300F94FAFA00A0C422 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
HEADER_SEARCH_PATHS = "$(SRCROOT)";
PRODUCT_NAME = ProtocolBuffers;
@@ -746,6 +839,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
HEADER_SEARCH_PATHS = (
"${PROJECT_DERIVED_FILE_DIR}/protos",
@@ -753,10 +847,18 @@
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
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 = 3.0;
+ WARNING_CFLAGS = (
+ "$(inherited)",
+ "-Wno-documentation-unknown-command",
+ "-Wno-reserved-id-macro",
+ "-Wno-direct-ivar-access",
+ );
};
name = Debug;
};
@@ -764,6 +866,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
HEADER_SEARCH_PATHS = (
"${PROJECT_DERIVED_FILE_DIR}/protos",
@@ -771,9 +874,17 @@
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
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 = 3.0;
+ WARNING_CFLAGS = (
+ "$(inherited)",
+ "-Wno-documentation-unknown-command",
+ "-Wno-reserved-id-macro",
+ "-Wno-direct-ivar-access",
+ );
};
name = Release;
};
@@ -781,18 +892,33 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
+ CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
+ CLANG_WARN_ASSIGN_ENUM = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
@@ -810,6 +936,7 @@
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
@@ -820,6 +947,14 @@
ONLY_ACTIVE_ARCH = YES;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx;
+ WARNING_CFLAGS = (
+ "-Wdocumentation-unknown-command",
+ "-Wundef",
+ "-Wreserved-id-macro",
+ "-Wswitch-enum",
+ "-Wdirect-ivar-access",
+ "-Woverriding-method-mismatch",
+ );
};
name = Debug;
};
@@ -827,18 +962,33 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
+ CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
+ CLANG_WARN_ASSIGN_ENUM = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
@@ -854,6 +1004,7 @@
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
@@ -863,12 +1014,22 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
+ WARNING_CFLAGS = (
+ "-Wdocumentation-unknown-command",
+ "-Wundef",
+ "-Wreserved-id-macro",
+ "-Wswitch-enum",
+ "-Wdirect-ivar-access",
+ "-Woverriding-method-mismatch",
+ );
};
name = Release;
};
F4487C4F1A9F8E0200531423 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
HEADER_SEARCH_PATHS = "$(SRCROOT)";
PRODUCT_NAME = TestSingleSourceBuild;
@@ -878,6 +1039,7 @@
F4487C501A9F8E0200531423 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
HEADER_SEARCH_PATHS = "$(SRCROOT)";
PRODUCT_NAME = TestSingleSourceBuild;
@@ -887,12 +1049,14 @@
F45BBC151B0CE3C6002D064D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
};
name = Debug;
};
F45BBC161B0CE3C6002D064D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
};
name = Release;
};
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 00000000..18d98100
--- /dev/null
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IDEDidComputeMac32BitWarning</key>
+ <true/>
+</dict>
+</plist>
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
index 25814c5f..6653a1b0 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0710"
+ LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -51,6 +51,12 @@
Identifier = "DescriptorTests">
</Test>
<Test
+ Identifier = "GPBAutocreatedArrayTests">
+ </Test>
+ <Test
+ Identifier = "GPBAutocreatedDictionaryTests">
+ </Test>
+ <Test
Identifier = "GPBBoolArrayTests">
</Test>
<Test
@@ -90,6 +96,9 @@
Identifier = "GPBEnumArrayTests">
</Test>
<Test
+ Identifier = "GPBExtensionRegistryTest">
+ </Test>
+ <Test
Identifier = "GPBFloatArrayTests">
</Test>
<Test
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
index 8f510f5d..328771b8 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0710"
+ LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -54,6 +54,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
index e9d3fc95..470652d0 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
@@ -7,7 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
- 2CFB390415C718CE00CBF84D /* Descriptor.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */; };
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */; };
7461B5360F94FB4600A0C422 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
7461B53C0F94FB4E00A0C422 /* GPBCodedInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */; };
@@ -24,17 +23,8 @@
8B4248E41A929C8900BC1EC6 /* GPBWellKnownTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248E21A929C8900BC1EC6 /* GPBWellKnownTypes.m */; };
8B4248E61A929C9900BC1EC6 /* GPBWellKnownTypesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */; };
8B79657B14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; };
- 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; };
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 */; };
- 8B96157514CA019D00A2AC0B /* Descriptor.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */; };
- 8B9742331A89D19F00DCE92C /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8B9742321A89D19F00DCE92C /* LaunchScreen.xib */; };
- 8B9742431A8AAA7800DCE92C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B9742421A8AAA7800DCE92C /* CoreGraphics.framework */; };
- 8B9A5EA61831993600A9D33B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
- 8B9A5EA81831993600A9D33B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B9A5E9F1831913D00A9D33B /* UIKit.framework */; };
- 8B9A5EAE1831993600A9D33B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8B9A5EAC1831993600A9D33B /* InfoPlist.strings */; };
- 8B9A5EB41831993600A9D33B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B9A5EB31831993600A9D33B /* AppDelegate.m */; };
- 8B9A5EB61831993600A9D33B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8B9A5EB51831993600A9D33B /* Images.xcassets */; };
8B9A5EEC18330A0F00A9D33B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B9A5E9F1831913D00A9D33B /* UIKit.framework */; };
8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */; };
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */; };
@@ -47,6 +37,31 @@
8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */; };
8BF8193514A0DDA600A2C982 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
F401DC351A8E5C6F00FCC765 /* GPBArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F401DC341A8E5C6F00FCC765 /* GPBArrayTests.m */; };
+ F40EE4F0206BF91E0071091A /* GPBCompileTest01.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CD206BF9170071091A /* GPBCompileTest01.m */; };
+ F40EE4F1206BF91E0071091A /* GPBCompileTest02.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4C6206BF9170071091A /* GPBCompileTest02.m */; };
+ F40EE4F2206BF91E0071091A /* GPBCompileTest03.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4D6206BF9190071091A /* GPBCompileTest03.m */; };
+ F40EE4F3206BF91E0071091A /* GPBCompileTest04.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4C3206BF9160071091A /* GPBCompileTest04.m */; };
+ F40EE4F4206BF91E0071091A /* GPBCompileTest05.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4C4206BF9160071091A /* GPBCompileTest05.m */; };
+ F40EE4F5206BF91E0071091A /* GPBCompileTest06.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4D7206BF9190071091A /* GPBCompileTest06.m */; };
+ F40EE4F6206BF91E0071091A /* GPBCompileTest07.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4C5206BF9170071091A /* GPBCompileTest07.m */; };
+ F40EE4F7206BF91E0071091A /* GPBCompileTest08.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4C2206BF9160071091A /* GPBCompileTest08.m */; };
+ F40EE4F8206BF91E0071091A /* GPBCompileTest09.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4C9206BF9170071091A /* GPBCompileTest09.m */; };
+ F40EE4F9206BF91E0071091A /* GPBCompileTest10.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4D1206BF9180071091A /* GPBCompileTest10.m */; };
+ F40EE4FA206BF91E0071091A /* GPBCompileTest11.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4D8206BF9190071091A /* GPBCompileTest11.m */; };
+ F40EE4FB206BF91E0071091A /* GPBCompileTest12.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4D5206BF9180071091A /* GPBCompileTest12.m */; };
+ F40EE4FC206BF91E0071091A /* GPBCompileTest13.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4C8206BF9170071091A /* GPBCompileTest13.m */; };
+ F40EE4FD206BF91E0071091A /* GPBCompileTest14.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4D4206BF9180071091A /* GPBCompileTest14.m */; };
+ F40EE4FE206BF91E0071091A /* GPBCompileTest15.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CE206BF9170071091A /* GPBCompileTest15.m */; };
+ F40EE4FF206BF91E0071091A /* GPBCompileTest16.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4D0206BF9180071091A /* GPBCompileTest16.m */; };
+ F40EE500206BF91E0071091A /* GPBCompileTest17.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4D2206BF9180071091A /* GPBCompileTest17.m */; };
+ F40EE501206BF91E0071091A /* GPBCompileTest18.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4D3206BF9180071091A /* GPBCompileTest18.m */; };
+ F40EE502206BF91E0071091A /* GPBCompileTest19.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4C7206BF9170071091A /* GPBCompileTest19.m */; };
+ F40EE503206BF91E0071091A /* GPBCompileTest20.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CA206BF9170071091A /* GPBCompileTest20.m */; };
+ 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 */; };
@@ -63,17 +78,13 @@
F4487C771AADF84900531423 /* GPBMessageTests+Runtime.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C761AADF84900531423 /* GPBMessageTests+Runtime.m */; };
F4487C811AAF62FC00531423 /* GPBMessageTests+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */; };
F4487C851AAF6AC500531423 /* GPBMessageTests+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */; };
+ F4584D831ECCB53600803AB6 /* GPBExtensionRegistryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F4584D801ECCB39E00803AB6 /* GPBExtensionRegistryTest.m */; };
F45C69CC16DFD08D0081955B /* GPBExtensionInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */; };
F45E57C91AE6DC98000B7D99 /* text_format_map_unittest_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */; };
+ F47476E91D21A537007C7B1A /* Duration.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248DE1A929C7D00BC1EC6 /* Duration.pbobjc.m */; };
+ F47476EA1D21A537007C7B1A /* Timestamp.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248E01A929C7D00BC1EC6 /* Timestamp.pbobjc.m */; };
F4B51B1C1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B51B1B1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm */; };
- F4E675C81B21D1610054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B71B21D1440054530B /* Any.pbobjc.m */; };
- F4E675C91B21D1610054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B91B21D1440054530B /* Api.pbobjc.m */; };
- F4E675CA1B21D1610054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675BC1B21D1440054530B /* Empty.pbobjc.m */; };
- F4E675CB1B21D1610054530B /* FieldMask.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675BE1B21D1440054530B /* FieldMask.pbobjc.m */; };
- F4E675CC1B21D1610054530B /* SourceContext.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C01B21D1440054530B /* SourceContext.pbobjc.m */; };
- F4E675CD1B21D1610054530B /* Struct.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C21B21D1440054530B /* Struct.pbobjc.m */; };
- F4E675CE1B21D1610054530B /* Type.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C51B21D1440054530B /* Type.pbobjc.m */; };
- F4E675CF1B21D1610054530B /* Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C71B21D1440054530B /* Wrappers.pbobjc.m */; };
+ F4C4B9E71E1D97BF00D3B61D /* GPBDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */; };
F4E675D01B21D1620054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B71B21D1440054530B /* Any.pbobjc.m */; };
F4E675D11B21D1620054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B91B21D1440054530B /* Api.pbobjc.m */; };
F4E675D21B21D1620054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675BC1B21D1440054530B /* Empty.pbobjc.m */; };
@@ -82,16 +93,10 @@
F4E675D51B21D1620054530B /* Struct.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C21B21D1440054530B /* Struct.pbobjc.m */; };
F4E675D61B21D1620054530B /* Type.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C51B21D1440054530B /* Type.pbobjc.m */; };
F4E675D71B21D1620054530B /* Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C71B21D1440054530B /* Wrappers.pbobjc.m */; };
+ F4F8D8861D78A193002CE128 /* GPBUnittestProtos2.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F8D8841D78A186002CE128 /* GPBUnittestProtos2.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
- 8B9A5ED01831994600A9D33B /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = 8B9A5EA41831993600A9D33B;
- remoteInfo = iOSTestHarness;
- };
8BBEA4BC147C729A00C4ADB7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
@@ -155,7 +160,6 @@
8B4248E21A929C8900BC1EC6 /* GPBWellKnownTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWellKnownTypes.m; sourceTree = "<group>"; };
8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWellKnownTypesTest.m; sourceTree = "<group>"; };
8B4249481A92A02300BC1EC6 /* timestamp.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = timestamp.proto; path = ../src/google/protobuf/timestamp.proto; sourceTree = "<group>"; };
- 8B4249491A92A0BA00BC1EC6 /* descriptor.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = descriptor.proto; path = ../src/google/protobuf/descriptor.proto; sourceTree = "<group>"; };
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>"; };
@@ -170,22 +174,40 @@
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>"; };
- 8B9742321A89D19F00DCE92C /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; 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; };
- 8B9A5EA51831993600A9D33B /* iOSTestHarness.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSTestHarness.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 8B9A5EAB1831993600A9D33B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
- 8B9A5EAD1831993600A9D33B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
- 8B9A5EB31831993600A9D33B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
- 8B9A5EB51831993600A9D33B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; 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>"; };
- 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Descriptor.pbobjc.m; path = google/protobuf/Descriptor.pbobjc.m; sourceTree = SOURCE_ROOT; };
8BEB5AE01498033E0078BF9D /* GPBRuntimeTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRuntimeTypes.h; sourceTree = "<group>"; };
F401DC341A8E5C6F00FCC765 /* GPBArrayTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBArrayTests.m; sourceTree = "<group>"; };
+ F40EE4C2206BF9160071091A /* GPBCompileTest08.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest08.m; sourceTree = "<group>"; };
+ F40EE4C3206BF9160071091A /* GPBCompileTest04.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest04.m; sourceTree = "<group>"; };
+ F40EE4C4206BF9160071091A /* GPBCompileTest05.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest05.m; sourceTree = "<group>"; };
+ F40EE4C5206BF9170071091A /* GPBCompileTest07.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest07.m; sourceTree = "<group>"; };
+ F40EE4C6206BF9170071091A /* GPBCompileTest02.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest02.m; sourceTree = "<group>"; };
+ F40EE4C7206BF9170071091A /* GPBCompileTest19.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest19.m; sourceTree = "<group>"; };
+ F40EE4C8206BF9170071091A /* GPBCompileTest13.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest13.m; sourceTree = "<group>"; };
+ F40EE4C9206BF9170071091A /* GPBCompileTest09.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest09.m; sourceTree = "<group>"; };
+ F40EE4CA206BF9170071091A /* GPBCompileTest20.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest20.m; sourceTree = "<group>"; };
+ F40EE4CB206BF9170071091A /* GPBCompileTest21.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest21.m; sourceTree = "<group>"; };
+ F40EE4CC206BF9170071091A /* GPBCompileTest23.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest23.m; sourceTree = "<group>"; };
+ F40EE4CD206BF9170071091A /* GPBCompileTest01.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest01.m; sourceTree = "<group>"; };
+ F40EE4CE206BF9170071091A /* GPBCompileTest15.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest15.m; sourceTree = "<group>"; };
+ F40EE4CF206BF9170071091A /* GPBCompileTest22.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest22.m; sourceTree = "<group>"; };
+ F40EE4D0206BF9180071091A /* GPBCompileTest16.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest16.m; sourceTree = "<group>"; };
+ F40EE4D1206BF9180071091A /* GPBCompileTest10.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest10.m; sourceTree = "<group>"; };
+ F40EE4D2206BF9180071091A /* GPBCompileTest17.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest17.m; sourceTree = "<group>"; };
+ F40EE4D3206BF9180071091A /* GPBCompileTest18.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest18.m; sourceTree = "<group>"; };
+ F40EE4D4206BF9180071091A /* GPBCompileTest14.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest14.m; sourceTree = "<group>"; };
+ F40EE4D5206BF9180071091A /* GPBCompileTest12.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest12.m; sourceTree = "<group>"; };
+ 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>"; };
@@ -209,7 +231,9 @@
F4487C7D1AAE06C500531423 /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUtilities_PackagePrivate.h; sourceTree = "<group>"; };
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>"; };
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>"; };
F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = "<group>"; };
F4AC9E1C1A8BEB1000BD6E83 /* unittest_cycle.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_cycle.proto; sourceTree = "<group>"; };
@@ -218,12 +242,12 @@
F4B6B8B11A9CCBBB00892426 /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
F4B6B8B31A9CD1C600892426 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBExtensionInternals.h; sourceTree = "<group>"; };
F4B6B8B51A9CD1C600892426 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
+ F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionaryTests.m; sourceTree = "<group>"; };
F4CF31711B162EF500BD9B06 /* unittest_objc_startup.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_objc_startup.proto; sourceTree = "<group>"; };
F4E675B61B21D1440054530B /* Any.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Any.pbobjc.h; path = google/protobuf/Any.pbobjc.h; sourceTree = "<group>"; };
F4E675B71B21D1440054530B /* Any.pbobjc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Any.pbobjc.m; path = google/protobuf/Any.pbobjc.m; sourceTree = "<group>"; };
F4E675B81B21D1440054530B /* Api.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Api.pbobjc.h; path = google/protobuf/Api.pbobjc.h; sourceTree = "<group>"; };
F4E675B91B21D1440054530B /* Api.pbobjc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Api.pbobjc.m; path = google/protobuf/Api.pbobjc.m; sourceTree = "<group>"; };
- F4E675BA1B21D1440054530B /* Descriptor.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Descriptor.pbobjc.h; path = google/protobuf/Descriptor.pbobjc.h; sourceTree = "<group>"; };
F4E675BB1B21D1440054530B /* Empty.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Empty.pbobjc.h; path = google/protobuf/Empty.pbobjc.h; sourceTree = "<group>"; };
F4E675BC1B21D1440054530B /* Empty.pbobjc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Empty.pbobjc.m; path = google/protobuf/Empty.pbobjc.m; sourceTree = "<group>"; };
F4E675BD1B21D1440054530B /* FieldMask.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FieldMask.pbobjc.h; path = google/protobuf/FieldMask.pbobjc.h; sourceTree = "<group>"; };
@@ -245,6 +269,7 @@
F4E675DD1B21D1DE0054530B /* struct.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = struct.proto; path = ../src/google/protobuf/struct.proto; sourceTree = "<group>"; };
F4E675DE1B21D1DE0054530B /* type.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = type.proto; path = ../src/google/protobuf/type.proto; sourceTree = "<group>"; };
F4E675DF1B21D1DE0054530B /* wrappers.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = wrappers.proto; path = ../src/google/protobuf/wrappers.proto; sourceTree = "<group>"; };
+ F4F8D8841D78A186002CE128 /* GPBUnittestProtos2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnittestProtos2.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -256,16 +281,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
- 8B9A5EA21831993600A9D33B /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 8B9742431A8AAA7800DCE92C /* CoreGraphics.framework in Frameworks */,
- 8B9A5EA81831993600A9D33B /* UIKit.framework in Frameworks */,
- 8B9A5EA61831993600A9D33B /* Foundation.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
8BBEA4A3147C727100C4ADB7 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -308,7 +323,6 @@
children = (
7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */,
8BBEA4A6147C727100C4ADB7 /* UnitTests.xctest */,
- 8B9A5EA51831993600A9D33B /* iOSTestHarness.app */,
F4487C6E1A9F8F8100531423 /* libTestSingleSourceBuild.a */,
);
name = Products;
@@ -334,9 +348,6 @@
F4E675B81B21D1440054530B /* Api.pbobjc.h */,
F4E675B91B21D1440054530B /* Api.pbobjc.m */,
F4E675D91B21D1DE0054530B /* api.proto */,
- F4E675BA1B21D1440054530B /* Descriptor.pbobjc.h */,
- 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */,
- 8B4249491A92A0BA00BC1EC6 /* descriptor.proto */,
8B4248DD1A929C7D00BC1EC6 /* Duration.pbobjc.h */,
8B4248DE1A929C7D00BC1EC6 /* Duration.pbobjc.m */,
8B42494A1A92A0BA00BC1EC6 /* duration.proto */,
@@ -405,9 +416,10 @@
7461B4860F94F96B00A0C422 /* IO */ = {
isa = PBXGroup;
children = (
- 7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */,
51457B5F18D0B7AF00CCC606 /* GPBCodedInputStream_PackagePrivate.h */,
+ 7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */,
7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */,
+ F44929021C866B3B00C2548A /* GPBCodedOutputStream_PackagePrivate.h */,
7461B4900F94F99000A0C422 /* GPBCodedOutputStream.h */,
7461B4910F94F99000A0C422 /* GPBCodedOutputStream.m */,
7461B4E70F94F99000A0C422 /* GPBWireFormat.h */,
@@ -432,7 +444,6 @@
7461B6940F94FDDD00A0C422 /* Tests */ = {
isa = PBXGroup;
children = (
- 8B9A5EA91831993600A9D33B /* iOSTestHarness */,
8B4248B71A8BDD9600BC1EC6 /* protobuf */,
8B210CCD159383D60032D72D /* golden_message */,
8B210CCF159386920032D72D /* golden_packed_fields_message */,
@@ -440,8 +451,34 @@
F401DC341A8E5C6F00FCC765 /* GPBArrayTests.m */,
7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */,
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */,
+ F40EE4CD206BF9170071091A /* GPBCompileTest01.m */,
+ F40EE4C6206BF9170071091A /* GPBCompileTest02.m */,
+ F40EE4D6206BF9190071091A /* GPBCompileTest03.m */,
+ F40EE4C3206BF9160071091A /* GPBCompileTest04.m */,
+ F40EE4C4206BF9160071091A /* GPBCompileTest05.m */,
+ F40EE4D7206BF9190071091A /* GPBCompileTest06.m */,
+ F40EE4C5206BF9170071091A /* GPBCompileTest07.m */,
+ F40EE4C2206BF9160071091A /* GPBCompileTest08.m */,
+ F40EE4C9206BF9170071091A /* GPBCompileTest09.m */,
+ F40EE4D1206BF9180071091A /* GPBCompileTest10.m */,
+ F40EE4D8206BF9190071091A /* GPBCompileTest11.m */,
+ F40EE4D5206BF9180071091A /* GPBCompileTest12.m */,
+ F40EE4C8206BF9170071091A /* GPBCompileTest13.m */,
+ F40EE4D4206BF9180071091A /* GPBCompileTest14.m */,
+ F40EE4CE206BF9170071091A /* GPBCompileTest15.m */,
+ F40EE4D0206BF9180071091A /* GPBCompileTest16.m */,
+ F40EE4D2206BF9180071091A /* GPBCompileTest17.m */,
+ F40EE4D3206BF9180071091A /* GPBCompileTest18.m */,
+ F40EE4C7206BF9170071091A /* GPBCompileTest19.m */,
+ F40EE4CA206BF9170071091A /* GPBCompileTest20.m */,
+ F40EE4CB206BF9170071091A /* GPBCompileTest21.m */,
+ F40EE4CF206BF9170071091A /* GPBCompileTest22.m */,
+ F40EE4CC206BF9170071091A /* GPBCompileTest23.m */,
+ F40EE50E206C06880071091A /* GPBCompileTest24.m */,
+ F40EE50D206C06880071091A /* GPBCompileTest25.m */,
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */,
+ F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */,
F4353D3A1AC06F31005A6198 /* GPBDictionaryTests.pddm */,
F4353D3B1AC06F31005A6198 /* GPBDictionaryTests+Bool.m */,
F4353D3C1AC06F31005A6198 /* GPBDictionaryTests+Int32.m */,
@@ -449,6 +486,7 @@
F4353D3E1AC06F31005A6198 /* GPBDictionaryTests+String.m */,
F4353D3F1AC06F31005A6198 /* GPBDictionaryTests+UInt32.m */,
F4353D401AC06F31005A6198 /* GPBDictionaryTests+UInt64.m */,
+ F4584D801ECCB39E00803AB6 /* GPBExtensionRegistryTest.m */,
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */,
F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */,
F4487C761AADF84900531423 /* GPBMessageTests+Runtime.m */,
@@ -459,12 +497,13 @@
7461B6AB0F94FDF800A0C422 /* GPBTestUtilities.h */,
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */,
8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */,
+ F4F8D8841D78A186002CE128 /* GPBUnittestProtos2.m */,
7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */,
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */,
8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */,
7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */,
- F43C88CF191D77FC009E917D /* text_format_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 */,
8B7E6A7514893DBA00F8884A /* unittest_embed_optimize_for.proto */,
@@ -474,8 +513,8 @@
8BBD9DB016DD1DC8008E1EC1 /* unittest_lite.proto */,
8B7E6A7B14893DBC00F8884A /* unittest_mset.proto */,
8B7E6A7C14893DBC00F8884A /* unittest_no_generic_services.proto */,
- 8B09AAF614B663A7007B4184 /* unittest_objc.proto */,
F4CF31711B162EF500BD9B06 /* unittest_objc_startup.proto */,
+ 8B09AAF614B663A7007B4184 /* unittest_objc.proto */,
8B7E6A7D14893DBC00F8884A /* unittest_optimize_for.proto */,
F4487C7A1AADFB5500531423 /* unittest_runtime_proto2.proto */,
F4487C7B1AADFB5500531423 /* unittest_runtime_proto3.proto */,
@@ -486,26 +525,6 @@
path = Tests;
sourceTree = "<group>";
};
- 8B9A5EA91831993600A9D33B /* iOSTestHarness */ = {
- isa = PBXGroup;
- children = (
- 8B9A5EB31831993600A9D33B /* AppDelegate.m */,
- 8B9A5EB51831993600A9D33B /* Images.xcassets */,
- 8B9A5EAA1831993600A9D33B /* Supporting Files */,
- 8B9742321A89D19F00DCE92C /* LaunchScreen.xib */,
- );
- path = iOSTestHarness;
- sourceTree = "<group>";
- };
- 8B9A5EAA1831993600A9D33B /* Supporting Files */ = {
- isa = PBXGroup;
- children = (
- 8B9A5EAB1831993600A9D33B /* Info.plist */,
- 8B9A5EAC1831993600A9D33B /* InfoPlist.strings */,
- );
- name = "Supporting Files";
- sourceTree = "<group>";
- };
8BCF334414ED727300BC5317 /* Support */ = {
isa = PBXGroup;
children = (
@@ -580,23 +599,6 @@
productReference = 7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */;
productType = "com.apple.product-type.library.static";
};
- 8B9A5EA41831993600A9D33B /* iOSTestHarness */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 8B9A5ECA1831993600A9D33B /* Build configuration list for PBXNativeTarget "iOSTestHarness" */;
- buildPhases = (
- 8B9A5EA11831993600A9D33B /* Sources */,
- 8B9A5EA21831993600A9D33B /* Frameworks */,
- 8B9A5EA31831993600A9D33B /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = iOSTestHarness;
- productName = iOSTestHarness;
- productReference = 8B9A5EA51831993600A9D33B /* iOSTestHarness.app */;
- productType = "com.apple.product-type.application";
- };
8BBEA4A5147C727100C4ADB7 /* UnitTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 8BBEA4BA147C728600C4ADB7 /* Build configuration list for PBXNativeTarget "UnitTests" */;
@@ -611,7 +613,6 @@
dependencies = (
8BBEA4BD147C729A00C4ADB7 /* PBXTargetDependency */,
F45BBC131B0CDBBA002D064D /* PBXTargetDependency */,
- 8B9A5ED11831994600A9D33B /* PBXTargetDependency */,
);
name = UnitTests;
productName = UnitTests;
@@ -643,9 +644,10 @@
attributes = {
LastSwiftUpdateCheck = 0710;
LastTestingUpgradeCheck = 0600;
- LastUpgradeCheck = 0710;
+ LastUpgradeCheck = 0930;
TargetAttributes = {
8BBEA4A5147C727100C4ADB7 = {
+ LastSwiftMigration = 0800;
TestTargetID = 8B9A5EA41831993600A9D33B;
};
F45BBC0E1B0CDB50002D064D = {
@@ -666,7 +668,6 @@
targets = (
7461B52D0F94FAF800A0C422 /* ProtocolBuffers */,
8BBEA4A5147C727100C4ADB7 /* UnitTests */,
- 8B9A5EA41831993600A9D33B /* iOSTestHarness */,
F4487C551A9F8F8100531423 /* TestSingleSourceBuild */,
F45BBC0E1B0CDB50002D064D /* Compile Unittest Protos */,
);
@@ -674,16 +675,6 @@
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
- 8B9A5EA31831993600A9D33B /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 8B9A5EAE1831993600A9D33B /* InfoPlist.strings in Resources */,
- 8B9A5EB61831993600A9D33B /* Images.xcassets in Resources */,
- 8B9742331A89D19F00DCE92C /* LaunchScreen.xib in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
8BBEA4A1147C727100C4ADB7 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -720,7 +711,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 2CFB390415C718CE00CBF84D /* Descriptor.pbobjc.m in Sources */,
7461B53C0F94FB4E00A0C422 /* GPBCodedInputStream.m in Sources */,
F4E675D21B21D1620054530B /* Empty.pbobjc.m in Sources */,
F4487C731A9F906200531423 /* GPBArray.m in Sources */,
@@ -729,6 +719,7 @@
F4E675D31B21D1620054530B /* FieldMask.pbobjc.m in Sources */,
7461B54C0F94FB4E00A0C422 /* GPBUnknownField.m in Sources */,
7461B5530F94FB4E00A0C422 /* GPBMessage.m in Sources */,
+ F47476E91D21A537007C7B1A /* Duration.pbobjc.m in Sources */,
7461B5610F94FB4E00A0C422 /* GPBUnknownFieldSet.m in Sources */,
7461B5630F94FB4E00A0C422 /* GPBUtilities.m in Sources */,
7461B5640F94FB4E00A0C422 /* GPBWireFormat.m in Sources */,
@@ -743,14 +734,7 @@
F4E675D61B21D1620054530B /* Type.pbobjc.m in Sources */,
F4E675D51B21D1620054530B /* Struct.pbobjc.m in Sources */,
F4E675D71B21D1620054530B /* Wrappers.pbobjc.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 8B9A5EA11831993600A9D33B /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 8B9A5EB41831993600A9D33B /* AppDelegate.m in Sources */,
+ F47476EA1D21A537007C7B1A /* Timestamp.pbobjc.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -759,40 +743,58 @@
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 */,
F4353D441AC06F31005A6198 /* GPBDictionaryTests+Int64.m in Sources */,
+ F40EE505206BF91E0071091A /* GPBCompileTest22.m in Sources */,
+ F40EE4F7206BF91E0071091A /* GPBCompileTest08.m in Sources */,
+ F40EE500206BF91E0071091A /* GPBCompileTest17.m in Sources */,
F4353D471AC06F31005A6198 /* GPBDictionaryTests+UInt64.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */,
- F4E675CC1B21D1610054530B /* SourceContext.pbobjc.m in Sources */,
+ F40EE506206BF91E0071091A /* GPBCompileTest23.m in Sources */,
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */,
F4487C811AAF62FC00531423 /* GPBMessageTests+Serialization.m in Sources */,
+ F40EE502206BF91E0071091A /* GPBCompileTest19.m in Sources */,
+ F40EE4F5206BF91E0071091A /* GPBCompileTest06.m in Sources */,
+ F40EE4FB206BF91E0071091A /* GPBCompileTest12.m in Sources */,
8B4248E61A929C9900BC1EC6 /* GPBWellKnownTypesTest.m in Sources */,
- F4E675CA1B21D1610054530B /* Empty.pbobjc.m in Sources */,
- F4E675CE1B21D1610054530B /* Type.pbobjc.m in Sources */,
+ F40EE4F2206BF91E0071091A /* GPBCompileTest03.m in Sources */,
+ F40EE501206BF91E0071091A /* GPBCompileTest18.m in Sources */,
+ F40EE4FC206BF91E0071091A /* GPBCompileTest13.m in Sources */,
+ F40EE4FE206BF91E0071091A /* GPBCompileTest15.m in Sources */,
+ F40EE4F6206BF91E0071091A /* GPBCompileTest07.m in Sources */,
F4353D1F1AB88243005A6198 /* GPBDescriptorTests.m in Sources */,
- F4E675CF1B21D1610054530B /* Wrappers.pbobjc.m in Sources */,
+ F40EE504206BF91E0071091A /* GPBCompileTest21.m in Sources */,
+ F40EE4FA206BF91E0071091A /* GPBCompileTest11.m in Sources */,
+ F4F8D8861D78A193002CE128 /* GPBUnittestProtos2.m in Sources */,
F4B51B1C1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */,
- F4E675C81B21D1610054530B /* Any.pbobjc.m in Sources */,
8B4248B41A8BD96E00BC1EC6 /* GPBSwiftTests.swift in Sources */,
+ F40EE512206C068D0071091A /* GPBCompileTest25.m in Sources */,
+ F4584D831ECCB53600803AB6 /* GPBExtensionRegistryTest.m in Sources */,
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
- F4E675CD1B21D1610054530B /* Struct.pbobjc.m in Sources */,
F4487C771AADF84900531423 /* GPBMessageTests+Runtime.m in Sources */,
+ F40EE4F1206BF91E0071091A /* GPBCompileTest02.m in Sources */,
F4353D431AC06F31005A6198 /* GPBDictionaryTests+Int32.m in Sources */,
+ F40EE4F4206BF91E0071091A /* GPBCompileTest05.m in Sources */,
+ F40EE4FD206BF91E0071091A /* GPBCompileTest14.m in Sources */,
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */,
+ F40EE4F3206BF91E0071091A /* GPBCompileTest04.m in Sources */,
+ F40EE4FF206BF91E0071091A /* GPBCompileTest16.m in Sources */,
F41C175D1833D3310064ED4D /* GPBPerfTests.m in Sources */,
F4353D421AC06F31005A6198 /* GPBDictionaryTests+Bool.m in Sources */,
F4487C851AAF6AC500531423 /* GPBMessageTests+Merge.m in Sources */,
+ F40EE4F0206BF91E0071091A /* GPBCompileTest01.m in Sources */,
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */,
F4353D451AC06F31005A6198 /* GPBDictionaryTests+String.m in Sources */,
F4353D461AC06F31005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
+ F40EE4F8206BF91E0071091A /* GPBCompileTest09.m in Sources */,
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */,
+ F4C4B9E71E1D97BF00D3B61D /* GPBDictionaryTests.m in Sources */,
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */,
- 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */,
8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */,
- F4E675CB1B21D1610054530B /* FieldMask.pbobjc.m in Sources */,
- 8B96157514CA019D00A2AC0B /* Descriptor.pbobjc.m in Sources */,
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */,
- F4E675C91B21D1610054530B /* Api.pbobjc.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -807,11 +809,6 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
- 8B9A5ED11831994600A9D33B /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = 8B9A5EA41831993600A9D33B /* iOSTestHarness */;
- targetProxy = 8B9A5ED01831994600A9D33B /* PBXContainerItemProxy */;
- };
8BBEA4BD147C729A00C4ADB7 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 7461B52D0F94FAF800A0C422 /* ProtocolBuffers */;
@@ -824,21 +821,11 @@
};
/* End PBXTargetDependency section */
-/* Begin PBXVariantGroup section */
- 8B9A5EAC1831993600A9D33B /* InfoPlist.strings */ = {
- isa = PBXVariantGroup;
- children = (
- 8B9A5EAD1831993600A9D33B /* en */,
- );
- name = InfoPlist.strings;
- sourceTree = "<group>";
- };
-/* End PBXVariantGroup section */
-
/* Begin XCBuildConfiguration section */
7461B52F0F94FAFA00A0C422 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
HEADER_SEARCH_PATHS = "$(SRCROOT)";
PRODUCT_NAME = ProtocolBuffers;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -848,48 +835,19 @@
7461B5300F94FAFA00A0C422 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
HEADER_SEARCH_PATHS = "$(SRCROOT)";
PRODUCT_NAME = ProtocolBuffers;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
- 8B9A5ECB1831993600A9D33B /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
- CLANG_ENABLE_OBJC_ARC = YES;
- INFOPLIST_FILE = "$(SRCROOT)/Tests/iOSTestHarness/Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.1;
- PRODUCT_BUNDLE_IDENTIFIER = "com.google.${PRODUCT_NAME:rfc1034identifier}";
- PRODUCT_NAME = "$(TARGET_NAME)";
- TARGETED_DEVICE_FAMILY = "1,2";
- WRAPPER_EXTENSION = app;
- };
- name = Debug;
- };
- 8B9A5ECC1831993600A9D33B /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
- CLANG_ENABLE_OBJC_ARC = YES;
- INFOPLIST_FILE = "$(SRCROOT)/Tests/iOSTestHarness/Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.1;
- PRODUCT_BUNDLE_IDENTIFIER = "com.google.${PRODUCT_NAME:rfc1034identifier}";
- PRODUCT_NAME = "$(TARGET_NAME)";
- TARGETED_DEVICE_FAMILY = "1,2";
- WRAPPER_EXTENSION = app;
- };
- name = Release;
- };
8BBEA4A7147C727100C4ADB7 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
FRAMEWORK_SEARCH_PATHS = (
- "\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
"$(inherited)",
);
@@ -898,17 +856,24 @@
"$(SRCROOT)",
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/usr/lib\"",
);
+ OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness";
+ WARNING_CFLAGS = (
+ "$(inherited)",
+ "-Wno-documentation-unknown-command",
+ "-Wno-reserved-id-macro",
+ "-Wno-direct-ivar-access",
+ );
};
name = Debug;
};
@@ -916,8 +881,8 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
FRAMEWORK_SEARCH_PATHS = (
- "\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
"$(inherited)",
);
@@ -926,16 +891,23 @@
"$(SRCROOT)",
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/usr/lib\"",
);
+ OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
+ SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness";
+ WARNING_CFLAGS = (
+ "$(inherited)",
+ "-Wno-documentation-unknown-command",
+ "-Wno-reserved-id-macro",
+ "-Wno-direct-ivar-access",
+ );
};
name = Release;
};
@@ -943,19 +915,34 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
+ CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
+ CLANG_WARN_ASSIGN_ENUM = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
@@ -973,16 +960,25 @@
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = NO;
- IPHONEOS_DEPLOYMENT_TARGET = 6.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
ONLY_ACTIVE_ARCH = YES;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
+ WARNING_CFLAGS = (
+ "-Wdocumentation-unknown-command",
+ "-Wundef",
+ "-Wreserved-id-macro",
+ "-Wswitch-enum",
+ "-Wdirect-ivar-access",
+ "-Woverriding-method-mismatch",
+ );
};
name = Debug;
};
@@ -990,19 +986,34 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
+ CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
+ CLANG_WARN_ASSIGN_ENUM = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
@@ -1018,21 +1029,32 @@
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = NO;
- IPHONEOS_DEPLOYMENT_TARGET = 6.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
+ WARNING_CFLAGS = (
+ "-Wdocumentation-unknown-command",
+ "-Wundef",
+ "-Wreserved-id-macro",
+ "-Wswitch-enum",
+ "-Wdirect-ivar-access",
+ "-Woverriding-method-mismatch",
+ );
};
name = Release;
};
F4487C6C1A9F8F8100531423 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
HEADER_SEARCH_PATHS = "$(SRCROOT)";
PRODUCT_NAME = TestSingleSourceBuild;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -1042,6 +1064,7 @@
F4487C6D1A9F8F8100531423 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
HEADER_SEARCH_PATHS = "$(SRCROOT)";
PRODUCT_NAME = TestSingleSourceBuild;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -1051,12 +1074,14 @@
F45BBC0F1B0CDB50002D064D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
};
name = Debug;
};
F45BBC101B0CDB50002D064D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
};
name = Release;
};
@@ -1072,15 +1097,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
- 8B9A5ECA1831993600A9D33B /* Build configuration list for PBXNativeTarget "iOSTestHarness" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 8B9A5ECB1831993600A9D33B /* Debug */,
- 8B9A5ECC1831993600A9D33B /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
8BBEA4BA147C728600C4ADB7 /* Build configuration list for PBXNativeTarget "UnitTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 00000000..18d98100
--- /dev/null
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IDEDidComputeMac32BitWarning</key>
+ <true/>
+</dict>
+</plist>
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/FFE465CA-0E74-40E8-9F09-500B66B7DCB2.plist b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/FFE465CA-0E74-40E8-9F09-500B66B7DCB2.plist
deleted file mode 100644
index 0ac0943a..00000000
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/FFE465CA-0E74-40E8-9F09-500B66B7DCB2.plist
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>classNames</key>
- <dict>
- <key>PerfTests</key>
- <dict>
- <key>testExtensionsPerformance</key>
- <dict>
- <key>com.apple.XCTPerformanceMetric_WallClockTime</key>
- <dict>
- <key>baselineAverage</key>
- <real>0.9</real>
- <key>baselineIntegrationDisplayName</key>
- <string>Feb 5, 2015, 9:42:41 AM</string>
- </dict>
- </dict>
- <key>testHas</key>
- <dict>
- <key>com.apple.XCTPerformanceMetric_WallClockTime</key>
- <dict>
- <key>baselineAverage</key>
- <real>0.09</real>
- <key>baselineIntegrationDisplayName</key>
- <string>Feb 5, 2015, 9:42:35 AM</string>
- </dict>
- </dict>
- <key>testMessagePerformance</key>
- <dict>
- <key>com.apple.XCTPerformanceMetric_WallClockTime</key>
- <dict>
- <key>baselineAverage</key>
- <real>0.57</real>
- <key>baselineIntegrationDisplayName</key>
- <string>Feb 5, 2015, 9:42:47 AM</string>
- </dict>
- </dict>
- <key>testPackedExtensionsPerformance</key>
- <dict>
- <key>com.apple.XCTPerformanceMetric_WallClockTime</key>
- <dict>
- <key>baselineAverage</key>
- <real>0.75</real>
- <key>baselineIntegrationDisplayName</key>
- <string>Feb 5, 2015, 9:42:51 AM</string>
- </dict>
- </dict>
- <key>testPackedTypesPerformance</key>
- <dict>
- <key>com.apple.XCTPerformanceMetric_WallClockTime</key>
- <dict>
- <key>baselineAverage</key>
- <real>0.26</real>
- <key>baselineIntegrationDisplayName</key>
- <string>Feb 5, 2015, 9:42:55 AM</string>
- </dict>
- </dict>
- </dict>
- </dict>
-</dict>
-</plist>
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/Info.plist b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/Info.plist
deleted file mode 100644
index 45bb9c1b..00000000
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/Info.plist
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>runDestinationsByUUID</key>
- <dict>
- <key>FFE465CA-0E74-40E8-9F09-500B66B7DCB2</key>
- <dict>
- <key>targetArchitecture</key>
- <string>arm64</string>
- <key>targetDevice</key>
- <dict>
- <key>modelCode</key>
- <string>iPhone7,1</string>
- <key>platformIdentifier</key>
- <string>com.apple.platform.iphoneos</string>
- </dict>
- </dict>
- </dict>
-</dict>
-</plist>
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
index 0b96b75f..77483d38 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0710"
+ LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -51,6 +51,12 @@
Identifier = "DescriptorTests">
</Test>
<Test
+ Identifier = "GPBAutocreatedArrayTests">
+ </Test>
+ <Test
+ Identifier = "GPBAutocreatedDictionaryTests">
+ </Test>
+ <Test
Identifier = "GPBBoolArrayTests">
</Test>
<Test
@@ -90,6 +96,9 @@
Identifier = "GPBEnumArrayTests">
</Test>
<Test
+ Identifier = "GPBExtensionRegistryTest">
+ </Test>
+ <Test
Identifier = "GPBFloatArrayTests">
</Test>
<Test
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
index 7d219bcd..bacbcba3 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0710"
+ LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -54,6 +54,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -94,16 +95,15 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
- <BuildableProductRunnable
- runnableDebuggingMode = "0">
+ <MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
- BlueprintIdentifier = "8B9A5EA41831993600A9D33B"
- BuildableName = "iOSTestHarness.app"
- BlueprintName = "iOSTestHarness"
+ BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
+ BuildableName = "libProtocolBuffers.a"
+ BlueprintName = "ProtocolBuffers"
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
</BuildableReference>
- </BuildableProductRunnable>
+ </MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
diff --git a/objectivec/README.md b/objectivec/README.md
index c7313e4f..21ac07d8 100644
--- a/objectivec/README.md
+++ b/objectivec/README.md
@@ -13,16 +13,17 @@ Requirements
The Objective C implementation requires:
- Objective C 2.0 Runtime (32bit & 64bit iOS, 64bit OS X).
-- Xcode 7.0 (or later).
+- Xcode 8.0 (or later).
- The library code does *not* use ARC (for performance reasons), but it all can
be called from ARC code.
Installation
------------
-The full distribution pulled from github includes the sources for both the
-compiler (protoc) and the runtime (this directory). To build the compiler
-and run the runtime tests, you can use:
+The distribution pulled from github includes the sources for both the
+compiler (protoc) and the runtime (this directory). After cloning the distribution
+and needed submodules ([see the src directory's README](../src/README.md)),
+to build the compiler and run the runtime tests, you can use:
$ objectivec/DevTools/full_mac_build.sh
@@ -33,19 +34,21 @@ Building
There are two ways to include the Runtime sources in your project:
-Add `objectivec/\*.h` & `objectivec/GPBProtocolBuffers.m` to your project.
+Add `objectivec/*.h`, `objectivec/google/protobuf/*.pbobjc.h`, and
+`objectivec/GPBProtocolBuffers.m` to your project.
*or*
-Add `objectivec/\*.h` & `objectivec/\*.m` except for
+Add `objectivec/*.h`, `objectivec/google/protobuf/*.pbobjc.h`,
+`objectivec/google/protobuf/*.pbobjc.m`, and `objectivec/*.m` except for
`objectivec/GPBProtocolBuffers.m` to your project.
If the target is using ARC, remember to turn off ARC (`-fno-objc-arc`) for the
`.m` files.
-The files generated by `protoc` for the `*.proto` files (`\*.pbobjc.h' and
-`\*.pbobjc.m`) are then also added to the target.
+The files generated by `protoc` for the `*.proto` files (`*.pbobjc.h` and
+`*.pbobjc.m`) are then also added to the target.
Usage
-----
@@ -123,8 +126,8 @@ never included when the message is encoded.
The Objective C classes/enums can be used from Swift code.
-Objective C Generator Options
------------------------------
+Objective C Generator Proto File Options
+----------------------------------------
**objc_class_prefix=\<prefix\>** (no default)
@@ -133,6 +136,42 @@ be collisions. This option provides a prefix that will be added to the Enums
and Objects (for messages) generated from the proto. Convention is to base
the prefix on the package the proto is in.
+Objective C Generator `protoc` Options
+--------------------------------------
+
+When generating Objective C code, `protoc` supports a `--objc_opt` argument; the
+argument is comma-delimited name/value pairs (_key=value,key2=value2_). The
+_keys_ are used to change the behavior during generation. The currently
+supported keys are:
+
+ * `generate_for_named_framework`: The `value` used for this key will be used
+ when generating the `#import` statements in the generated code. Instead
+ of being plain `#import "some/path/file.pbobjc.h"` lines, they will be
+ framework based, i.e. - `#import <VALUE/file.pbobjc.h>`.
+
+ _NOTE:_ If this is used with `named_framework_to_proto_path_mappings_path`,
+ then this is effectively the _default_ to use for everything that wasn't
+ mapped by the other.
+
+ * `named_framework_to_proto_path_mappings_path`: The `value` used for this key
+ is a path to a file containing the listing of framework names and proto
+ files. The generator uses this to decide if another proto file referenced
+ should use a framework style import vs. a user level import
+ (`#import <FRAMEWORK/file.pbobjc.h>` vs `#import "dir/file.pbobjc.h"`).
+
+ The format of the file is:
+ * An entry is a line of `frameworkName: file.proto, dir/file2.proto`.
+ * Comments start with `#`.
+ * A comment can go on a line after an entry.
+ (i.e. - `frameworkName: file.proto # comment`)
+
+ Any number of files can be listed for a framework, just separate them with
+ commas.
+
+ There can be multiple lines listing the same frameworkName incase it has a
+ lot of proto files included in it; and having multiple lines makes things
+ easier to read.
+
Contributing
------------
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj
new file mode 100644
index 00000000..b9df381a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj
@@ -0,0 +1,290 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ F4D5A0AE1CEE2D8F00562D79 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A0AD1CEE2D8F00562D79 /* AppDelegate.m */; };
+ F4D5A0B11CEE2D8F00562D79 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A0B01CEE2D8F00562D79 /* main.m */; };
+ F4D5A0B31CEE2D8F00562D79 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0B21CEE2D8F00562D79 /* Assets.xcassets */; };
+ F4D5A0B61CEE2D8F00562D79 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0B41CEE2D8F00562D79 /* MainMenu.xib */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ F4D5A0A91CEE2D8F00562D79 /* OSXCocoaPodsTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OSXCocoaPodsTester.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ F4D5A0AC1CEE2D8F00562D79 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ F4D5A0AD1CEE2D8F00562D79 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ F4D5A0B01CEE2D8F00562D79 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ F4D5A0B21CEE2D8F00562D79 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
+ F4D5A0B51CEE2D8F00562D79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
+ F4D5A0B71CEE2D8F00562D79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ F4D5A0A61CEE2D8F00562D79 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ F4D5A0A01CEE2D8F00562D79 = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0AB1CEE2D8F00562D79 /* OSXCocoaPodsTester */,
+ F4D5A0AA1CEE2D8F00562D79 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ F4D5A0AA1CEE2D8F00562D79 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0A91CEE2D8F00562D79 /* OSXCocoaPodsTester.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ F4D5A0AB1CEE2D8F00562D79 /* OSXCocoaPodsTester */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0AC1CEE2D8F00562D79 /* AppDelegate.h */,
+ F4D5A0AD1CEE2D8F00562D79 /* AppDelegate.m */,
+ F4D5A0B21CEE2D8F00562D79 /* Assets.xcassets */,
+ F4D5A0B41CEE2D8F00562D79 /* MainMenu.xib */,
+ F4D5A0B71CEE2D8F00562D79 /* Info.plist */,
+ F4D5A0AF1CEE2D8F00562D79 /* Supporting Files */,
+ );
+ path = OSXCocoaPodsTester;
+ sourceTree = "<group>";
+ };
+ F4D5A0AF1CEE2D8F00562D79 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0B01CEE2D8F00562D79 /* main.m */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ F4D5A0A81CEE2D8F00562D79 /* OSXCocoaPodsTester */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = F4D5A0BA1CEE2D8F00562D79 /* Build configuration list for PBXNativeTarget "OSXCocoaPodsTester" */;
+ buildPhases = (
+ F4D5A0A51CEE2D8F00562D79 /* Sources */,
+ F4D5A0A61CEE2D8F00562D79 /* Frameworks */,
+ F4D5A0A71CEE2D8F00562D79 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = OSXCocoaPodsTester;
+ productName = OSXCocoaPodsTester;
+ productReference = F4D5A0A91CEE2D8F00562D79 /* OSXCocoaPodsTester.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ F4D5A0A11CEE2D8F00562D79 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0730;
+ ORGANIZATIONNAME = Google;
+ TargetAttributes = {
+ F4D5A0A81CEE2D8F00562D79 = {
+ CreatedOnToolsVersion = 7.3.1;
+ };
+ };
+ };
+ buildConfigurationList = F4D5A0A41CEE2D8F00562D79 /* Build configuration list for PBXProject "OSXCocoaPodsTester" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = F4D5A0A01CEE2D8F00562D79;
+ productRefGroup = F4D5A0AA1CEE2D8F00562D79 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ F4D5A0A81CEE2D8F00562D79 /* OSXCocoaPodsTester */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ F4D5A0A71CEE2D8F00562D79 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F4D5A0B31CEE2D8F00562D79 /* Assets.xcassets in Resources */,
+ F4D5A0B61CEE2D8F00562D79 /* MainMenu.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ F4D5A0A51CEE2D8F00562D79 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F4D5A0B11CEE2D8F00562D79 /* main.m in Sources */,
+ F4D5A0AE1CEE2D8F00562D79 /* AppDelegate.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ F4D5A0B41CEE2D8F00562D79 /* MainMenu.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ F4D5A0B51CEE2D8F00562D79 /* Base */,
+ );
+ name = MainMenu.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ F4D5A0B81CEE2D8F00562D79 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ F4D5A0B91CEE2D8F00562D79 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ F4D5A0BB1CEE2D8F00562D79 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ COMBINE_HIDPI_IMAGES = YES;
+ INFOPLIST_FILE = OSXCocoaPodsTester/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.google.OSXCocoaPodsTester;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ F4D5A0BC1CEE2D8F00562D79 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ COMBINE_HIDPI_IMAGES = YES;
+ INFOPLIST_FILE = OSXCocoaPodsTester/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.google.OSXCocoaPodsTester;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ F4D5A0A41CEE2D8F00562D79 /* Build configuration list for PBXProject "OSXCocoaPodsTester" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F4D5A0B81CEE2D8F00562D79 /* Debug */,
+ F4D5A0B91CEE2D8F00562D79 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ F4D5A0BA1CEE2D8F00562D79 /* Build configuration list for PBXNativeTarget "OSXCocoaPodsTester" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F4D5A0BB1CEE2D8F00562D79 /* Debug */,
+ F4D5A0BC1CEE2D8F00562D79 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = F4D5A0A11CEE2D8F00562D79 /* Project object */;
+}
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 00000000..6d874e28
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:OSXCocoaPodsTester.xcodeproj">
+ </FileRef>
+</Workspace>
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme
new file mode 100644
index 00000000..56f8782e
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0730"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0A81CEE2D8F00562D79"
+ BuildableName = "OSXCocoaPodsTester.app"
+ BlueprintName = "OSXCocoaPodsTester"
+ ReferencedContainer = "container:OSXCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0A81CEE2D8F00562D79"
+ BuildableName = "OSXCocoaPodsTester.app"
+ BlueprintName = "OSXCocoaPodsTester"
+ ReferencedContainer = "container:OSXCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0A81CEE2D8F00562D79"
+ BuildableName = "OSXCocoaPodsTester.app"
+ BlueprintName = "OSXCocoaPodsTester"
+ ReferencedContainer = "container:OSXCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0A81CEE2D8F00562D79"
+ BuildableName = "OSXCocoaPodsTester.app"
+ BlueprintName = "OSXCocoaPodsTester"
+ ReferencedContainer = "container:OSXCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h
new file mode 100644
index 00000000..c7ab521d
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h
@@ -0,0 +1,37 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <Cocoa/Cocoa.h>
+
+@interface AppDelegate : NSObject <NSApplicationDelegate>
+
+
+@end
+
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m
new file mode 100644
index 00000000..08735a00
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m
@@ -0,0 +1,48 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "AppDelegate.h"
+
+@interface AppDelegate ()
+
+@property (weak) IBOutlet NSWindow *window;
+@end
+
+@implementation AppDelegate
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
+ // Insert code here to initialize your application
+}
+
+- (void)applicationWillTerminate:(NSNotification *)aNotification {
+ // Insert code here to tear down your application
+}
+
+@end
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 00000000..2db2b1c7
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,58 @@
+{
+ "images" : [
+ {
+ "idiom" : "mac",
+ "size" : "16x16",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "16x16",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "32x32",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "32x32",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "128x128",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "128x128",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "256x256",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "256x256",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "512x512",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "512x512",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+} \ No newline at end of file
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib
new file mode 100644
index 00000000..aa3547ca
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib
@@ -0,0 +1,680 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6233" systemVersion="14A329f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+ <dependencies>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6233"/>
+ </dependencies>
+ <objects>
+ <customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
+ <connections>
+ <outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
+ </connections>
+ </customObject>
+ <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+ <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+ <customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="">
+ <connections>
+ <outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
+ </connections>
+ </customObject>
+ <customObject id="YLy-65-1bz" customClass="NSFontManager"/>
+ <menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
+ <items>
+ <menuItem title="OSXCocoaPodsTester" id="1Xt-HY-uBw">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="OSXCocoaPodsTester" systemMenu="apple" id="uQy-DD-JDr">
+ <items>
+ <menuItem title="About OSXCocoaPodsTester" id="5kV-Vb-QxS">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
+ <menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
+ <menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
+ <menuItem title="Services" id="NMo-om-nkz">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
+ <menuItem title="Hide OSXCocoaPodsTester" keyEquivalent="h" id="Olw-nP-bQN">
+ <connections>
+ <action selector="hide:" target="-1" id="PnN-Uc-m68"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Show All" id="Kd2-mp-pUS">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
+ <menuItem title="Quit OSXCocoaPodsTester" keyEquivalent="q" id="4sb-4s-VLi">
+ <connections>
+ <action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="File" id="dMs-cI-mzQ">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="File" id="bib-Uj-vzu">
+ <items>
+ <menuItem title="New" keyEquivalent="n" id="Was-JA-tGl">
+ <connections>
+ <action selector="newDocument:" target="-1" id="4Si-XN-c54"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Open…" keyEquivalent="o" id="IAo-SY-fd9">
+ <connections>
+ <action selector="openDocument:" target="-1" id="bVn-NM-KNZ"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Open Recent" id="tXI-mr-wws">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="oas-Oc-fiZ">
+ <items>
+ <menuItem title="Clear Menu" id="vNY-rz-j42">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="clearRecentDocuments:" target="-1" id="Daa-9d-B3U"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="m54-Is-iLE"/>
+ <menuItem title="Close" keyEquivalent="w" id="DVo-aG-piG">
+ <connections>
+ <action selector="performClose:" target="-1" id="HmO-Ls-i7Q"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Save…" keyEquivalent="s" id="pxx-59-PXV">
+ <connections>
+ <action selector="saveDocument:" target="-1" id="teZ-XB-qJY"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Save As…" keyEquivalent="S" id="Bw7-FT-i3A">
+ <connections>
+ <action selector="saveDocumentAs:" target="-1" id="mDf-zr-I0C"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Revert to Saved" id="KaW-ft-85H">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="revertDocumentToSaved:" target="-1" id="iJ3-Pv-kwq"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="aJh-i4-bef"/>
+ <menuItem title="Page Setup…" keyEquivalent="P" id="qIS-W8-SiK">
+ <modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
+ <connections>
+ <action selector="runPageLayout:" target="-1" id="Din-rz-gC5"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Print…" keyEquivalent="p" id="aTl-1u-JFS">
+ <connections>
+ <action selector="print:" target="-1" id="qaZ-4w-aoO"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Edit" id="5QF-Oa-p0T">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Edit" id="W48-6f-4Dl">
+ <items>
+ <menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg">
+ <connections>
+ <action selector="undo:" target="-1" id="M6e-cu-g7V"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam">
+ <connections>
+ <action selector="redo:" target="-1" id="oIA-Rs-6OD"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/>
+ <menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG">
+ <connections>
+ <action selector="cut:" target="-1" id="YJe-68-I9s"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU">
+ <connections>
+ <action selector="copy:" target="-1" id="G1f-GL-Joy"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL">
+ <connections>
+ <action selector="paste:" target="-1" id="UvS-8e-Qdg"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Delete" id="pa3-QI-u2k">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="delete:" target="-1" id="0Mk-Ml-PaM"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m">
+ <connections>
+ <action selector="selectAll:" target="-1" id="VNm-Mi-diN"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/>
+ <menuItem title="Find" id="4EN-yA-p0u">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Find" id="1b7-l0-nxx">
+ <items>
+ <menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
+ <connections>
+ <action selector="centerSelectionInVisibleArea:" target="-1" id="IOG-6D-g5B"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Spelling and Grammar" id="Dv1-io-Yv7">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Spelling" id="3IN-sU-3Bg">
+ <items>
+ <menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI">
+ <connections>
+ <action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7">
+ <connections>
+ <action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="bNw-od-mp5"/>
+ <menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Correct Spelling Automatically" id="78Y-hA-62v">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Substitutions" id="9ic-FL-obx">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Substitutions" id="FeM-D8-WVr">
+ <items>
+ <menuItem title="Show Substitutions" id="z6F-FW-3nz">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/>
+ <menuItem title="Smart Copy/Paste" id="9yt-4B-nSM">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Smart Quotes" id="hQb-2v-fYv">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Smart Dashes" id="rgM-f4-ycn">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Smart Links" id="cwL-P1-jid">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Data Detectors" id="tRr-pd-1PS">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Text Replacement" id="HFQ-gK-NFA">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Transformations" id="2oI-Rn-ZJC">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Transformations" id="c8a-y6-VQd">
+ <items>
+ <menuItem title="Make Upper Case" id="vmV-6d-7jI">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="uppercaseWord:" target="-1" id="sPh-Tk-edu"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Make Lower Case" id="d9M-CD-aMd">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="lowercaseWord:" target="-1" id="iUZ-b5-hil"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Capitalize" id="UEZ-Bs-lqG">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="capitalizeWord:" target="-1" id="26H-TL-nsh"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Speech" id="xrE-MZ-jX0">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Speech" id="3rS-ZA-NoH">
+ <items>
+ <menuItem title="Start Speaking" id="Ynk-f8-cLZ">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Stop Speaking" id="Oyz-dy-DGm">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Format" id="jxT-CU-nIS">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Format" id="GEO-Iw-cKr">
+ <items>
+ <menuItem title="Font" id="Gi5-1S-RQB">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Font" systemMenu="font" id="aXa-aM-Jaq">
+ <items>
+ <menuItem title="Show Fonts" keyEquivalent="t" id="Q5e-8K-NDq">
+ <connections>
+ <action selector="orderFrontFontPanel:" target="YLy-65-1bz" id="WHr-nq-2xA"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Bold" tag="2" keyEquivalent="b" id="GB9-OM-e27">
+ <connections>
+ <action selector="addFontTrait:" target="YLy-65-1bz" id="hqk-hr-sYV"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Italic" tag="1" keyEquivalent="i" id="Vjx-xi-njq">
+ <connections>
+ <action selector="addFontTrait:" target="YLy-65-1bz" id="IHV-OB-c03"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Underline" keyEquivalent="u" id="WRG-CD-K1S">
+ <connections>
+ <action selector="underline:" target="-1" id="FYS-2b-JAY"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="5gT-KC-WSO"/>
+ <menuItem title="Bigger" tag="3" keyEquivalent="+" id="Ptp-SP-VEL">
+ <connections>
+ <action selector="modifyFont:" target="YLy-65-1bz" id="Uc7-di-UnL"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Smaller" tag="4" keyEquivalent="-" id="i1d-Er-qST">
+ <connections>
+ <action selector="modifyFont:" target="YLy-65-1bz" id="HcX-Lf-eNd"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="kx3-Dk-x3B"/>
+ <menuItem title="Kern" id="jBQ-r6-VK2">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Kern" id="tlD-Oa-oAM">
+ <items>
+ <menuItem title="Use Default" id="GUa-eO-cwY">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="useStandardKerning:" target="-1" id="6dk-9l-Ckg"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Use None" id="cDB-IK-hbR">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="turnOffKerning:" target="-1" id="U8a-gz-Maa"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Tighten" id="46P-cB-AYj">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="tightenKerning:" target="-1" id="hr7-Nz-8ro"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Loosen" id="ogc-rX-tC1">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="loosenKerning:" target="-1" id="8i4-f9-FKE"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Ligatures" id="o6e-r0-MWq">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Ligatures" id="w0m-vy-SC9">
+ <items>
+ <menuItem title="Use Default" id="agt-UL-0e3">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="useStandardLigatures:" target="-1" id="7uR-wd-Dx6"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Use None" id="J7y-lM-qPV">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="turnOffLigatures:" target="-1" id="iX2-gA-Ilz"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Use All" id="xQD-1f-W4t">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="useAllLigatures:" target="-1" id="KcB-kA-TuK"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Baseline" id="OaQ-X3-Vso">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Baseline" id="ijk-EB-dga">
+ <items>
+ <menuItem title="Use Default" id="3Om-Ey-2VK">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="unscript:" target="-1" id="0vZ-95-Ywn"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Superscript" id="Rqc-34-cIF">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="superscript:" target="-1" id="3qV-fo-wpU"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Subscript" id="I0S-gh-46l">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="subscript:" target="-1" id="Q6W-4W-IGz"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Raise" id="2h7-ER-AoG">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="raiseBaseline:" target="-1" id="4sk-31-7Q9"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Lower" id="1tx-W0-xDw">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="lowerBaseline:" target="-1" id="OF1-bc-KW4"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="Ndw-q3-faq"/>
+ <menuItem title="Show Colors" keyEquivalent="C" id="bgn-CT-cEk">
+ <connections>
+ <action selector="orderFrontColorPanel:" target="-1" id="mSX-Xz-DV3"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="iMs-zA-UFJ"/>
+ <menuItem title="Copy Style" keyEquivalent="c" id="5Vv-lz-BsD">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="copyFont:" target="-1" id="GJO-xA-L4q"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Paste Style" keyEquivalent="v" id="vKC-jM-MkH">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="pasteFont:" target="-1" id="JfD-CL-leO"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Text" id="Fal-I4-PZk">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Text" id="d9c-me-L2H">
+ <items>
+ <menuItem title="Align Left" keyEquivalent="{" id="ZM1-6Q-yy1">
+ <connections>
+ <action selector="alignLeft:" target="-1" id="zUv-R1-uAa"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Center" keyEquivalent="|" id="VIY-Ag-zcb">
+ <connections>
+ <action selector="alignCenter:" target="-1" id="spX-mk-kcS"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Justify" id="J5U-5w-g23">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="alignJustified:" target="-1" id="ljL-7U-jND"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Align Right" keyEquivalent="}" id="wb2-vD-lq4">
+ <connections>
+ <action selector="alignRight:" target="-1" id="r48-bG-YeY"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="4s2-GY-VfK"/>
+ <menuItem title="Writing Direction" id="H1b-Si-o9J">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Writing Direction" id="8mr-sm-Yjd">
+ <items>
+ <menuItem title="Paragraph" enabled="NO" id="ZvO-Gk-QUH">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ </menuItem>
+ <menuItem id="YGs-j5-SAR">
+ <string key="title"> Default</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeBaseWritingDirectionNatural:" target="-1" id="qtV-5e-UBP"/>
+ </connections>
+ </menuItem>
+ <menuItem id="Lbh-J2-qVU">
+ <string key="title"> Left to Right</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeBaseWritingDirectionLeftToRight:" target="-1" id="S0X-9S-QSf"/>
+ </connections>
+ </menuItem>
+ <menuItem id="jFq-tB-4Kx">
+ <string key="title"> Right to Left</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeBaseWritingDirectionRightToLeft:" target="-1" id="5fk-qB-AqJ"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="swp-gr-a21"/>
+ <menuItem title="Selection" enabled="NO" id="cqv-fj-IhA">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ </menuItem>
+ <menuItem id="Nop-cj-93Q">
+ <string key="title"> Default</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeTextWritingDirectionNatural:" target="-1" id="lPI-Se-ZHp"/>
+ </connections>
+ </menuItem>
+ <menuItem id="BgM-ve-c93">
+ <string key="title"> Left to Right</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeTextWritingDirectionLeftToRight:" target="-1" id="caW-Bv-w94"/>
+ </connections>
+ </menuItem>
+ <menuItem id="RB4-Sm-HuC">
+ <string key="title"> Right to Left</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeTextWritingDirectionRightToLeft:" target="-1" id="EXD-6r-ZUu"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="fKy-g9-1gm"/>
+ <menuItem title="Show Ruler" id="vLm-3I-IUL">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleRuler:" target="-1" id="FOx-HJ-KwY"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Copy Ruler" keyEquivalent="c" id="MkV-Pr-PK5">
+ <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
+ <connections>
+ <action selector="copyRuler:" target="-1" id="71i-fW-3W2"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Paste Ruler" keyEquivalent="v" id="LVM-kO-fVI">
+ <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
+ <connections>
+ <action selector="pasteRuler:" target="-1" id="cSh-wd-qM2"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="View" id="H8h-7b-M4v">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="View" id="HyV-fh-RgO">
+ <items>
+ <menuItem title="Show Toolbar" keyEquivalent="t" id="snW-S8-Cw5">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="toggleToolbarShown:" target="-1" id="BXY-wc-z0C"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Customize Toolbar…" id="1UK-8n-QPP">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="runToolbarCustomizationPalette:" target="-1" id="pQI-g3-MTW"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Window" id="aUF-d1-5bR">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
+ <items>
+ <menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
+ <connections>
+ <action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Zoom" id="R4o-n2-Eq4">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="performZoom:" target="-1" id="DIl-cC-cCs"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
+ <menuItem title="Bring All to Front" id="LE2-aR-0XJ">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Help" id="wpr-3q-Mcd">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
+ <items>
+ <menuItem title="OSXCocoaPodsTester Help" keyEquivalent="?" id="FKE-Sm-Kum">
+ <connections>
+ <action selector="showHelp:" target="-1" id="y7X-2Q-9no"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ </items>
+ </menu>
+ <window title="OSXCocoaPodsTester" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
+ <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+ <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+ <rect key="contentRect" x="335" y="390" width="480" height="360"/>
+ <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
+ <view key="contentView" id="EiT-Mj-1SZ">
+ <rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </view>
+ </window>
+ </objects>
+</document>
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist
new file mode 100644
index 00000000..ed806e40
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2016 Google. All rights reserved.</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m
new file mode 100644
index 00000000..b230090e
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m
@@ -0,0 +1,35 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, const char * argv[]) {
+ return NSApplicationMain(argc, argv);
+}
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework
new file mode 100644
index 00000000..27eeafc9
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework
@@ -0,0 +1,10 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :osx, '10.9'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+use_frameworks!
+
+target 'OSXCocoaPodsTester' do
+ pod 'Protobuf', :path => '../../../..'
+end
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static
new file mode 100644
index 00000000..5dfc8de5
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static
@@ -0,0 +1,8 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :osx, '10.9'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+target 'OSXCocoaPodsTester' do
+ pod 'Protobuf', :path => '../../../..'
+end
diff --git a/objectivec/Tests/CocoaPods/README.md b/objectivec/Tests/CocoaPods/README.md
new file mode 100644
index 00000000..08785918
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/README.md
@@ -0,0 +1,9 @@
+CocoaPods Protocol Buffers Integration Tests
+============================================
+
+The sub directories are the basic projects as created by Xcode 6.3. They are
+used to then drive `pod` and `xcodebuild` to ensure things integrate/build
+as expected.
+
+`run_tests.sh` defaults to running all the tests, invoke it with `--help` to
+see the arguments to control what tests are run.
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework
new file mode 100644
index 00000000..913a289b
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework
@@ -0,0 +1,10 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+use_frameworks!
+
+target 'iOSCocoaPodsTester' do
+ pod 'Protobuf', :path => '../../../..'
+end
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static
new file mode 100644
index 00000000..e9b3c235
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static
@@ -0,0 +1,8 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+target 'iOSCocoaPodsTester' do
+ pod 'Protobuf', :path => '../../../..'
+end
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj
new file mode 100644
index 00000000..27fb553f
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj
@@ -0,0 +1,309 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ F4D5A08B1CEE01E200562D79 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A08A1CEE01E200562D79 /* main.m */; };
+ F4D5A08E1CEE01E200562D79 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A08D1CEE01E200562D79 /* AppDelegate.m */; };
+ F4D5A0911CEE01E200562D79 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A0901CEE01E200562D79 /* ViewController.m */; };
+ F4D5A0941CEE01E200562D79 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0921CEE01E200562D79 /* Main.storyboard */; };
+ F4D5A0961CEE01E200562D79 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0951CEE01E200562D79 /* Assets.xcassets */; };
+ F4D5A0991CEE01E200562D79 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0971CEE01E200562D79 /* LaunchScreen.storyboard */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ F4D5A0861CEE01E200562D79 /* iOSCocoaPodsTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSCocoaPodsTester.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ F4D5A08A1CEE01E200562D79 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ F4D5A08C1CEE01E200562D79 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ F4D5A08D1CEE01E200562D79 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ F4D5A08F1CEE01E200562D79 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
+ F4D5A0901CEE01E200562D79 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
+ F4D5A0931CEE01E200562D79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
+ F4D5A0951CEE01E200562D79 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
+ F4D5A0981CEE01E200562D79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
+ F4D5A09A1CEE01E200562D79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ F4D5A0831CEE01E200562D79 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ F4D5A07D1CEE01E200562D79 = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0881CEE01E200562D79 /* iOSCocoaPodsTester */,
+ F4D5A0871CEE01E200562D79 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ F4D5A0871CEE01E200562D79 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0861CEE01E200562D79 /* iOSCocoaPodsTester.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ F4D5A0881CEE01E200562D79 /* iOSCocoaPodsTester */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A08C1CEE01E200562D79 /* AppDelegate.h */,
+ F4D5A08D1CEE01E200562D79 /* AppDelegate.m */,
+ F4D5A08F1CEE01E200562D79 /* ViewController.h */,
+ F4D5A0901CEE01E200562D79 /* ViewController.m */,
+ F4D5A0921CEE01E200562D79 /* Main.storyboard */,
+ F4D5A0951CEE01E200562D79 /* Assets.xcassets */,
+ F4D5A0971CEE01E200562D79 /* LaunchScreen.storyboard */,
+ F4D5A09A1CEE01E200562D79 /* Info.plist */,
+ F4D5A0891CEE01E200562D79 /* Supporting Files */,
+ );
+ path = iOSCocoaPodsTester;
+ sourceTree = "<group>";
+ };
+ F4D5A0891CEE01E200562D79 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A08A1CEE01E200562D79 /* main.m */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ F4D5A0851CEE01E200562D79 /* iOSCocoaPodsTester */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = F4D5A09D1CEE01E200562D79 /* Build configuration list for PBXNativeTarget "iOSCocoaPodsTester" */;
+ buildPhases = (
+ F4D5A0821CEE01E200562D79 /* Sources */,
+ F4D5A0831CEE01E200562D79 /* Frameworks */,
+ F4D5A0841CEE01E200562D79 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = iOSCocoaPodsTester;
+ productName = iOSCocoaPodsTester;
+ productReference = F4D5A0861CEE01E200562D79 /* iOSCocoaPodsTester.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ F4D5A07E1CEE01E200562D79 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0730;
+ ORGANIZATIONNAME = Google;
+ TargetAttributes = {
+ F4D5A0851CEE01E200562D79 = {
+ CreatedOnToolsVersion = 7.3.1;
+ };
+ };
+ };
+ buildConfigurationList = F4D5A0811CEE01E200562D79 /* Build configuration list for PBXProject "iOSCocoaPodsTester" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = F4D5A07D1CEE01E200562D79;
+ productRefGroup = F4D5A0871CEE01E200562D79 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ F4D5A0851CEE01E200562D79 /* iOSCocoaPodsTester */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ F4D5A0841CEE01E200562D79 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F4D5A0991CEE01E200562D79 /* LaunchScreen.storyboard in Resources */,
+ F4D5A0961CEE01E200562D79 /* Assets.xcassets in Resources */,
+ F4D5A0941CEE01E200562D79 /* Main.storyboard in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ F4D5A0821CEE01E200562D79 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F4D5A0911CEE01E200562D79 /* ViewController.m in Sources */,
+ F4D5A08E1CEE01E200562D79 /* AppDelegate.m in Sources */,
+ F4D5A08B1CEE01E200562D79 /* main.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ F4D5A0921CEE01E200562D79 /* Main.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ F4D5A0931CEE01E200562D79 /* Base */,
+ );
+ name = Main.storyboard;
+ sourceTree = "<group>";
+ };
+ F4D5A0971CEE01E200562D79 /* LaunchScreen.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ F4D5A0981CEE01E200562D79 /* Base */,
+ );
+ name = LaunchScreen.storyboard;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ F4D5A09B1CEE01E200562D79 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ F4D5A09C1CEE01E200562D79 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ F4D5A09E1CEE01E200562D79 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ INFOPLIST_FILE = iOSCocoaPodsTester/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.google.iOSCocoaPodsTester;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ F4D5A09F1CEE01E200562D79 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ INFOPLIST_FILE = iOSCocoaPodsTester/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.google.iOSCocoaPodsTester;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ F4D5A0811CEE01E200562D79 /* Build configuration list for PBXProject "iOSCocoaPodsTester" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F4D5A09B1CEE01E200562D79 /* Debug */,
+ F4D5A09C1CEE01E200562D79 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ F4D5A09D1CEE01E200562D79 /* Build configuration list for PBXNativeTarget "iOSCocoaPodsTester" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F4D5A09E1CEE01E200562D79 /* Debug */,
+ F4D5A09F1CEE01E200562D79 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = F4D5A07E1CEE01E200562D79 /* Project object */;
+}
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 00000000..008f7b4a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:iOSCocoaPodsTester.xcodeproj">
+ </FileRef>
+</Workspace>
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme
new file mode 100644
index 00000000..9558dd7a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0730"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0851CEE01E200562D79"
+ BuildableName = "iOSCocoaPodsTester.app"
+ BlueprintName = "iOSCocoaPodsTester"
+ ReferencedContainer = "container:iOSCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0851CEE01E200562D79"
+ BuildableName = "iOSCocoaPodsTester.app"
+ BlueprintName = "iOSCocoaPodsTester"
+ ReferencedContainer = "container:iOSCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0851CEE01E200562D79"
+ BuildableName = "iOSCocoaPodsTester.app"
+ BlueprintName = "iOSCocoaPodsTester"
+ ReferencedContainer = "container:iOSCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0851CEE01E200562D79"
+ BuildableName = "iOSCocoaPodsTester.app"
+ BlueprintName = "iOSCocoaPodsTester"
+ ReferencedContainer = "container:iOSCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h
new file mode 100644
index 00000000..5eca690c
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h
@@ -0,0 +1,39 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <UIKit/UIKit.h>
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+
+@end
+
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m
new file mode 100644
index 00000000..dd7b969a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m
@@ -0,0 +1,67 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "AppDelegate.h"
+
+@interface AppDelegate ()
+
+@end
+
+@implementation AppDelegate
+
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+ // Override point for customization after application launch.
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json
index 0cbf9acc..36d2c80d 100644
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -3,11 +3,6 @@
{
"idiom" : "iphone",
"size" : "29x29",
- "scale" : "1x"
- },
- {
- "idiom" : "iphone",
- "size" : "29x29",
"scale" : "2x"
},
{
@@ -26,27 +21,13 @@
"scale" : "3x"
},
{
- "size" : "57x57",
- "idiom" : "iphone",
- "filename" : "iPhone6.png",
- "scale" : "1x"
- },
- {
- "size" : "57x57",
"idiom" : "iphone",
- "filename" : "iPhone6_2x.png",
- "scale" : "2x"
- },
- {
"size" : "60x60",
- "idiom" : "iphone",
- "filename" : "iPhone7_2x.png",
"scale" : "2x"
},
{
- "size" : "60x60",
"idiom" : "iphone",
- "filename" : "iPhone7_3x.png",
+ "size" : "60x60",
"scale" : "3x"
},
{
@@ -71,46 +52,17 @@
},
{
"idiom" : "ipad",
- "size" : "50x50",
- "scale" : "1x"
- },
- {
- "idiom" : "ipad",
- "size" : "50x50",
- "scale" : "2x"
- },
- {
- "size" : "72x72",
- "idiom" : "ipad",
- "filename" : "iPad6.png",
- "scale" : "1x"
- },
- {
- "size" : "72x72",
- "idiom" : "ipad",
- "filename" : "iPad6_2x.png",
- "scale" : "2x"
- },
- {
"size" : "76x76",
- "idiom" : "ipad",
- "filename" : "iPad7.png",
"scale" : "1x"
},
{
- "size" : "76x76",
"idiom" : "ipad",
- "filename" : "iPad7_2x.png",
+ "size" : "76x76",
"scale" : "2x"
- },
- {
- "idiom" : "car",
- "size" : "120x120",
- "scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
-}
+} \ No newline at end of file
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard
new file mode 100644
index 00000000..2e721e18
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
+ <dependencies>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
+ </dependencies>
+ <scenes>
+ <!--View Controller-->
+ <scene sceneID="EHf-IW-A2E">
+ <objects>
+ <viewController id="01J-lp-oVM" sceneMemberID="viewController">
+ <layoutGuides>
+ <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
+ <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
+ </layoutGuides>
+ <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
+ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <animations/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </view>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="53" y="375"/>
+ </scene>
+ </scenes>
+</document>
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard
new file mode 100644
index 00000000..82cd159a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
+ <dependencies>
+ <deployment identifier="iOS"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
+ </dependencies>
+ <scenes>
+ <!--View Controller-->
+ <scene sceneID="tne-QT-ifu">
+ <objects>
+ <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
+ <layoutGuides>
+ <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
+ <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
+ </layoutGuides>
+ <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
+ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </view>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
+ </objects>
+ </scene>
+ </scenes>
+</document>
diff --git a/objectivec/Tests/iOSTestHarness/Info.plist b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist
index 24bd333d..40c6215d 100644
--- a/objectivec/Tests/iOSTestHarness/Info.plist
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist
@@ -4,16 +4,14 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
- <key>CFBundleDisplayName</key>
- <string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
+ <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
+ <string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
@@ -21,11 +19,17 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.0</string>
+ <string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
+ <key>UIMainStoryboardFile</key>
+ <string>Main</string>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
@@ -35,9 +39,9 @@
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
- <string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
</dict>
</plist>
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h
new file mode 100644
index 00000000..777257b8
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h
@@ -0,0 +1,37 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <UIKit/UIKit.h>
+
+@interface ViewController : UIViewController
+
+
+@end
+
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m
new file mode 100644
index 00000000..c3b7e6c0
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m
@@ -0,0 +1,49 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "ViewController.h"
+
+@interface ViewController ()
+
+@end
+
+@implementation ViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ // Do any additional setup after loading the view, typically from a nib.
+}
+
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
+}
+
+@end
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m
new file mode 100644
index 00000000..4df0b769
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m
@@ -0,0 +1,39 @@
+//
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <UIKit/UIKit.h>
+#import "AppDelegate.h"
+
+int main(int argc, char * argv[]) {
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+ }
+}
diff --git a/objectivec/Tests/CocoaPods/run_tests.sh b/objectivec/Tests/CocoaPods/run_tests.sh
new file mode 100755
index 00000000..6d3e12be
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/run_tests.sh
@@ -0,0 +1,150 @@
+#!/bin/bash
+#
+# Helper to run the pods tests.
+
+set -eu
+
+readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
+
+printUsage() {
+ NAME=$(basename "${0}")
+ cat << EOF
+usage: ${NAME} [OPTIONS]
+
+This script runs some test to check the CocoaPods integration.
+
+OPTIONS:
+
+ General:
+
+ -h, --help
+ Show this message
+ --skip-static
+ Skip the static based pods tests.
+ --skip-framework
+ Skip the framework based pods tests.
+ --skip-ios
+ Skip the iOS pods tests.
+ --skip-osx
+ Skip the OS X pods tests.
+
+EOF
+}
+
+TEST_MODES=( "static" "framework" )
+TEST_NAMES=( "iOSCocoaPodsTester" "OSXCocoaPodsTester" )
+while [[ $# != 0 ]]; do
+ case "${1}" in
+ -h | --help )
+ printUsage
+ exit 0
+ ;;
+ --skip-static )
+ TEST_MODES=(${TEST_MODES[@]/static})
+ ;;
+ --skip-framework )
+ TEST_MODES=(${TEST_MODES[@]/framework})
+ ;;
+ --skip-ios )
+ TEST_NAMES=(${TEST_NAMES[@]/iOSCocoaPodsTester})
+ ;;
+ --skip-osx )
+ TEST_NAMES=(${TEST_NAMES[@]/OSXCocoaPodsTester})
+ ;;
+ -*)
+ echo "ERROR: Unknown option: ${1}" 1>&2
+ printUsage
+ exit 1
+ ;;
+ *)
+ echo "ERROR: Unknown argument: ${1}" 1>&2
+ printUsage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+# Sanity check.
+if [[ "${#TEST_NAMES[@]}" == 0 ]] ; then
+ echo "ERROR: Need to run at least iOS or OS X tests." 1>&2
+ exit 2
+fi
+if [[ "${#TEST_MODES[@]}" == 0 ]] ; then
+ echo "ERROR: Need to run at least static or frameworks tests." 1>&2
+ exit 2
+fi
+
+header() {
+ echo ""
+ echo "========================================================================"
+ echo " ${@}"
+ echo "========================================================================"
+ echo ""
+}
+
+# Cleanup hook for do_test, assumes directory is correct.
+cleanup() {
+ local TEST_NAME="$1"
+
+ echo "Cleaning up..."
+
+ # Generally don't let things fail, and eat common stdout, but let stderr show
+ # incase something does hiccup.
+ xcodebuild -workspace "${TEST_NAME}.xcworkspace" -scheme "${TEST_NAME}" clean > /dev/null || true
+ pod deintegrate > /dev/null || true
+ # Flush the cache so nothing is left behind.
+ pod cache clean --all || true
+ # Delete the files left after pod deintegrate.
+ rm -f Podfile.lock || true
+ rm -rf "${TEST_NAME}.xcworkspace" || true
+ git checkout -- "${TEST_NAME}.xcodeproj" || true
+ # Remove the Podfile that was put in place.
+ rm -f Podfile || true
+}
+
+do_test() {
+ local TEST_NAME="$1"
+ local TEST_MODE="$2"
+
+ header "${TEST_NAME}" - Mode: "${TEST_MODE}"
+ cd "${ScriptDir}/${TEST_NAME}"
+
+ # Hook in cleanup for any failures.
+ trap "cleanup ${TEST_NAME}" EXIT
+
+ # Ensure nothing is cached by pods to start with that could throw things off.
+ pod cache clean --all
+
+ # Put the right Podfile in place.
+ cp -f "Podfile-${TEST_MODE}" "Podfile"
+
+ xcodebuild_args=( "-workspace" "${TEST_NAME}.xcworkspace" "-scheme" "${TEST_NAME}" )
+
+ # For iOS, if the SDK is not provided it tries to use iphoneos, and the test
+ # fail on Travis since those machines don't have a Code Signing identity.
+ if [[ "${TEST_NAME}" == iOS* ]] ; then
+ # Apparently the destination flag is required to avoid "Unsupported architecture"
+ # errors.
+ xcodebuild_args+=(
+ -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO
+ -destination "platform=iOS Simulator,name=iPad 2,OS=9.3"
+ )
+ fi
+
+ # Do the work!
+ pod install --verbose
+
+ xcodebuild "${xcodebuild_args[@]}" build
+
+ # Clear the hook and manually run cleanup.
+ trap - EXIT
+ cleanup "${TEST_NAME}"
+}
+
+# Run the tests.
+for TEST_NAME in "${TEST_NAMES[@]}" ; do
+ for TEST_MODE in "${TEST_MODES[@]}" ; do
+ do_test "${TEST_NAME}" "${TEST_MODE}"
+ done
+done
diff --git a/objectivec/Tests/GPBARCUnittestProtos.m b/objectivec/Tests/GPBARCUnittestProtos.m
index d0408869..29f6ccf6 100644
--- a/objectivec/Tests/GPBARCUnittestProtos.m
+++ b/objectivec/Tests/GPBARCUnittestProtos.m
@@ -34,9 +34,16 @@
// Makes sure all the generated headers compile with ARC on.
+// 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"
diff --git a/objectivec/Tests/GPBArrayTests.m b/objectivec/Tests/GPBArrayTests.m
index 0fb15e40..e414d90a 100644
--- a/objectivec/Tests/GPBArrayTests.m
+++ b/objectivec/Tests/GPBArrayTests.m
@@ -32,12 +32,14 @@
#import <XCTest/XCTest.h>
#import "GPBArray.h"
+#import "GPBArray_PackagePrivate.h"
#import "GPBTestUtilities.h"
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBEnumArray (TestingTweak)
+ (instancetype)arrayWithValue:(int32_t)value;
++ (instancetype)arrayWithCapacity:(NSUInteger)count;
- (instancetype)initWithValues:(const int32_t [])values
count:(NSUInteger)count;
@end
@@ -71,6 +73,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
rawValues:&value
count:1] autorelease];
}
++ (instancetype)arrayWithCapacity:(NSUInteger)count {
+ return [[[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
+ capacity:count] autorelease];
+}
- (instancetype)initWithValues:(const int32_t [])values
count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
@@ -176,6 +182,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% XCTAssertNotEqual(idx, 0U);
//% ++idx2;
//% }];
+//% // Ensure description doesn't choke.
+//% XCTAssertTrue(array.description.length > 10);
//% [array release];
//%}
//%
@@ -200,6 +208,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% NAME$S count:GPBARRAYSIZE(kValues3)];
//% XCTAssertNotNil(array3);
//%
+//% // Identity
+//% XCTAssertTrue([array1 isEqual:array1]);
+//% // Wrong type doesn't blow up.
+//% XCTAssertFalse([array1 isEqual:@"bogus"]);
//% // 1/1Prime should be different objects, but equal.
//% XCTAssertNotEqual(array1, array1prime);
//% XCTAssertEqualObjects(array1, array1prime);
@@ -270,6 +282,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% [array add##HELPER##ValuesFromArray:array2];
//% XCTAssertEqual(array.count, 5U);
//%
+//% // Zero/nil inputs do nothing.
+//% [array addValues:kValues1 count:0];
+//% XCTAssertEqual(array.count, 5U);
+//% [array addValues:NULL count:5];
+//% XCTAssertEqual(array.count, 5U);
+//%
//% XCTAssertEqual([array valueAtIndex:0], VAL1);
//% XCTAssertEqual([array valueAtIndex:1], VAL2);
//% XCTAssertEqual([array valueAtIndex:2], VAL3);
@@ -390,9 +408,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//%- (void)testInternalResizing {
//% const TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 };
//% GPB##NAME##Array *array =
-//% [[GPB##NAME##Array alloc] initWithValues:kValues
-//% NAME$S count:GPBARRAYSIZE(kValues)];
+//% [GPB##NAME##Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(array);
+//% [array addValues:kValues count:GPBARRAYSIZE(kValues)];
//%
//% // Add/remove to trigger the intneral buffer to grow/shrink.
//% for (int i = 0; i < 100; ++i) {
@@ -409,7 +427,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% XCTAssertEqual(array.count, 404U);
//% [array removeAll];
//% XCTAssertEqual(array.count, 0U);
-//% [array release];
//%}
//%
//%@end
@@ -509,6 +526,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -533,6 +552,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -603,6 +626,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 1);
XCTAssertEqual([array valueAtIndex:1], 2);
XCTAssertEqual([array valueAtIndex:2], 3);
@@ -723,9 +752,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const int32_t kValues[] = { 1, 2, 3, 4 };
GPBInt32Array *array =
- [[GPBInt32Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBInt32Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -742,7 +771,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -842,6 +870,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -866,6 +896,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -936,6 +970,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 11U);
XCTAssertEqual([array valueAtIndex:1], 12U);
XCTAssertEqual([array valueAtIndex:2], 13U);
@@ -1056,9 +1096,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const uint32_t kValues[] = { 11U, 12U, 13U, 14U };
GPBUInt32Array *array =
- [[GPBUInt32Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBUInt32Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -1075,7 +1115,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -1175,6 +1214,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -1199,6 +1240,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -1269,6 +1314,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 31LL);
XCTAssertEqual([array valueAtIndex:1], 32LL);
XCTAssertEqual([array valueAtIndex:2], 33LL);
@@ -1389,9 +1440,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const int64_t kValues[] = { 31LL, 32LL, 33LL, 34LL };
GPBInt64Array *array =
- [[GPBInt64Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBInt64Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -1408,7 +1459,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -1508,6 +1558,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -1532,6 +1584,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -1602,6 +1658,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 41ULL);
XCTAssertEqual([array valueAtIndex:1], 42ULL);
XCTAssertEqual([array valueAtIndex:2], 43ULL);
@@ -1722,9 +1784,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const uint64_t kValues[] = { 41ULL, 42ULL, 43ULL, 44ULL };
GPBUInt64Array *array =
- [[GPBUInt64Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBUInt64Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -1741,7 +1803,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -1841,6 +1902,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -1865,6 +1928,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -1935,6 +2002,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 51.f);
XCTAssertEqual([array valueAtIndex:1], 52.f);
XCTAssertEqual([array valueAtIndex:2], 53.f);
@@ -2055,9 +2128,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const float kValues[] = { 51.f, 52.f, 53.f, 54.f };
GPBFloatArray *array =
- [[GPBFloatArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBFloatArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -2074,7 +2147,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -2174,6 +2246,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -2198,6 +2272,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -2268,6 +2346,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 61.);
XCTAssertEqual([array valueAtIndex:1], 62.);
XCTAssertEqual([array valueAtIndex:2], 63.);
@@ -2388,9 +2472,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const double kValues[] = { 61., 62., 63., 64. };
GPBDoubleArray *array =
- [[GPBDoubleArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBDoubleArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -2407,7 +2491,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -2507,6 +2590,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -2531,6 +2616,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -2601,6 +2690,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], TRUE);
XCTAssertEqual([array valueAtIndex:1], TRUE);
XCTAssertEqual([array valueAtIndex:2], FALSE);
@@ -2721,9 +2816,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const BOOL kValues[] = { TRUE, TRUE, FALSE, FALSE };
GPBBoolArray *array =
- [[GPBBoolArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBBoolArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -2740,7 +2835,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -2840,6 +2934,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -2864,6 +2960,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -2934,6 +3034,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addRawValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 71);
XCTAssertEqual([array valueAtIndex:1], 72);
XCTAssertEqual([array valueAtIndex:2], 73);
@@ -3054,9 +3160,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const int32_t kValues[] = { 71, 72, 73, 74 };
GPBEnumArray *array =
- [[GPBEnumArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBEnumArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -3073,7 +3179,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -3436,3 +3541,175 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
}
@end
+
+#pragma mark - GPBAutocreatedArray Tests
+
+// These are hand written tests to double check some behaviors of the
+// GPBAutocreatedArray.
+
+// NOTE: GPBAutocreatedArray is private to the library, users of the library
+// should never have to directly deal with this class.
+
+@interface GPBAutocreatedArrayTests : XCTestCase
+@end
+
+@implementation GPBAutocreatedArrayTests
+
+- (void)testEquality {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ XCTAssertTrue([array isEqual:@[]]);
+ XCTAssertTrue([array isEqualToArray:@[]]);
+
+ XCTAssertFalse([array isEqual:@[ @"foo" ]]);
+ XCTAssertFalse([array isEqualToArray:@[ @"foo" ]]);
+
+ [array addObject:@"foo"];
+
+ XCTAssertFalse([array isEqual:@[]]);
+ XCTAssertFalse([array isEqualToArray:@[]]);
+ XCTAssertTrue([array isEqual:@[ @"foo" ]]);
+ XCTAssertTrue([array isEqualToArray:@[ @"foo" ]]);
+ XCTAssertFalse([array isEqual:@[ @"bar" ]]);
+ XCTAssertFalse([array isEqualToArray:@[ @"bar" ]]);
+
+ GPBAutocreatedArray *array2 = [[GPBAutocreatedArray alloc] init];
+
+ XCTAssertFalse([array isEqual:array2]);
+ XCTAssertFalse([array isEqualToArray:array2]);
+
+ [array2 addObject:@"bar"];
+ XCTAssertFalse([array isEqual:array2]);
+ XCTAssertFalse([array isEqualToArray:array2]);
+
+ [array2 replaceObjectAtIndex:0 withObject:@"foo"];
+ XCTAssertTrue([array isEqual:array2]);
+ XCTAssertTrue([array isEqualToArray:array2]);
+
+ [array2 release];
+ [array release];
+}
+
+- (void)testCopy {
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ NSArray *cpy = [array copy];
+ 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
+ // 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]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ NSMutableArray *cpy = [array mutableCopy];
+ 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 isKindOfClass:[NSMutableArray class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+ [array addObject:@"foo"];
+ [array addObject:@"bar"];
+
+ NSArray *cpy = [array copy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[0], @"foo");
+ XCTAssertEqualObjects(cpy[1], @"bar");
+
+ NSArray *cpy2 = [array copy];
+ 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);
+ XCTAssertEqualObjects(cpy2[0], @"foo");
+ XCTAssertEqualObjects(cpy2[1], @"bar");
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+ [array addObject:@"foo"];
+ [array addObject:@"bar"];
+
+ NSMutableArray *cpy = [array mutableCopy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[0], @"foo");
+ XCTAssertEqualObjects(cpy[1], @"bar");
+
+ NSMutableArray *cpy2 = [array mutableCopy];
+ 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);
+ XCTAssertEqualObjects(cpy2[0], @"foo");
+ XCTAssertEqualObjects(cpy2[1], @"bar");
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+}
+
+- (void)testIndexedSubscriptSupport {
+ // The base NSArray/NSMutableArray behaviors for *IndexedSubscript methods
+ // should still work via the methods that one has to override to make an
+ // NSMutableArray subclass. i.e. - this should "just work" and if these
+ // crash/fail, then something is wrong in how NSMutableArray is subclassed.
+
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ [array addObject:@"foo"];
+ [array addObject:@"bar"];
+ XCTAssertEqual(array.count, (NSUInteger)2);
+ XCTAssertEqualObjects(array[0], @"foo");
+ XCTAssertEqualObjects(array[1], @"bar");
+ array[0] = @"foo2";
+ array[2] = @"baz";
+ XCTAssertEqual(array.count, (NSUInteger)3);
+ XCTAssertEqualObjects(array[0], @"foo2");
+ XCTAssertEqualObjects(array[1], @"bar");
+ XCTAssertEqualObjects(array[2], @"baz");
+
+ [array release];
+}
+
+@end
diff --git a/objectivec/Tests/GPBCodedInputStreamTests.m b/objectivec/Tests/GPBCodedInputStreamTests.m
index b0e39d2c..f5aa6903 100644
--- a/objectivec/Tests/GPBCodedInputStreamTests.m
+++ b/objectivec/Tests/GPBCodedInputStreamTests.m
@@ -62,52 +62,101 @@
#define bytes(...) [self bytes_with_sentinel:0, __VA_ARGS__, 256]
- (void)testDecodeZigZag {
- XCTAssertEqual(0, GPBDecodeZigZag32(0));
- XCTAssertEqual(-1, GPBDecodeZigZag32(1));
- XCTAssertEqual(1, GPBDecodeZigZag32(2));
- XCTAssertEqual(-2, GPBDecodeZigZag32(3));
- XCTAssertEqual((int32_t)0x3FFFFFFF, GPBDecodeZigZag32(0x7FFFFFFE));
- XCTAssertEqual((int32_t)0xC0000000, GPBDecodeZigZag32(0x7FFFFFFF));
- XCTAssertEqual((int32_t)0x7FFFFFFF, GPBDecodeZigZag32(0xFFFFFFFE));
- XCTAssertEqual((int32_t)0x80000000, GPBDecodeZigZag32(0xFFFFFFFF));
-
- XCTAssertEqual((int64_t)0, GPBDecodeZigZag64(0));
- XCTAssertEqual((int64_t)-1, GPBDecodeZigZag64(1));
- XCTAssertEqual((int64_t)1, GPBDecodeZigZag64(2));
- XCTAssertEqual((int64_t)-2, GPBDecodeZigZag64(3));
- XCTAssertEqual((int64_t)0x000000003FFFFFFFL,
- GPBDecodeZigZag64(0x000000007FFFFFFEL));
- XCTAssertEqual((int64_t)0xFFFFFFFFC0000000L,
- GPBDecodeZigZag64(0x000000007FFFFFFFL));
- XCTAssertEqual((int64_t)0x000000007FFFFFFFL,
- GPBDecodeZigZag64(0x00000000FFFFFFFEL));
- XCTAssertEqual((int64_t)0xFFFFFFFF80000000L,
- GPBDecodeZigZag64(0x00000000FFFFFFFFL));
- XCTAssertEqual((int64_t)0x7FFFFFFFFFFFFFFFL,
- GPBDecodeZigZag64(0xFFFFFFFFFFFFFFFEL));
- XCTAssertEqual((int64_t)0x8000000000000000L,
- GPBDecodeZigZag64(0xFFFFFFFFFFFFFFFFL));
+ [self assertReadZigZag32:bytes(0x0) value:0];
+ [self assertReadZigZag32:bytes(0x1) value:-1];
+ [self assertReadZigZag32:bytes(0x2) value:1];
+ [self assertReadZigZag32:bytes(0x3) value:-2];
+
+ [self assertReadZigZag32:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0x3FFFFFFF];
+ [self assertReadZigZag32:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0xC0000000];
+ [self assertReadZigZag32:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x7FFFFFFF];
+ [self assertReadZigZag32:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x80000000];
+
+ [self assertReadZigZag64:bytes(0x0) value:0];
+ [self assertReadZigZag64:bytes(0x1) value:-1];
+ [self assertReadZigZag64:bytes(0x2) value:1];
+ [self assertReadZigZag64:bytes(0x3) value:-2];
+
+ [self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0x3FFFFFFF];
+ [self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0xC0000000];
+ [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];
}
- (void)assertReadVarint:(NSData*)data value:(int64_t)value {
- {
+ if (value <= INT32_MAX && value >= INT32_MIN) {
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((int32_t)value, [input readInt32]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((int32_t)value, [input readEnum]);
+ }
+ }
+ if (value <= UINT32_MAX && value >= 0) {
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
- XCTAssertEqual((int32_t)value, [input readInt32]);
+ XCTAssertEqual((uint32_t)value, [input readUInt32]);
}
{
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
XCTAssertEqual(value, [input readInt64]);
}
+ if (value >= 0) {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((uint64_t)value, [input readUInt64]);
+ }
}
- (void)assertReadLittleEndian32:(NSData*)data value:(int32_t)value {
- GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
- XCTAssertEqual(value, [input readSFixed32]);
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSFixed32]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(GPBConvertInt32ToFloat(value), [input readFloat]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((uint32_t)value, [input readFixed32]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSFixed32]);
+ }
}
- (void)assertReadLittleEndian64:(NSData*)data value:(int64_t)value {
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSFixed64]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(GPBConvertInt64ToDouble(value), [input readDouble]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((uint64_t)value, [input readFixed64]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSFixed64]);
+ }
+}
+
+- (void)assertReadZigZag32:(NSData*)data value:(int64_t)value {
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
- XCTAssertEqual(value, [input readSFixed64]);
+ XCTAssertEqual((int32_t)value, [input readSInt32]);
+}
+
+- (void)assertReadZigZag64:(NSData*)data value:(int64_t)value {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSInt64]);
}
- (void)assertReadVarintFailure:(NSData*)data {
@@ -128,12 +177,28 @@
XCTAssertEqual(((uint8_t*)data.bytes)[1], (uint8_t)0x74);
}
+- (void)testReadBool {
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:bytes(0x00)];
+ XCTAssertEqual(NO, [input readBool]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:bytes(0x01)];
+ XCTAssertEqual(YES, [input readBool]);
+ }
+}
+
- (void)testReadVarint {
[self assertReadVarint:bytes(0x00) value:0];
[self assertReadVarint:bytes(0x01) value:1];
[self assertReadVarint:bytes(0x7f) value:127];
// 14882
[self assertReadVarint:bytes(0xa2, 0x74) value:(0x22 << 0) | (0x74 << 7)];
+ // 1904930
+ [self assertReadVarint:bytes(0xa2, 0xa2, 0x74) value:(0x22 << 0) | (0x22 << 7) | (0x74 << 14)];
+ // 243831074
+ [self assertReadVarint:bytes(0xa2, 0xa2, 0xa2, 0x74)
+ 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) |
@@ -155,7 +220,7 @@
0xa6, 0x01)
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
(0x3bLL << 28) | (0x56LL << 35) | (0x00LL << 42) |
- (0x05LL << 49) | (0x26LL << 56) | (0x01LL << 63)];
+ (0x05LL << 49) | (0x26LL << 56) | (0x01ULL << 63)];
// Failures
[self assertReadVarintFailure:bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
@@ -163,6 +228,45 @@
[self assertReadVarintFailure:bytes(0x80)];
}
+- (void)testReadVarint32FromVarint64 {
+ {
+ // Turn on lower 31 bits of the upper half on a 64 bit varint.
+ NSData* data = bytes(0x80, 0x80, 0x80, 0x80, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E);
+
+ int32_t value32 = 0x0;
+ GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value32, [input32 readInt32]);
+
+ int64_t value64 = INT64_MAX & 0xFFFFFFFF00000000;
+ GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value64, [input64 readInt64]);
+ }
+ {
+ // Turn on lower 31 bits and lower 31 bits on upper half on a 64 bit varint.
+ NSData* data = bytes(0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E);
+
+ int32_t value32 = INT32_MAX;
+ GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value32, [input32 readInt32]);
+
+ int64_t value64 = INT64_MAX & 0xFFFFFFFF7FFFFFFF;
+ GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value64, [input64 readInt64]);
+ }
+ {
+ // Turn on bits 32 and 64 bit on a 64 bit varint.
+ NSData* data = bytes(0x80, 0x80, 0x80, 0x80, 0x88, 0x80, 0x80, 0x80, 0x80, 0x01);
+
+ int32_t value32 = INT32_MIN;
+ GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value32, [input32 readInt32]);
+
+ int64_t value64 = INT64_MIN | (0x01LL << 31);
+ GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value64, [input64 readInt64]);
+ }
+}
+
- (void)testReadLittleEndian {
[self assertReadLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12)
value:0x12345678];
@@ -265,6 +369,27 @@
XCTAssertThrows([input readBytes]);
}
+- (void)testReadEmptyString {
+ NSData *data = bytes(0x00);
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqualObjects(@"", [input readString]);
+}
+
+- (void)testInvalidGroupEndTagThrows {
+ NSData *data = bytes(0x0B, 0x1A, 0x02, 0x4B, 0x50, 0x14);
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ 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];
+ XCTAssertNil([input readBytes]);
+}
+
// Verifies fix for b/10315336.
// Note: Now that there isn't a custom string class under the hood, this test
// isn't as critical, but it does cover bad input and if a custom class is added
@@ -283,16 +408,53 @@
[output writeRawData:[NSData dataWithBytes:bytes length:sizeof(bytes)]];
[output flush];
- NSData* data =
+ NSData *data =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ NSError *error = nil;
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
extensionRegistry:nil
- error:NULL];
- XCTAssertNotNil(message);
- // Make sure we can read string properties twice without crashing.
- XCTAssertEqual([message.defaultString length], (NSUInteger)0);
- XCTAssertEqualObjects(@"", message.defaultString);
+ error:&error];
+ XCTAssertNotNil(error);
+ XCTAssertNil(message);
+}
+
+- (void)testBOMWithinStrings {
+ // We've seen servers that end up with BOMs within strings (not always at the
+ // start, and sometimes in multiple places), make sure they always parse
+ // correctly. (Again, this is inpart incase 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",
+ };
+ for (size_t i = 0; i < GPBARRAYSIZE(strs); ++i) {
+ NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
+ GPBCodedOutputStream* output =
+ [GPBCodedOutputStream streamWithOutputStream:rawOutput];
+
+ 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];
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
+ extensionRegistry:nil
+ error:NULL];
+ XCTAssertNotNil(message, @"Loop %zd", i);
+ // Ensure the string is there. NSString can consume the BOM in some
+ // cases, so don't actually check the string for exact equality.
+ XCTAssertTrue(message.defaultString.length > 0, @"Loop %zd", i);
+ }
}
@end
diff --git a/objectivec/Tests/GPBCodedOuputStreamTests.m b/objectivec/Tests/GPBCodedOuputStreamTests.m
index 77d88033..109239d5 100644
--- a/objectivec/Tests/GPBCodedOuputStreamTests.m
+++ b/objectivec/Tests/GPBCodedOuputStreamTests.m
@@ -30,11 +30,30 @@
#import "GPBTestUtilities.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
#import "GPBCodedInputStream.h"
#import "GPBUtilities_PackagePrivate.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;
+@end
+
+@interface GPBCodedOutputStream (Helper)
++ (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];
+ return [[[self alloc] initWithOutputStream:output data:data] autorelease];
+}
+@end
+
@interface CodedOutputStreamTests : GPBTestCase
@end
@@ -174,6 +193,32 @@
}
}
+- (void)assertWriteStringNoTag:(NSData*)data
+ value:(NSString *)value
+ context:(NSString *)contextMessage {
+ NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
+ GPBCodedOutputStream* output =
+ [GPBCodedOutputStream streamWithOutputStream:rawOutput];
+ [output writeStringNoTag:value];
+ [output flush];
+
+ 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 writeStringNoTag:value];
+ [output flush];
+
+ actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
+ XCTAssertEqualObjects(data, actual, @"%@", contextMessage);
+ }
+}
+
- (void)testWriteVarint1 {
[self assertWriteVarint:bytes(0x00) value:0];
}
@@ -221,7 +266,7 @@
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) |
(0x42 << 21) | (0x3bLL << 28) | (0x56LL << 35) |
(0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
- (0x01LL << 63)];
+ (0x01ULL << 63)];
}
- (void)testWriteLittleEndian {
@@ -318,4 +363,74 @@
XCTAssertEqualObjects(rawBytes, goldenData);
}
+- (void)testCFStringGetCStringPtrAndStringsWithNullChars {
+ // This test exists to verify that CFStrings with embedded NULLs still expose
+ // their raw buffer if they are backed by UTF8 storage. If this fails, the
+ // quick/direct access paths in GPBCodedOutputStream that depend on
+ // CFStringGetCStringPtr need to be re-evalutated (maybe just removed).
+ // And yes, we do get NULLs in strings from some servers.
+
+ 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
+ length:sizeof(zeroTest)
+ encoding:NSUTF8StringEncoding];
+ 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
+ // CFStringGetCStringPtr in GPBCodedOutputStream will still work (it will take
+ // a different code path); but the optimizations for when
+ // CFStringGetCStringPtr does work could possibly go away.
+
+ XCTAssertEqual(sizeof(zeroTest),
+ [asNSString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
+ XCTAssertTrue(0 == memcmp(cString, zeroTest, sizeof(zeroTest)));
+ [asNSString release];
+}
+
+- (void)testWriteStringsWithZeroChar {
+ // Unicode allows `\0` as a character, and NSString is a class cluster, so
+ // there are a few different classes that could end up beind a given string.
+ // Historically, we've seen differences based on constant strings in code and
+ // strings built via the NSString apis. So this round trips them to ensure
+ // they are acting as expected.
+
+ 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];
+ uint8_t lengthByte = (uint8_t)asUTF8.length;
+ [expected appendBytes:&lengthByte length:1];
+ [expected appendData:asUTF8];
+
+ 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];
+ context = [NSString stringWithFormat:@"Loop %d - Built", i];
+ [self assertWriteStringNoTag:expected value:str2 context:context];
+
+ ++i;
+ }
+}
+
+- (void)testThatItThrowsWhenWriteRawPtrFails {
+ 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";
+ XCTAssertThrowsSpecificNamed([codedOutput writeRawPtr:cString offset:0 length:strlen(cString)],
+ NSException, GPBCodedOutputStreamException_WriteFailed);
+}
+
@end
diff --git a/objectivec/Tests/GPBCompileTest01.m b/objectivec/Tests/GPBCompileTest01.m
new file mode 100644
index 00000000..c8bc433a
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest01.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest02.m b/objectivec/Tests/GPBCompileTest02.m
new file mode 100644
index 00000000..c44e201a
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest02.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest03.m b/objectivec/Tests/GPBCompileTest03.m
new file mode 100644
index 00000000..41994f94
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest03.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest04.m b/objectivec/Tests/GPBCompileTest04.m
new file mode 100644
index 00000000..c31498f1
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest04.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest05.m b/objectivec/Tests/GPBCompileTest05.m
new file mode 100644
index 00000000..adb72252
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest05.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest06.m b/objectivec/Tests/GPBCompileTest06.m
new file mode 100644
index 00000000..b7505b02
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest06.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest07.m b/objectivec/Tests/GPBCompileTest07.m
new file mode 100644
index 00000000..939bb709
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest07.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest08.m b/objectivec/Tests/GPBCompileTest08.m
new file mode 100644
index 00000000..a84f38cf
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest08.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest09.m b/objectivec/Tests/GPBCompileTest09.m
new file mode 100644
index 00000000..f8ccb4a0
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest09.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest10.m b/objectivec/Tests/GPBCompileTest10.m
new file mode 100644
index 00000000..d8318678
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest10.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest11.m b/objectivec/Tests/GPBCompileTest11.m
new file mode 100644
index 00000000..9f2c6b11
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest11.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest12.m b/objectivec/Tests/GPBCompileTest12.m
new file mode 100644
index 00000000..3aa29b31
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest12.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest13.m b/objectivec/Tests/GPBCompileTest13.m
new file mode 100644
index 00000000..fef2af5f
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest13.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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;
diff --git a/objectivec/Tests/GPBCompileTest14.m b/objectivec/Tests/GPBCompileTest14.m
new file mode 100644
index 00000000..ae04349a
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest14.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Any.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;
diff --git a/objectivec/Tests/GPBCompileTest15.m b/objectivec/Tests/GPBCompileTest15.m
new file mode 100644
index 00000000..889243aa
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest15.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Api.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;
diff --git a/objectivec/Tests/GPBCompileTest16.m b/objectivec/Tests/GPBCompileTest16.m
new file mode 100644
index 00000000..c5aaf14f
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest16.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Duration.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;
diff --git a/objectivec/Tests/GPBCompileTest17.m b/objectivec/Tests/GPBCompileTest17.m
new file mode 100644
index 00000000..feb64d66
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest17.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Empty.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;
diff --git a/objectivec/Tests/GPBCompileTest18.m b/objectivec/Tests/GPBCompileTest18.m
new file mode 100644
index 00000000..66784c4f
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest18.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/FieldMask.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;
diff --git a/objectivec/Tests/GPBCompileTest19.m b/objectivec/Tests/GPBCompileTest19.m
new file mode 100644
index 00000000..435dea01
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest19.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/SourceContext.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;
diff --git a/objectivec/Tests/GPBCompileTest20.m b/objectivec/Tests/GPBCompileTest20.m
new file mode 100644
index 00000000..c2da8066
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest20.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Struct.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;
diff --git a/objectivec/Tests/GPBCompileTest21.m b/objectivec/Tests/GPBCompileTest21.m
new file mode 100644
index 00000000..d7110b93
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest21.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Timestamp.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;
diff --git a/objectivec/Tests/GPBCompileTest22.m b/objectivec/Tests/GPBCompileTest22.m
new file mode 100644
index 00000000..17380618
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest22.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Type.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;
diff --git a/objectivec/Tests/GPBCompileTest23.m b/objectivec/Tests/GPBCompileTest23.m
new file mode 100644
index 00000000..f22f9bdd
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest23.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Wrappers.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;
diff --git a/objectivec/Tests/GPBCompileTest24.m b/objectivec/Tests/GPBCompileTest24.m
new file mode 100644
index 00000000..c81ea732
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest24.m
@@ -0,0 +1,42 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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.
+
+#import "google/protobuf/Descriptor.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_24 = 0;
diff --git a/objectivec/Tests/GPBCompileTest25.m b/objectivec/Tests/GPBCompileTest25.m
new file mode 100644
index 00000000..7a482b51
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest25.m
@@ -0,0 +1,42 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This 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/UnittestCustomOptions.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_25 = 0;
diff --git a/objectivec/Tests/GPBDescriptorTests.m b/objectivec/Tests/GPBDescriptorTests.m
index ccdbb645..d47cc30f 100644
--- a/objectivec/Tests/GPBDescriptorTests.m
+++ b/objectivec/Tests/GPBDescriptorTests.m
@@ -32,14 +32,43 @@
#import <objc/runtime.h>
-#import "GPBDescriptor.h"
+#import "GPBDescriptor_PackagePrivate.h"
#import "google/protobuf/Unittest.pbobjc.h"
+#import "google/protobuf/UnittestObjc.pbobjc.h"
+#import "google/protobuf/Descriptor.pbobjc.h"
@interface DescriptorTests : GPBTestCase
@end
@implementation DescriptorTests
+- (void)testDescriptor_containingType {
+ GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
+ GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
+ XCTAssertNil(testAllTypesDesc.containingType);
+ XCTAssertNotNil(nestedMessageDesc.containingType);
+ XCTAssertEqual(nestedMessageDesc.containingType, testAllTypesDesc); // Ptr comparison
+}
+
+- (void)testDescriptor_fullName {
+ GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
+ XCTAssertEqualObjects(testAllTypesDesc.fullName, @"protobuf_unittest.TestAllTypes");
+ GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
+ XCTAssertEqualObjects(nestedMessageDesc.fullName, @"protobuf_unittest.TestAllTypes.NestedMessage");
+
+ // Prefixes removed.
+ 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, @"protobuf_unittest.Point");
+ GPBDescriptor *pointRectDesc = [Point_Rect descriptor];
+ XCTAssertEqualObjects(pointRectDesc.fullName, @"protobuf_unittest.Point.Rect");
+}
+
- (void)testFieldDescriptor {
GPBDescriptor *descriptor = [TestAllTypes descriptor];
@@ -54,6 +83,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"TestAllTypes_NestedEnum");
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
// Foreign Enum
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalForeignEnum"];
@@ -64,6 +95,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"ForeignEnum");
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
// Import Enum
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportEnum"];
@@ -74,6 +107,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"ImportEnum");
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
// Nested Message
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalNestedMessage"];
@@ -82,6 +117,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
// Foreign Message
fieldDescriptorWithName =
@@ -91,6 +128,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
// Import Message
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportMessage"];
@@ -99,6 +138,12 @@
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
+
+ // Some failed lookups.
+ XCTAssertNil([descriptor fieldWithName:@"NOT THERE"]);
+ XCTAssertNil([descriptor fieldWithNumber:9876543]);
}
- (void)testEnumDescriptor {
@@ -125,6 +170,13 @@
[descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Baz"]);
XCTAssertEqual(value, TestAllTypes_NestedEnum_Baz);
+ // TextFormat
+ enumName = [descriptor textFormatNameForValue:1];
+ XCTAssertNotNil(enumName);
+ XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:@"FOO"]);
+ XCTAssertEqual(value, TestAllTypes_NestedEnum_Foo);
+ XCTAssertNil([descriptor textFormatNameForValue:99999]);
+
// Bad values
enumName = [descriptor enumNameForValue:0];
XCTAssertNil(enumName);
@@ -134,6 +186,65 @@
forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
XCTAssertFalse([descriptor getValue:NULL
forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
+ XCTAssertFalse([descriptor getValue:NULL forEnumTextFormatName:@"Unknown"]);
+ XCTAssertFalse([descriptor getValue:&value forEnumTextFormatName:@"Unknown"]);
+}
+
+- (void)testEnumDescriptorIntrospection {
+ GPBEnumDescriptor *descriptor = TestAllTypes_NestedEnum_EnumDescriptor();
+
+ XCTAssertEqual(descriptor.enumNameCount, 4U);
+ XCTAssertEqualObjects([descriptor getEnumNameForIndex:0],
+ @"TestAllTypes_NestedEnum_Foo");
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:0], @"FOO");
+ XCTAssertEqualObjects([descriptor getEnumNameForIndex:1],
+ @"TestAllTypes_NestedEnum_Bar");
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:1], @"BAR");
+ XCTAssertEqualObjects([descriptor getEnumNameForIndex:2],
+ @"TestAllTypes_NestedEnum_Baz");
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:2], @"BAZ");
+ XCTAssertEqualObjects([descriptor getEnumNameForIndex:3],
+ @"TestAllTypes_NestedEnum_Neg");
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:3], @"NEG");
+}
+
+- (void)testEnumDescriptorIntrospectionWithAlias {
+ GPBEnumDescriptor *descriptor = TestEnumWithDupValue_EnumDescriptor();
+ NSString *enumName;
+ int32_t value;
+
+ XCTAssertEqual(descriptor.enumNameCount, 5U);
+
+ enumName = [descriptor getEnumNameForIndex:0];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Foo1");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 1);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:0], @"FOO1");
+
+ enumName = [descriptor getEnumNameForIndex:1];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Bar1");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 2);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:1], @"BAR1");
+
+ enumName = [descriptor getEnumNameForIndex:2];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Baz");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 3);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:2], @"BAZ");
+
+ enumName = [descriptor getEnumNameForIndex:3];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Foo2");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 1);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:3], @"FOO2");
+
+ enumName = [descriptor getEnumNameForIndex:4];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Bar2");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 2);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:4], @"BAR2");
+
}
- (void)testEnumValueValidator {
@@ -153,19 +264,6 @@
XCTAssertFalse([fieldDescriptor isValidEnumValue:-2]);
}
-- (void)testEnumDescriptorLookup {
- GPBDescriptor *descriptor = [TestAllTypes descriptor];
- GPBEnumDescriptor *enumDescriptor =
- [descriptor enumWithName:@"TestAllTypes_NestedEnum"];
- XCTAssertNotNil(enumDescriptor);
-
- // Descriptor cannot find foreign or imported enums.
- enumDescriptor = [descriptor enumWithName:@"ForeignEnumEnum"];
- XCTAssertNil(enumDescriptor);
- enumDescriptor = [descriptor enumWithName:@"ImportEnumEnum"];
- XCTAssertNil(enumDescriptor);
-}
-
- (void)testOneofDescriptor {
GPBDescriptor *descriptor = [TestOneof2 descriptor];
@@ -229,4 +327,102 @@
XCTAssertNil(bazString.containingOneof);
}
+- (void)testExtensiondDescriptor {
+ Class msgClass = [TestAllExtensions class];
+ Class packedMsgClass = [TestPackedExtensions class];
+
+ // Int
+
+ GPBExtensionDescriptor *descriptor = [UnittestRoot optionalInt32Extension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertEqualObjects(descriptor.defaultValue, @0);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ descriptor = [UnittestRoot defaultInt32Extension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertEqualObjects(descriptor.defaultValue, @41);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ // Enum
+
+ descriptor = [UnittestRoot optionalNestedEnumExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertEqual(descriptor.defaultValue, @1);
+ XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"TestAllTypes_NestedEnum");
+
+ descriptor = [UnittestRoot defaultNestedEnumExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertEqual(descriptor.defaultValue, @2);
+ XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"TestAllTypes_NestedEnum");
+
+ // Message
+
+ descriptor = [UnittestRoot optionalNestedMessageExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ // Repeated Int
+
+ descriptor = [UnittestRoot repeatedInt32Extension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ descriptor = [UnittestRoot packedInt32Extension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, packedMsgClass); // ptr equality
+ XCTAssertTrue(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ // Repeated Enum
+
+ descriptor = [UnittestRoot repeatedNestedEnumExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"TestAllTypes_NestedEnum");
+
+ descriptor = [UnittestRoot packedEnumExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, packedMsgClass); // ptr equality
+ XCTAssertTrue(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"ForeignEnum");
+
+ // Repeated Message
+
+ descriptor = [UnittestRoot repeatedNestedMessageExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ // Compare (used internally for serialization).
+
+ GPBExtensionDescriptor *ext1 = [UnittestRoot optionalInt32Extension];
+ XCTAssertEqual(ext1.fieldNumber, 1u);
+ GPBExtensionDescriptor *ext2 = [UnittestRoot optionalInt64Extension];
+ XCTAssertEqual(ext2.fieldNumber, 2u);
+
+ XCTAssertEqual([ext1 compareByFieldNumber:ext2], NSOrderedAscending);
+ XCTAssertEqual([ext2 compareByFieldNumber:ext1], NSOrderedDescending);
+ XCTAssertEqual([ext1 compareByFieldNumber:ext1], NSOrderedSame);
+}
+
@end
diff --git a/objectivec/Tests/GPBDictionaryTests+Bool.m b/objectivec/Tests/GPBDictionaryTests+Bool.m
index 8b1900fe..0af0c815 100644
--- a/objectivec/Tests/GPBDictionaryTests+Bool.m
+++ b/objectivec/Tests/GPBDictionaryTests+Bool.m
@@ -54,8 +54,8 @@
GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:YES]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -63,42 +63,44 @@
}
- (void)testOne {
- GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionaryWithValue:100U forKey:YES];
+ GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
uint32_t *seenValues = malloc(2 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -120,7 +122,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, 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);
@@ -136,29 +138,29 @@
const uint32_t kValues2[] = { 101U, 100U };
const uint32_t kValues3[] = { 101U };
GPBBoolUInt32Dictionary *dict1 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolUInt32Dictionary *dict1prime =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolUInt32Dictionary *dict2 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolUInt32Dictionary *dict3 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolUInt32Dictionary *dict4 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -187,9 +189,9 @@
const BOOL kKeys[] = { YES, NO };
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolUInt32Dictionary *dict2 = [dict copy];
@@ -208,79 +210,81 @@
const BOOL kKeys[] = { YES, NO };
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolUInt32Dictionary *dict2 =
- [GPBBoolUInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBBoolUInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionary];
+ GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:YES];
+ [dict setUInt32:100U forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const uint32_t kValues[] = { 101U };
GPBBoolUInt32Dictionary *dict2 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeUInt32ForKey:NO];
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeUInt32ForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:YES]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
[dict release];
}
@@ -288,51 +292,51 @@
const BOOL kKeys[] = { YES, NO };
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
- [dict setValue:101U forKey:YES];
+ [dict setUInt32:101U forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
- [dict setValue:100U forKey:NO];
+ [dict setUInt32:100U forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 100U);
const BOOL kKeys2[] = { NO, YES };
const uint32_t kValues2[] = { 101U, 100U };
GPBBoolUInt32Dictionary *dict2 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -355,8 +359,8 @@
GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:YES]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -364,42 +368,44 @@
}
- (void)testOne {
- GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionaryWithValue:200 forKey:YES];
+ GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init];
+ [dict setInt32:200 forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:NO]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
int32_t *seenValues = malloc(2 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -421,7 +427,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, 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);
@@ -437,27 +443,27 @@
const int32_t kValues2[] = { 201, 200 };
const int32_t kValues3[] = { 201 };
GPBBoolInt32Dictionary *dict1 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolInt32Dictionary *dict1prime =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolInt32Dictionary *dict2 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues2
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolInt32Dictionary *dict3 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolInt32Dictionary *dict4 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues3
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -488,7 +494,7 @@
const BOOL kKeys[] = { YES, NO };
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -509,33 +515,34 @@
const BOOL kKeys[] = { YES, NO };
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolInt32Dictionary *dict2 =
- [GPBBoolInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBBoolInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionary];
+ GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:YES];
+ [dict setInt32:200 forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const int32_t kValues[] = { 201 };
GPBBoolInt32Dictionary *dict2 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -543,45 +550,46 @@
XCTAssertEqual(dict.count, 2U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeInt32ForKey:NO];
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeInt32ForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:YES]);
+ XCTAssertFalse([dict getInt32:NULL forKey:NO]);
[dict release];
}
@@ -589,51 +597,51 @@
const BOOL kKeys[] = { YES, NO };
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
- [dict setValue:201 forKey:YES];
+ [dict setInt32:201 forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
- [dict setValue:200 forKey:NO];
+ [dict setInt32:200 forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 200);
const BOOL kKeys2[] = { NO, YES };
const int32_t kValues2[] = { 201, 200 };
GPBBoolInt32Dictionary *dict2 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues2
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -656,8 +664,8 @@
GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:YES]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -665,42 +673,44 @@
}
- (void)testOne {
- GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionaryWithValue:300U forKey:YES];
+ GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
uint64_t *seenValues = malloc(2 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -722,7 +732,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, 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);
@@ -738,29 +748,29 @@
const uint64_t kValues2[] = { 301U, 300U };
const uint64_t kValues3[] = { 301U };
GPBBoolUInt64Dictionary *dict1 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolUInt64Dictionary *dict1prime =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolUInt64Dictionary *dict2 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolUInt64Dictionary *dict3 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolUInt64Dictionary *dict4 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -789,9 +799,9 @@
const BOOL kKeys[] = { YES, NO };
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolUInt64Dictionary *dict2 = [dict copy];
@@ -810,79 +820,81 @@
const BOOL kKeys[] = { YES, NO };
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolUInt64Dictionary *dict2 =
- [GPBBoolUInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBBoolUInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionary];
+ GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:YES];
+ [dict setUInt64:300U forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const uint64_t kValues[] = { 301U };
GPBBoolUInt64Dictionary *dict2 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeUInt64ForKey:NO];
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeUInt64ForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:YES]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
[dict release];
}
@@ -890,51 +902,51 @@
const BOOL kKeys[] = { YES, NO };
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
- [dict setValue:301U forKey:YES];
+ [dict setUInt64:301U forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
- [dict setValue:300U forKey:NO];
+ [dict setUInt64:300U forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 300U);
const BOOL kKeys2[] = { NO, YES };
const uint64_t kValues2[] = { 301U, 300U };
GPBBoolUInt64Dictionary *dict2 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -957,8 +969,8 @@
GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:YES]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -966,42 +978,44 @@
}
- (void)testOne {
- GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionaryWithValue:400 forKey:YES];
+ GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init];
+ [dict setInt64:400 forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:NO]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
int64_t *seenValues = malloc(2 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1023,7 +1037,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, 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);
@@ -1039,27 +1053,27 @@
const int64_t kValues2[] = { 401, 400 };
const int64_t kValues3[] = { 401 };
GPBBoolInt64Dictionary *dict1 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolInt64Dictionary *dict1prime =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolInt64Dictionary *dict2 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues2
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolInt64Dictionary *dict3 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolInt64Dictionary *dict4 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues3
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1090,7 +1104,7 @@
const BOOL kKeys[] = { YES, NO };
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1111,33 +1125,34 @@
const BOOL kKeys[] = { YES, NO };
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolInt64Dictionary *dict2 =
- [GPBBoolInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBBoolInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionary];
+ GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:YES];
+ [dict setInt64:400 forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const int64_t kValues[] = { 401 };
GPBBoolInt64Dictionary *dict2 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1145,45 +1160,46 @@
XCTAssertEqual(dict.count, 2U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeInt64ForKey:NO];
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeInt64ForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:YES]);
+ XCTAssertFalse([dict getInt64:NULL forKey:NO]);
[dict release];
}
@@ -1191,51 +1207,51 @@
const BOOL kKeys[] = { YES, NO };
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
- [dict setValue:401 forKey:YES];
+ [dict setInt64:401 forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
- [dict setValue:400 forKey:NO];
+ [dict setInt64:400 forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 400);
const BOOL kKeys2[] = { NO, YES };
const int64_t kValues2[] = { 401, 400 };
GPBBoolInt64Dictionary *dict2 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues2
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1258,8 +1274,8 @@
GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:YES]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1267,42 +1283,44 @@
}
- (void)testOne {
- GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionaryWithValue:NO forKey:YES];
+ GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init];
+ [dict setBool:NO forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:NO]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, NO);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
BOOL *seenValues = malloc(2 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1324,7 +1342,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1340,29 +1358,29 @@
const BOOL kValues2[] = { YES, NO };
const BOOL kValues3[] = { YES };
GPBBoolBoolDictionary *dict1 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolBoolDictionary *dict1prime =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolBoolDictionary *dict2 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolBoolDictionary *dict3 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolBoolDictionary *dict4 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1391,9 +1409,9 @@
const BOOL kKeys[] = { YES, NO };
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolBoolDictionary *dict2 = [dict copy];
@@ -1412,79 +1430,81 @@
const BOOL kKeys[] = { YES, NO };
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolBoolDictionary *dict2 =
- [GPBBoolBoolDictionary dictionaryWithDictionary:dict];
+ [[GPBBoolBoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionary];
+ GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:NO forKey:YES];
+ [dict setBool:NO forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const BOOL kValues[] = { YES };
GPBBoolBoolDictionary *dict2 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeBoolForKey:NO];
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeBoolForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:YES]);
+ XCTAssertFalse([dict getBool:NULL forKey:NO]);
[dict release];
}
@@ -1492,51 +1512,51 @@
const BOOL kKeys[] = { YES, NO };
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
- [dict setValue:YES forKey:YES];
+ [dict setBool:YES forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
- [dict setValue:NO forKey:NO];
+ [dict setBool:NO forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, NO);
const BOOL kKeys2[] = { NO, YES };
const BOOL kValues2[] = { YES, NO };
GPBBoolBoolDictionary *dict2 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1559,8 +1579,8 @@
GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:YES]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1568,42 +1588,44 @@
}
- (void)testOne {
- GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionaryWithValue:500.f forKey:YES];
+ GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:NO]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
float *seenValues = malloc(2 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1625,7 +1647,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1641,27 +1663,27 @@
const float kValues2[] = { 501.f, 500.f };
const float kValues3[] = { 501.f };
GPBBoolFloatDictionary *dict1 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues1
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolFloatDictionary *dict1prime =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues1
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolFloatDictionary *dict2 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues2
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolFloatDictionary *dict3 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues1
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolFloatDictionary *dict4 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues3
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1692,7 +1714,7 @@
const BOOL kKeys[] = { YES, NO };
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1713,33 +1735,34 @@
const BOOL kKeys[] = { YES, NO };
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolFloatDictionary *dict2 =
- [GPBBoolFloatDictionary dictionaryWithDictionary:dict];
+ [[GPBBoolFloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionary];
+ GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:YES];
+ [dict setFloat:500.f forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const float kValues[] = { 501.f };
GPBBoolFloatDictionary *dict2 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1747,45 +1770,46 @@
XCTAssertEqual(dict.count, 2U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeFloatForKey:NO];
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeFloatForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:YES]);
+ XCTAssertFalse([dict getFloat:NULL forKey:NO]);
[dict release];
}
@@ -1793,51 +1817,51 @@
const BOOL kKeys[] = { YES, NO };
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
- [dict setValue:501.f forKey:YES];
+ [dict setFloat:501.f forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
- [dict setValue:500.f forKey:NO];
+ [dict setFloat:500.f forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 500.f);
const BOOL kKeys2[] = { NO, YES };
const float kValues2[] = { 501.f, 500.f };
GPBBoolFloatDictionary *dict2 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues2
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -1860,8 +1884,8 @@
GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:YES]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1869,42 +1893,44 @@
}
- (void)testOne {
- GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionaryWithValue:600. forKey:YES];
+ GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:NO]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
double *seenValues = malloc(2 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1926,7 +1952,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1942,29 +1968,29 @@
const double kValues2[] = { 601., 600. };
const double kValues3[] = { 601. };
GPBBoolDoubleDictionary *dict1 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolDoubleDictionary *dict1prime =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolDoubleDictionary *dict2 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolDoubleDictionary *dict3 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolDoubleDictionary *dict4 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1993,9 +2019,9 @@
const BOOL kKeys[] = { YES, NO };
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolDoubleDictionary *dict2 = [dict copy];
@@ -2014,79 +2040,81 @@
const BOOL kKeys[] = { YES, NO };
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolDoubleDictionary *dict2 =
- [GPBBoolDoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBBoolDoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionary];
+ GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:YES];
+ [dict setDouble:600. forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const double kValues[] = { 601. };
GPBBoolDoubleDictionary *dict2 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeDoubleForKey:NO];
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeDoubleForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:YES]);
+ XCTAssertFalse([dict getDouble:NULL forKey:NO]);
[dict release];
}
@@ -2094,51 +2122,51 @@
const BOOL kKeys[] = { YES, NO };
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
- [dict setValue:601. forKey:YES];
+ [dict setDouble:601. forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
- [dict setValue:600. forKey:NO];
+ [dict setDouble:600. forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 600.);
const BOOL kKeys2[] = { NO, YES };
const double kValues2[] = { 601., 600. };
GPBBoolDoubleDictionary *dict2 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2147,7 +2175,7 @@
@end
-//%PDDM-EXPAND TESTS_FOR_BOOL_KEY_OBJECT_VALUE(Object, id, @"abc", @"def")
+//%PDDM-EXPAND TESTS_FOR_BOOL_KEY_OBJECT_VALUE(Object, NSString*, @"abc", @"def")
// This block of code is generated, do not edit it directly.
#pragma mark - Bool -> Object
@@ -2158,11 +2186,11 @@
@implementation GPBBoolObjectDictionaryTests
- (void)testEmpty {
- GPBBoolObjectDictionary *dict = [[GPBBoolObjectDictionary alloc] init];
+ GPBBoolObjectDictionary<NSString*> *dict = [[GPBBoolObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:YES]);
- [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2170,22 +2198,24 @@
}
- (void)testOne {
- GPBBoolObjectDictionary *dict = [GPBBoolObjectDictionary dictionaryWithObject:@"abc" forKey:YES];
+ GPBBoolObjectDictionary<NSString*> *dict = [[GPBBoolObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
XCTAssertNil([dict objectForKey:NO]);
- [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -2196,8 +2226,8 @@
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
- id *seenObjects = malloc(2 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(2 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -2219,7 +2249,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2231,30 +2261,30 @@
- (void)testEquality {
const BOOL kKeys1[] = { YES, NO };
const BOOL kKeys2[] = { NO, YES };
- const id kObjects1[] = { @"abc", @"def" };
- const id kObjects2[] = { @"def", @"abc" };
- const id kObjects3[] = { @"def" };
- GPBBoolObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def" };
+ const NSString* kObjects2[] = { @"def", @"abc" };
+ const NSString* kObjects3[] = { @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict1 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBBoolObjectDictionary *dict1prime =
+ GPBBoolObjectDictionary<NSString*> *dict1prime =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBBoolObjectDictionary *dict2 =
+ GPBBoolObjectDictionary<NSString*> *dict2 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBBoolObjectDictionary *dict3 =
+ GPBBoolObjectDictionary<NSString*> *dict3 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBBoolObjectDictionary *dict4 =
+ GPBBoolObjectDictionary<NSString*> *dict4 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -2284,14 +2314,14 @@
- (void)testCopy {
const BOOL kKeys[] = { YES, NO };
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBBoolObjectDictionary *dict2 = [dict copy];
+ GPBBoolObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -2305,25 +2335,26 @@
- (void)testDictionaryFromDictionary {
const BOOL kKeys[] = { YES, NO };
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBBoolObjectDictionary *dict2 =
- [GPBBoolObjectDictionary dictionaryWithDictionary:dict];
+ GPBBoolObjectDictionary<NSString*> *dict2 =
+ [[GPBBoolObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolObjectDictionary *dict = [GPBBoolObjectDictionary dictionary];
+ GPBBoolObjectDictionary<NSString*> *dict = [[GPBBoolObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -2331,8 +2362,8 @@
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
- const id kObjects[] = { @"def" };
- GPBBoolObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict2 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -2343,12 +2374,13 @@
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
XCTAssertEqualObjects([dict objectForKey:NO], @"def");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -2375,11 +2407,11 @@
- (void)testInplaceMutation {
const BOOL kKeys[] = { YES, NO };
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
@@ -2396,8 +2428,8 @@
XCTAssertEqualObjects([dict objectForKey:NO], @"abc");
const BOOL kKeys2[] = { NO, YES };
- const id kObjects2[] = { @"def", @"abc" };
- GPBBoolObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"def", @"abc" };
+ GPBBoolObjectDictionary<NSString*> *dict2 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests+Int32.m b/objectivec/Tests/GPBDictionaryTests+Int32.m
index 21d3f07d..4ba30203 100644
--- a/objectivec/Tests/GPBDictionaryTests+Int32.m
+++ b/objectivec/Tests/GPBDictionaryTests+Int32.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBInt32EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(int32_t)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const int32_t [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBInt32EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(int32_t)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBInt32EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const int32_t [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32UInt32Dictionary *dict = [[GPBInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:11]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32UInt32Dictionary *dict = [GPBInt32UInt32Dictionary dictionaryWithValue:100U forKey:11];
+ GPBInt32UInt32Dictionary *dict = [[GPBInt32UInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, 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);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict1 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32UInt32Dictionary *dict1prime =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32UInt32Dictionary *dict2 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32UInt32Dictionary *dict3 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32UInt32Dictionary *dict4 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32UInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32UInt32Dictionary *dict2 =
- [GPBInt32UInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt32UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32UInt32Dictionary *dict = [GPBInt32UInt32Dictionary dictionary];
+ GPBInt32UInt32Dictionary *dict = [[GPBInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:11];
+ [dict setUInt32:100U forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict2 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeUInt32ForKey:12];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeUInt32ForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:14];
+ [dict removeUInt32ForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:11]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:13]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:14]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:11];
+ [dict setUInt32:103U forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:14];
+ [dict setUInt32:101U forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 101U);
const int32_t kKeys2[] = { 12, 13 };
const uint32_t kValues2[] = { 102U, 100U };
GPBInt32UInt32Dictionary *dict2 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32Int32Dictionary *dict = [[GPBInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:11]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32Int32Dictionary *dict = [GPBInt32Int32Dictionary dictionaryWithValue:200 forKey:11];
+ GPBInt32Int32Dictionary *dict = [[GPBInt32Int32Dictionary alloc] init];
+ [dict setInt32:200 forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const int32_t kValues[] = { 200, 201, 202 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, 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);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict1 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32Int32Dictionary *dict1prime =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32Int32Dictionary *dict2 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32Int32Dictionary *dict3 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32Int32Dictionary *dict4 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues3
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32Int32Dictionary *dict2 =
- [GPBInt32Int32Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt32Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32Int32Dictionary *dict = [GPBInt32Int32Dictionary dictionary];
+ GPBInt32Int32Dictionary *dict = [[GPBInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:11];
+ [dict setInt32:200 forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const int32_t kValues[] = { 201, 202, 203 };
GPBInt32Int32Dictionary *dict2 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeInt32ForKey:12];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeInt32ForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:14];
+ [dict removeInt32ForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:11]);
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ XCTAssertFalse([dict getInt32:NULL forKey:13]);
+ XCTAssertFalse([dict getInt32:NULL forKey:14]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:11];
+ [dict setInt32:203 forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:14];
+ [dict setInt32:201 forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 201);
const int32_t kKeys2[] = { 12, 13 };
const int32_t kValues2[] = { 202, 200 };
GPBInt32Int32Dictionary *dict2 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32UInt64Dictionary *dict = [[GPBInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:11]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32UInt64Dictionary *dict = [GPBInt32UInt64Dictionary dictionaryWithValue:300U forKey:11];
+ GPBInt32UInt64Dictionary *dict = [[GPBInt32UInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, 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);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict1 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32UInt64Dictionary *dict1prime =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32UInt64Dictionary *dict2 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32UInt64Dictionary *dict3 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32UInt64Dictionary *dict4 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32UInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32UInt64Dictionary *dict2 =
- [GPBInt32UInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt32UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32UInt64Dictionary *dict = [GPBInt32UInt64Dictionary dictionary];
+ GPBInt32UInt64Dictionary *dict = [[GPBInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:11];
+ [dict setUInt64:300U forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict2 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeUInt64ForKey:12];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeUInt64ForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:14];
+ [dict removeUInt64ForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:11]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:13]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:14]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:11];
+ [dict setUInt64:303U forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:14];
+ [dict setUInt64:301U forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 301U);
const int32_t kKeys2[] = { 12, 13 };
const uint64_t kValues2[] = { 302U, 300U };
GPBInt32UInt64Dictionary *dict2 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32Int64Dictionary *dict = [[GPBInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:11]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32Int64Dictionary *dict = [GPBInt32Int64Dictionary dictionaryWithValue:400 forKey:11];
+ GPBInt32Int64Dictionary *dict = [[GPBInt32Int64Dictionary alloc] init];
+ [dict setInt64:400 forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const int64_t kValues[] = { 400, 401, 402 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, 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);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict1 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32Int64Dictionary *dict1prime =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32Int64Dictionary *dict2 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32Int64Dictionary *dict3 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32Int64Dictionary *dict4 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues3
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32Int64Dictionary *dict2 =
- [GPBInt32Int64Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt32Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32Int64Dictionary *dict = [GPBInt32Int64Dictionary dictionary];
+ GPBInt32Int64Dictionary *dict = [[GPBInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:11];
+ [dict setInt64:400 forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const int64_t kValues[] = { 401, 402, 403 };
GPBInt32Int64Dictionary *dict2 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeInt64ForKey:12];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeInt64ForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:14];
+ [dict removeInt64ForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:11]);
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ XCTAssertFalse([dict getInt64:NULL forKey:13]);
+ XCTAssertFalse([dict getInt64:NULL forKey:14]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:11];
+ [dict setInt64:403 forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:14];
+ [dict setInt64:401 forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 401);
const int32_t kKeys2[] = { 12, 13 };
const int64_t kValues2[] = { 402, 400 };
GPBInt32Int64Dictionary *dict2 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32BoolDictionary *dict = [[GPBInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:11]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32BoolDictionary *dict = [GPBInt32BoolDictionary dictionaryWithValue:YES forKey:11];
+ GPBInt32BoolDictionary *dict = [[GPBInt32BoolDictionary alloc] init];
+ [dict setBool:YES forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const BOOL kValues[] = { YES, YES, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, 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);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict1 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32BoolDictionary *dict1prime =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32BoolDictionary *dict2 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32BoolDictionary *dict3 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32BoolDictionary *dict4 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32BoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32BoolDictionary *dict2 =
- [GPBInt32BoolDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32BoolDictionary *dict = [GPBInt32BoolDictionary dictionary];
+ GPBInt32BoolDictionary *dict = [[GPBInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:11];
+ [dict setBool:YES forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const BOOL kValues[] = { YES, NO, NO };
GPBInt32BoolDictionary *dict2 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeBoolForKey:12];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeBoolForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:14];
+ [dict removeBoolForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:11]);
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ XCTAssertFalse([dict getBool:NULL forKey:13]);
+ XCTAssertFalse([dict getBool:NULL forKey:14]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:11];
+ [dict setBool:NO forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:14];
+ [dict setBool:YES forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, YES);
const int32_t kKeys2[] = { 12, 13 };
const BOOL kValues2[] = { NO, YES };
GPBInt32BoolDictionary *dict2 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32FloatDictionary *dict = [[GPBInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:11]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32FloatDictionary *dict = [GPBInt32FloatDictionary dictionaryWithValue:500.f forKey:11];
+ GPBInt32FloatDictionary *dict = [[GPBInt32FloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, 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);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict1 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32FloatDictionary *dict1prime =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32FloatDictionary *dict2 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues2
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32FloatDictionary *dict3 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32FloatDictionary *dict4 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues3
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32FloatDictionary *dict2 =
- [GPBInt32FloatDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32FloatDictionary *dict = [GPBInt32FloatDictionary dictionary];
+ GPBInt32FloatDictionary *dict = [[GPBInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:11];
+ [dict setFloat:500.f forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict2 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeFloatForKey:12];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeFloatForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:14];
+ [dict removeFloatForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:11]);
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ XCTAssertFalse([dict getFloat:NULL forKey:13]);
+ XCTAssertFalse([dict getFloat:NULL forKey:14]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:11];
+ [dict setFloat:503.f forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:14];
+ [dict setFloat:501.f forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 501.f);
const int32_t kKeys2[] = { 12, 13 };
const float kValues2[] = { 502.f, 500.f };
GPBInt32FloatDictionary *dict2 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues2
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32DoubleDictionary *dict = [[GPBInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:11]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32DoubleDictionary *dict = [GPBInt32DoubleDictionary dictionaryWithValue:600. forKey:11];
+ GPBInt32DoubleDictionary *dict = [[GPBInt32DoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const double kValues[] = { 600., 601., 602. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, 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);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict1 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32DoubleDictionary *dict1prime =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32DoubleDictionary *dict2 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32DoubleDictionary *dict3 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32DoubleDictionary *dict4 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32DoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32DoubleDictionary *dict2 =
- [GPBInt32DoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32DoubleDictionary *dict = [GPBInt32DoubleDictionary dictionary];
+ GPBInt32DoubleDictionary *dict = [[GPBInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:11];
+ [dict setDouble:600. forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const double kValues[] = { 601., 602., 603. };
GPBInt32DoubleDictionary *dict2 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeDoubleForKey:12];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeDoubleForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:14];
+ [dict removeDoubleForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:11]);
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ XCTAssertFalse([dict getDouble:NULL forKey:13]);
+ XCTAssertFalse([dict getDouble:NULL forKey:14]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:11];
+ [dict setDouble:603. forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:14];
+ [dict setDouble:601. forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 601.);
const int32_t kKeys2[] = { 12, 13 };
const double kValues2[] = { 602., 600. };
GPBInt32DoubleDictionary *dict2 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32EnumDictionary *dict = [[GPBInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:11]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32EnumDictionary *dict = [GPBInt32EnumDictionary dictionaryWithValue:700 forKey:11];
+ GPBInt32EnumDictionary *dict = [[GPBInt32EnumDictionary alloc] init];
+ [dict setEnum:700 forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const int32_t kValues[] = { 700, 701, 702 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, 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);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict1 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32EnumDictionary *dict1prime =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32EnumDictionary *dict2 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32EnumDictionary *dict3 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32EnumDictionary *dict4 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32EnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32EnumDictionary *dict2 =
- [GPBInt32EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32EnumDictionary *dict = [GPBInt32EnumDictionary dictionary];
+ GPBInt32EnumDictionary *dict = [[GPBInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:11];
+ [dict setEnum:700 forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const int32_t kValues[] = { 701, 702, 703 };
GPBInt32EnumDictionary *dict2 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeEnumForKey:12];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeEnumForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:14];
+ [dict removeEnumForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:11]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertFalse([dict getEnum:NULL forKey:13]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:11];
+ [dict setEnum:703 forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:14];
+ [dict setEnum:701 forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 701);
const int32_t kKeys2[] = { 12, 13 };
const int32_t kValues2[] = { 702, 700 };
GPBInt32EnumDictionary *dict2 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:11 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:11 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:11]);
+ XCTAssertTrue([dict getRawValue:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:13 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:13]);
+ XCTAssertTrue([dict getRawValue:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:14 rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32EnumDictionary *dict2 =
- [GPBInt32EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBInt32EnumDictionary *dict =
- [GPBInt32EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBInt32EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:12], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:12], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:12]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 13, 14 };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBInt32EnumDictionary *dict2 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeEnumForKey:12];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeEnumForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:14];
+ [dict removeEnumForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:11]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertFalse([dict getEnum:NULL forKey:13]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:11], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:11], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:11]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:11 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:11]);
+ XCTAssertTrue([dict getRawValue:&value forKey:11]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:11 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:11]);
+ XCTAssertTrue([dict getRawValue:&value forKey:11]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 700);
const int32_t kKeys2[] = { 12, 13 };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:11 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:11]);
+ XCTAssertTrue([dict getRawValue:&value forKey:11]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:13 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:13 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:13]);
+ XCTAssertTrue([dict getRawValue:&value forKey:13]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 700);
[dict2 release];
@@ -3363,11 +3388,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
@implementation GPBInt32ObjectDictionaryTests
- (void)testEmpty {
- GPBInt32ObjectDictionary *dict = [[GPBInt32ObjectDictionary alloc] init];
+ GPBInt32ObjectDictionary<NSString*> *dict = [[GPBInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:11]);
- [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -3375,22 +3400,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32ObjectDictionary *dict = [GPBInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:11];
+ GPBInt32ObjectDictionary<NSString*> *dict = [[GPBInt32ObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
XCTAssertNil([dict objectForKey:12]);
- [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
- const id kObjects[] = { @"abc", @"def", @"ghi" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3403,8 +3430,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
- id *seenObjects = malloc(3 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(3 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -3426,7 +3453,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -3438,30 +3465,30 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testEquality {
const int32_t kKeys1[] = { 11, 12, 13, 14 };
const int32_t kKeys2[] = { 12, 11, 14 };
- const id kObjects1[] = { @"abc", @"def", @"ghi" };
- const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
- const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def", @"ghi" };
+ const NSString* kObjects2[] = { @"abc", @"jkl", @"ghi" };
+ const NSString* kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict1 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBInt32ObjectDictionary *dict1prime =
+ GPBInt32ObjectDictionary<NSString*> *dict1prime =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBInt32ObjectDictionary *dict2 =
+ GPBInt32ObjectDictionary<NSString*> *dict2 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBInt32ObjectDictionary *dict3 =
+ GPBInt32ObjectDictionary<NSString*> *dict3 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBInt32ObjectDictionary *dict4 =
+ GPBInt32ObjectDictionary<NSString*> *dict4 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -3491,14 +3518,14 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testCopy {
const int32_t kKeys[] = { 11, 12, 13, 14 };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBInt32ObjectDictionary *dict2 = [dict copy];
+ GPBInt32ObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -3512,25 +3539,26 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testDictionaryFromDictionary {
const int32_t kKeys[] = { 11, 12, 13, 14 };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBInt32ObjectDictionary *dict2 =
- [GPBInt32ObjectDictionary dictionaryWithDictionary:dict];
+ GPBInt32ObjectDictionary<NSString*> *dict2 =
+ [[GPBInt32ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32ObjectDictionary *dict = [GPBInt32ObjectDictionary dictionary];
+ GPBInt32ObjectDictionary<NSString*> *dict = [[GPBInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -3538,8 +3566,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
- const id kObjects[] = { @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict2 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3552,15 +3580,16 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
XCTAssertEqualObjects([dict objectForKey:14], @"jkl");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
@@ -3597,11 +3626,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testInplaceMutation {
const int32_t kKeys[] = { 11, 12, 13, 14 };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
@@ -3624,8 +3653,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:14], @"def");
const int32_t kKeys2[] = { 12, 13 };
- const id kObjects2[] = { @"ghi", @"abc" };
- GPBInt32ObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"ghi", @"abc" };
+ GPBInt32ObjectDictionary<NSString*> *dict2 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests+Int64.m b/objectivec/Tests/GPBDictionaryTests+Int64.m
index 27f77f28..966024b7 100644
--- a/objectivec/Tests/GPBDictionaryTests+Int64.m
+++ b/objectivec/Tests/GPBDictionaryTests+Int64.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBInt64EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(int64_t)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const int64_t [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBInt64EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(int64_t)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBInt64EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const int64_t [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64UInt32Dictionary *dict = [[GPBInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:21LL]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64UInt32Dictionary *dict = [GPBInt64UInt32Dictionary dictionaryWithValue:100U forKey:21LL];
+ GPBInt64UInt32Dictionary *dict = [[GPBInt64UInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict1 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64UInt32Dictionary *dict1prime =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64UInt32Dictionary *dict2 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64UInt32Dictionary *dict3 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64UInt32Dictionary *dict4 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64UInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64UInt32Dictionary *dict2 =
- [GPBInt64UInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt64UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64UInt32Dictionary *dict = [GPBInt64UInt32Dictionary dictionary];
+ GPBInt64UInt32Dictionary *dict = [[GPBInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:21LL];
+ [dict setUInt32:100U forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict2 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeUInt32ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeUInt32ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:24LL];
+ [dict removeUInt32ForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:24LL]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:21LL];
+ [dict setUInt32:103U forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:24LL];
+ [dict setUInt32:101U forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 101U);
const int64_t kKeys2[] = { 22LL, 23LL };
const uint32_t kValues2[] = { 102U, 100U };
GPBInt64UInt32Dictionary *dict2 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64Int32Dictionary *dict = [[GPBInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:21LL]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64Int32Dictionary *dict = [GPBInt64Int32Dictionary dictionaryWithValue:200 forKey:21LL];
+ GPBInt64Int32Dictionary *dict = [[GPBInt64Int32Dictionary alloc] init];
+ [dict setInt32:200 forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const int32_t kValues[] = { 200, 201, 202 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict1 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64Int32Dictionary *dict1prime =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64Int32Dictionary *dict2 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64Int32Dictionary *dict3 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64Int32Dictionary *dict4 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues3
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64Int32Dictionary *dict2 =
- [GPBInt64Int32Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt64Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64Int32Dictionary *dict = [GPBInt64Int32Dictionary dictionary];
+ GPBInt64Int32Dictionary *dict = [[GPBInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:21LL];
+ [dict setInt32:200 forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const int32_t kValues[] = { 201, 202, 203 };
GPBInt64Int32Dictionary *dict2 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeInt32ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeInt32ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:24LL];
+ [dict removeInt32ForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:21LL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:23LL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:24LL]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:21LL];
+ [dict setInt32:203 forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:24LL];
+ [dict setInt32:201 forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 201);
const int64_t kKeys2[] = { 22LL, 23LL };
const int32_t kValues2[] = { 202, 200 };
GPBInt64Int32Dictionary *dict2 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64UInt64Dictionary *dict = [[GPBInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:21LL]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64UInt64Dictionary *dict = [GPBInt64UInt64Dictionary dictionaryWithValue:300U forKey:21LL];
+ GPBInt64UInt64Dictionary *dict = [[GPBInt64UInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict1 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64UInt64Dictionary *dict1prime =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64UInt64Dictionary *dict2 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64UInt64Dictionary *dict3 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64UInt64Dictionary *dict4 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64UInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64UInt64Dictionary *dict2 =
- [GPBInt64UInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt64UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64UInt64Dictionary *dict = [GPBInt64UInt64Dictionary dictionary];
+ GPBInt64UInt64Dictionary *dict = [[GPBInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:21LL];
+ [dict setUInt64:300U forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict2 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeUInt64ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeUInt64ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:24LL];
+ [dict removeUInt64ForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:24LL]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:21LL];
+ [dict setUInt64:303U forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:24LL];
+ [dict setUInt64:301U forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 301U);
const int64_t kKeys2[] = { 22LL, 23LL };
const uint64_t kValues2[] = { 302U, 300U };
GPBInt64UInt64Dictionary *dict2 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64Int64Dictionary *dict = [[GPBInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:21LL]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64Int64Dictionary *dict = [GPBInt64Int64Dictionary dictionaryWithValue:400 forKey:21LL];
+ GPBInt64Int64Dictionary *dict = [[GPBInt64Int64Dictionary alloc] init];
+ [dict setInt64:400 forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const int64_t kValues[] = { 400, 401, 402 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict1 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64Int64Dictionary *dict1prime =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64Int64Dictionary *dict2 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64Int64Dictionary *dict3 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64Int64Dictionary *dict4 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues3
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64Int64Dictionary *dict2 =
- [GPBInt64Int64Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt64Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64Int64Dictionary *dict = [GPBInt64Int64Dictionary dictionary];
+ GPBInt64Int64Dictionary *dict = [[GPBInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:21LL];
+ [dict setInt64:400 forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const int64_t kValues[] = { 401, 402, 403 };
GPBInt64Int64Dictionary *dict2 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeInt64ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeInt64ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:24LL];
+ [dict removeInt64ForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:21LL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:23LL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:24LL]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:21LL];
+ [dict setInt64:403 forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:24LL];
+ [dict setInt64:401 forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 401);
const int64_t kKeys2[] = { 22LL, 23LL };
const int64_t kValues2[] = { 402, 400 };
GPBInt64Int64Dictionary *dict2 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64BoolDictionary *dict = [[GPBInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:21LL]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64BoolDictionary *dict = [GPBInt64BoolDictionary dictionaryWithValue:YES forKey:21LL];
+ GPBInt64BoolDictionary *dict = [[GPBInt64BoolDictionary alloc] init];
+ [dict setBool:YES forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const BOOL kValues[] = { YES, YES, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict1 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64BoolDictionary *dict1prime =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64BoolDictionary *dict2 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64BoolDictionary *dict3 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64BoolDictionary *dict4 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64BoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64BoolDictionary *dict2 =
- [GPBInt64BoolDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64BoolDictionary *dict = [GPBInt64BoolDictionary dictionary];
+ GPBInt64BoolDictionary *dict = [[GPBInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:21LL];
+ [dict setBool:YES forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, NO, NO };
GPBInt64BoolDictionary *dict2 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeBoolForKey:22LL];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeBoolForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:24LL];
+ [dict removeBoolForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:21LL]);
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ XCTAssertFalse([dict getBool:NULL forKey:23LL]);
+ XCTAssertFalse([dict getBool:NULL forKey:24LL]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:21LL];
+ [dict setBool:NO forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:24LL];
+ [dict setBool:YES forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, YES);
const int64_t kKeys2[] = { 22LL, 23LL };
const BOOL kValues2[] = { NO, YES };
GPBInt64BoolDictionary *dict2 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64FloatDictionary *dict = [[GPBInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:21LL]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64FloatDictionary *dict = [GPBInt64FloatDictionary dictionaryWithValue:500.f forKey:21LL];
+ GPBInt64FloatDictionary *dict = [[GPBInt64FloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict1 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64FloatDictionary *dict1prime =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64FloatDictionary *dict2 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues2
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64FloatDictionary *dict3 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64FloatDictionary *dict4 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues3
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64FloatDictionary *dict2 =
- [GPBInt64FloatDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64FloatDictionary *dict = [GPBInt64FloatDictionary dictionary];
+ GPBInt64FloatDictionary *dict = [[GPBInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:21LL];
+ [dict setFloat:500.f forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict2 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeFloatForKey:22LL];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeFloatForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:24LL];
+ [dict removeFloatForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:21LL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:23LL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:24LL]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:21LL];
+ [dict setFloat:503.f forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:24LL];
+ [dict setFloat:501.f forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 501.f);
const int64_t kKeys2[] = { 22LL, 23LL };
const float kValues2[] = { 502.f, 500.f };
GPBInt64FloatDictionary *dict2 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues2
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64DoubleDictionary *dict = [[GPBInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:21LL]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64DoubleDictionary *dict = [GPBInt64DoubleDictionary dictionaryWithValue:600. forKey:21LL];
+ GPBInt64DoubleDictionary *dict = [[GPBInt64DoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const double kValues[] = { 600., 601., 602. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict1 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64DoubleDictionary *dict1prime =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64DoubleDictionary *dict2 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64DoubleDictionary *dict3 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64DoubleDictionary *dict4 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64DoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64DoubleDictionary *dict2 =
- [GPBInt64DoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64DoubleDictionary *dict = [GPBInt64DoubleDictionary dictionary];
+ GPBInt64DoubleDictionary *dict = [[GPBInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:21LL];
+ [dict setDouble:600. forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const double kValues[] = { 601., 602., 603. };
GPBInt64DoubleDictionary *dict2 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeDoubleForKey:22LL];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeDoubleForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:24LL];
+ [dict removeDoubleForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:21LL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:23LL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:24LL]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:21LL];
+ [dict setDouble:603. forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:24LL];
+ [dict setDouble:601. forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 601.);
const int64_t kKeys2[] = { 22LL, 23LL };
const double kValues2[] = { 602., 600. };
GPBInt64DoubleDictionary *dict2 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64EnumDictionary *dict = [[GPBInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:21LL]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64EnumDictionary *dict = [GPBInt64EnumDictionary dictionaryWithValue:700 forKey:21LL];
+ GPBInt64EnumDictionary *dict = [[GPBInt64EnumDictionary alloc] init];
+ [dict setEnum:700 forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const int32_t kValues[] = { 700, 701, 702 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict1 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64EnumDictionary *dict1prime =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64EnumDictionary *dict2 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64EnumDictionary *dict3 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64EnumDictionary *dict4 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64EnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64EnumDictionary *dict2 =
- [GPBInt64EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64EnumDictionary *dict = [GPBInt64EnumDictionary dictionary];
+ GPBInt64EnumDictionary *dict = [[GPBInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:21LL];
+ [dict setEnum:700 forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const int32_t kValues[] = { 701, 702, 703 };
GPBInt64EnumDictionary *dict2 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeEnumForKey:22LL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeEnumForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:24LL];
+ [dict removeEnumForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:21LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:23LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:21LL];
+ [dict setEnum:703 forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:24LL];
+ [dict setEnum:701 forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 701);
const int64_t kKeys2[] = { 22LL, 23LL };
const int32_t kValues2[] = { 702, 700 };
GPBInt64EnumDictionary *dict2 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:21LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:21LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:23LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:23LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:24LL rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64EnumDictionary *dict2 =
- [GPBInt64EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBInt64EnumDictionary *dict =
- [GPBInt64EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBInt64EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:22LL], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:22LL], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:22LL]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBInt64EnumDictionary *dict2 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeEnumForKey:22LL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeEnumForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:24LL];
+ [dict removeEnumForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:21LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:23LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:21LL], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:21LL], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:21LL]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:21LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:21LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:21LL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:21LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:21LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:21LL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 700);
const int64_t kKeys2[] = { 22LL, 23LL };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:21LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:21LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:21LL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:23LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:23LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:23LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:23LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 700);
[dict2 release];
@@ -3363,11 +3388,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
@implementation GPBInt64ObjectDictionaryTests
- (void)testEmpty {
- GPBInt64ObjectDictionary *dict = [[GPBInt64ObjectDictionary alloc] init];
+ GPBInt64ObjectDictionary<NSString*> *dict = [[GPBInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:21LL]);
- [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -3375,22 +3400,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64ObjectDictionary *dict = [GPBInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:21LL];
+ GPBInt64ObjectDictionary<NSString*> *dict = [[GPBInt64ObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
XCTAssertNil([dict objectForKey:22LL]);
- [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
- const id kObjects[] = { @"abc", @"def", @"ghi" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3403,8 +3430,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
- id *seenObjects = malloc(3 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(3 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -3426,7 +3453,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -3438,30 +3465,30 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testEquality {
const int64_t kKeys1[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kKeys2[] = { 22LL, 21LL, 24LL };
- const id kObjects1[] = { @"abc", @"def", @"ghi" };
- const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
- const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def", @"ghi" };
+ const NSString* kObjects2[] = { @"abc", @"jkl", @"ghi" };
+ const NSString* kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict1 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBInt64ObjectDictionary *dict1prime =
+ GPBInt64ObjectDictionary<NSString*> *dict1prime =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBInt64ObjectDictionary *dict2 =
+ GPBInt64ObjectDictionary<NSString*> *dict2 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBInt64ObjectDictionary *dict3 =
+ GPBInt64ObjectDictionary<NSString*> *dict3 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBInt64ObjectDictionary *dict4 =
+ GPBInt64ObjectDictionary<NSString*> *dict4 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -3491,14 +3518,14 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testCopy {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBInt64ObjectDictionary *dict2 = [dict copy];
+ GPBInt64ObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -3512,25 +3539,26 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testDictionaryFromDictionary {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBInt64ObjectDictionary *dict2 =
- [GPBInt64ObjectDictionary dictionaryWithDictionary:dict];
+ GPBInt64ObjectDictionary<NSString*> *dict2 =
+ [[GPBInt64ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64ObjectDictionary *dict = [GPBInt64ObjectDictionary dictionary];
+ GPBInt64ObjectDictionary<NSString*> *dict = [[GPBInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -3538,8 +3566,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
- const id kObjects[] = { @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict2 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3552,15 +3580,16 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
@@ -3597,11 +3626,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testInplaceMutation {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
@@ -3624,8 +3653,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:24LL], @"def");
const int64_t kKeys2[] = { 22LL, 23LL };
- const id kObjects2[] = { @"ghi", @"abc" };
- GPBInt64ObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"ghi", @"abc" };
+ GPBInt64ObjectDictionary<NSString*> *dict2 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests+String.m b/objectivec/Tests/GPBDictionaryTests+String.m
index bfa10b19..82d7952b 100644
--- a/objectivec/Tests/GPBDictionaryTests+String.m
+++ b/objectivec/Tests/GPBDictionaryTests+String.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBStringEnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(NSString *)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const NSString * [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBStringEnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(NSString *)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBStringEnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const NSString * [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringUInt32Dictionary *dict = [[GPBStringUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringUInt32Dictionary *dict = [GPBStringUInt32Dictionary dictionaryWithValue:100U forKey:@"foo"];
+ GPBStringUInt32Dictionary *dict = [[GPBStringUInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict1 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringUInt32Dictionary *dict1prime =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringUInt32Dictionary *dict2 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringUInt32Dictionary *dict3 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringUInt32Dictionary *dict4 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringUInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringUInt32Dictionary *dict2 =
- [GPBStringUInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBStringUInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringUInt32Dictionary *dict = [GPBStringUInt32Dictionary dictionary];
+ GPBStringUInt32Dictionary *dict = [[GPBStringUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:@"foo"];
+ [dict setUInt32:100U forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict2 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeUInt32ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeUInt32ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:@"mumble"];
+ [dict removeUInt32ForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"mumble"]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:@"foo"];
+ [dict setUInt32:103U forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:@"mumble"];
+ [dict setUInt32:101U forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 101U);
const NSString *kKeys2[] = { @"bar", @"baz" };
const uint32_t kValues2[] = { 102U, 100U };
GPBStringUInt32Dictionary *dict2 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringInt32Dictionary *dict = [[GPBStringInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringInt32Dictionary *dict = [GPBStringInt32Dictionary dictionaryWithValue:200 forKey:@"foo"];
+ GPBStringInt32Dictionary *dict = [[GPBStringInt32Dictionary alloc] init];
+ [dict setInt32:200 forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const int32_t kValues[] = { 200, 201, 202 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict1 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringInt32Dictionary *dict1prime =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringInt32Dictionary *dict2 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues2
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringInt32Dictionary *dict3 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringInt32Dictionary *dict4 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues3
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringInt32Dictionary *dict2 =
- [GPBStringInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBStringInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringInt32Dictionary *dict = [GPBStringInt32Dictionary dictionary];
+ GPBStringInt32Dictionary *dict = [[GPBStringInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:@"foo"];
+ [dict setInt32:200 forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 201, 202, 203 };
GPBStringInt32Dictionary *dict2 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeInt32ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeInt32ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:@"mumble"];
+ [dict removeInt32ForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"mumble"]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:@"foo"];
+ [dict setInt32:203 forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:@"mumble"];
+ [dict setInt32:201 forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 201);
const NSString *kKeys2[] = { @"bar", @"baz" };
const int32_t kValues2[] = { 202, 200 };
GPBStringInt32Dictionary *dict2 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues2
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringUInt64Dictionary *dict = [[GPBStringUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringUInt64Dictionary *dict = [GPBStringUInt64Dictionary dictionaryWithValue:300U forKey:@"foo"];
+ GPBStringUInt64Dictionary *dict = [[GPBStringUInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict1 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringUInt64Dictionary *dict1prime =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringUInt64Dictionary *dict2 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringUInt64Dictionary *dict3 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringUInt64Dictionary *dict4 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringUInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringUInt64Dictionary *dict2 =
- [GPBStringUInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBStringUInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringUInt64Dictionary *dict = [GPBStringUInt64Dictionary dictionary];
+ GPBStringUInt64Dictionary *dict = [[GPBStringUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:@"foo"];
+ [dict setUInt64:300U forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict2 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeUInt64ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeUInt64ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:@"mumble"];
+ [dict removeUInt64ForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"mumble"]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:@"foo"];
+ [dict setUInt64:303U forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:@"mumble"];
+ [dict setUInt64:301U forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 301U);
const NSString *kKeys2[] = { @"bar", @"baz" };
const uint64_t kValues2[] = { 302U, 300U };
GPBStringUInt64Dictionary *dict2 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringInt64Dictionary *dict = [[GPBStringInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringInt64Dictionary *dict = [GPBStringInt64Dictionary dictionaryWithValue:400 forKey:@"foo"];
+ GPBStringInt64Dictionary *dict = [[GPBStringInt64Dictionary alloc] init];
+ [dict setInt64:400 forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const int64_t kValues[] = { 400, 401, 402 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict1 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringInt64Dictionary *dict1prime =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringInt64Dictionary *dict2 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues2
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringInt64Dictionary *dict3 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringInt64Dictionary *dict4 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues3
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringInt64Dictionary *dict2 =
- [GPBStringInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBStringInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringInt64Dictionary *dict = [GPBStringInt64Dictionary dictionary];
+ GPBStringInt64Dictionary *dict = [[GPBStringInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:@"foo"];
+ [dict setInt64:400 forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 401, 402, 403 };
GPBStringInt64Dictionary *dict2 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeInt64ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeInt64ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:@"mumble"];
+ [dict removeInt64ForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"mumble"]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:@"foo"];
+ [dict setInt64:403 forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:@"mumble"];
+ [dict setInt64:401 forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 401);
const NSString *kKeys2[] = { @"bar", @"baz" };
const int64_t kValues2[] = { 402, 400 };
GPBStringInt64Dictionary *dict2 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues2
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringBoolDictionary *dict = [[GPBStringBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringBoolDictionary *dict = [GPBStringBoolDictionary dictionaryWithValue:YES forKey:@"foo"];
+ GPBStringBoolDictionary *dict = [[GPBStringBoolDictionary alloc] init];
+ [dict setBool:YES forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const BOOL kValues[] = { YES, YES, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict1 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringBoolDictionary *dict1prime =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringBoolDictionary *dict2 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringBoolDictionary *dict3 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringBoolDictionary *dict4 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringBoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringBoolDictionary *dict2 =
- [GPBStringBoolDictionary dictionaryWithDictionary:dict];
+ [[GPBStringBoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringBoolDictionary *dict = [GPBStringBoolDictionary dictionary];
+ GPBStringBoolDictionary *dict = [[GPBStringBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:@"foo"];
+ [dict setBool:YES forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, NO, NO };
GPBStringBoolDictionary *dict2 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeBoolForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeBoolForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:@"mumble"];
+ [dict removeBoolForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"mumble"]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:@"foo"];
+ [dict setBool:NO forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:@"mumble"];
+ [dict setBool:YES forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, YES);
const NSString *kKeys2[] = { @"bar", @"baz" };
const BOOL kValues2[] = { NO, YES };
GPBStringBoolDictionary *dict2 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringFloatDictionary *dict = [[GPBStringFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringFloatDictionary *dict = [GPBStringFloatDictionary dictionaryWithValue:500.f forKey:@"foo"];
+ GPBStringFloatDictionary *dict = [[GPBStringFloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict1 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues1
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringFloatDictionary *dict1prime =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues1
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringFloatDictionary *dict2 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues2
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringFloatDictionary *dict3 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues1
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringFloatDictionary *dict4 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues3
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringFloatDictionary *dict2 =
- [GPBStringFloatDictionary dictionaryWithDictionary:dict];
+ [[GPBStringFloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringFloatDictionary *dict = [GPBStringFloatDictionary dictionary];
+ GPBStringFloatDictionary *dict = [[GPBStringFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:@"foo"];
+ [dict setFloat:500.f forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict2 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeFloatForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeFloatForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:@"mumble"];
+ [dict removeFloatForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"mumble"]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:@"foo"];
+ [dict setFloat:503.f forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:@"mumble"];
+ [dict setFloat:501.f forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 501.f);
const NSString *kKeys2[] = { @"bar", @"baz" };
const float kValues2[] = { 502.f, 500.f };
GPBStringFloatDictionary *dict2 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues2
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringDoubleDictionary *dict = [[GPBStringDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringDoubleDictionary *dict = [GPBStringDoubleDictionary dictionaryWithValue:600. forKey:@"foo"];
+ GPBStringDoubleDictionary *dict = [[GPBStringDoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const double kValues[] = { 600., 601., 602. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict1 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringDoubleDictionary *dict1prime =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringDoubleDictionary *dict2 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringDoubleDictionary *dict3 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringDoubleDictionary *dict4 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const double kValues[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringDoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const double kValues[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringDoubleDictionary *dict2 =
- [GPBStringDoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBStringDoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringDoubleDictionary *dict = [GPBStringDoubleDictionary dictionary];
+ GPBStringDoubleDictionary *dict = [[GPBStringDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:@"foo"];
+ [dict setDouble:600. forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const double kValues[] = { 601., 602., 603. };
GPBStringDoubleDictionary *dict2 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const double kValues[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeDoubleForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeDoubleForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:@"mumble"];
+ [dict removeDoubleForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"mumble"]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const double kValues[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:@"foo"];
+ [dict setDouble:603. forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:@"mumble"];
+ [dict setDouble:601. forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 601.);
const NSString *kKeys2[] = { @"bar", @"baz" };
const double kValues2[] = { 602., 600. };
GPBStringDoubleDictionary *dict2 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringEnumDictionary *dict = [[GPBStringEnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringEnumDictionary *dict = [GPBStringEnumDictionary dictionaryWithValue:700 forKey:@"foo"];
+ GPBStringEnumDictionary *dict = [[GPBStringEnumDictionary alloc] init];
+ [dict setEnum:700 forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const int32_t kValues[] = { 700, 701, 702 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict1 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringEnumDictionary *dict1prime =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringEnumDictionary *dict2 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringEnumDictionary *dict3 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringEnumDictionary *dict4 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringEnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringEnumDictionary *dict2 =
- [GPBStringEnumDictionary dictionaryWithDictionary:dict];
+ [[GPBStringEnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringEnumDictionary *dict = [GPBStringEnumDictionary dictionary];
+ GPBStringEnumDictionary *dict = [[GPBStringEnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:@"foo"];
+ [dict setEnum:700 forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 701, 702, 703 };
GPBStringEnumDictionary *dict2 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeEnumForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeEnumForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:@"mumble"];
+ [dict removeEnumForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:@"foo"];
+ [dict setEnum:703 forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:@"mumble"];
+ [dict setEnum:701 forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 701);
const NSString *kKeys2[] = { @"bar", @"baz" };
const int32_t kValues2[] = { 702, 700 };
GPBStringEnumDictionary *dict2 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:@"mumble" rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringEnumDictionary *dict2 =
- [GPBStringEnumDictionary dictionaryWithDictionary:dict];
+ [[GPBStringEnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBStringEnumDictionary *dict =
- [GPBStringEnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBStringEnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:@"bar"], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:@"bar"], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:@"bar"]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBStringEnumDictionary *dict2 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeEnumForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeEnumForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:@"mumble"];
+ [dict removeEnumForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:@"foo"], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:@"foo"], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:@"foo"]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"foo"]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"foo"]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 700);
const NSString *kKeys2[] = { @"bar", @"baz" };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"foo"]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"baz" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"baz"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 700);
[dict2 release];
diff --git a/objectivec/Tests/GPBDictionaryTests+UInt32.m b/objectivec/Tests/GPBDictionaryTests+UInt32.m
index c7c57652..5314c58a 100644
--- a/objectivec/Tests/GPBDictionaryTests+UInt32.m
+++ b/objectivec/Tests/GPBDictionaryTests+UInt32.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBUInt32EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(uint32_t)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const uint32_t [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBUInt32EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(uint32_t)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBUInt32EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const uint32_t [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32UInt32Dictionary *dict = [[GPBUInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:1U]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32UInt32Dictionary *dict = [GPBUInt32UInt32Dictionary dictionaryWithValue:100U forKey:1U];
+ GPBUInt32UInt32Dictionary *dict = [[GPBUInt32UInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict1 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32UInt32Dictionary *dict1prime =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32UInt32Dictionary *dict2 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32UInt32Dictionary *dict3 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32UInt32Dictionary *dict4 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32UInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32UInt32Dictionary *dict2 =
- [GPBUInt32UInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32UInt32Dictionary *dict = [GPBUInt32UInt32Dictionary dictionary];
+ GPBUInt32UInt32Dictionary *dict = [[GPBUInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:1U];
+ [dict setUInt32:100U forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict2 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeUInt32ForKey:2U];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeUInt32ForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:4U];
+ [dict removeUInt32ForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:1U]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:3U]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:4U]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:1U];
+ [dict setUInt32:103U forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:4U];
+ [dict setUInt32:101U forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 101U);
const uint32_t kKeys2[] = { 2U, 3U };
const uint32_t kValues2[] = { 102U, 100U };
GPBUInt32UInt32Dictionary *dict2 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32Int32Dictionary *dict = [[GPBUInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:1U]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32Int32Dictionary *dict = [GPBUInt32Int32Dictionary dictionaryWithValue:200 forKey:1U];
+ GPBUInt32Int32Dictionary *dict = [[GPBUInt32Int32Dictionary alloc] init];
+ [dict setInt32:200 forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const int32_t kValues[] = { 200, 201, 202 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict1 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32Int32Dictionary *dict1prime =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32Int32Dictionary *dict2 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32Int32Dictionary *dict3 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32Int32Dictionary *dict4 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues3
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32Int32Dictionary *dict2 =
- [GPBUInt32Int32Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32Int32Dictionary *dict = [GPBUInt32Int32Dictionary dictionary];
+ GPBUInt32Int32Dictionary *dict = [[GPBUInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:1U];
+ [dict setInt32:200 forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const int32_t kValues[] = { 201, 202, 203 };
GPBUInt32Int32Dictionary *dict2 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeInt32ForKey:2U];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeInt32ForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:4U];
+ [dict removeInt32ForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:1U]);
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ XCTAssertFalse([dict getInt32:NULL forKey:3U]);
+ XCTAssertFalse([dict getInt32:NULL forKey:4U]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:1U];
+ [dict setInt32:203 forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:4U];
+ [dict setInt32:201 forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 201);
const uint32_t kKeys2[] = { 2U, 3U };
const int32_t kValues2[] = { 202, 200 };
GPBUInt32Int32Dictionary *dict2 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32UInt64Dictionary *dict = [[GPBUInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:1U]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32UInt64Dictionary *dict = [GPBUInt32UInt64Dictionary dictionaryWithValue:300U forKey:1U];
+ GPBUInt32UInt64Dictionary *dict = [[GPBUInt32UInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict1 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32UInt64Dictionary *dict1prime =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32UInt64Dictionary *dict2 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32UInt64Dictionary *dict3 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32UInt64Dictionary *dict4 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32UInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32UInt64Dictionary *dict2 =
- [GPBUInt32UInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32UInt64Dictionary *dict = [GPBUInt32UInt64Dictionary dictionary];
+ GPBUInt32UInt64Dictionary *dict = [[GPBUInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:1U];
+ [dict setUInt64:300U forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict2 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeUInt64ForKey:2U];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeUInt64ForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:4U];
+ [dict removeUInt64ForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:1U]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:3U]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:4U]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:1U];
+ [dict setUInt64:303U forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:4U];
+ [dict setUInt64:301U forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 301U);
const uint32_t kKeys2[] = { 2U, 3U };
const uint64_t kValues2[] = { 302U, 300U };
GPBUInt32UInt64Dictionary *dict2 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32Int64Dictionary *dict = [[GPBUInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:1U]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32Int64Dictionary *dict = [GPBUInt32Int64Dictionary dictionaryWithValue:400 forKey:1U];
+ GPBUInt32Int64Dictionary *dict = [[GPBUInt32Int64Dictionary alloc] init];
+ [dict setInt64:400 forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const int64_t kValues[] = { 400, 401, 402 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict1 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32Int64Dictionary *dict1prime =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32Int64Dictionary *dict2 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32Int64Dictionary *dict3 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32Int64Dictionary *dict4 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues3
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32Int64Dictionary *dict2 =
- [GPBUInt32Int64Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32Int64Dictionary *dict = [GPBUInt32Int64Dictionary dictionary];
+ GPBUInt32Int64Dictionary *dict = [[GPBUInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:1U];
+ [dict setInt64:400 forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const int64_t kValues[] = { 401, 402, 403 };
GPBUInt32Int64Dictionary *dict2 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeInt64ForKey:2U];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeInt64ForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:4U];
+ [dict removeInt64ForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:1U]);
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ XCTAssertFalse([dict getInt64:NULL forKey:3U]);
+ XCTAssertFalse([dict getInt64:NULL forKey:4U]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:1U];
+ [dict setInt64:403 forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:4U];
+ [dict setInt64:401 forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 401);
const uint32_t kKeys2[] = { 2U, 3U };
const int64_t kValues2[] = { 402, 400 };
GPBUInt32Int64Dictionary *dict2 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32BoolDictionary *dict = [[GPBUInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:1U]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32BoolDictionary *dict = [GPBUInt32BoolDictionary dictionaryWithValue:YES forKey:1U];
+ GPBUInt32BoolDictionary *dict = [[GPBUInt32BoolDictionary alloc] init];
+ [dict setBool:YES forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const BOOL kValues[] = { YES, YES, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict1 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32BoolDictionary *dict1prime =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32BoolDictionary *dict2 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32BoolDictionary *dict3 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32BoolDictionary *dict4 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32BoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32BoolDictionary *dict2 =
- [GPBUInt32BoolDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32BoolDictionary *dict = [GPBUInt32BoolDictionary dictionary];
+ GPBUInt32BoolDictionary *dict = [[GPBUInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:1U];
+ [dict setBool:YES forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const BOOL kValues[] = { YES, NO, NO };
GPBUInt32BoolDictionary *dict2 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeBoolForKey:2U];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeBoolForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:4U];
+ [dict removeBoolForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:1U]);
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ XCTAssertFalse([dict getBool:NULL forKey:3U]);
+ XCTAssertFalse([dict getBool:NULL forKey:4U]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:1U];
+ [dict setBool:NO forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:4U];
+ [dict setBool:YES forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, YES);
const uint32_t kKeys2[] = { 2U, 3U };
const BOOL kValues2[] = { NO, YES };
GPBUInt32BoolDictionary *dict2 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32FloatDictionary *dict = [[GPBUInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:1U]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32FloatDictionary *dict = [GPBUInt32FloatDictionary dictionaryWithValue:500.f forKey:1U];
+ GPBUInt32FloatDictionary *dict = [[GPBUInt32FloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict1 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32FloatDictionary *dict1prime =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32FloatDictionary *dict2 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues2
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32FloatDictionary *dict3 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32FloatDictionary *dict4 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues3
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32FloatDictionary *dict2 =
- [GPBUInt32FloatDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32FloatDictionary *dict = [GPBUInt32FloatDictionary dictionary];
+ GPBUInt32FloatDictionary *dict = [[GPBUInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:1U];
+ [dict setFloat:500.f forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict2 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeFloatForKey:2U];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeFloatForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:4U];
+ [dict removeFloatForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:1U]);
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ XCTAssertFalse([dict getFloat:NULL forKey:3U]);
+ XCTAssertFalse([dict getFloat:NULL forKey:4U]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:1U];
+ [dict setFloat:503.f forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:4U];
+ [dict setFloat:501.f forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 501.f);
const uint32_t kKeys2[] = { 2U, 3U };
const float kValues2[] = { 502.f, 500.f };
GPBUInt32FloatDictionary *dict2 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues2
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32DoubleDictionary *dict = [[GPBUInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:1U]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32DoubleDictionary *dict = [GPBUInt32DoubleDictionary dictionaryWithValue:600. forKey:1U];
+ GPBUInt32DoubleDictionary *dict = [[GPBUInt32DoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const double kValues[] = { 600., 601., 602. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict1 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32DoubleDictionary *dict1prime =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32DoubleDictionary *dict2 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32DoubleDictionary *dict3 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32DoubleDictionary *dict4 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32DoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32DoubleDictionary *dict2 =
- [GPBUInt32DoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32DoubleDictionary *dict = [GPBUInt32DoubleDictionary dictionary];
+ GPBUInt32DoubleDictionary *dict = [[GPBUInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:1U];
+ [dict setDouble:600. forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const double kValues[] = { 601., 602., 603. };
GPBUInt32DoubleDictionary *dict2 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeDoubleForKey:2U];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeDoubleForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:4U];
+ [dict removeDoubleForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:1U]);
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ XCTAssertFalse([dict getDouble:NULL forKey:3U]);
+ XCTAssertFalse([dict getDouble:NULL forKey:4U]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:1U];
+ [dict setDouble:603. forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:4U];
+ [dict setDouble:601. forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 601.);
const uint32_t kKeys2[] = { 2U, 3U };
const double kValues2[] = { 602., 600. };
GPBUInt32DoubleDictionary *dict2 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32EnumDictionary *dict = [[GPBUInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:1U]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32EnumDictionary *dict = [GPBUInt32EnumDictionary dictionaryWithValue:700 forKey:1U];
+ GPBUInt32EnumDictionary *dict = [[GPBUInt32EnumDictionary alloc] init];
+ [dict setEnum:700 forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const int32_t kValues[] = { 700, 701, 702 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict1 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32EnumDictionary *dict1prime =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32EnumDictionary *dict2 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32EnumDictionary *dict3 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32EnumDictionary *dict4 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32EnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32EnumDictionary *dict2 =
- [GPBUInt32EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32EnumDictionary *dict = [GPBUInt32EnumDictionary dictionary];
+ GPBUInt32EnumDictionary *dict = [[GPBUInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:1U];
+ [dict setEnum:700 forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const int32_t kValues[] = { 701, 702, 703 };
GPBUInt32EnumDictionary *dict2 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeEnumForKey:2U];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeEnumForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:4U];
+ [dict removeEnumForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:1U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:3U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:1U];
+ [dict setEnum:703 forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:4U];
+ [dict setEnum:701 forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 701);
const uint32_t kKeys2[] = { 2U, 3U };
const int32_t kValues2[] = { 702, 700 };
GPBUInt32EnumDictionary *dict2 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:1U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:1U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:1U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:3U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:3U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:4U rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32EnumDictionary *dict2 =
- [GPBUInt32EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBUInt32EnumDictionary *dict =
- [GPBUInt32EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBUInt32EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:2U], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:2U], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:2U]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 3U, 4U };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBUInt32EnumDictionary *dict2 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeEnumForKey:2U];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeEnumForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:4U];
+ [dict removeEnumForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:1U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:3U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:1U], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:1U], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:1U]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:1U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:1U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:1U]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:1U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:1U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:1U]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 700);
const uint32_t kKeys2[] = { 2U, 3U };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:1U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:1U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:1U]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:3U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:3U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:3U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:3U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 700);
[dict2 release];
@@ -3363,11 +3388,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
@implementation GPBUInt32ObjectDictionaryTests
- (void)testEmpty {
- GPBUInt32ObjectDictionary *dict = [[GPBUInt32ObjectDictionary alloc] init];
+ GPBUInt32ObjectDictionary<NSString*> *dict = [[GPBUInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:1U]);
- [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -3375,22 +3400,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32ObjectDictionary *dict = [GPBUInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:1U];
+ GPBUInt32ObjectDictionary<NSString*> *dict = [[GPBUInt32ObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
XCTAssertNil([dict objectForKey:2U]);
- [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
- const id kObjects[] = { @"abc", @"def", @"ghi" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3403,8 +3430,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
- id *seenObjects = malloc(3 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(3 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -3426,7 +3453,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -3438,30 +3465,30 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testEquality {
const uint32_t kKeys1[] = { 1U, 2U, 3U, 4U };
const uint32_t kKeys2[] = { 2U, 1U, 4U };
- const id kObjects1[] = { @"abc", @"def", @"ghi" };
- const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
- const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def", @"ghi" };
+ const NSString* kObjects2[] = { @"abc", @"jkl", @"ghi" };
+ const NSString* kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict1 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBUInt32ObjectDictionary *dict1prime =
+ GPBUInt32ObjectDictionary<NSString*> *dict1prime =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBUInt32ObjectDictionary *dict2 =
+ GPBUInt32ObjectDictionary<NSString*> *dict2 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBUInt32ObjectDictionary *dict3 =
+ GPBUInt32ObjectDictionary<NSString*> *dict3 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBUInt32ObjectDictionary *dict4 =
+ GPBUInt32ObjectDictionary<NSString*> *dict4 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -3491,14 +3518,14 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testCopy {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBUInt32ObjectDictionary *dict2 = [dict copy];
+ GPBUInt32ObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -3512,25 +3539,26 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testDictionaryFromDictionary {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBUInt32ObjectDictionary *dict2 =
- [GPBUInt32ObjectDictionary dictionaryWithDictionary:dict];
+ GPBUInt32ObjectDictionary<NSString*> *dict2 =
+ [[GPBUInt32ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32ObjectDictionary *dict = [GPBUInt32ObjectDictionary dictionary];
+ GPBUInt32ObjectDictionary<NSString*> *dict = [[GPBUInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -3538,8 +3566,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
- const id kObjects[] = { @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict2 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3552,15 +3580,16 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
XCTAssertEqualObjects([dict objectForKey:4U], @"jkl");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
@@ -3597,11 +3626,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testInplaceMutation {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
@@ -3624,8 +3653,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:4U], @"def");
const uint32_t kKeys2[] = { 2U, 3U };
- const id kObjects2[] = { @"ghi", @"abc" };
- GPBUInt32ObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"ghi", @"abc" };
+ GPBUInt32ObjectDictionary<NSString*> *dict2 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests+UInt64.m b/objectivec/Tests/GPBDictionaryTests+UInt64.m
index b64d3a96..ccd063f5 100644
--- a/objectivec/Tests/GPBDictionaryTests+UInt64.m
+++ b/objectivec/Tests/GPBDictionaryTests+UInt64.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBUInt64EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(uint64_t)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const uint64_t [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBUInt64EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(uint64_t)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBUInt64EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const uint64_t [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64UInt32Dictionary *dict = [[GPBUInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:31ULL]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64UInt32Dictionary *dict = [GPBUInt64UInt32Dictionary dictionaryWithValue:100U forKey:31ULL];
+ GPBUInt64UInt32Dictionary *dict = [[GPBUInt64UInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict1 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64UInt32Dictionary *dict1prime =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64UInt32Dictionary *dict2 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64UInt32Dictionary *dict3 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64UInt32Dictionary *dict4 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64UInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64UInt32Dictionary *dict2 =
- [GPBUInt64UInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64UInt32Dictionary *dict = [GPBUInt64UInt32Dictionary dictionary];
+ GPBUInt64UInt32Dictionary *dict = [[GPBUInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:31ULL];
+ [dict setUInt32:100U forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict2 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeUInt32ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeUInt32ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:34ULL];
+ [dict removeUInt32ForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:34ULL]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:31ULL];
+ [dict setUInt32:103U forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:34ULL];
+ [dict setUInt32:101U forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 101U);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const uint32_t kValues2[] = { 102U, 100U };
GPBUInt64UInt32Dictionary *dict2 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64Int32Dictionary *dict = [[GPBUInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:31ULL]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64Int32Dictionary *dict = [GPBUInt64Int32Dictionary dictionaryWithValue:200 forKey:31ULL];
+ GPBUInt64Int32Dictionary *dict = [[GPBUInt64Int32Dictionary alloc] init];
+ [dict setInt32:200 forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const int32_t kValues[] = { 200, 201, 202 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict1 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64Int32Dictionary *dict1prime =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64Int32Dictionary *dict2 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64Int32Dictionary *dict3 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64Int32Dictionary *dict4 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues3
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64Int32Dictionary *dict2 =
- [GPBUInt64Int32Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64Int32Dictionary *dict = [GPBUInt64Int32Dictionary dictionary];
+ GPBUInt64Int32Dictionary *dict = [[GPBUInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:31ULL];
+ [dict setInt32:200 forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 201, 202, 203 };
GPBUInt64Int32Dictionary *dict2 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeInt32ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeInt32ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:34ULL];
+ [dict removeInt32ForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:34ULL]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:31ULL];
+ [dict setInt32:203 forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:34ULL];
+ [dict setInt32:201 forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 201);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const int32_t kValues2[] = { 202, 200 };
GPBUInt64Int32Dictionary *dict2 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64UInt64Dictionary *dict = [[GPBUInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:31ULL]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64UInt64Dictionary *dict = [GPBUInt64UInt64Dictionary dictionaryWithValue:300U forKey:31ULL];
+ GPBUInt64UInt64Dictionary *dict = [[GPBUInt64UInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict1 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64UInt64Dictionary *dict1prime =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64UInt64Dictionary *dict2 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64UInt64Dictionary *dict3 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64UInt64Dictionary *dict4 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64UInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64UInt64Dictionary *dict2 =
- [GPBUInt64UInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64UInt64Dictionary *dict = [GPBUInt64UInt64Dictionary dictionary];
+ GPBUInt64UInt64Dictionary *dict = [[GPBUInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:31ULL];
+ [dict setUInt64:300U forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict2 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeUInt64ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeUInt64ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:34ULL];
+ [dict removeUInt64ForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:34ULL]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:31ULL];
+ [dict setUInt64:303U forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:34ULL];
+ [dict setUInt64:301U forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 301U);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const uint64_t kValues2[] = { 302U, 300U };
GPBUInt64UInt64Dictionary *dict2 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64Int64Dictionary *dict = [[GPBUInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:31ULL]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64Int64Dictionary *dict = [GPBUInt64Int64Dictionary dictionaryWithValue:400 forKey:31ULL];
+ GPBUInt64Int64Dictionary *dict = [[GPBUInt64Int64Dictionary alloc] init];
+ [dict setInt64:400 forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const int64_t kValues[] = { 400, 401, 402 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict1 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64Int64Dictionary *dict1prime =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64Int64Dictionary *dict2 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64Int64Dictionary *dict3 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64Int64Dictionary *dict4 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues3
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64Int64Dictionary *dict2 =
- [GPBUInt64Int64Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64Int64Dictionary *dict = [GPBUInt64Int64Dictionary dictionary];
+ GPBUInt64Int64Dictionary *dict = [[GPBUInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:31ULL];
+ [dict setInt64:400 forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 401, 402, 403 };
GPBUInt64Int64Dictionary *dict2 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeInt64ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeInt64ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:34ULL];
+ [dict removeInt64ForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:34ULL]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:31ULL];
+ [dict setInt64:403 forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:34ULL];
+ [dict setInt64:401 forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 401);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const int64_t kValues2[] = { 402, 400 };
GPBUInt64Int64Dictionary *dict2 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64BoolDictionary *dict = [[GPBUInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:31ULL]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64BoolDictionary *dict = [GPBUInt64BoolDictionary dictionaryWithValue:YES forKey:31ULL];
+ GPBUInt64BoolDictionary *dict = [[GPBUInt64BoolDictionary alloc] init];
+ [dict setBool:YES forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const BOOL kValues[] = { YES, YES, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict1 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64BoolDictionary *dict1prime =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64BoolDictionary *dict2 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64BoolDictionary *dict3 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64BoolDictionary *dict4 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64BoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64BoolDictionary *dict2 =
- [GPBUInt64BoolDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64BoolDictionary *dict = [GPBUInt64BoolDictionary dictionary];
+ GPBUInt64BoolDictionary *dict = [[GPBUInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:31ULL];
+ [dict setBool:YES forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, NO, NO };
GPBUInt64BoolDictionary *dict2 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeBoolForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeBoolForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:34ULL];
+ [dict removeBoolForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:34ULL]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:31ULL];
+ [dict setBool:NO forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:34ULL];
+ [dict setBool:YES forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, YES);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const BOOL kValues2[] = { NO, YES };
GPBUInt64BoolDictionary *dict2 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64FloatDictionary *dict = [[GPBUInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:31ULL]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64FloatDictionary *dict = [GPBUInt64FloatDictionary dictionaryWithValue:500.f forKey:31ULL];
+ GPBUInt64FloatDictionary *dict = [[GPBUInt64FloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict1 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64FloatDictionary *dict1prime =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64FloatDictionary *dict2 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues2
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64FloatDictionary *dict3 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64FloatDictionary *dict4 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues3
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64FloatDictionary *dict2 =
- [GPBUInt64FloatDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64FloatDictionary *dict = [GPBUInt64FloatDictionary dictionary];
+ GPBUInt64FloatDictionary *dict = [[GPBUInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:31ULL];
+ [dict setFloat:500.f forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict2 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeFloatForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeFloatForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:34ULL];
+ [dict removeFloatForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:34ULL]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:31ULL];
+ [dict setFloat:503.f forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:34ULL];
+ [dict setFloat:501.f forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 501.f);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const float kValues2[] = { 502.f, 500.f };
GPBUInt64FloatDictionary *dict2 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues2
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64DoubleDictionary *dict = [[GPBUInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:31ULL]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64DoubleDictionary *dict = [GPBUInt64DoubleDictionary dictionaryWithValue:600. forKey:31ULL];
+ GPBUInt64DoubleDictionary *dict = [[GPBUInt64DoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const double kValues[] = { 600., 601., 602. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict1 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64DoubleDictionary *dict1prime =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64DoubleDictionary *dict2 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64DoubleDictionary *dict3 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64DoubleDictionary *dict4 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64DoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64DoubleDictionary *dict2 =
- [GPBUInt64DoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64DoubleDictionary *dict = [GPBUInt64DoubleDictionary dictionary];
+ GPBUInt64DoubleDictionary *dict = [[GPBUInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:31ULL];
+ [dict setDouble:600. forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const double kValues[] = { 601., 602., 603. };
GPBUInt64DoubleDictionary *dict2 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeDoubleForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeDoubleForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:34ULL];
+ [dict removeDoubleForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:34ULL]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:31ULL];
+ [dict setDouble:603. forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:34ULL];
+ [dict setDouble:601. forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 601.);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const double kValues2[] = { 602., 600. };
GPBUInt64DoubleDictionary *dict2 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64EnumDictionary *dict = [[GPBUInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:31ULL]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64EnumDictionary *dict = [GPBUInt64EnumDictionary dictionaryWithValue:700 forKey:31ULL];
+ GPBUInt64EnumDictionary *dict = [[GPBUInt64EnumDictionary alloc] init];
+ [dict setEnum:700 forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const int32_t kValues[] = { 700, 701, 702 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict1 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64EnumDictionary *dict1prime =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64EnumDictionary *dict2 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64EnumDictionary *dict3 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64EnumDictionary *dict4 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64EnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64EnumDictionary *dict2 =
- [GPBUInt64EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64EnumDictionary *dict = [GPBUInt64EnumDictionary dictionary];
+ GPBUInt64EnumDictionary *dict = [[GPBUInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:31ULL];
+ [dict setEnum:700 forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 701, 702, 703 };
GPBUInt64EnumDictionary *dict2 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeEnumForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeEnumForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:34ULL];
+ [dict removeEnumForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:31ULL];
+ [dict setEnum:703 forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:34ULL];
+ [dict setEnum:701 forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 701);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const int32_t kValues2[] = { 702, 700 };
GPBUInt64EnumDictionary *dict2 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:34ULL rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64EnumDictionary *dict2 =
- [GPBUInt64EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBUInt64EnumDictionary *dict =
- [GPBUInt64EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBUInt64EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:32ULL], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:32ULL], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:32ULL]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBUInt64EnumDictionary *dict2 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeEnumForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeEnumForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:34ULL];
+ [dict removeEnumForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:31ULL], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:31ULL], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:31ULL]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:31ULL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:31ULL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 700);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:31ULL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:33ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:33ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 700);
[dict2 release];
@@ -3363,11 +3388,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
@implementation GPBUInt64ObjectDictionaryTests
- (void)testEmpty {
- GPBUInt64ObjectDictionary *dict = [[GPBUInt64ObjectDictionary alloc] init];
+ GPBUInt64ObjectDictionary<NSString*> *dict = [[GPBUInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:31ULL]);
- [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -3375,22 +3400,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:31ULL];
+ GPBUInt64ObjectDictionary<NSString*> *dict = [[GPBUInt64ObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
XCTAssertNil([dict objectForKey:32ULL]);
- [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3403,8 +3430,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
- id *seenObjects = malloc(3 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(3 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -3426,7 +3453,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -3438,30 +3465,30 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testEquality {
const uint64_t kKeys1[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kKeys2[] = { 32ULL, 31ULL, 34ULL };
- const id kObjects1[] = { @"abc", @"def", @"ghi" };
- const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
- const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def", @"ghi" };
+ const NSString* kObjects2[] = { @"abc", @"jkl", @"ghi" };
+ const NSString* kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict1 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBUInt64ObjectDictionary *dict1prime =
+ GPBUInt64ObjectDictionary<NSString*> *dict1prime =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBUInt64ObjectDictionary *dict2 =
+ GPBUInt64ObjectDictionary<NSString*> *dict2 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBUInt64ObjectDictionary *dict3 =
+ GPBUInt64ObjectDictionary<NSString*> *dict3 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBUInt64ObjectDictionary *dict4 =
+ GPBUInt64ObjectDictionary<NSString*> *dict4 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -3491,14 +3518,14 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testCopy {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBUInt64ObjectDictionary *dict2 = [dict copy];
+ GPBUInt64ObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -3512,25 +3539,26 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testDictionaryFromDictionary {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBUInt64ObjectDictionary *dict2 =
- [GPBUInt64ObjectDictionary dictionaryWithDictionary:dict];
+ GPBUInt64ObjectDictionary<NSString*> *dict2 =
+ [[GPBUInt64ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionary];
+ GPBUInt64ObjectDictionary<NSString*> *dict = [[GPBUInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -3538,8 +3566,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict2 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3552,15 +3580,16 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
@@ -3597,11 +3626,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testInplaceMutation {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
@@ -3624,8 +3653,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:34ULL], @"def");
const uint64_t kKeys2[] = { 32ULL, 33ULL };
- const id kObjects2[] = { @"ghi", @"abc" };
- GPBUInt64ObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"ghi", @"abc" };
+ GPBUInt64ObjectDictionary<NSString*> *dict2 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests.m b/objectivec/Tests/GPBDictionaryTests.m
new file mode 100644
index 00000000..52b4b328
--- /dev/null
+++ b/objectivec/Tests/GPBDictionaryTests.m
@@ -0,0 +1,186 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <Foundation/Foundation.h>
+#import <XCTest/XCTest.h>
+
+#import "GPBDictionary.h"
+#import "GPBDictionary_PackagePrivate.h"
+
+#import "GPBTestUtilities.h"
+
+#pragma mark - GPBAutocreatedDictionary Tests
+
+// These are hand written tests to double check some behaviors of the
+// GPBAutocreatedDictionary. The GPBDictionary+[type]Tests files are generate
+// tests.
+
+// NOTE: GPBAutocreatedDictionary is private to the library, users of the
+// library should never have to directly deal with this class.
+
+@interface GPBAutocreatedDictionaryTests : XCTestCase
+@end
+
+@implementation GPBAutocreatedDictionaryTests
+
+- (void)testEquality {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+
+ XCTAssertTrue([dict isEqual:@{}]);
+ XCTAssertTrue([dict isEqualToDictionary:@{}]);
+
+ XCTAssertFalse([dict isEqual:@{ @"foo" : @"bar" }]);
+ XCTAssertFalse([dict isEqualToDictionary:@{ @"foo" : @"bar" }]);
+
+ [dict setObject:@"bar" forKey:@"foo"];
+
+ XCTAssertFalse([dict isEqual:@{}]);
+ XCTAssertFalse([dict isEqualToDictionary:@{}]);
+ XCTAssertTrue([dict isEqual:@{ @"foo" : @"bar" }]);
+ XCTAssertTrue([dict isEqualToDictionary:@{ @"foo" : @"bar" }]);
+ XCTAssertFalse([dict isEqual:@{ @"bar" : @"baz" }]);
+ XCTAssertFalse([dict isEqualToDictionary:@{ @"bar" : @"baz" }]);
+
+ GPBAutocreatedDictionary *dict2 = [[GPBAutocreatedDictionary alloc] init];
+
+ XCTAssertFalse([dict isEqual:dict2]);
+ XCTAssertFalse([dict isEqualToDictionary:dict2]);
+
+ [dict2 setObject:@"mumble" forKey:@"foo"];
+ XCTAssertFalse([dict isEqual:dict2]);
+ XCTAssertFalse([dict isEqualToDictionary:dict2]);
+
+ [dict2 setObject:@"bar" forKey:@"foo"];
+ XCTAssertTrue([dict isEqual:dict2]);
+ XCTAssertTrue([dict isEqualToDictionary:dict2]);
+
+ [dict2 release];
+ [dict release];
+}
+
+- (void)testCopy {
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+
+ NSDictionary *cpy = [dict copy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSDictionary *cpy2 = [dict copy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+
+ NSMutableDictionary *cpy = [dict mutableCopy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSMutableDictionary *cpy2 = [dict mutableCopy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+ dict[@"foo"] = @"bar";
+ dict[@"baz"] = @"mumble";
+
+ NSDictionary *cpy = [dict copy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
+
+ NSDictionary *cpy2 = [dict copy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+ dict[@"foo"] = @"bar";
+ dict[@"baz"] = @"mumble";
+
+ NSMutableDictionary *cpy = [dict mutableCopy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
+
+ NSMutableDictionary *cpy2 = [dict mutableCopy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+}
+
+@end
diff --git a/objectivec/Tests/GPBDictionaryTests.pddm b/objectivec/Tests/GPBDictionaryTests.pddm
index ada93c64..17f12c28 100644
--- a/objectivec/Tests/GPBDictionaryTests.pddm
+++ b/objectivec/Tests/GPBDictionaryTests.pddm
@@ -30,7 +30,7 @@
//%PDDM-DEFINE TEST_FOR_POD_KEY(KEY_NAME, KEY_TYPE, KEY1, KEY2, KEY3, KEY4)
//%TESTS_FOR_POD_VALUES(KEY_NAME, KEY_TYPE, , , KEY1, KEY2, KEY3, KEY4)
-//%TESTS_FOR_POD_KEY_OBJECT_VALUE(KEY_NAME, KEY_TYPE, KEY1, KEY2, KEY3, KEY4, Object, id, @"abc", @"def", @"ghi", @"jkl")
+//%TESTS_FOR_POD_KEY_OBJECT_VALUE(KEY_NAME, KEY_TYPE, KEY1, KEY2, KEY3, KEY4, Object, NSString*, @"abc", @"def", @"ghi", @"jkl")
//%PDDM-DEFINE TESTS_FOR_POD_VALUES(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4)
//%TEST_HELPERS(KEY_NAME, KEY_TYPE, KisP)
@@ -50,6 +50,13 @@
//%PDDM-DEFINE TESTS_FOR_POD_KEY_OBJECT_VALUE(KEY_NAME, KEY_TYPE, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VAL1, VAL2, VAL3, VAL4)
//%TESTS_COMMON(KEY_NAME, KEY_TYPE, , , KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, Objects, object, OBJECT, , VAL1, VAL2, VAL3, VAL4)
+//%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE)
+//%GPB##KEY_NAME##VALUE_NAME##Dictionary
+//%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE)
+//%GPB##KEY_NAME##VALUE_NAME##Dictionary
+//%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE)
+//%GPB##KEY_NAME##VALUE_NAME##Dictionary<VALUE_TYPE>
+
//%PDDM-DEFINE TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VSUFFIX, VNAME, VHELPER, VACCESSOR, VAL1, VAL2, VAL3, VAL4)
//%#pragma mark - KEY_NAME -> VALUE_NAME
//%
@@ -59,11 +66,11 @@
//%@implementation GPB##KEY_NAME##VALUE_NAME##DictionaryTests
//%
//%- (void)testEmpty {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% #pragma unused(aKey, a##VNAME$u, stop)
//% XCTFail(@"Shouldn't get here!");
//% }];
@@ -71,36 +78,38 @@
//%}
//%
//%- (void)testOne {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VNAME$u##:VAL1 forKey:KEY1];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
+//% [dict set##VALUE_NAME$u##:VAL1 forKey:KEY1];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 1U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% XCTAssertEqual##KSUFFIX(aKey, KEY1);
//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1);
//% XCTAssertNotEqual(stop, NULL);
//% }];
+//% [dict release];
//%}
//%
//%- (void)testBasics {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME$u##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 3U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//%
//% __block NSUInteger idx = 0;
//% KEY_TYPE KisP##*seenKeys = malloc(3 * sizeof(KEY_TYPE##KisP));
//% VALUE_TYPE *seen##VNAME$u##s = malloc(3 * sizeof(VALUE_TYPE));
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% XCTAssertLessThan(idx, 3U);
//% seenKeys[idx] = aKey;
//% seen##VNAME$u##s[idx] = a##VNAME$u##;
@@ -122,7 +131,7 @@
//%
//% // Stopping the enumeration.
//% idx = 0;
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% #pragma unused(aKey, a##VNAME$u)
//% if (idx == 1) *stop = YES;
//% XCTAssertNotEqual(idx, 2U);
@@ -137,30 +146,30 @@
//% const VALUE_TYPE k##VNAME$u##s1[] = { VAL1, VAL2, VAL3 };
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL1, VAL4, VAL3 };
//% const VALUE_TYPE k##VNAME$u##s3[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict1);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1prime =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict1prime);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
//% XCTAssertNotNil(dict2);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict3 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict3);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s3
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict4 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s3
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)];
//% XCTAssertNotNil(dict4);
//%
//% // 1/1Prime should be different objects, but equal.
@@ -188,13 +197,13 @@
//%- (void)testCopy {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 = [dict copy];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new object but equal.
@@ -209,129 +218,131 @@
//%- (void)testDictionaryFromDictionary {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithDictionary:dict];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithDictionary:dict];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
//% XCTAssertNotEqual(dict, dict2);
//% XCTAssertEqualObjects(dict, dict2);
+//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testAdds {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionary];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//%
//% XCTAssertEqual(dict.count, 0U);
-//% [dict set##VNAME$u##:VAL1 forKey:KEY1];
+//% [dict set##VALUE_NAME##:VAL1 forKey:KEY1];
//% XCTAssertEqual(dict.count, 1U);
//%
//% const KEY_TYPE KisP##kKeys[] = { KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict2);
//% [dict add##VACCESSOR##EntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 4U);
//%
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//% [dict2 release];
+//% [dict release];
//%}
//%
//%- (void)testRemove {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 4U);
//%
-//% [dict remove##VNAME$u##ForKey:KEY2];
+//% [dict remove##VALUE_NAME##ForKey:KEY2];
//% XCTAssertEqual(dict.count, 3U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//%
//% // Remove again does nothing.
-//% [dict remove##VNAME$u##ForKey:KEY2];
+//% [dict remove##VALUE_NAME##ForKey:KEY2];
//% XCTAssertEqual(dict.count, 3U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//%
-//% [dict remove##VNAME$u##ForKey:KEY4];
+//% [dict remove##VALUE_NAME##ForKey:KEY4];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//%
//% [dict removeAll];
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//% [dict release];
//%}
//%
//%- (void)testInplaceMutation {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 4U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//%
-//% [dict set##VNAME$u##:VAL4 forKey:KEY1];
+//% [dict set##VALUE_NAME##:VAL4 forKey:KEY1];
//% XCTAssertEqual(dict.count, 4U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL4)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//%
-//% [dict set##VNAME$u##:VAL2 forKey:KEY4];
+//% [dict set##VALUE_NAME##:VAL2 forKey:KEY4];
//% XCTAssertEqual(dict.count, 4U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL4)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL2)
//%
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY3 };
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL3, VAL1 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
//% XCTAssertNotNil(dict2);
//% [dict add##VACCESSOR##EntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 4U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL4)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL2)
//%
//% [dict2 release];
//% [dict release];
@@ -353,7 +364,7 @@
//%- (void)testRawBasics {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
@@ -362,15 +373,15 @@
//% XCTAssertEqual(dict.count, 3U);
//% XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_RAW_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, value, KEY2, kGPBUnrecognizedEnumeratorValue)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY2, kGPBUnrecognizedEnumeratorValue)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY3, VAL3)
-//%RAW_VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%RAW_VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//%
//% __block NSUInteger idx = 0;
//% KEY_TYPE KisP##*seenKeys = malloc(3 * sizeof(KEY_TYPE##KisP));
//% VALUE_TYPE *seenValues = malloc(3 * sizeof(VALUE_TYPE));
-//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
+//% [dict enumerateKeysAndEnumsUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
//% XCTAssertLessThan(idx, 3U);
//% seenKeys[idx] = aKey;
//% seenValues[idx] = aValue;
@@ -429,31 +440,31 @@
//% const VALUE_TYPE kValues1[] = { VAL1, VAL2, VAL3 }; // Unknown
//% const VALUE_TYPE kValues2[] = { VAL1, VAL4, VAL3 }; // Unknown
//% const VALUE_TYPE kValues3[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknowns
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues1
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
//% XCTAssertNotNil(dict1);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1prime =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues1
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
//% XCTAssertNotNil(dict1prime);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues2
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)];
//% XCTAssertNotNil(dict2);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict3 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues1
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
//% XCTAssertNotNil(dict3);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict4 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues3
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
@@ -485,14 +496,14 @@
//%- (void)testCopyWithUnknowns {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknown
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 = [dict copy];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
@@ -507,31 +518,32 @@
//%- (void)testDictionaryFromDictionary {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknowns
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithDictionary:dict];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithDictionary:dict];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
//% XCTAssertNotEqual(dict, dict2);
//% XCTAssertEqualObjects(dict, dict2);
//% XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testUnknownAdds {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
//% XCTAssertNotNil(dict);
//%
//% XCTAssertEqual(dict.count, 0U);
-//% XCTAssertThrowsSpecificNamed([dict setValue:VAL2 forKey:KEY2], // Unknown
+//% XCTAssertThrowsSpecificNamed([dict setEnum:VAL2 forKey:KEY2], // Unknown
//% NSException, NSInvalidArgumentException);
//% XCTAssertEqual(dict.count, 0U);
//% [dict setRawValue:VAL2 forKey:KEY2]; // Unknown
@@ -539,27 +551,28 @@
//%
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL3, VAL4 }; // Unknown
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues
-//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithEnums:kValues
+//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict2);
//% [dict addRawEntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 4U);
//%
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, value, KEY2, kGPBUnrecognizedEnumeratorValue)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY2, kGPBUnrecognizedEnumeratorValue)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, value, KEY4, kGPBUnrecognizedEnumeratorValue)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY4, kGPBUnrecognizedEnumeratorValue)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//% [dict2 release];
+//% [dict release];
//%}
//%
//%- (void)testUnknownRemove {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknowns
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
@@ -567,77 +580,77 @@
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 4U);
//%
-//% [dict removeValueForKey:KEY2];
+//% [dict removeEnumForKey:KEY2];
//% XCTAssertEqual(dict.count, 3U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
//% // Remove again does nothing.
-//% [dict removeValueForKey:KEY2];
+//% [dict removeEnumForKey:KEY2];
//% XCTAssertEqual(dict.count, 3U);
-//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
-//% [dict removeValueForKey:KEY4];
+//% [dict removeEnumForKey:KEY4];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//%
//% [dict removeAll];
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//% [dict release];
//%}
//%
//%- (void)testInplaceMutationUnknowns {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknowns
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 4U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
-//% XCTAssertThrowsSpecificNamed([dict setValue:VAL4 forKey:KEY1], // Unknown
+//% XCTAssertThrowsSpecificNamed([dict setEnum:VAL4 forKey:KEY1], // Unknown
//% NSException, NSInvalidArgumentException);
//% XCTAssertEqual(dict.count, 4U);
-//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
//% [dict setRawValue:VAL4 forKey:KEY1]; // Unknown
//% XCTAssertEqual(dict.count, 4U);
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY1, VAL4)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
//% [dict setRawValue:VAL1 forKey:KEY4];
//% XCTAssertEqual(dict.count, 4U);
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY1, VAL4)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY4, VAL1)
//%
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY3 };
//% const VALUE_TYPE kValues2[] = { VAL3, VAL2 }; // Unknown
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues2
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2
@@ -646,9 +659,9 @@
//% [dict addRawEntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 4U);
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY1, VAL4)
-//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY2, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY3, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY4, VAL1)
//%
//% [dict2 release];
//% [dict release];
@@ -657,14 +670,14 @@
//%- (void)testCopyUnknowns {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 = [dict copy];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
@@ -687,19 +700,19 @@
//%PDDM-DEFINE DECLARE_VALUE_STORAGEPOD(VALUE_TYPE, NAME)
//% VALUE_TYPE NAME;
//%
-//%PDDM-DEFINE VALUE_NOT_FOUNDPOD(DICT, KEY)
-//% XCTAssertFalse([DICT valueForKey:KEY value:NULL]);
-//%PDDM-DEFINE TEST_VALUEPOD(DICT, STORAGE, KEY, VALUE)
-//% XCTAssertTrue([DICT valueForKey:KEY value:NULL]);
-//% XCTAssertTrue([DICT valueForKey:KEY value:&STORAGE]);
+//%PDDM-DEFINE VALUE_NOT_FOUNDPOD(VALUE_NAME, DICT, KEY)
+//% XCTAssertFalse([DICT get##VALUE_NAME##:NULL forKey:KEY]);
+//%PDDM-DEFINE TEST_VALUEPOD(VALUE_NAME, DICT, STORAGE, KEY, VALUE)
+//% XCTAssertTrue([DICT get##VALUE_NAME##:NULL forKey:KEY]);
+//% XCTAssertTrue([DICT get##VALUE_NAME##:&STORAGE forKey:KEY]);
//% XCTAssertEqual(STORAGE, VALUE);
//%PDDM-DEFINE COMPARE_KEYS(KEY1, KEY2)
//%KEY1 == KEY2
-//%PDDM-DEFINE RAW_VALUE_NOT_FOUNDPOD(DICT, KEY)
-//% XCTAssertFalse([DICT valueForKey:KEY rawValue:NULL]);
+//%PDDM-DEFINE RAW_VALUE_NOT_FOUNDPOD(VALUE_NAME, DICT, KEY)
+//% XCTAssertFalse([DICT getRawValue:NULL forKey:KEY]);
//%PDDM-DEFINE TEST_RAW_VALUEPOD(DICT, STORAGE, KEY, VALUE)
-//% XCTAssertTrue([DICT valueForKey:KEY rawValue:NULL]);
-//% XCTAssertTrue([DICT valueForKey:KEY rawValue:&STORAGE]);
+//% XCTAssertTrue([DICT getRawValue:NULL forKey:KEY]);
+//% XCTAssertTrue([DICT getRawValue:&STORAGE forKey:KEY]);
//% XCTAssertEqual(STORAGE, VALUE);
//
@@ -708,9 +721,9 @@
//%PDDM-DEFINE DECLARE_VALUE_STORAGEOBJECT(VALUE_TYPE, NAME)
// Empty
-//%PDDM-DEFINE VALUE_NOT_FOUNDOBJECT(DICT, KEY)
+//%PDDM-DEFINE VALUE_NOT_FOUNDOBJECT(VALUE_NAME, DICT, KEY)
//% XCTAssertNil([DICT objectForKey:KEY]);
-//%PDDM-DEFINE TEST_VALUEOBJECT(DICT, STORAGE, KEY, VALUE)
+//%PDDM-DEFINE TEST_VALUEOBJECT(VALUE_NAME, DICT, STORAGE, KEY, VALUE)
//% XCTAssertEqualObjects([DICT objectForKey:KEY], VALUE);
//%PDDM-DEFINE COMPARE_KEYSObjects(KEY1, KEY2)
//%[KEY1 isEqual:KEY2]
@@ -722,10 +735,9 @@
//%PDDM-DEFINE TEST_HELPERS(KEY_NAME, KEY_TYPE, KisP)
//%// To let the testing macros work, add some extra methods to simplify things.
//%@interface GPB##KEY_NAME##EnumDictionary (TestingTweak)
-//%+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(KEY_TYPE##KisP$S##KisP)key;
-//%- (instancetype)initWithValues:(const int32_t [])values
-//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
-//% count:(NSUInteger)count;
+//%- (instancetype)initWithEnums:(const int32_t [])values
+//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
+//% count:(NSUInteger)count;
//%@end
//%
//%static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -741,17 +753,9 @@
//%}
//%
//%@implementation GPB##KEY_NAME##EnumDictionary (TestingTweak)
-//%+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(KEY_TYPE##KisP$S##KisP)key {
-//% // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
-//% // type correct.
-//% return [[(GPB##KEY_NAME##EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
-//% KEY_NAME$S rawValues:&value
-//% KEY_NAME$S forKeys:&key
-//% KEY_NAME$S count:1] autorelease];
-//%}
-//%- (instancetype)initWithValues:(const int32_t [])values
-//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
-//% count:(NSUInteger)count {
+//%- (instancetype)initWithEnums:(const int32_t [])values
+//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
+//% count:(NSUInteger)count {
//% return [self initWithValidationFunction:TestingEnum_IsValidValue
//% rawValues:values
//% forKeys:keys
@@ -782,11 +786,11 @@
//%@implementation GPB##KEY_NAME##VALUE_NAME##DictionaryTests
//%
//%- (void)testEmpty {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//% [dict enumerateKeysAnd##VALUE_NAME##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
//% #pragma unused(aKey, a##VNAME$u##, stop)
//% XCTFail(@"Shouldn't get here!");
//% }];
@@ -794,34 +798,36 @@
//%}
//%
//%- (void)testOne {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VNAME$u##:VAL1 forKey:KEY1];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
+//% [dict set##VALUE_NAME$u##:VAL1 forKey:KEY1];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 1U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% XCTAssertEqual##KSUFFIX(aKey, KEY1);
//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1);
//% XCTAssertNotEqual(stop, NULL);
//% }];
+//% [dict release];
//%}
//%
//%- (void)testBasics {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 2U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//%
//% __block NSUInteger idx = 0;
//% KEY_TYPE KisP##*seenKeys = malloc(2 * sizeof(KEY_TYPE##KisP));
//% VALUE_TYPE *seen##VNAME$u##s = malloc(2 * sizeof(VALUE_TYPE));
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
//% XCTAssertLessThan(idx, 2U);
//% seenKeys[idx] = aKey;
//% seen##VNAME$u##s[idx] = a##VNAME$u;
@@ -843,7 +849,7 @@
//%
//% // Stopping the enumeration.
//% idx = 0;
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
//% #pragma unused(aKey, a##VNAME$u)
//% if (idx == 0) *stop = YES;
//% XCTAssertNotEqual(idx, 2U);
@@ -858,30 +864,30 @@
//% const VALUE_TYPE k##VNAME$u##s1[] = { VAL1, VAL2 };
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL2, VAL1 };
//% const VALUE_TYPE k##VNAME$u##s3[] = { VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict1);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1prime =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict1prime);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
//% XCTAssertNotNil(dict2);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict3 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict3);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s3
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict4 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s3
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)];
//% XCTAssertNotNil(dict4);
//%
//% // 1/1Prime should be different objects, but equal.
@@ -909,13 +915,13 @@
//%- (void)testCopy {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 = [dict copy];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new object but equal.
@@ -930,106 +936,108 @@
//%- (void)testDictionaryFromDictionary {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithDictionary:dict];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithDictionary:dict];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
//% XCTAssertNotEqual(dict, dict2);
//% XCTAssertEqualObjects(dict, dict2);
+//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testAdds {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionary];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//%
//% XCTAssertEqual(dict.count, 0U);
-//% [dict set##VNAME$u:VAL1 forKey:KEY1];
+//% [dict set##VALUE_NAME:VAL1 forKey:KEY1];
//% XCTAssertEqual(dict.count, 1U);
//%
//% const KEY_TYPE KisP##kKeys[] = { KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict2);
//% [dict addEntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 2U);
//%
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//% [dict2 release];
+//% [dict release];
//%}
//%
//%- (void)testRemove {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2};
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 2U);
//%
-//% [dict remove##VNAME$u##ForKey:KEY2];
+//% [dict remove##VALUE_NAME##ForKey:KEY2];
//% XCTAssertEqual(dict.count, 1U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
//%
//% // Remove again does nothing.
-//% [dict remove##VNAME$u##ForKey:KEY2];
+//% [dict remove##VALUE_NAME##ForKey:KEY2];
//% XCTAssertEqual(dict.count, 1U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
//%
//% [dict removeAll];
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
//% [dict release];
//%}
//%
//%- (void)testInplaceMutation {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 2U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//%
-//% [dict set##VNAME$u##:VAL2 forKey:KEY1];
+//% [dict set##VALUE_NAME##:VAL2 forKey:KEY1];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//%
-//% [dict set##VNAME$u##:VAL1 forKey:KEY2];
+//% [dict set##VALUE_NAME##:VAL1 forKey:KEY2];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL1)
//%
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY1 };
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL2, VAL1 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
//% XCTAssertNotNil(dict2);
//% [dict addEntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//%
//% [dict2 release];
//% [dict release];
diff --git a/objectivec/Tests/GPBExtensionRegistryTest.m b/objectivec/Tests/GPBExtensionRegistryTest.m
new file mode 100644
index 00000000..b1168826
--- /dev/null
+++ b/objectivec/Tests/GPBExtensionRegistryTest.m
@@ -0,0 +1,138 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "GPBTestUtilities.h"
+
+#import "GPBExtensionRegistry.h"
+#import "google/protobuf/Unittest.pbobjc.h"
+
+@interface GPBExtensionRegistryTest : GPBTestCase
+@end
+
+@implementation GPBExtensionRegistryTest
+
+- (void)testBasics {
+ GPBExtensionRegistry *reg = [[[GPBExtensionRegistry alloc] init] autorelease];
+ XCTAssertNotNil(reg);
+
+ XCTAssertNil([reg extensionForDescriptor:[TestAllExtensions descriptor]
+ fieldNumber:1]);
+ XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor]
+ fieldNumber:1]);
+
+ [reg addExtension:[UnittestRoot optionalInt32Extension]];
+ [reg addExtension:[UnittestRoot packedInt64Extension]];
+
+ XCTAssertTrue([reg extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
+ [UnittestRoot optionalInt32Extension]); // ptr equality
+ XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor]
+ fieldNumber:1]);
+ XCTAssertTrue([reg extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
+ [UnittestRoot packedInt64Extension]); // ptr equality
+}
+
+- (void)testCopy {
+ GPBExtensionRegistry *reg1 = [[[GPBExtensionRegistry alloc] init] autorelease];
+ [reg1 addExtension:[UnittestRoot optionalInt32Extension]];
+
+ GPBExtensionRegistry *reg2 = [[reg1 copy] autorelease];
+ XCTAssertNotNil(reg2);
+
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
+ [UnittestRoot optionalInt32Extension]); // ptr equality
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
+ [UnittestRoot optionalInt32Extension]); // ptr equality
+
+ // Message class that had registered extension(s) at the -copy time.
+
+ [reg1 addExtension:[UnittestRoot optionalBoolExtension]];
+ [reg2 addExtension:[UnittestRoot optionalStringExtension]];
+
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] ==
+ [UnittestRoot optionalBoolExtension]); // ptr equality
+ XCTAssertNil([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14]);
+ XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13]);
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14] ==
+ [UnittestRoot optionalStringExtension]); // ptr equality
+
+ // Message class that did not have any registered extensions at the -copy time.
+
+ [reg1 addExtension:[UnittestRoot packedInt64Extension]];
+ [reg2 addExtension:[UnittestRoot packedSint32Extension]];
+
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
+ [UnittestRoot packedInt64Extension]); // ptr equality
+ XCTAssertNil([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94]);
+ XCTAssertNil([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91]);
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94] ==
+ [UnittestRoot packedSint32Extension]); // ptr equality
+
+}
+
+- (void)testAddExtensions {
+ GPBExtensionRegistry *reg1 = [[[GPBExtensionRegistry alloc] init] autorelease];
+ [reg1 addExtension:[UnittestRoot optionalInt32Extension]];
+
+ GPBExtensionRegistry *reg2 = [[[GPBExtensionRegistry alloc] init] autorelease];
+
+ XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor]
+ fieldNumber:1]);
+
+ [reg2 addExtensions:reg1];
+
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
+ [UnittestRoot optionalInt32Extension]); // ptr equality
+
+ // Confirm adding to the first doesn't add to the second.
+
+ [reg1 addExtension:[UnittestRoot optionalBoolExtension]];
+ [reg1 addExtension:[UnittestRoot packedInt64Extension]];
+
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] ==
+ [UnittestRoot optionalBoolExtension]); // ptr equality
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
+ [UnittestRoot packedInt64Extension]); // ptr equality
+ XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13]);
+ XCTAssertNil([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91]);
+
+ // Confirm adding to the second doesn't add to the first.
+
+ [reg2 addExtension:[UnittestRoot optionalStringExtension]];
+ [reg2 addExtension:[UnittestRoot packedSint32Extension]];
+
+ XCTAssertNil([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14]);
+ XCTAssertNil([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94]);
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14] ==
+ [UnittestRoot optionalStringExtension]); // ptr equality
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94] ==
+ [UnittestRoot packedSint32Extension]); // ptr equality
+}
+
+@end
diff --git a/objectivec/Tests/GPBMessageTests+Runtime.m b/objectivec/Tests/GPBMessageTests+Runtime.m
index 5e197711..0058311b 100644
--- a/objectivec/Tests/GPBMessageTests+Runtime.m
+++ b/objectivec/Tests/GPBMessageTests+Runtime.m
@@ -36,6 +36,7 @@
#import "google/protobuf/MapUnittest.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
+#import "google/protobuf/UnittestCycle.pbobjc.h"
#import "google/protobuf/UnittestObjcStartup.pbobjc.h"
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
@@ -49,11 +50,24 @@
// specific.
- (void)testStartupOrdering {
- // Just have to create a message. Nothing else uses the classes from
- // this file, so the first selector invoked on the class will initialize
- // it, which also initializes the root.
+ // Message class/Root class initialization is a little tricky, so these just
+ // create some possible patterns that can be a problem. The messages don't
+ // have to be exercised, just creating them is enough to test. If there
+ // is a problem, the runtime should assert or hang.
+ //
+ // Note: the messages from these proto files should not be used in any other
+ // tests, that way when they are referenced here it will be the first use and
+ // initialization will take place now.
+
TestObjCStartupMessage *message = [TestObjCStartupMessage message];
XCTAssertNotNil(message);
+
+ CycleBaz *baz = [CycleBaz message];
+ CycleBar *bar = [CycleBar message];
+ CycleFoo *foo = [CycleFoo message];
+ XCTAssertNotNil(baz);
+ XCTAssertNotNil(bar);
+ XCTAssertNotNil(foo);
}
- (void)testProto2HasMethodSupport {
@@ -326,6 +340,17 @@
//% [msg release];
//% }
//%
+//%PDDM-DEFINE PROTO2_TEST_CLEAR_FIELD_WITH_NIL(FIELD, VALUE)
+//% { // optional##FIELD
+//% Message2 *msg = [[Message2 alloc] init];
+//% XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_Optional##FIELD));
+//% msg.optional##FIELD = VALUE;
+//% XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_Optional##FIELD));
+//% msg.optional##FIELD = nil;
+//% XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_Optional##FIELD));
+//% [msg release];
+//% }
+//%
//%PDDM-DEFINE PROTO2_TEST_HAS_FIELDS()
//%PROTO2_TEST_HAS_FIELD(Int32, 1, 0)
//%PROTO2_TEST_HAS_FIELD(Int64, 1, 0)
@@ -347,6 +372,14 @@
//% //
//%
//%PROTO2_TEST_HAS_FIELD(Enum, Message2_Enum_Bar, Message2_Enum_Foo)
+//% //
+//% // Nil can also be used to clear strings, bytes, groups, and messages.
+//% //
+//%
+//%PROTO2_TEST_CLEAR_FIELD_WITH_NIL(String, @"foo")
+//%PROTO2_TEST_CLEAR_FIELD_WITH_NIL(Bytes, [@"foo" dataUsingEncoding:NSUTF8StringEncoding])
+//%PROTO2_TEST_CLEAR_FIELD_WITH_NIL(Group, [Message2_OptionalGroup message])
+//%PROTO2_TEST_CLEAR_FIELD_WITH_NIL(Message, [Message2 message])
//%PDDM-EXPAND PROTO2_TEST_HAS_FIELDS()
// This block of code is generated, do not edit it directly.
@@ -658,13 +691,57 @@
[msg release];
}
+ //
+ // Nil can also be used to clear strings, bytes, groups, and messages.
+ //
+
+ { // optionalString
+ Message2 *msg = [[Message2 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalString));
+ msg.optionalString = @"foo";
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalString));
+ msg.optionalString = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalString));
+ [msg release];
+ }
+
+ { // optionalBytes
+ Message2 *msg = [[Message2 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalBytes));
+ msg.optionalBytes = [@"foo" dataUsingEncoding:NSUTF8StringEncoding];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalBytes));
+ msg.optionalBytes = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalBytes));
+ [msg release];
+ }
+
+ { // optionalGroup
+ Message2 *msg = [[Message2 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalGroup));
+ msg.optionalGroup = [Message2_OptionalGroup message];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalGroup));
+ msg.optionalGroup = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalGroup));
+ [msg release];
+ }
+
+ { // optionalMessage
+ Message2 *msg = [[Message2 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalMessage));
+ msg.optionalMessage = [Message2 message];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalMessage));
+ msg.optionalMessage = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalMessage));
+ [msg release];
+ }
+
//%PDDM-EXPAND-END PROTO2_TEST_HAS_FIELDS()
}
- (void)testProto3SingleFieldHasBehavior {
//
- // Setting to any value including the default value (0) should result has*
- // being true.
+ // Setting to any value but the default value (0) should result has*
+ // being true. When set to the default, shouldn't be true.
//
//%PDDM-DEFINE PROTO3_TEST_HAS_FIELD(FIELD, NON_ZERO_VALUE, ZERO_VALUE)
@@ -678,6 +755,17 @@
//% [msg release];
//% }
//%
+//%PDDM-DEFINE PROTO3_TEST_CLEAR_FIELD_WITH_NIL(FIELD, VALUE)
+//% { // optional##FIELD
+//% Message3 *msg = [[Message3 alloc] init];
+//% XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_Optional##FIELD));
+//% msg.optional##FIELD = VALUE;
+//% XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_Optional##FIELD));
+//% msg.optional##FIELD = nil;
+//% XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_Optional##FIELD));
+//% [msg release];
+//% }
+//%
//%PDDM-DEFINE PROTO3_TEST_HAS_FIELDS()
//%PROTO3_TEST_HAS_FIELD(Int32, 1, 0)
//%PROTO3_TEST_HAS_FIELD(Int64, 1, 0)
@@ -695,10 +783,17 @@
//%PROTO3_TEST_HAS_FIELD(String, @"foo", @"")
//%PROTO3_TEST_HAS_FIELD(Bytes, [@"foo" dataUsingEncoding:NSUTF8StringEncoding], [NSData data])
//% //
-//% // Test doesn't apply to optionalGroup/optionalMessage.
+//% // Test doesn't apply to optionalMessage (no groups in proto3).
//% //
//%
//%PROTO3_TEST_HAS_FIELD(Enum, Message3_Enum_Bar, Message3_Enum_Foo)
+//% //
+//% // Nil can also be used to clear strings, bytes, and messages (no groups in proto3).
+//% //
+//%
+//%PROTO3_TEST_CLEAR_FIELD_WITH_NIL(String, @"foo")
+//%PROTO3_TEST_CLEAR_FIELD_WITH_NIL(Bytes, [@"foo" dataUsingEncoding:NSUTF8StringEncoding])
+//%PROTO3_TEST_CLEAR_FIELD_WITH_NIL(Message, [Message3 message])
//%PDDM-EXPAND PROTO3_TEST_HAS_FIELDS()
// This block of code is generated, do not edit it directly.
@@ -853,7 +948,7 @@
}
//
- // Test doesn't apply to optionalGroup/optionalMessage.
+ // Test doesn't apply to optionalMessage (no groups in proto3).
//
{ // optionalEnum
@@ -866,6 +961,40 @@
[msg release];
}
+ //
+ // Nil can also be used to clear strings, bytes, and messages (no groups in proto3).
+ //
+
+ { // optionalString
+ Message3 *msg = [[Message3 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalString));
+ msg.optionalString = @"foo";
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalString));
+ msg.optionalString = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalString));
+ [msg release];
+ }
+
+ { // optionalBytes
+ Message3 *msg = [[Message3 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalBytes));
+ msg.optionalBytes = [@"foo" dataUsingEncoding:NSUTF8StringEncoding];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalBytes));
+ msg.optionalBytes = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalBytes));
+ [msg release];
+ }
+
+ { // optionalMessage
+ Message3 *msg = [[Message3 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalMessage));
+ msg.optionalMessage = [Message3 message];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalMessage));
+ msg.optionalMessage = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalMessage));
+ [msg release];
+ }
+
//%PDDM-EXPAND-END PROTO3_TEST_HAS_FIELDS()
}
@@ -1972,6 +2101,262 @@
[msg release];
}
+- (void)testProto2OneofSetToDefault {
+
+ // proto3 doesn't normally write out zero (default) fields, but if they are
+ // in a oneof it does. proto2 doesn't have this special behavior, but we
+ // still confirm setting to the explicit default does set the case to be
+ // sure the runtime is working correctly.
+
+ NSString *oneofStringDefault = @"string";
+ NSData *oneofBytesDefault = [@"data" dataUsingEncoding:NSUTF8StringEncoding];
+
+ Message2 *msg = [[Message2 alloc] init];
+
+ uint32_t values[] = {
+ Message2_O_OneOfCase_OneofInt32,
+ Message2_O_OneOfCase_OneofInt64,
+ Message2_O_OneOfCase_OneofUint32,
+ Message2_O_OneOfCase_OneofUint64,
+ Message2_O_OneOfCase_OneofSint32,
+ Message2_O_OneOfCase_OneofSint64,
+ Message2_O_OneOfCase_OneofFixed32,
+ Message2_O_OneOfCase_OneofFixed64,
+ Message2_O_OneOfCase_OneofSfixed32,
+ Message2_O_OneOfCase_OneofSfixed64,
+ Message2_O_OneOfCase_OneofFloat,
+ Message2_O_OneOfCase_OneofDouble,
+ Message2_O_OneOfCase_OneofBool,
+ Message2_O_OneOfCase_OneofString,
+ Message2_O_OneOfCase_OneofBytes,
+ // Skip group
+ // Skip message
+ Message2_O_OneOfCase_OneofEnum,
+ };
+
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ switch (values[i]) {
+ case Message2_O_OneOfCase_OneofInt32:
+ msg.oneofInt32 = 100;
+ break;
+ case Message2_O_OneOfCase_OneofInt64:
+ msg.oneofInt64 = 101;
+ break;
+ case Message2_O_OneOfCase_OneofUint32:
+ msg.oneofUint32 = 102;
+ break;
+ case Message2_O_OneOfCase_OneofUint64:
+ msg.oneofUint64 = 103;
+ break;
+ case Message2_O_OneOfCase_OneofSint32:
+ msg.oneofSint32 = 104;
+ break;
+ case Message2_O_OneOfCase_OneofSint64:
+ msg.oneofSint64 = 105;
+ break;
+ case Message2_O_OneOfCase_OneofFixed32:
+ msg.oneofFixed32 = 106;
+ break;
+ case Message2_O_OneOfCase_OneofFixed64:
+ msg.oneofFixed64 = 107;
+ break;
+ case Message2_O_OneOfCase_OneofSfixed32:
+ msg.oneofSfixed32 = 108;
+ break;
+ case Message2_O_OneOfCase_OneofSfixed64:
+ msg.oneofSfixed64 = 109;
+ break;
+ case Message2_O_OneOfCase_OneofFloat:
+ msg.oneofFloat = 110.0f;
+ break;
+ case Message2_O_OneOfCase_OneofDouble:
+ msg.oneofDouble = 111.0;
+ break;
+ case Message2_O_OneOfCase_OneofBool:
+ msg.oneofBool = YES;
+ break;
+ case Message2_O_OneOfCase_OneofString:
+ msg.oneofString = oneofStringDefault;
+ break;
+ case Message2_O_OneOfCase_OneofBytes:
+ msg.oneofBytes = oneofBytesDefault;
+ break;
+ case Message2_O_OneOfCase_OneofEnum:
+ msg.oneofEnum = Message3_Enum_Baz;
+ break;
+ default:
+ XCTFail(@"shouldn't happen, loop: %zd, value: %d", i, values[i]);
+ break;
+ }
+
+ // Should be set to the correct case.
+ XCTAssertEqual(msg.oOneOfCase, values[i], "Loop: %zd", i);
+
+ // Confirm everything is the defaults.
+ XCTAssertEqual(msg.oneofInt32, 100, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofInt64, 101, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofUint32, 102U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofUint64, 103U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSint32, 104, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSint64, 105, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFixed32, 106U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFixed64, 107U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSfixed32, 108, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSfixed64, 109, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFloat, 110.0f, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofDouble, 111.0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofBool, YES, "Loop: %zd", i);
+ XCTAssertEqualObjects(msg.oneofString, oneofStringDefault, "Loop: %zd", i);
+ XCTAssertEqualObjects(msg.oneofBytes, oneofBytesDefault, "Loop: %zd", i);
+ // Skip group, no default to consider.
+ // Skip message, no default to consider.
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum_Baz, "Loop: %zd", i);
+ }
+
+ // We special case nil on string, data, group, and message, ensure they work
+ // as expected. i.e. - it clears the case.
+ msg.oneofString = nil;
+ XCTAssertEqualObjects(msg.oneofString, oneofStringDefault);
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase);
+ msg.oneofBytes = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertEqualObjects(msg.oneofBytes, oneofBytesDefault);
+ msg.oneofGroup = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertNotNil(msg.oneofGroup);
+ msg.oneofMessage = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertNotNil(msg.oneofMessage);
+
+ [msg release];
+}
+
+- (void)testProto3OneofSetToZero {
+
+ // Normally setting a proto3 field to the zero value should result in it being
+ // reset/cleared. But in a oneof, it still gets recored so it can go out
+ // over the wire and the other side can see what was set in the oneof.
+
+ NSString *oneofStringDefault = @"";
+ NSData *oneofBytesDefault = [NSData data];
+
+ Message3 *msg = [[Message3 alloc] init];
+
+ uint32_t values[] = {
+ Message3_O_OneOfCase_OneofInt32,
+ Message3_O_OneOfCase_OneofInt64,
+ Message3_O_OneOfCase_OneofUint32,
+ Message3_O_OneOfCase_OneofUint64,
+ Message3_O_OneOfCase_OneofSint32,
+ Message3_O_OneOfCase_OneofSint64,
+ Message3_O_OneOfCase_OneofFixed32,
+ Message3_O_OneOfCase_OneofFixed64,
+ Message3_O_OneOfCase_OneofSfixed32,
+ Message3_O_OneOfCase_OneofSfixed64,
+ Message3_O_OneOfCase_OneofFloat,
+ Message3_O_OneOfCase_OneofDouble,
+ Message3_O_OneOfCase_OneofBool,
+ Message3_O_OneOfCase_OneofString,
+ Message3_O_OneOfCase_OneofBytes,
+ Message3_O_OneOfCase_OneofMessage,
+ Message3_O_OneOfCase_OneofEnum,
+ };
+
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ switch (values[i]) {
+ case Message3_O_OneOfCase_OneofInt32:
+ msg.oneofInt32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofInt64:
+ msg.oneofInt64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofUint32:
+ msg.oneofUint32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofUint64:
+ msg.oneofUint64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofSint32:
+ msg.oneofSint32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofSint64:
+ msg.oneofSint64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofFixed32:
+ msg.oneofFixed32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofFixed64:
+ msg.oneofFixed64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofSfixed32:
+ msg.oneofSfixed32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofSfixed64:
+ msg.oneofSfixed64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofFloat:
+ msg.oneofFloat = 0.0f;
+ break;
+ case Message3_O_OneOfCase_OneofDouble:
+ msg.oneofDouble = 0.0;
+ break;
+ case Message3_O_OneOfCase_OneofBool:
+ msg.oneofBool = NO;
+ break;
+ case Message3_O_OneOfCase_OneofString:
+ msg.oneofString = oneofStringDefault;
+ break;
+ case Message3_O_OneOfCase_OneofBytes:
+ msg.oneofBytes = oneofBytesDefault;
+ break;
+ case Message3_O_OneOfCase_OneofMessage:
+ msg.oneofMessage.optionalInt32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofEnum:
+ msg.oneofEnum = Message3_Enum_Foo;
+ break;
+ default:
+ XCTFail(@"shouldn't happen, loop: %zd, value: %d", i, values[i]);
+ break;
+ }
+
+ // Should be set to the correct case.
+ XCTAssertEqual(msg.oOneOfCase, values[i], "Loop: %zd", i);
+
+ // Confirm everything is still zeros.
+ XCTAssertEqual(msg.oneofInt32, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofInt64, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofUint32, 0U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofUint64, 0U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSint32, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSint64, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFixed32, 0U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFixed64, 0U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSfixed32, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSfixed64, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFloat, 0.0f, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofDouble, 0.0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofBool, NO, "Loop: %zd", i);
+ XCTAssertEqualObjects(msg.oneofString, oneofStringDefault, "Loop: %zd", i);
+ XCTAssertEqualObjects(msg.oneofBytes, oneofBytesDefault, "Loop: %zd", i);
+ XCTAssertNotNil(msg.oneofMessage, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum_Foo, "Loop: %zd", i);
+ }
+
+ // We special case nil on string, data, message, ensure they work as expected.
+ msg.oneofString = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertEqualObjects(msg.oneofString, oneofStringDefault);
+ msg.oneofBytes = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertEqualObjects(msg.oneofBytes, oneofBytesDefault);
+ msg.oneofMessage = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertNotNil(msg.oneofMessage);
+
+ [msg release];
+}
+
- (void)testCopyingMakesUniqueObjects {
const int repeatCount = 5;
TestAllTypes *msg1 = [TestAllTypes message];
@@ -2066,6 +2451,46 @@
}];
}
+- (void)test_GPBGetMessageRepeatedField {
+ TestAllTypes *message = [TestAllTypes message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"repeatedStringArray"];
+ XCTAssertNotNil(fieldDescriptor);
+ NSMutableArray *fieldArray = GPBGetMessageRepeatedField(message, fieldDescriptor);
+ XCTAssertNotNil(fieldArray); // Should have autocreated.
+ XCTAssertTrue(fieldArray == message.repeatedStringArray); // Same pointer
+}
+
+- (void)test_GPBSetMessageRepeatedField {
+ TestAllTypes *message = [TestAllTypes message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"repeatedStringArray"];
+ XCTAssertNotNil(fieldDescriptor);
+
+ NSMutableArray *fieldArray = [NSMutableArray arrayWithObject:@"foo"];
+ GPBSetMessageRepeatedField(message, fieldDescriptor, fieldArray);
+ XCTAssertTrue(fieldArray == message.repeatedStringArray); // Same pointer
+ XCTAssertEqualObjects(@"foo", message.repeatedStringArray.firstObject);
+}
+
+- (void)test_GPBGetMessageMapField {
+ TestMap *message = [TestMap message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"mapStringString"];
+ XCTAssertNotNil(fieldDescriptor);
+ NSMutableDictionary *fieldMap = GPBGetMessageMapField(message, fieldDescriptor);
+ XCTAssertNotNil(fieldMap); // Should have autocreated.
+ XCTAssertTrue(fieldMap == message.mapStringString); // Same pointer
+}
+
+- (void)test_GPBSetMessageMapField {
+ TestMap *message = [TestMap message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"mapStringString"];
+ XCTAssertNotNil(fieldDescriptor);
+
+ NSMutableDictionary *fieldMap = [NSMutableDictionary dictionaryWithObject:@"bar" forKey:@"foo"];
+ GPBSetMessageMapField(message, fieldDescriptor, fieldMap);
+ XCTAssertTrue(fieldMap == message.mapStringString); // Same pointer
+ XCTAssertEqualObjects(@"bar", message.mapStringString[@"foo"]);
+}
+
#pragma mark - Subset from from map_tests.cc
// TEST(GeneratedMapFieldTest, IsInitialized)
diff --git a/objectivec/Tests/GPBMessageTests+Serialization.m b/objectivec/Tests/GPBMessageTests+Serialization.m
index 0d811a96..921feab7 100644
--- a/objectivec/Tests/GPBMessageTests+Serialization.m
+++ b/objectivec/Tests/GPBMessageTests+Serialization.m
@@ -42,10 +42,6 @@
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
-static NSData *DataFromCStr(const char *str) {
- return [NSData dataWithBytes:str length:strlen(str)];
-}
-
@interface MessageSerializationTests : GPBTestCase
@end
@@ -113,35 +109,6 @@ static NSData *DataFromCStr(const char *str) {
[msg release];
}
-- (void)testProto3DroppingUnknownFields {
- DropUnknownsFooWithExtraFields *fooWithExtras =
- [[DropUnknownsFooWithExtraFields alloc] init];
-
- fooWithExtras.int32Value = 1;
- fooWithExtras.enumValue = DropUnknownsFooWithExtraFields_NestedEnum_Baz;
- fooWithExtras.extraInt32Value = 2;
-
- NSData *data = [fooWithExtras data];
- XCTAssertNotNil(data);
- DropUnknownsFoo *foo = [DropUnknownsFoo parseFromData:data error:NULL];
-
- XCTAssertEqual(foo.int32Value, 1);
- XCTAssertEqual(foo.enumValue, DropUnknownsFoo_NestedEnum_Baz);
- // Nothing should end up in the unknowns.
- XCTAssertEqual([foo.unknownFields countOfFields], 0U);
-
- [fooWithExtras release];
- data = [foo data];
- fooWithExtras =
- [DropUnknownsFooWithExtraFields parseFromData:data error:NULL];
- XCTAssertEqual(fooWithExtras.int32Value, 1);
- XCTAssertEqual(fooWithExtras.enumValue,
- DropUnknownsFooWithExtraFields_NestedEnum_Baz);
- // And the extra value is gone (back to the default).
- XCTAssertEqual(fooWithExtras.extraInt32Value, 0);
- XCTAssertEqual([foo.unknownFields countOfFields], 0U);
-}
-
- (void)testProto2UnknownEnumToUnknownField {
Message3 *orig = [[Message3 alloc] init];
@@ -881,6 +848,156 @@ static NSData *DataFromCStr(const char *str) {
XCTAssertEqualObjects(extsParse, extsOrig);
}
+- (void)testErrorSubsectionInvalidLimit {
+ NSData *data = DataFromCStr(
+ "\x0A\x08\x0A\x07\x12\x04\x72\x02\x4B\x50\x12\x04\x72\x02\x4B\x50");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidSubsectionLimit);
+}
+
+- (void)testErrorSubsectionLimitReached {
+ NSData *data = DataFromCStr("\x0A\x06\x12\x03\x72\x02\x4B\x50");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorSubsectionLimitReached);
+}
+
+- (void)testErrorInvalidVarint {
+ NSData *data = DataFromCStr("\x72\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF");
+ NSError *error = nil;
+ TestAllTypes *msg = [TestAllTypes parseFromData:data error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidVarInt);
+}
+
+- (void)testErrorInvalidUTF8 {
+ NSData *data = DataFromCStr("\x72\x04\xF4\xFF\xFF\xFF");
+ NSError *error = nil;
+ TestAllTypes *msg = [TestAllTypes parseFromData:data error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidUTF8);
+}
+
+- (void)testErrorInvalidSize {
+ NSData *data = DataFromCStr("\x72\x03\x4B\x50");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidSize);
+}
+
+- (void)testErrorInvalidTag {
+ NSData *data = DataFromCStr("\x0F");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidTag);
+}
+
+- (void)testZeroFieldNum {
+ // These are ConformanceTestSuite::TestIllegalTags.
+
+ const char *tests[] = {
+ "\1DEADBEEF",
+ "\2\1\1",
+ "\3\4",
+ "\5DEAD"
+ };
+
+ for (size_t i = 0; i < GPBARRAYSIZE(tests); ++i) {
+ NSData *data = DataFromCStr(tests[i]);
+
+ {
+ // Message from proto2 syntax file
+ NSError *error = nil;
+ Message2 *msg = [Message2 parseFromData:data error:&error];
+ XCTAssertNil(msg, @"i = %zd", i);
+ XCTAssertNotNil(error, @"i = %zd", i);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain, @"i = %zd", i);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidTag, @"i = %zd", i);
+ }
+
+ {
+ // Message from proto3 syntax file
+ NSError *error = nil;
+ Message3 *msg = [Message3 parseFromData:data error:&error];
+ XCTAssertNil(msg, @"i = %zd", i);
+ XCTAssertNotNil(error, @"i = %zd", i);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain, @"i = %zd", i);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidTag, @"i = %zd", i);
+ }
+ }
+}
+
+- (void)testErrorRecursionDepthReached {
+ NSData *data = DataFromCStr(
+ "\x0A\xF2\x01\x0A\xEF\x01\x0A\xEC\x01\x0A\xE9\x01\x0A\xE6\x01"
+ "\x0A\xE3\x01\x0A\xE0\x01\x0A\xDD\x01\x0A\xDA\x01\x0A\xD7\x01"
+ "\x0A\xD4\x01\x0A\xD1\x01\x0A\xCE\x01\x0A\xCB\x01\x0A\xC8\x01"
+ "\x0A\xC5\x01\x0A\xC2\x01\x0A\xBF\x01\x0A\xBC\x01\x0A\xB9\x01"
+ "\x0A\xB6\x01\x0A\xB3\x01\x0A\xB0\x01\x0A\xAD\x01\x0A\xAA\x01"
+ "\x0A\xA7\x01\x0A\xA4\x01\x0A\xA1\x01\x0A\x9E\x01\x0A\x9B\x01"
+ "\x0A\x98\x01\x0A\x95\x01\x0A\x92\x01\x0A\x8F\x01\x0A\x8C\x01"
+ "\x0A\x89\x01\x0A\x86\x01\x0A\x83\x01\x0A\x80\x01\x0A\x7E"
+ "\x0A\x7C\x0A\x7A\x0A\x78\x0A\x76\x0A\x74\x0A\x72\x0A\x70"
+ "\x0A\x6E\x0A\x6C\x0A\x6A\x0A\x68\x0A\x66\x0A\x64\x0A\x62"
+ "\x0A\x60\x0A\x5E\x0A\x5C\x0A\x5A\x0A\x58\x0A\x56\x0A\x54"
+ "\x0A\x52\x0A\x50\x0A\x4E\x0A\x4C\x0A\x4A\x0A\x48\x0A\x46"
+ "\x0A\x44\x0A\x42\x0A\x40\x0A\x3E\x0A\x3C\x0A\x3A\x0A\x38"
+ "\x0A\x36\x0A\x34\x0A\x32\x0A\x30\x0A\x2E\x0A\x2C\x0A\x2A"
+ "\x0A\x28\x0A\x26\x0A\x24\x0A\x22\x0A\x20\x0A\x1E\x0A\x1C"
+ "\x0A\x1A\x0A\x18\x0A\x16\x0A\x14\x0A\x12\x0A\x10\x0A\x0E"
+ "\x0A\x0C\x0A\x0A\x0A\x08\x0A\x06\x12\x04\x72\x02\x4B\x50");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorRecursionDepthExceeded);
+}
+
+- (void)testParseDelimitedDataWithNegativeSize {
+ NSData *data = DataFromCStr("\xFF\xFF\xFF\xFF\x0F");
+ GPBCodedInputStream *input = [GPBCodedInputStream streamWithData:data];
+ NSError *error;
+ [GPBMessage parseDelimitedFromCodedInputStream:input
+ extensionRegistry:nil
+ error:&error];
+ XCTAssertNil(error);
+}
+
+#ifdef DEBUG
+- (void)testErrorMissingRequiredField {
+ NSData *data = DataFromCStr("");
+ NSError *error = nil;
+ TestRequired *msg = [TestRequired parseFromData:data error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBMessageErrorDomain);
+ XCTAssertEqual(error.code, GPBMessageErrorCodeMissingRequiredField);
+}
+#endif
+
#pragma mark - Subset from from map_tests.cc
// TEST(GeneratedMapFieldTest, StandardWireFormat)
@@ -890,7 +1007,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:1 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:1]);
XCTAssertEqual(val, 1);
[msg release];
@@ -904,7 +1021,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:2 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:2]);
XCTAssertEqual(val, 1);
[msg release];
@@ -918,7 +1035,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:2 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:2]);
XCTAssertEqual(val, 1);
[msg release];
@@ -932,7 +1049,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:1 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:1]);
XCTAssertEqual(val, 2);
[msg release];
@@ -946,7 +1063,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:0 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:0]);
XCTAssertEqual(val, 1);
[msg release];
@@ -960,7 +1077,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:1 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:1]);
XCTAssertEqual(val, 0);
[msg release];
@@ -974,7 +1091,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:2 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:2]);
XCTAssertEqual(val, 3);
[msg release];
@@ -989,29 +1106,29 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [TestMap parseFromData:data error:&error];
XCTAssertNil(msg);
XCTAssertNotNil(error);
- XCTAssertEqualObjects(error.domain, GPBMessageErrorDomain);
- XCTAssertEqual(error.code, GPBMessageErrorCodeMalformedData);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidSubsectionLimit);
}
// TEST(GeneratedMapFieldTest, Proto2UnknownEnum)
- (void)testMap_Proto2UnknownEnum {
TestEnumMapPlusExtra *orig = [[TestEnumMapPlusExtra alloc] init];
- orig.knownMapField = [GPBInt32EnumDictionary
- dictionaryWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue];
- orig.unknownMapField = [GPBInt32EnumDictionary
- dictionaryWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue];
- [orig.knownMapField setValue:Proto2MapEnumPlusExtra_EProto2MapEnumFoo
- forKey:0];
- [orig.unknownMapField setValue:Proto2MapEnumPlusExtra_EProto2MapEnumExtra
- forKey:0];
+ orig.knownMapField = [[[GPBInt32EnumDictionary alloc]
+ initWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue] autorelease];
+ orig.unknownMapField = [[[GPBInt32EnumDictionary alloc]
+ initWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue] autorelease];
+ [orig.knownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumFoo
+ forKey:0];
+ [orig.unknownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumExtra
+ forKey:0];
NSData *data = [orig data];
XCTAssertNotNil(data);
TestEnumMap *msg1 = [TestEnumMap parseFromData:data error:NULL];
XCTAssertEqual(msg1.knownMapField.count, 1U);
int32_t val = -1;
- XCTAssertTrue([msg1.knownMapField valueForKey:0 value:&val]);
+ XCTAssertTrue([msg1.knownMapField getEnum:&val forKey:0]);
XCTAssertEqual(val, Proto2MapEnum_Proto2MapEnumFoo);
XCTAssertEqual(msg1.unknownFields.countOfFields, 1U);
@@ -1020,11 +1137,11 @@ static NSData *DataFromCStr(const char *str) {
[TestEnumMapPlusExtra parseFromData:data error:NULL];
val = -1;
XCTAssertEqual(msg2.knownMapField.count, 1U);
- XCTAssertTrue([msg2.knownMapField valueForKey:0 value:&val]);
+ XCTAssertTrue([msg2.knownMapField getEnum:&val forKey:0]);
XCTAssertEqual(val, Proto2MapEnumPlusExtra_EProto2MapEnumFoo);
val = -1;
XCTAssertEqual(msg2.unknownMapField.count, 1U);
- XCTAssertTrue([msg2.unknownMapField valueForKey:0 value:&val]);
+ XCTAssertTrue([msg2.unknownMapField getEnum:&val forKey:0]);
XCTAssertEqual(val, Proto2MapEnumPlusExtra_EProto2MapEnumExtra);
XCTAssertEqual(msg2.unknownFields.countOfFields, 0U);
@@ -1040,32 +1157,37 @@ static NSData *DataFromCStr(const char *str) {
// Key/Value data should result in different byte lengths on wire to ensure
// everything is right.
- [msg.mapInt32Int32 setValue:1000 forKey:200];
- [msg.mapInt32Int32 setValue:101 forKey:2001];
- [msg.mapInt64Int64 setValue:1002 forKey:202];
- [msg.mapInt64Int64 setValue:103 forKey:2003];
- [msg.mapUint32Uint32 setValue:1004 forKey:204];
- [msg.mapUint32Uint32 setValue:105 forKey:2005];
- [msg.mapUint64Uint64 setValue:1006 forKey:206];
- [msg.mapUint64Uint64 setValue:107 forKey:2007];
- [msg.mapSint32Sint32 setValue:1008 forKey:208];
- [msg.mapSint32Sint32 setValue:109 forKey:2009];
- [msg.mapSint64Sint64 setValue:1010 forKey:210];
- [msg.mapSint64Sint64 setValue:111 forKey:2011];
- [msg.mapFixed32Fixed32 setValue:1012 forKey:212];
- [msg.mapFixed32Fixed32 setValue:113 forKey:2013];
- [msg.mapFixed64Fixed64 setValue:1014 forKey:214];
- [msg.mapFixed64Fixed64 setValue:115 forKey:2015];
- [msg.mapSfixed32Sfixed32 setValue:1016 forKey:216];
- [msg.mapSfixed32Sfixed32 setValue:117 forKey:2017];
- [msg.mapSfixed64Sfixed64 setValue:1018 forKey:218];
- [msg.mapSfixed64Sfixed64 setValue:119 forKey:2019];
- [msg.mapInt32Float setValue:1020.f forKey:220];
- [msg.mapInt32Float setValue:121.f forKey:2021];
- [msg.mapInt32Double setValue:1022. forKey:222];
- [msg.mapInt32Double setValue:123. forKey:2023];
- [msg.mapBoolBool setValue:false forKey:true];
- [msg.mapBoolBool setValue:true forKey:false];
+ [msg.mapInt32Int32 setInt32:1000 forKey:200];
+ [msg.mapInt32Int32 setInt32:101 forKey:2001];
+ [msg.mapInt64Int64 setInt64:1002 forKey:202];
+ [msg.mapInt64Int64 setInt64:103 forKey:2003];
+ [msg.mapInt64Int64 setInt64:4294967296 forKey:4294967297];
+ [msg.mapUint32Uint32 setUInt32:1004 forKey:204];
+ [msg.mapUint32Uint32 setUInt32:105 forKey:2005];
+ [msg.mapUint64Uint64 setUInt64:1006 forKey:206];
+ [msg.mapUint64Uint64 setUInt64:107 forKey:2007];
+ [msg.mapUint64Uint64 setUInt64:4294967298 forKey:4294967299];
+ [msg.mapSint32Sint32 setInt32:1008 forKey:208];
+ [msg.mapSint32Sint32 setInt32:109 forKey:2009];
+ [msg.mapSint64Sint64 setInt64:1010 forKey:210];
+ [msg.mapSint64Sint64 setInt64:111 forKey:2011];
+ [msg.mapSint64Sint64 setInt64:4294967300 forKey:4294967301];
+ [msg.mapFixed32Fixed32 setUInt32:1012 forKey:212];
+ [msg.mapFixed32Fixed32 setUInt32:113 forKey:2013];
+ [msg.mapFixed64Fixed64 setUInt64:1014 forKey:214];
+ [msg.mapFixed64Fixed64 setUInt64:115 forKey:2015];
+ [msg.mapFixed64Fixed64 setUInt64:4294967302 forKey:4294967303];
+ [msg.mapSfixed32Sfixed32 setInt32:1016 forKey:216];
+ [msg.mapSfixed32Sfixed32 setInt32:117 forKey:2017];
+ [msg.mapSfixed64Sfixed64 setInt64:1018 forKey:218];
+ [msg.mapSfixed64Sfixed64 setInt64:119 forKey:2019];
+ [msg.mapSfixed64Sfixed64 setInt64:4294967304 forKey:4294967305];
+ [msg.mapInt32Float setFloat:1020.f forKey:220];
+ [msg.mapInt32Float setFloat:121.f forKey:2021];
+ [msg.mapInt32Double setDouble:1022. forKey:222];
+ [msg.mapInt32Double setDouble:123. forKey:2023];
+ [msg.mapBoolBool setBool:false forKey:true];
+ [msg.mapBoolBool setBool:true forKey:false];
msg.mapStringString[@"224"] = @"1024";
msg.mapStringString[@"2025"] = @"125";
msg.mapStringBytes[@"226"] = DataFromCStr("1026");
@@ -1074,12 +1196,12 @@ static NSData *DataFromCStr(const char *str) {
val1.optionalInt32 = 1028;
Message2 *val2 = [[Message2 alloc] init];
val2.optionalInt32 = 129;
- [msg.mapStringMessage setValue:val1 forKey:@"228"];
- [msg.mapStringMessage setValue:val2 forKey:@"2029"];
+ [msg.mapStringMessage setObject:val1 forKey:@"228"];
+ [msg.mapStringMessage setObject:val2 forKey:@"2029"];
[msg.mapInt32Bytes setObject:DataFromCStr("1030 bytes") forKey:230];
[msg.mapInt32Bytes setObject:DataFromCStr("131") forKey:2031];
- [msg.mapInt32Enum setValue:Message2_Enum_Bar forKey:232];
- [msg.mapInt32Enum setValue:Message2_Enum_Baz forKey:2033];
+ [msg.mapInt32Enum setEnum:Message2_Enum_Bar forKey:232];
+ [msg.mapInt32Enum setEnum:Message2_Enum_Baz forKey:2033];
Message2 *val3 = [[Message2 alloc] init];
val3.optionalInt32 = 1034;
Message2 *val4 = [[Message2 alloc] init];
diff --git a/objectivec/Tests/GPBMessageTests.m b/objectivec/Tests/GPBMessageTests.m
index 7b37ca95..a3149096 100644
--- a/objectivec/Tests/GPBMessageTests.m
+++ b/objectivec/Tests/GPBMessageTests.m
@@ -1082,6 +1082,20 @@
[repeatedStringArray release];
}
+- (void)testSetOverAutocreatedArrayAndSetAgain {
+ // Ensure when dealing with replacing an array it is handled being either
+ // an autocreated one or a straight NSArray.
+
+ // The real test here is that nothing crashes while doing the work.
+ TestAllTypes *message = [TestAllTypes message];
+ [message.repeatedStringArray addObject:@"foo"];
+ XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
+ message.repeatedStringArray = [NSMutableArray arrayWithObjects:@"bar", @"bar2", nil];
+ XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)2);
+ message.repeatedStringArray = [NSMutableArray arrayWithObject:@"baz"];
+ XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
+}
+
- (void)testReplaceAutocreatedArray {
// Replacing array should orphan the old one and cause its creator to become
// visible.
@@ -1171,7 +1185,7 @@
XCTAssertFalse([message2.a hasA]);
// But adding an element to the map should.
- [message.a.a.iToI setValue:100 forKey:200];
+ [message.a.a.iToI setInt32:100 forKey:200];
XCTAssertTrue([message hasA]);
XCTAssertTrue([message.a hasA]);
XCTAssertEqual([message.a.a.iToI count], (NSUInteger)1);
@@ -1190,7 +1204,7 @@
message1a.a.iToI = message1b.a.iToI;
XCTAssertTrue([message1a hasA]);
XCTAssertFalse([message1b hasA]);
- [message1a.a.iToI setValue:1 forKey:2];
+ [message1a.a.iToI setInt32:1 forKey:2];
XCTAssertTrue([message1a hasA]);
XCTAssertTrue([message1b hasA]);
XCTAssertEqual(message1a.a.iToI, message1b.a.iToI);
@@ -1224,7 +1238,8 @@
// with different objects that are equal).
TestRecursiveMessageWithRepeatedField *message3 =
[TestRecursiveMessageWithRepeatedField message];
- message3.iToI = [GPBInt32Int32Dictionary dictionaryWithValue:10 forKey:20];
+ message3.iToI = [[[GPBInt32Int32Dictionary alloc] init] autorelease];
+ [message3.iToI setInt32:10 forKey:20];
message3.strToStr =
[NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"123"];
XCTAssertNotNil(message.iToI);
@@ -1281,6 +1296,23 @@
[strToStr release];
}
+- (void)testSetOverAutocreatedMapAndSetAgain {
+ // Ensure when dealing with replacing a map it is handled being either
+ // an autocreated one or a straight NSDictionary.
+
+ // The real test here is that nothing crashes while doing the work.
+ TestRecursiveMessageWithRepeatedField *message =
+ [TestRecursiveMessageWithRepeatedField message];
+ message.strToStr[@"foo"] = @"bar";
+ XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
+ message.strToStr =
+ [NSMutableDictionary dictionaryWithObjectsAndKeys:@"bar", @"key1", @"baz", @"key2", nil];
+ XCTAssertEqual(message.strToStr_Count, (NSUInteger)2);
+ message.strToStr =
+ [NSMutableDictionary dictionaryWithObject:@"baz" forKey:@"mumble"];
+ XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
+}
+
- (void)testReplaceAutocreatedMap {
// Replacing map should orphan the old one and cause its creator to become
// visible.
@@ -1292,7 +1324,8 @@
XCTAssertFalse([message hasA]);
GPBInt32Int32Dictionary *iToI = [message.a.iToI retain];
XCTAssertEqual(iToI->_autocreator, message.a); // Pointer comparision
- message.a.iToI = [GPBInt32Int32Dictionary dictionaryWithValue:6 forKey:7];
+ message.a.iToI = [[[GPBInt32Int32Dictionary alloc] init] autorelease];
+ [message.a.iToI setInt32:6 forKey:7];
XCTAssertTrue([message hasA]);
XCTAssertNotEqual(message.a.iToI, iToI); // Pointer comparision
XCTAssertNil(iToI->_autocreator);
@@ -1820,6 +1853,24 @@
XCTAssertEqualObjects(enumDescriptor, expectedDescriptor);
}
+- (void)testPropertyNaming {
+ // objectivec_helpers.cc has some special handing to get proper all caps
+ // for a few cases to meet objc developer expectations.
+ //
+ // This "test" confirms that the expected names are generated, otherwise the
+ // test itself will fail to compile.
+ ObjCPropertyNaming *msg = [ObjCPropertyNaming message];
+ // On their own, at the end, in the middle.
+ msg.URL = @"good";
+ msg.thumbnailURL = @"good";
+ msg.URLFoo = @"good";
+ msg.someURLBlah = @"good";
+ msg.HTTP = @"good";
+ msg.HTTPS = @"good";
+ // No caps since it was "urls".
+ [msg.urlsArray addObject:@"good"];
+}
+
- (void)testEnumNaming {
// objectivec_helpers.cc has some interesting cases to deal with in
// EnumValueName/EnumValueShortName. Confirm that things generated as
@@ -1929,4 +1980,127 @@
EnumTestMsg_MyEnum_NegTwo);
}
+- (void)testOneBasedEnumHolder {
+ // Test case for https://github.com/google/protobuf/issues/1453
+ // Message with no explicit defaults, but a non zero default for an enum.
+ MessageWithOneBasedEnum *enumMsg = [MessageWithOneBasedEnum message];
+ XCTAssertEqual(enumMsg.enumField, MessageWithOneBasedEnum_OneBasedEnum_One);
+}
+
+- (void)testBoolOffsetUsage {
+ // Bools use storage within has_bits; this test ensures that this is honored
+ // in all places where things should crash or fail based on reading out of
+ // field storage instead.
+ BoolOnlyMessage *msg1 = [BoolOnlyMessage message];
+ BoolOnlyMessage *msg2 = [BoolOnlyMessage message];
+
+ msg1.boolField1 = YES;
+ msg2.boolField1 = YES;
+ msg1.boolField3 = YES;
+ msg2.boolField3 = YES;
+ msg1.boolField5 = YES;
+ msg2.boolField5 = YES;
+ msg1.boolField7 = YES;
+ msg2.boolField7 = YES;
+ msg1.boolField9 = YES;
+ msg2.boolField9 = YES;
+ msg1.boolField11 = YES;
+ msg2.boolField11 = YES;
+ msg1.boolField13 = YES;
+ msg2.boolField13 = YES;
+ msg1.boolField15 = YES;
+ msg2.boolField15 = YES;
+ msg1.boolField17 = YES;
+ msg2.boolField17 = YES;
+ msg1.boolField19 = YES;
+ msg2.boolField19 = YES;
+ msg1.boolField21 = YES;
+ msg2.boolField21 = YES;
+ msg1.boolField23 = YES;
+ msg2.boolField23 = YES;
+ msg1.boolField25 = YES;
+ msg2.boolField25 = YES;
+ msg1.boolField27 = YES;
+ msg2.boolField27 = YES;
+ msg1.boolField29 = YES;
+ msg2.boolField29 = YES;
+ msg1.boolField31 = YES;
+ msg2.boolField31 = YES;
+
+ msg1.boolField32 = YES;
+ msg2.boolField32 = YES;
+
+ XCTAssertTrue(msg1 != msg2); // Different pointers.
+ XCTAssertEqual([msg1 hash], [msg2 hash]);
+ XCTAssertEqualObjects(msg1, msg2);
+
+ BoolOnlyMessage *msg1Prime = [[msg1 copy] autorelease];
+ XCTAssertTrue(msg1Prime != msg1); // Different pointers.
+ XCTAssertEqual([msg1 hash], [msg1Prime hash]);
+ XCTAssertEqualObjects(msg1, msg1Prime);
+
+ // Field set in one, but not the other means they don't match (even if
+ // set to default value).
+ msg1Prime.boolField2 = NO;
+ XCTAssertNotEqualObjects(msg1Prime, msg1);
+ // And when set to different values.
+ msg1.boolField2 = YES;
+ XCTAssertNotEqualObjects(msg1Prime, msg1);
+ // And then they match again.
+ msg1.boolField2 = NO;
+ XCTAssertEqualObjects(msg1Prime, msg1);
+ XCTAssertEqual([msg1 hash], [msg1Prime hash]);
+}
+
+- (void)testCopyingMapFileds {
+ TestMessageOfMaps *msg = [TestMessageOfMaps message];
+
+ msg.strToStr[@"foo"] = @"bar";
+
+ [msg.strToInt setInt32:1 forKey:@"mumble"];
+ [msg.intToStr setObject:@"wee" forKey:42];
+ [msg.intToInt setInt32:123 forKey:321];
+
+ [msg.strToBool setBool:YES forKey:@"one"];
+ [msg.boolToStr setObject:@"something" forKey:YES];
+ [msg.boolToBool setBool:YES forKey:NO];
+
+ [msg.intToBool setBool:YES forKey:13];
+ [msg.boolToInt setInt32:111 forKey:NO];
+
+ TestAllTypes *subMsg1 = [TestAllTypes message];
+ subMsg1.optionalInt32 = 1;
+ TestAllTypes *subMsg2 = [TestAllTypes message];
+ subMsg1.optionalInt32 = 2;
+ TestAllTypes *subMsg3 = [TestAllTypes message];
+ subMsg1.optionalInt32 = 3;
+
+ msg.strToMsg[@"baz"] = subMsg1;
+ [msg.intToMsg setObject:subMsg2 forKey:222];
+ [msg.boolToMsg setObject:subMsg3 forKey:YES];
+
+ TestMessageOfMaps *msg2 = [[msg copy] autorelease];
+ XCTAssertNotNil(msg2);
+ XCTAssertEqualObjects(msg2, msg);
+ XCTAssertTrue(msg2 != msg); // ptr compare
+ XCTAssertTrue(msg.strToStr != msg2.strToStr); // ptr compare
+ XCTAssertTrue(msg.intToStr != msg2.intToStr); // ptr compare
+ XCTAssertTrue(msg.intToInt != msg2.intToInt); // ptr compare
+ XCTAssertTrue(msg.strToBool != msg2.strToBool); // ptr compare
+ XCTAssertTrue(msg.boolToStr != msg2.boolToStr); // ptr compare
+ XCTAssertTrue(msg.boolToBool != msg2.boolToBool); // ptr compare
+ XCTAssertTrue(msg.intToBool != msg2.intToBool); // ptr compare
+ XCTAssertTrue(msg.boolToInt != msg2.boolToInt); // ptr compare
+ XCTAssertTrue(msg.strToMsg != msg2.strToMsg); // ptr compare
+ XCTAssertTrue(msg.intToMsg != msg2.intToMsg); // ptr compare
+ XCTAssertTrue(msg.boolToMsg != msg2.boolToMsg); // ptr compare
+
+ XCTAssertTrue(msg.strToMsg[@"baz"] != msg2.strToMsg[@"baz"]); // ptr compare
+ XCTAssertEqualObjects(msg.strToMsg[@"baz"], msg2.strToMsg[@"baz"]);
+ XCTAssertTrue([msg.intToMsg objectForKey:222] != [msg2.intToMsg objectForKey:222]); // ptr compare
+ XCTAssertEqualObjects([msg.intToMsg objectForKey:222], [msg2.intToMsg objectForKey:222]);
+ XCTAssertTrue([msg.boolToMsg objectForKey:YES] != [msg2.boolToMsg objectForKey:YES]); // ptr compare
+ XCTAssertEqualObjects([msg.boolToMsg objectForKey:YES], [msg2.boolToMsg objectForKey:YES]);
+}
+
@end
diff --git a/objectivec/Tests/GPBPerfTests.m b/objectivec/Tests/GPBPerfTests.m
index 1259d146..8dd0ffc5 100644
--- a/objectivec/Tests/GPBPerfTests.m
+++ b/objectivec/Tests/GPBPerfTests.m
@@ -64,6 +64,112 @@ static const uint32_t kRepeatedCount = 100;
}];
}
+- (void)testMessageSerialParsingPerformance {
+ // This and the next test are meant to monitor that the parsing functionality of protos does not
+ // lock across threads when parsing different instances. The Serial version of the test should run
+ // around ~2 times slower than the Parallel version since it's parsing the protos in the same
+ // thread.
+ TestAllTypes *allTypesMessage = [TestAllTypes message];
+ [self setAllFields:allTypesMessage repeatedCount:2];
+ NSData *allTypesData = allTypesMessage.data;
+
+ [self measureBlock:^{
+ for (int i = 0; i < 500; ++i) {
+ [TestAllTypes parseFromData:allTypesData error:NULL];
+ [TestAllTypes parseFromData:allTypesData error:NULL];
+ }
+ }];
+}
+
+- (void)testMessageParallelParsingPerformance {
+ // This and the previous test are meant to monitor that the parsing functionality of protos does
+ // not lock across threads when parsing different instances. The Serial version of the test should
+ // run around ~2 times slower than the Parallel version since it's parsing the protos in the same
+ // thread.
+ TestAllTypes *allTypesMessage = [TestAllTypes message];
+ [self setAllFields:allTypesMessage repeatedCount:2];
+ NSData *allTypesData = allTypesMessage.data;
+
+ dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT);
+
+ [self measureBlock:^{
+ for (int i = 0; i < 500; ++i) {
+ dispatch_group_t group = dispatch_group_create();
+
+ dispatch_group_async(group, concurrentQueue, ^{
+ [TestAllTypes parseFromData:allTypesData error:NULL];
+ });
+
+ dispatch_group_async(group, concurrentQueue, ^{
+ [TestAllTypes parseFromData:allTypesData error:NULL];
+ });
+
+ dispatch_group_notify(group, concurrentQueue, ^{});
+
+ dispatch_release(group);
+ }
+ }];
+
+ dispatch_release(concurrentQueue);
+}
+
+- (void)testMessageSerialExtensionsParsingPerformance {
+ // This and the next test are meant to monitor that the parsing functionality of protos does not
+ // lock across threads when parsing different instances when using extensions. The Serial version
+ // of the test should run around ~2 times slower than the Parallel version since it's parsing the
+ // protos in the same thread.
+ TestAllExtensions *allExtensionsMessage = [TestAllExtensions message];
+ [self setAllExtensions:allExtensionsMessage repeatedCount:2];
+ NSData *allExtensionsData = allExtensionsMessage.data;
+
+ [self measureBlock:^{
+ for (int i = 0; i < 500; ++i) {
+ [TestAllExtensions parseFromData:allExtensionsData
+ extensionRegistry:[self extensionRegistry]
+ error:NULL];
+ [TestAllExtensions parseFromData:allExtensionsData
+ extensionRegistry:[self extensionRegistry]
+ error:NULL];
+ }
+ }];
+}
+
+- (void)testMessageParallelExtensionsParsingPerformance {
+ // This and the previous test are meant to monitor that the parsing functionality of protos does
+ // not lock across threads when parsing different instances when using extensions. The Serial
+ // version of the test should run around ~2 times slower than the Parallel version since it's
+ // parsing the protos in the same thread.
+ TestAllExtensions *allExtensionsMessage = [TestAllExtensions message];
+ [self setAllExtensions:allExtensionsMessage repeatedCount:2];
+ NSData *allExtensionsData = allExtensionsMessage.data;
+
+ dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT);
+
+ [self measureBlock:^{
+ for (int i = 0; i < 500; ++i) {
+ dispatch_group_t group = dispatch_group_create();
+
+ dispatch_group_async(group, concurrentQueue, ^{
+ [TestAllExtensions parseFromData:allExtensionsData
+ extensionRegistry:[UnittestRoot extensionRegistry]
+ error:NULL];
+ });
+
+ dispatch_group_async(group, concurrentQueue, ^{
+ [TestAllExtensions parseFromData:allExtensionsData
+ extensionRegistry:[UnittestRoot extensionRegistry]
+ error:NULL];
+ });
+
+ dispatch_group_notify(group, concurrentQueue, ^{});
+
+ dispatch_release(group);
+ }
+ }];
+
+ dispatch_release(concurrentQueue);
+}
+
- (void)testExtensionsPerformance {
[self measureBlock:^{
for (int i = 0; i < 200; ++i) {
diff --git a/objectivec/Tests/GPBSwiftTests.swift b/objectivec/Tests/GPBSwiftTests.swift
index 36ed2a62..9d8a0fae 100644
--- a/objectivec/Tests/GPBSwiftTests.swift
+++ b/objectivec/Tests/GPBSwiftTests.swift
@@ -42,23 +42,23 @@ class GPBBridgeTests: XCTestCase {
msg.optionalInt32 = 100
msg.optionalString = "abc"
- msg.optionalEnum = .Bar
+ msg.optionalEnum = .bar
msg2.optionalString = "other"
- msg.optionalMessage = msg2
+ msg.optional = msg2
msg3.a = 200
msg.optionalGroup = msg3
msg.repeatedInt32Array.addValue(300)
msg.repeatedInt32Array.addValue(301)
- msg.repeatedStringArray.addObject("mno")
- msg.repeatedStringArray.addObject("pqr")
- msg.repeatedEnumArray.addValue(Message2_Enum.Bar.rawValue)
- msg.repeatedEnumArray.addValue(Message2_Enum.Baz.rawValue)
- msg.mapInt32Int32.setValue(400, forKey:500)
- msg.mapInt32Int32.setValue(401, forKey:501)
- msg.mapStringString.setObject("foo", forKey:"bar")
- msg.mapStringString.setObject("abc", forKey:"xyz")
- msg.mapInt32Enum.setValue(Message2_Enum.Bar.rawValue, forKey:600)
- msg.mapInt32Enum.setValue(Message2_Enum.Baz.rawValue, forKey:601)
+ msg.repeatedStringArray.add("mno")
+ msg.repeatedStringArray.add("pqr")
+ msg.repeatedEnumArray.addValue(Message2_Enum.bar.rawValue)
+ msg.repeatedEnumArray.addValue(Message2_Enum.baz.rawValue)
+ msg.mapInt32Int32.setInt32(400, forKey:500)
+ msg.mapInt32Int32.setInt32(401, forKey:501)
+ msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
+ msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
+ msg.mapInt32Enum.setEnum(Message2_Enum.bar.rawValue, forKey:600)
+ msg.mapInt32Enum.setEnum(Message2_Enum.baz.rawValue, forKey:601)
// Check has*.
XCTAssertTrue(msg.hasOptionalInt32)
@@ -75,34 +75,34 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalString, "abc")
XCTAssertEqual(msg2.optionalString, "other")
- XCTAssertTrue(msg.optionalMessage === msg2)
- XCTAssertEqual(msg.optionalEnum, Message2_Enum.Bar)
+ XCTAssertTrue(msg.optional === msg2)
+ XCTAssertEqual(msg.optionalEnum, Message2_Enum.bar)
XCTAssertEqual(msg3.a, Int32(200))
XCTAssertTrue(msg.optionalGroup === msg3)
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(2))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(0), Int32(300))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(1), Int32(301))
+ XCTAssertEqual(msg.repeatedInt32Array.value(at: 0), Int32(300))
+ XCTAssertEqual(msg.repeatedInt32Array.value(at: 1), Int32(301))
XCTAssertEqual(msg.repeatedStringArray.count, Int(2))
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(0) as? String, "mno")
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(1) as? String, "pqr")
+ XCTAssertEqual(msg.repeatedStringArray.object(at: 0) as? String, "mno")
+ XCTAssertEqual(msg.repeatedStringArray.object(at: 1) as? String, "pqr")
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(2))
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(0), Message2_Enum.Bar.rawValue)
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(1), Message2_Enum.Baz.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 0), Message2_Enum.bar.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 1), Message2_Enum.baz.rawValue)
XCTAssertEqual(msg.repeatedInt64Array.count, UInt(0))
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
- var intValue: Int32 = 0;
- XCTAssertTrue(msg.mapInt32Int32.valueForKey(500, value:&intValue))
+ var intValue: Int32 = 0
+ XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey: 500))
XCTAssertEqual(intValue, Int32(400))
- XCTAssertTrue(msg.mapInt32Int32.valueForKey(501, value:&intValue))
+ XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey: 501))
XCTAssertEqual(intValue, Int32(401))
XCTAssertEqual(msg.mapStringString.count, Int(2))
- XCTAssertEqual(msg.mapStringString.objectForKey("bar") as? String, "foo")
- XCTAssertEqual(msg.mapStringString.objectForKey("xyz") as? String, "abc")
+ XCTAssertEqual(msg.mapStringString.object(forKey: "bar") as? String, "foo")
+ XCTAssertEqual(msg.mapStringString.object(forKey: "xyz") as? String, "abc")
XCTAssertEqual(msg.mapInt32Enum.count, UInt(2))
- XCTAssertTrue(msg.mapInt32Enum.valueForKey(600, value:&intValue))
- XCTAssertEqual(intValue, Message2_Enum.Bar.rawValue)
- XCTAssertTrue(msg.mapInt32Enum.valueForKey(601, value:&intValue))
- XCTAssertEqual(intValue, Message2_Enum.Baz.rawValue)
+ XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
+ XCTAssertEqual(intValue, Message2_Enum.bar.rawValue)
+ XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
+ XCTAssertEqual(intValue, Message2_Enum.baz.rawValue)
// Clearing a string with nil.
msg2.optionalString = nil
@@ -124,8 +124,8 @@ class GPBBridgeTests: XCTestCase {
XCTAssertFalse(msg.hasOptionalFloat)
XCTAssertEqual(msg.optionalInt32, Int32(0))
XCTAssertEqual(msg.optionalString, "")
- XCTAssertTrue(msg.optionalMessage !== msg2) // New instance
- XCTAssertEqual(msg.optionalEnum, Message2_Enum.Foo) // Default
+ XCTAssertTrue(msg.optional !== msg2) // New instance
+ XCTAssertEqual(msg.optionalEnum, Message2_Enum.foo) // Default
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(0))
XCTAssertEqual(msg.repeatedStringArray.count, Int(0))
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(0))
@@ -140,22 +140,22 @@ class GPBBridgeTests: XCTestCase {
msg.optionalInt32 = 100
msg.optionalString = "abc"
- msg.optionalEnum = .Bar
+ msg.optionalEnum = .bar
msg2.optionalString = "other"
- msg.optionalMessage = msg2
+ msg.optional = msg2
msg.repeatedInt32Array.addValue(300)
msg.repeatedInt32Array.addValue(301)
- msg.repeatedStringArray.addObject("mno")
- msg.repeatedStringArray.addObject("pqr")
+ msg.repeatedStringArray.add("mno")
+ msg.repeatedStringArray.add("pqr")
// "proto3" syntax lets enum get unknown values.
- msg.repeatedEnumArray.addValue(Message3_Enum.Bar.rawValue)
+ msg.repeatedEnumArray.addValue(Message3_Enum.bar.rawValue)
msg.repeatedEnumArray.addRawValue(666)
SetMessage3_OptionalEnum_RawValue(msg2, 666)
- msg.mapInt32Int32.setValue(400, forKey:500)
- msg.mapInt32Int32.setValue(401, forKey:501)
- msg.mapStringString.setObject("foo", forKey:"bar")
- msg.mapStringString.setObject("abc", forKey:"xyz")
- msg.mapInt32Enum.setValue(Message2_Enum.Bar.rawValue, forKey:600)
+ msg.mapInt32Int32.setInt32(400, forKey:500)
+ msg.mapInt32Int32.setInt32(401, forKey:501)
+ msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
+ msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
+ msg.mapInt32Enum.setEnum(Message2_Enum.bar.rawValue, forKey:600)
// "proto3" syntax lets enum get unknown values.
msg.mapInt32Enum.setRawValue(666, forKey:601)
@@ -167,36 +167,36 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalString, "abc")
XCTAssertEqual(msg2.optionalString, "other")
- XCTAssertTrue(msg.optionalMessage === msg2)
- XCTAssertEqual(msg.optionalEnum, Message3_Enum.Bar)
+ XCTAssertTrue(msg.optional === msg2)
+ XCTAssertEqual(msg.optionalEnum, Message3_Enum.bar)
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(2))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(0), Int32(300))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(1), Int32(301))
+ XCTAssertEqual(msg.repeatedInt32Array.value(at: 0), Int32(300))
+ XCTAssertEqual(msg.repeatedInt32Array.value(at: 1), Int32(301))
XCTAssertEqual(msg.repeatedStringArray.count, Int(2))
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(0) as? String, "mno")
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(1) as? String, "pqr")
+ XCTAssertEqual(msg.repeatedStringArray.object(at: 0) as? String, "mno")
+ XCTAssertEqual(msg.repeatedStringArray.object(at: 1) as? String, "pqr")
XCTAssertEqual(msg.repeatedInt64Array.count, UInt(0))
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(2))
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(0), Message3_Enum.Bar.rawValue)
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(1), Message3_Enum.GPBUnrecognizedEnumeratorValue.rawValue)
- XCTAssertEqual(msg.repeatedEnumArray.rawValueAtIndex(1), 666)
- XCTAssertEqual(msg2.optionalEnum, Message3_Enum.GPBUnrecognizedEnumeratorValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 0), Message3_Enum.bar.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 1), Message3_Enum.gpbUnrecognizedEnumeratorValue.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.rawValue(at: 1), 666)
+ XCTAssertEqual(msg2.optionalEnum, Message3_Enum.gpbUnrecognizedEnumeratorValue)
XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Int32(666))
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
- var intValue: Int32 = 0;
- XCTAssertTrue(msg.mapInt32Int32.valueForKey(500, value:&intValue))
+ var intValue: Int32 = 0
+ XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey:500))
XCTAssertEqual(intValue, Int32(400))
- XCTAssertTrue(msg.mapInt32Int32.valueForKey(501, value:&intValue))
+ XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey:501))
XCTAssertEqual(intValue, Int32(401))
XCTAssertEqual(msg.mapStringString.count, Int(2))
- XCTAssertEqual(msg.mapStringString.objectForKey("bar") as? String, "foo")
- XCTAssertEqual(msg.mapStringString.objectForKey("xyz") as? String, "abc")
+ XCTAssertEqual(msg.mapStringString.object(forKey: "bar") as? String, "foo")
+ XCTAssertEqual(msg.mapStringString.object(forKey: "xyz") as? String, "abc")
XCTAssertEqual(msg.mapInt32Enum.count, UInt(2))
- XCTAssertTrue(msg.mapInt32Enum.valueForKey(600, value:&intValue))
- XCTAssertEqual(intValue, Message2_Enum.Bar.rawValue)
- XCTAssertTrue(msg.mapInt32Enum.valueForKey(601, value:&intValue))
- XCTAssertEqual(intValue, Message3_Enum.GPBUnrecognizedEnumeratorValue.rawValue)
- XCTAssertTrue(msg.mapInt32Enum.valueForKey(601, rawValue:&intValue))
+ XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
+ XCTAssertEqual(intValue, Message2_Enum.bar.rawValue)
+ XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
+ XCTAssertEqual(intValue, Message3_Enum.gpbUnrecognizedEnumeratorValue.rawValue)
+ XCTAssertTrue(msg.mapInt32Enum.getRawValue(&intValue, forKey:601))
XCTAssertEqual(intValue, 666)
// Clearing a string with nil.
@@ -204,23 +204,23 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual(msg2.optionalString, "")
// Clearing a message with nil.
- msg.optionalMessage = nil
+ msg.optional = nil
XCTAssertFalse(msg.hasOptionalMessage)
- XCTAssertTrue(msg.optionalMessage !== msg2) // New instance
+ XCTAssertTrue(msg.optional !== msg2) // New instance
// Clear.
msg.clear()
XCTAssertFalse(msg.hasOptionalMessage)
XCTAssertEqual(msg.optionalInt32, Int32(0))
XCTAssertEqual(msg.optionalString, "")
- XCTAssertTrue(msg.optionalMessage !== msg2) // New instance
- XCTAssertEqual(msg.optionalEnum, Message3_Enum.Foo) // Default
+ XCTAssertTrue(msg.optional !== msg2) // New instance
+ XCTAssertEqual(msg.optionalEnum, Message3_Enum.foo) // Default
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(0))
XCTAssertEqual(msg.repeatedStringArray.count, Int(0))
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(0))
msg2.clear()
- XCTAssertEqual(msg2.optionalEnum, Message3_Enum.Foo) // Default
- XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Message3_Enum.Foo.rawValue)
+ XCTAssertEqual(msg2.optionalEnum, Message3_Enum.foo) // Default
+ XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Message3_Enum.foo.rawValue)
XCTAssertEqual(msg.mapInt32Int32.count, UInt(0))
XCTAssertEqual(msg.mapStringString.count, Int(0))
XCTAssertEqual(msg.mapInt32Enum.count, UInt(0))
@@ -234,201 +234,201 @@ class GPBBridgeTests: XCTestCase {
// Access shouldn't result in has* but should return objects.
let msg2 = msg.optionalGroup
- let msg3 = msg.optionalMessage.optionalMessage
- let msg4 = msg.optionalMessage
+ let msg3 = msg.optional.optional
+ let msg4 = msg.optional
XCTAssertNotNil(msg2)
XCTAssertNotNil(msg3)
XCTAssertFalse(msg.hasOptionalGroup)
- XCTAssertFalse(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertFalse(msg.optional.hasOptionalMessage)
XCTAssertFalse(msg.hasOptionalMessage)
// Setting things should trigger has* getting set.
msg.optionalGroup.a = 10
- msg.optionalMessage.optionalMessage.optionalInt32 = 100
+ msg.optional.optional.optionalInt32 = 100
XCTAssertTrue(msg.hasOptionalGroup)
- XCTAssertTrue(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertTrue(msg.optional.hasOptionalMessage)
XCTAssertTrue(msg.hasOptionalMessage)
// And they should be the same pointer as before.
XCTAssertTrue(msg2 === msg.optionalGroup)
- XCTAssertTrue(msg3 === msg.optionalMessage.optionalMessage)
- XCTAssertTrue(msg4 === msg.optionalMessage)
+ XCTAssertTrue(msg3 === msg.optional.optional)
+ XCTAssertTrue(msg4 === msg.optional)
// Clear gets us new objects next time around.
msg.clear()
XCTAssertFalse(msg.hasOptionalGroup)
- XCTAssertFalse(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertFalse(msg.optional.hasOptionalMessage)
XCTAssertFalse(msg.hasOptionalMessage)
msg.optionalGroup.a = 20
- msg.optionalMessage.optionalMessage.optionalInt32 = 200
+ msg.optional.optional.optionalInt32 = 200
XCTAssertTrue(msg.hasOptionalGroup)
- XCTAssertTrue(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertTrue(msg.optional.hasOptionalMessage)
XCTAssertTrue(msg.hasOptionalMessage)
XCTAssertTrue(msg2 !== msg.optionalGroup)
- XCTAssertTrue(msg3 !== msg.optionalMessage.optionalMessage)
- XCTAssertTrue(msg4 !== msg.optionalMessage)
+ XCTAssertTrue(msg3 !== msg.optional.optional)
+ XCTAssertTrue(msg4 !== msg.optional)
// Explicit set of a message, means autocreated object doesn't bind.
msg.clear()
- let autoCreated = msg.optionalMessage
+ let autoCreated = msg.optional
XCTAssertFalse(msg.hasOptionalMessage)
let msg5 = Message2()
msg5.optionalInt32 = 123
- msg.optionalMessage = msg5
+ msg.optional = msg5
XCTAssertTrue(msg.hasOptionalMessage)
// Modifing the autocreated doesn't replaced the explicit set one.
- autoCreated.optionalInt32 = 456
+ autoCreated?.optionalInt32 = 456
XCTAssertTrue(msg.hasOptionalMessage)
- XCTAssertTrue(msg.optionalMessage === msg5)
- XCTAssertEqual(msg.optionalMessage.optionalInt32, Int32(123))
+ XCTAssertTrue(msg.optional === msg5)
+ XCTAssertEqual(msg.optional.optionalInt32, Int32(123))
}
func testProto2OneOfSupport() {
let msg = Message2()
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- let autoCreated = msg.oneofMessage // Default create one.
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ let autoCreated = msg.oneof // Default create one.
XCTAssertNotNil(autoCreated)
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofInt32)
msg.oneofFloat = 20.0
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(20.0))
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofFloat)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofFloat)
- msg.oneofEnum = .Bar
+ msg.oneofEnum = .bar
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Bar)
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofEnum)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.bar)
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofEnum)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 200
+ msg.oneof.optionalInt32 = 200
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(200))
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofMessage)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(200))
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofMessage)
// Clear the oneof.
Message2_ClearOOneOfCase(msg)
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- let autoCreated2 = msg.oneofMessage // Default create one
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ let autoCreated2 = msg.oneof // Default create one
XCTAssertNotNil(autoCreated2)
XCTAssertTrue(autoCreated2 !== autoCreated) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofInt32)
// Confirm Message.clear() handles the oneof correctly.
msg.clear()
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 300
- XCTAssertTrue(msg.oneofMessage !== autoCreated) // New instance
- XCTAssertTrue(msg.oneofMessage !== autoCreated2) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(300))
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofMessage)
+ msg.oneof.optionalInt32 = 300
+ XCTAssertTrue(msg.oneof !== autoCreated) // New instance
+ XCTAssertTrue(msg.oneof !== autoCreated2) // New instance
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(300))
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofMessage)
// Set message to nil clears the oneof.
- msg.oneofMessage = nil
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ msg.oneof = nil
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
}
func testProto3OneOfSupport() {
let msg = Message3()
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- let autoCreated = msg.oneofMessage // Default create one.
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ let autoCreated = msg.oneof // Default create one.
XCTAssertNotNil(autoCreated)
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofInt32)
msg.oneofFloat = 20.0
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(20.0))
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofFloat)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofFloat)
- msg.oneofEnum = .Bar
+ msg.oneofEnum = .bar
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Bar)
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofEnum)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.bar)
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofEnum)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 200
+ msg.oneof.optionalInt32 = 200
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(200))
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofMessage)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(200))
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofMessage)
// Clear the oneof.
Message3_ClearOOneOfCase(msg)
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- let autoCreated2 = msg.oneofMessage // Default create one
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ let autoCreated2 = msg.oneof // Default create one
XCTAssertNotNil(autoCreated2)
XCTAssertTrue(autoCreated2 !== autoCreated) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofInt32)
// Confirm Message.clear() handles the oneof correctly.
msg.clear()
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 300
- XCTAssertTrue(msg.oneofMessage !== autoCreated) // New instance
- XCTAssertTrue(msg.oneofMessage !== autoCreated2) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(300))
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofMessage)
+ msg.oneof.optionalInt32 = 300
+ XCTAssertTrue(msg.oneof !== autoCreated) // New instance
+ XCTAssertTrue(msg.oneof !== autoCreated2) // New instance
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(300))
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofMessage)
// Set message to nil clears the oneof.
- msg.oneofMessage = nil
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ msg.oneof = nil
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
}
func testSerialization() {
@@ -437,16 +437,16 @@ class GPBBridgeTests: XCTestCase {
msg.optionalInt32 = 100
msg.optionalInt64 = 101
msg.optionalGroup.a = 102
- msg.repeatedStringArray.addObject("abc")
- msg.repeatedStringArray.addObject("def")
- msg.mapInt32Int32.setValue(200, forKey:300)
- msg.mapInt32Int32.setValue(201, forKey:201)
- msg.mapStringString.setObject("foo", forKey:"bar")
- msg.mapStringString.setObject("abc", forKey:"xyz")
+ msg.repeatedStringArray.add("abc")
+ msg.repeatedStringArray.add("def")
+ msg.mapInt32Int32.setInt32(200, forKey:300)
+ msg.mapInt32Int32.setInt32(201, forKey:201)
+ msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
+ msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
let data = msg.data()
- let msg2 = Message2(data: data!, error:nil)
+ let msg2 = try! Message2(data: data!)
XCTAssertTrue(msg2 !== msg) // New instance
XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalInt64, Int64(101))
diff --git a/objectivec/Tests/GPBTestUtilities.h b/objectivec/Tests/GPBTestUtilities.h
index 44c80844..780184b0 100644
--- a/objectivec/Tests/GPBTestUtilities.h
+++ b/objectivec/Tests/GPBTestUtilities.h
@@ -39,6 +39,9 @@
@class TestUnpackedExtensions;
@class GPBExtensionRegistry;
+static inline NSData *DataFromCStr(const char *str) {
+ return [NSData dataWithBytes:str length:strlen(str)];
+}
// Helper for uses of C arrays in tests cases.
#ifndef GPBARRAYSIZE
diff --git a/objectivec/Tests/GPBTestUtilities.m b/objectivec/Tests/GPBTestUtilities.m
index 726761a7..ebccaac9 100644
--- a/objectivec/Tests/GPBTestUtilities.m
+++ b/objectivec/Tests/GPBTestUtilities.m
@@ -1089,19 +1089,19 @@ const uint32_t kGPBDefaultRepeatCount = 2;
- (void)setAllMapFields:(TestMap *)message numEntries:(uint32_t)count {
for (uint32_t i = 0; i < count; i++) {
- [message.mapInt32Int32 setValue:(i + 1) forKey:100 + i * 100];
- [message.mapInt64Int64 setValue:(i + 1) forKey:101 + i * 100];
- [message.mapUint32Uint32 setValue:(i + 1) forKey:102 + i * 100];
- [message.mapUint64Uint64 setValue:(i + 1) forKey:103 + i * 100];
- [message.mapSint32Sint32 setValue:(i + 1) forKey:104 + i * 100];
- [message.mapSint64Sint64 setValue:(i + 1) forKey:105 + i * 100];
- [message.mapFixed32Fixed32 setValue:(i + 1) forKey:106 + i * 100];
- [message.mapFixed64Fixed64 setValue:(i + 1) forKey:107 + i * 100];
- [message.mapSfixed32Sfixed32 setValue:(i + 1) forKey:108 + i * 100];
- [message.mapSfixed64Sfixed64 setValue:(i + 1) forKey:109 + i * 100];
- [message.mapInt32Float setValue:(i + 1) forKey:110 + i * 100];
- [message.mapInt32Double setValue:(i + 1) forKey:111 + i * 100];
- [message.mapBoolBool setValue:((i % 2) == 1) forKey:((i % 2) == 0)];
+ [message.mapInt32Int32 setInt32:(i + 1) forKey:100 + i * 100];
+ [message.mapInt64Int64 setInt64:(i + 1) forKey:101 + i * 100];
+ [message.mapUint32Uint32 setUInt32:(i + 1) forKey:102 + i * 100];
+ [message.mapUint64Uint64 setUInt64:(i + 1) forKey:103 + i * 100];
+ [message.mapSint32Sint32 setInt32:(i + 1) forKey:104 + i * 100];
+ [message.mapSint64Sint64 setInt64:(i + 1) forKey:105 + i * 100];
+ [message.mapFixed32Fixed32 setUInt32:(i + 1) forKey:106 + i * 100];
+ [message.mapFixed64Fixed64 setUInt64:(i + 1) forKey:107 + i * 100];
+ [message.mapSfixed32Sfixed32 setInt32:(i + 1) forKey:108 + i * 100];
+ [message.mapSfixed64Sfixed64 setInt64:(i + 1) forKey:109 + i * 100];
+ [message.mapInt32Float setFloat:(i + 1) forKey:110 + i * 100];
+ [message.mapInt32Double setDouble:(i + 1) forKey:111 + i * 100];
+ [message.mapBoolBool setBool:((i % 2) == 1) forKey:((i % 2) == 0)];
NSString *keyStr = [[NSString alloc] initWithFormat:@"%d", 112 + i * 100];
NSString *dataStr = [[NSString alloc] initWithFormat:@"%d", i + 1];
@@ -1114,8 +1114,8 @@ const uint32_t kGPBDefaultRepeatCount = 2;
[data release];
[message.mapInt32Enum
- setValue:(i % 2) ? MapEnum_MapEnumBar : MapEnum_MapEnumBaz
- forKey:114 + i * 100];
+ setEnum:(i % 2) ? MapEnum_MapEnumBar : MapEnum_MapEnumBaz
+ forKey:114 + i * 100];
ForeignMessage *subMsg = [[ForeignMessage alloc] init];
subMsg.c = i + 1;
diff --git a/objectivec/Tests/GPBUnittestProtos.m b/objectivec/Tests/GPBUnittestProtos.m
index 50c4dfa9..756bd99e 100644
--- a/objectivec/Tests/GPBUnittestProtos.m
+++ b/objectivec/Tests/GPBUnittestProtos.m
@@ -31,12 +31,20 @@
// Collects all the compiled protos into one file and compiles them to make sure
// the compiler is generating valid code.
+// 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.m"
+
+#import "google/protobuf/AnyTest.pbobjc.m"
#import "google/protobuf/MapProto2Unittest.pbobjc.m"
#import "google/protobuf/MapUnittest.pbobjc.m"
#import "google/protobuf/Unittest.pbobjc.m"
#import "google/protobuf/UnittestArena.pbobjc.m"
#import "google/protobuf/UnittestCustomOptions.pbobjc.m"
#import "google/protobuf/UnittestCycle.pbobjc.m"
+#import "google/protobuf/UnittestDeprecated.pbobjc.m"
+#import "google/protobuf/UnittestDeprecatedFile.pbobjc.m"
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.m"
#import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.m"
#import "google/protobuf/UnittestEmpty.pbobjc.m"
@@ -57,3 +65,11 @@
#import "google/protobuf/UnittestPreserveUnknownEnum.pbobjc.m"
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.m"
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.m"
+
+#import "google/protobuf/UnittestExtensionChainA.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainB.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainC.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainD.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainE.pbobjc.m"
+// See GPBUnittestProtos2.m for for "UnittestExtensionChainF.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainG.pbobjc.m"
diff --git a/objectivec/Tests/GPBUnittestProtos2.m b/objectivec/Tests/GPBUnittestProtos2.m
new file mode 100644
index 00000000..ef9f0702
--- /dev/null
+++ b/objectivec/Tests/GPBUnittestProtos2.m
@@ -0,0 +1,34 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// This one file in the chain tests is compiled by itself to ensure if was
+// generated with the extra #imports needed to pull in the indirect Root class
+// used in its Root registry.
+#import "google/protobuf/UnittestExtensionChainF.pbobjc.m"
diff --git a/objectivec/Tests/GPBUnknownFieldSetTest.m b/objectivec/Tests/GPBUnknownFieldSetTest.m
index 01217ca6..8e03a427 100644
--- a/objectivec/Tests/GPBUnknownFieldSetTest.m
+++ b/objectivec/Tests/GPBUnknownFieldSetTest.m
@@ -60,8 +60,93 @@
unknownFields_ = emptyMessage_.unknownFields;
}
-- (GPBUnknownField *)getField:(int32_t)number {
- return [unknownFields_ getField:number];
+- (void)testInvalidFieldNumber {
+ GPBUnknownFieldSet *set = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:0] autorelease];
+ XCTAssertThrowsSpecificNamed([set addField:field], NSException, NSInvalidArgumentException);
+}
+
+- (void)testEqualityAndHash {
+ // Empty
+
+ GPBUnknownFieldSet *set1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ XCTAssertTrue([set1 isEqual:set1]);
+ XCTAssertFalse([set1 isEqual:@"foo"]);
+ GPBUnknownFieldSet *set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Varint
+
+ GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ [field1 addVarint:1];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ [field2 addVarint:1];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Fixed32
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ [field1 addFixed32:2];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ [field2 addFixed32:2];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Fixed64
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
+ [field1 addFixed64:3];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
+ [field2 addFixed64:3];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // LengthDelimited
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field1 addLengthDelimited:DataFromCStr("foo")];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field2 addLengthDelimited:DataFromCStr("foo")];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Group
+
+ GPBUnknownFieldSet *group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [fieldGroup1 addVarint:1];
+ [group1 addField:fieldGroup1];
+ GPBUnknownFieldSet *group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [fieldGroup2 addVarint:1];
+ [group2 addField:fieldGroup2];
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field1 addGroup:group1];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field2 addGroup:group2];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Exercise description for completeness.
+ XCTAssertTrue(set1.description.length > 10);
}
// Constructs a protocol buffer which contains fields with all the same
@@ -116,6 +201,24 @@
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
[field addVarint:4];
[set1 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field addFixed32:6];
+ [set1 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field addFixed64:20];
+ [set1 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [field addLengthDelimited:DataFromCStr("data1")];
+ [set1 addField:field];
+
+ GPBUnknownFieldSet *group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
+ [fieldGroup1 addVarint:100];
+ [group1 addField:fieldGroup1];
+
+ field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
+ [field addGroup:group1];
+ [set1 addField:field];
GPBUnknownFieldSet* set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
@@ -124,22 +227,63 @@
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
[field addVarint:3];
[set2 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field addFixed32:7];
+ [set2 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field addFixed64:30];
+ [set2 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [field addLengthDelimited:DataFromCStr("data2")];
+ [set2 addField:field];
+
+ GPBUnknownFieldSet *group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
+ [fieldGroup2 addVarint:99];
+ [group2 addField:fieldGroup2];
+
+ field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
+ [field addGroup:group2];
+ [set2 addField:field];
GPBUnknownFieldSet* set3 = [[[GPBUnknownFieldSet alloc] init] autorelease];
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
[field addVarint:1];
[set3 addField:field];
- field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
- [field addVarint:4];
- [set3 addField:field];
-
- GPBUnknownFieldSet* set4 = [[[GPBUnknownFieldSet alloc] init] autorelease];
field = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
[field addVarint:2];
- [set4 addField:field];
+ [set3 addField:field];
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
+ [field addVarint:4];
+ [set3 addField:field];
[field addVarint:3];
- [set4 addField:field];
+ [set3 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field addFixed32:6];
+ [field addFixed32:7];
+ [set3 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field addFixed64:20];
+ [field addFixed64:30];
+ [set3 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [field addLengthDelimited:DataFromCStr("data1")];
+ [field addLengthDelimited:DataFromCStr("data2")];
+ [set3 addField:field];
+
+ GPBUnknownFieldSet *group3a = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup3a1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
+ [fieldGroup3a1 addVarint:100];
+ [group3a addField:fieldGroup3a1];
+ GPBUnknownFieldSet *group3b = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup3b2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
+ [fieldGroup3b2 addVarint:99];
+ [group3b addField:fieldGroup3b2];
+
+ field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
+ [field addGroup:group1];
+ [field addGroup:group3b];
+ [set3 addField:field];
TestEmptyMessage* source1 = [TestEmptyMessage message];
[source1 setUnknownFields:set1];
@@ -147,8 +291,6 @@
[source2 setUnknownFields:set2];
TestEmptyMessage* source3 = [TestEmptyMessage message];
[source3 setUnknownFields:set3];
- TestEmptyMessage* source4 = [TestEmptyMessage message];
- [source4 setUnknownFields:set4];
TestEmptyMessage* destination1 = [TestEmptyMessage message];
[destination1 mergeFrom:source1];
@@ -156,9 +298,10 @@
TestEmptyMessage* destination2 = [TestEmptyMessage message];
[destination2 mergeFrom:source3];
- [destination2 mergeFrom:source4];
XCTAssertEqualObjects(destination1.data, destination2.data);
+ XCTAssertEqualObjects(destination1.data, source3.data);
+ XCTAssertEqualObjects(destination2.data, source3.data);
}
- (void)testClearMessage {
@@ -244,6 +387,107 @@
XCTAssertEqual(0x7FFFFFFFFFFFFFFFULL, [field2.varintList valueAtIndex:0]);
}
+#pragma mark - Field tests
+// Some tests directly on fields since the dictionary in FieldSet can gate
+// testing some of these.
+
+- (void)testFieldEqualityAndHash {
+ GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ XCTAssertTrue([field1 isEqual:field1]);
+ XCTAssertFalse([field1 isEqual:@"foo"]);
+ GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ XCTAssertNotEqualObjects(field1, field2);
+
+ field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Varint
+
+ [field1 addVarint:10];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addVarint:10];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addVarint:11];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addVarint:11];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Fixed32
+
+ [field1 addFixed32:20];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed32:20];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addFixed32:21];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed32:21];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Fixed64
+
+ [field1 addFixed64:30];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed64:30];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addFixed64:31];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed64:31];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // LengthDelimited
+
+ [field1 addLengthDelimited:DataFromCStr("foo")];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addLengthDelimited:DataFromCStr("foo")];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addLengthDelimited:DataFromCStr("bar")];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addLengthDelimited:DataFromCStr("bar")];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Group
+
+ GPBUnknownFieldSet *group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
+ [fieldGroup addVarint:100];
+ [group addField:fieldGroup];
+ [field1 addGroup:group];
+ XCTAssertNotEqualObjects(field1, field2);
+ group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
+ [fieldGroup addVarint:100];
+ [group addField:fieldGroup];
+ [field2 addGroup:group];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
+ [fieldGroup addVarint:101];
+ [group addField:fieldGroup];
+ [field1 addGroup:group];
+ XCTAssertNotEqualObjects(field1, field2);
+ group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
+ [fieldGroup addVarint:101];
+ [group addField:fieldGroup];
+ [field2 addGroup:group];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Exercise description for completeness.
+ XCTAssertTrue(field1.description.length > 10);
+}
+
- (void)testMergingFields {
GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
[field1 addVarint:1];
@@ -251,9 +495,8 @@
[field1 addFixed64:3];
[field1 addLengthDelimited:[NSData dataWithBytes:"hello" length:5]];
[field1 addGroup:[[unknownFields_ copy] autorelease]];
- GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
[field2 mergeFromField:field1];
- XCTAssertEqualObjects(field1, field2);
}
@end
diff --git a/objectivec/Tests/GPBUtilitiesTests.m b/objectivec/Tests/GPBUtilitiesTests.m
index ba1fc270..8a8ba93e 100644
--- a/objectivec/Tests/GPBUtilitiesTests.m
+++ b/objectivec/Tests/GPBUtilitiesTests.m
@@ -39,6 +39,7 @@
#import "GPBDescriptor.h"
#import "GPBDescriptor_PackagePrivate.h"
#import "GPBMessage.h"
+#import "GPBUnknownField_PackagePrivate.h"
#import "google/protobuf/MapUnittest.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
@@ -51,12 +52,12 @@
- (void)testRightShiftFunctions {
XCTAssertEqual((1UL << 31) >> 31, 1UL);
- XCTAssertEqual((1 << 31) >> 31, -1);
+ XCTAssertEqual((int32_t)(1U << 31) >> 31, -1);
XCTAssertEqual((1ULL << 63) >> 63, 1ULL);
- XCTAssertEqual((1LL << 63) >> 63, -1LL);
+ XCTAssertEqual((int64_t)(1ULL << 63) >> 63, -1LL);
- XCTAssertEqual(GPBLogicalRightShift32((1 << 31), 31), 1);
- XCTAssertEqual(GPBLogicalRightShift64((1LL << 63), 63), 1LL);
+ XCTAssertEqual(GPBLogicalRightShift32((1U << 31), 31), 1);
+ XCTAssertEqual(GPBLogicalRightShift64((1ULL << 63), 63), 1LL);
}
- (void)testGPBDecodeTextFormatName {
@@ -170,4 +171,230 @@
// TODO(thomasvl): add test with extensions once those format with correct names.
+- (void)testSetRepeatedFields {
+ TestAllTypes *message = [TestAllTypes message];
+
+ NSDictionary *repeatedFieldValues = @{
+ @"repeatedStringArray" : [@[@"foo", @"bar"] mutableCopy],
+ @"repeatedBoolArray" : [GPBBoolArray arrayWithValue:YES],
+ @"repeatedInt32Array" : [GPBInt32Array arrayWithValue:14],
+ @"repeatedInt64Array" : [GPBInt64Array arrayWithValue:15],
+ @"repeatedUint32Array" : [GPBUInt32Array arrayWithValue:16],
+ @"repeatedUint64Array" : [GPBUInt64Array arrayWithValue:16],
+ @"repeatedFloatArray" : [GPBFloatArray arrayWithValue:16],
+ @"repeatedDoubleArray" : [GPBDoubleArray arrayWithValue:16],
+ @"repeatedNestedEnumArray" :
+ [GPBEnumArray arrayWithValidationFunction:TestAllTypes_NestedEnum_IsValidValue
+ rawValue:TestAllTypes_NestedEnum_Foo],
+ };
+ for (NSString *fieldName in repeatedFieldValues) {
+ GPBFieldDescriptor *field =
+ [message.descriptor fieldWithName:fieldName];
+ XCTAssertNotNil(field, @"No field with name: %@", fieldName);
+ id expectedValues = repeatedFieldValues[fieldName];
+ GPBSetMessageRepeatedField(message, field, expectedValues);
+ XCTAssertEqualObjects(expectedValues,
+ [message valueForKeyPath:fieldName]);
+ }
+}
+
+// Helper to make an unknown field set with something in it.
+static GPBUnknownFieldSet *UnknownFieldsSetHelper(int num) {
+ GPBUnknownFieldSet *result =
+ [[[GPBUnknownFieldSet alloc] init] autorelease];
+
+ GPBUnknownField *field =
+ [[[GPBUnknownField alloc] initWithNumber:num] autorelease];
+ [field addVarint:num];
+ [result addField:field];
+
+ return result;
+}
+
+- (void)testDropMessageUnknownFieldsRecursively {
+ TestAllExtensions *message = [TestAllExtensions message];
+
+ // Give it unknownFields.
+ message.unknownFields = UnknownFieldsSetHelper(777);
+
+ // Given it extensions that include a message with unknown fields of its own.
+ {
+ // Int
+ [message setExtension:[UnittestRoot optionalInt32Extension] value:@5];
+
+ // Group
+ OptionalGroup_extension *optionalGroup = [OptionalGroup_extension message];
+ optionalGroup.a = 123;
+ optionalGroup.unknownFields = UnknownFieldsSetHelper(779);
+ [message setExtension:[UnittestRoot optionalGroupExtension]
+ value:optionalGroup];
+
+ // Message
+ TestAllTypes_NestedMessage *nestedMessage =
+ [TestAllTypes_NestedMessage message];
+ nestedMessage.bb = 456;
+ nestedMessage.unknownFields = UnknownFieldsSetHelper(778);
+ [message setExtension:[UnittestRoot optionalNestedMessageExtension]
+ value:nestedMessage];
+
+ // Repeated Group
+ RepeatedGroup_extension *repeatedGroup =
+ [[RepeatedGroup_extension alloc] init];
+ repeatedGroup.a = 567;
+ repeatedGroup.unknownFields = UnknownFieldsSetHelper(780);
+ [message addExtension:[UnittestRoot repeatedGroupExtension]
+ value:repeatedGroup];
+ [repeatedGroup release];
+
+ // Repeated Message
+ nestedMessage = [[TestAllTypes_NestedMessage alloc] init];
+ nestedMessage.bb = 678;
+ nestedMessage.unknownFields = UnknownFieldsSetHelper(781);
+ [message addExtension:[UnittestRoot repeatedNestedMessageExtension]
+ value:nestedMessage];
+ [nestedMessage release];
+ }
+
+ // Confirm everything is there.
+
+ XCTAssertNotNil(message);
+ XCTAssertNotNil(message.unknownFields);
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalGroupExtension]]);
+ OptionalGroup_extension *optionalGroup =
+ [message getExtension:[UnittestRoot optionalGroupExtension]];
+ XCTAssertNotNil(optionalGroup);
+ XCTAssertEqual(optionalGroup.a, 123);
+ XCTAssertNotNil(optionalGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
+ TestAllTypes_NestedMessage *nestedMessage =
+ [message getExtension:[UnittestRoot optionalNestedMessageExtension]];
+ XCTAssertNotNil(nestedMessage);
+ XCTAssertEqual(nestedMessage.bb, 456);
+ XCTAssertNotNil(nestedMessage.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedGroupExtension]]);
+ NSArray *repeatedGroups = [message getExtension:[UnittestRoot repeatedGroupExtension]];
+ XCTAssertEqual(repeatedGroups.count, (NSUInteger)1);
+ RepeatedGroup_extension *repeatedGroup = repeatedGroups.firstObject;
+ XCTAssertNotNil(repeatedGroup);
+ XCTAssertEqual(repeatedGroup.a, 567);
+ XCTAssertNotNil(repeatedGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
+ NSArray *repeatedNestedMessages = [message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
+ XCTAssertEqual(repeatedNestedMessages.count, (NSUInteger)1);
+ TestAllTypes_NestedMessage *repeatedNestedMessage = repeatedNestedMessages.firstObject;
+ XCTAssertNotNil(repeatedNestedMessage);
+ XCTAssertEqual(repeatedNestedMessage.bb, 678);
+ XCTAssertNotNil(repeatedNestedMessage.unknownFields);
+ }
+
+ // Drop them.
+ GPBMessageDropUnknownFieldsRecursively(message);
+
+ // Confirm unknowns are gone from within the messages.
+
+ XCTAssertNotNil(message);
+ XCTAssertNil(message.unknownFields);
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalGroupExtension]]);
+ OptionalGroup_extension *optionalGroup =
+ [message getExtension:[UnittestRoot optionalGroupExtension]];
+ XCTAssertNotNil(optionalGroup);
+ XCTAssertEqual(optionalGroup.a, 123);
+ XCTAssertNil(optionalGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
+ TestAllTypes_NestedMessage *nestedMessage =
+ [message getExtension:[UnittestRoot optionalNestedMessageExtension]];
+ XCTAssertNotNil(nestedMessage);
+ XCTAssertEqual(nestedMessage.bb, 456);
+ XCTAssertNil(nestedMessage.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedGroupExtension]]);
+ NSArray *repeatedGroups = [message getExtension:[UnittestRoot repeatedGroupExtension]];
+ XCTAssertEqual(repeatedGroups.count, (NSUInteger)1);
+ RepeatedGroup_extension *repeatedGroup = repeatedGroups.firstObject;
+ XCTAssertNotNil(repeatedGroup);
+ XCTAssertEqual(repeatedGroup.a, 567);
+ XCTAssertNil(repeatedGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
+ NSArray *repeatedNestedMessages = [message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
+ XCTAssertEqual(repeatedNestedMessages.count, (NSUInteger)1);
+ TestAllTypes_NestedMessage *repeatedNestedMessage = repeatedNestedMessages.firstObject;
+ XCTAssertNotNil(repeatedNestedMessage);
+ XCTAssertEqual(repeatedNestedMessage.bb, 678);
+ XCTAssertNil(repeatedNestedMessage.unknownFields);
+ }
+
+}
+
+- (void)testDropMessageUnknownFieldsRecursively_Maps {
+ TestMap *message = [TestMap message];
+
+ {
+ ForeignMessage *foreignMessage = [ForeignMessage message];
+ foreignMessage.unknownFields = UnknownFieldsSetHelper(100);
+ [message.mapInt32ForeignMessage setObject:foreignMessage forKey:100];
+
+ foreignMessage = [ForeignMessage message];
+ foreignMessage.unknownFields = UnknownFieldsSetHelper(101);
+ [message.mapStringForeignMessage setObject:foreignMessage forKey:@"101"];
+ }
+
+ // Confirm everything is there.
+
+ XCTAssertNotNil(message);
+
+ {
+ ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNotNil(foreignMessage.unknownFields);
+ }
+
+ {
+ ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNotNil(foreignMessage.unknownFields);
+ }
+
+ GPBMessageDropUnknownFieldsRecursively(message);
+
+ // Confirm unknowns are gone from within the messages.
+
+ XCTAssertNotNil(message);
+
+ {
+ ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNil(foreignMessage.unknownFields);
+ }
+
+ {
+ ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNil(foreignMessage.unknownFields);
+ }
+
+}
+
@end
diff --git a/objectivec/Tests/GPBWellKnownTypesTest.m b/objectivec/Tests/GPBWellKnownTypesTest.m
index 78f4e637..592d5afd 100644
--- a/objectivec/Tests/GPBWellKnownTypesTest.m
+++ b/objectivec/Tests/GPBWellKnownTypesTest.m
@@ -32,8 +32,8 @@
#import <XCTest/XCTest.h>
-// A basically random interval into the future for testing with.
-static const NSTimeInterval kFutureOffsetInterval = 15000;
+#import "GPBTestUtilities.h"
+#import "google/protobuf/AnyTest.pbobjc.h"
// Nanosecond time accuracy
static const NSTimeInterval kTimeAccuracy = 1e-9;
@@ -44,59 +44,171 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
@implementation WellKnownTypesTest
- (void)testTimeStamp {
- // Test Creation.
- NSDate *date = [NSDate date];
- GPBTimestamp *timeStamp = [[GPBTimestamp alloc] initWithDate:date];
- NSDate *timeStampDate = timeStamp.date;
-
- // Comparing timeIntervals instead of directly comparing dates because date
- // equality requires the time intervals to be exactly the same, and the
- // timeintervals go through a bit of floating point error as they are
- // converted back and forth from the internal representation.
- XCTAssertEqualWithAccuracy(date.timeIntervalSince1970,
- timeStampDate.timeIntervalSince1970,
- kTimeAccuracy);
-
- NSTimeInterval time = [date timeIntervalSince1970];
- GPBTimestamp *timeStamp2 =
- [[GPBTimestamp alloc] initWithTimeIntervalSince1970:time];
- NSTimeInterval durationTime = timeStamp2.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [timeStamp release];
-
- // Test Mutation.
- date = [NSDate dateWithTimeIntervalSinceNow:kFutureOffsetInterval];
- timeStamp2.date = date;
- timeStampDate = timeStamp2.date;
- XCTAssertEqualWithAccuracy(date.timeIntervalSince1970,
- timeStampDate.timeIntervalSince1970,
- kTimeAccuracy);
-
- time = date.timeIntervalSince1970;
- timeStamp2.timeIntervalSince1970 = time;
- durationTime = timeStamp2.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [timeStamp2 release];
+ // Test negative and positive values.
+ NSTimeInterval values[] = {
+ -428027599.483999967, -1234567.0, -0.5, 0, 0.75, 54321.0, 2468086,483999967
+ };
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ NSTimeInterval value = values[i];
+
+ // Test Creation - date.
+ NSDate *date = [NSDate dateWithTimeIntervalSince1970:value];
+ GPBTimestamp *timeStamp = [[GPBTimestamp alloc] initWithDate:date];
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ // Comparing timeIntervals instead of directly comparing dates because date
+ // equality requires the time intervals to be exactly the same, and the
+ // timeintervals go through a bit of floating point error as they are
+ // converted back and forth from the internal representation.
+ XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+ [timeStamp release];
+
+ // Test Creation - timeIntervalSince1970.
+ timeStamp = [[GPBTimestamp alloc] initWithTimeIntervalSince1970:value];
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ XCTAssertEqualWithAccuracy(value, timeStamp.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+ [timeStamp release];
+
+ // Test Mutation - date.
+ timeStamp = [[GPBTimestamp alloc] init];
+ timeStamp.date = date;
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+ [timeStamp release];
+
+ // Test Mutation - timeIntervalSince1970.
+ timeStamp = [[GPBTimestamp alloc] init];
+ timeStamp.timeIntervalSince1970 = value;
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ [timeStamp release];
+ }
}
- (void)testDuration {
- // Test Creation.
- NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
- GPBDuration *duration =
- [[GPBDuration alloc] initWithTimeIntervalSince1970:time];
- NSTimeInterval durationTime = duration.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [duration release];
-
- // Test Mutation.
- GPBDuration *duration2 =
- [[GPBDuration alloc] initWithTimeIntervalSince1970:time];
- NSDate *date = [NSDate dateWithTimeIntervalSinceNow:kFutureOffsetInterval];
- time = date.timeIntervalSince1970;
- duration2.timeIntervalSince1970 = time;
- durationTime = duration2.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [duration2 release];
+ // Test negative and positive values.
+ NSTimeInterval values[] = { -1000.0001, -500.0, -0.5, 0, 0.75, 1000.0, 2000.0002 };
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ NSTimeInterval value = values[i];
+
+ // Test Creation.
+ GPBDuration *duration =
+ [[GPBDuration alloc] initWithTimeInterval:value];
+ XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy,
+ @"For interval %f", (double)value);
+ if (value > 0) {
+ XCTAssertGreaterThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertGreaterThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ } else {
+ XCTAssertLessThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertLessThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ }
+ [duration release];
+
+ // Test Mutation.
+ duration = [[GPBDuration alloc] init];
+ duration.timeInterval = value;
+ XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy,
+ @"For interval %f", (double)value);
+ if (value > 0) {
+ XCTAssertGreaterThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertGreaterThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ } else {
+ XCTAssertLessThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertLessThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ }
+ [duration release];
+ }
+}
+
+- (void)testAnyHelpers {
+
+ // Set and extract covers most of the code.
+
+ TestAny *subMessage = [TestAny message];
+ subMessage.int32Value = 12345;
+ TestAny *message = [TestAny message];
+ NSError *err = nil;
+ message.anyValue = [GPBAny anyWithMessage:subMessage error:&err];
+ XCTAssertNil(err);
+
+ NSData *data = message.data;
+ XCTAssertNotNil(data);
+
+ TestAny *message2 = [TestAny parseFromData:data error:&err];
+ XCTAssertNil(err);
+ XCTAssertNotNil(message2);
+ XCTAssertTrue(message2.hasAnyValue);
+
+ TestAny *subMessage2 =
+ (TestAny *)[message.anyValue unpackMessageClass:[TestAny class]
+ error:&err];
+ XCTAssertNil(err);
+ XCTAssertNotNil(subMessage2);
+ XCTAssertEqual(subMessage2.int32Value, 12345);
+
+ // NULL errorPtr in the two calls.
+
+ message.anyValue = [GPBAny anyWithMessage:subMessage error:NULL];
+ NSData *data2 = message.data;
+ XCTAssertEqualObjects(data2, data);
+
+ TestAny *subMessage3 =
+ (TestAny *)[message.anyValue unpackMessageClass:[TestAny class]
+ error:NULL];
+ XCTAssertNotNil(subMessage3);
+ XCTAssertEqualObjects(subMessage2, subMessage3);
+
+ // Try to extract wrong type.
+
+ GPBTimestamp *wrongMessage =
+ (GPBTimestamp *)[message.anyValue unpackMessageClass:[GPBTimestamp class]
+ error:&err];
+ XCTAssertNotNil(err);
+ XCTAssertNil(wrongMessage);
+ XCTAssertEqualObjects(err.domain, GPBWellKnownTypesErrorDomain);
+ XCTAssertEqual(err.code, GPBWellKnownTypesErrorCodeTypeURLMismatch);
+
+ wrongMessage =
+ (GPBTimestamp *)[message.anyValue unpackMessageClass:[GPBTimestamp class]
+ error:NULL];
+ XCTAssertNil(wrongMessage);
}
@end
diff --git a/objectivec/Tests/GPBWireFormatTests.m b/objectivec/Tests/GPBWireFormatTests.m
index 2a406f11..dbeab215 100644
--- a/objectivec/Tests/GPBWireFormatTests.m
+++ b/objectivec/Tests/GPBWireFormatTests.m
@@ -46,6 +46,7 @@
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes error:NULL];
@@ -58,6 +59,7 @@
[self packedSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestPackedTypes* message2 =
@@ -74,6 +76,7 @@
TestAllExtensions* message =
[self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes error:NULL];
@@ -87,6 +90,7 @@
TestPackedExtensions* message =
[self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
TestPackedTypes* message2 =
[self packedSetRepeatedCount:kGPBDefaultRepeatCount];
@@ -102,6 +106,7 @@
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
GPBExtensionRegistry* registry = [self extensionRegistry];
@@ -113,7 +118,7 @@
}
-- (void) testExtensionsSerializedSize {
+- (void)testExtensionsSerializedSize {
size_t allSet = [self allSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
size_t extensionSet = [self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
XCTAssertEqual(allSet, extensionSet);
@@ -124,6 +129,7 @@
TestPackedExtensions* message =
[self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
GPBExtensionRegistry* registry = [self extensionRegistry];
diff --git a/objectivec/Tests/iOSTestHarness/AppDelegate.m b/objectivec/Tests/iOSTestHarness/AppDelegate.m
deleted file mode 100644
index 8c4a586b..00000000
--- a/objectivec/Tests/iOSTestHarness/AppDelegate.m
+++ /dev/null
@@ -1,35 +0,0 @@
-#import <UIKit/UIKit.h>
-
-@interface AppDelegate : UIResponder <UIApplicationDelegate>
-@property (strong, nonatomic) UIWindow *window;
-@end
-
-@implementation AppDelegate
-
-@synthesize window;
-
-- (BOOL)application:(UIApplication *)application
- didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- #pragma unused (application, launchOptions)
-
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- self.window.backgroundColor = [UIColor whiteColor];
- [self.window makeKeyAndVisible];
- self.window.rootViewController = [[UIViewController alloc] init];
-
- UILabel *label =
- [[UILabel alloc] initWithFrame:CGRectMake(0, 200, CGRectGetWidth(self.window.frame), 40)];
- label.text = @"Protocol Buffer Test Harness";
- label.textAlignment = NSTextAlignmentCenter;
- [self.window addSubview:label];
-
- return YES;
-}
-
-@end
-
-int main(int argc, char * argv[]) {
- @autoreleasepool {
- return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
- }
-}
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png
deleted file mode 100644
index 43da2ee4..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png
deleted file mode 100644
index 2ec93704..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png
deleted file mode 100644
index aec8bc1b..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png
deleted file mode 100644
index e39cc3e7..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png
deleted file mode 100644
index 5572d79f..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png
deleted file mode 100644
index 2424997f..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png
deleted file mode 100644
index 10bfc3cf..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png
deleted file mode 100644
index 8d16f14d..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json b/objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json
deleted file mode 100644
index 5a296668..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json
+++ /dev/null
@@ -1,49 +0,0 @@
-{
- "images" : [
- {
- "orientation" : "portrait",
- "idiom" : "ipad",
- "minimum-system-version" : "7.0",
- "extent" : "full-screen",
- "scale" : "2x"
- },
- {
- "orientation" : "landscape",
- "idiom" : "ipad",
- "minimum-system-version" : "7.0",
- "extent" : "full-screen",
- "scale" : "1x"
- },
- {
- "orientation" : "landscape",
- "idiom" : "ipad",
- "minimum-system-version" : "7.0",
- "extent" : "full-screen",
- "scale" : "2x"
- },
- {
- "orientation" : "portrait",
- "idiom" : "iphone",
- "minimum-system-version" : "7.0",
- "scale" : "2x"
- },
- {
- "orientation" : "portrait",
- "idiom" : "iphone",
- "minimum-system-version" : "7.0",
- "subtype" : "retina4",
- "scale" : "2x"
- },
- {
- "orientation" : "portrait",
- "idiom" : "ipad",
- "minimum-system-version" : "7.0",
- "extent" : "full-screen",
- "scale" : "1x"
- }
- ],
- "info" : {
- "version" : 1,
- "author" : "xcode"
- }
-} \ No newline at end of file
diff --git a/objectivec/Tests/iOSTestHarness/LaunchScreen.xib b/objectivec/Tests/iOSTestHarness/LaunchScreen.xib
deleted file mode 100644
index 22204bfe..00000000
--- a/objectivec/Tests/iOSTestHarness/LaunchScreen.xib
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
- <dependencies>
- <deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
- <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
- </dependencies>
- <objects>
- <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
- <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
- <view contentMode="scaleToFill" id="iN0-l3-epB">
- <rect key="frame" x="0.0" y="0.0" width="630" height="503"/>
- <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
- <subviews>
- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Protocol Buffer Test Harness" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
- <rect key="frame" x="20" y="147" width="591" height="43"/>
- <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
- <nil key="highlightedColor"/>
- </label>
- </subviews>
- <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
- <constraints>
- <constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="Kid-kn-2rF"/>
- <constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
- <constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
- </constraints>
- <nil key="simulatedStatusBarMetrics"/>
- <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
- <point key="canvasLocation" x="479" y="456.5"/>
- </view>
- </objects>
-</document>
diff --git a/objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings b/objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings
deleted file mode 100644
index 477b28ff..00000000
--- a/objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Localized versions of Info.plist keys */
-
diff --git a/objectivec/Tests/unittest_cycle.proto b/objectivec/Tests/unittest_cycle.proto
index 5f6f56a1..afc1b0fe 100644
--- a/objectivec/Tests/unittest_cycle.proto
+++ b/objectivec/Tests/unittest_cycle.proto
@@ -31,10 +31,8 @@ syntax = "proto2";
package protobuf_unittest;
-// Cycles in the Message graph can cause problems for the mutable classes
-// since the properties on the mutable class change types. This file just
-// needs to generate source, and that source must compile, to ensure the
-// generated source works for this sort of case.
+// Cycles in the Message graph can cause problems for message class
+// initialization order.
// You can't make a object graph that spans files, so this can only be done
// within a single proto file.
diff --git a/objectivec/Tests/unittest_deprecated.proto b/objectivec/Tests/unittest_deprecated.proto
new file mode 100644
index 00000000..96a52bbb
--- /dev/null
+++ b/objectivec/Tests/unittest_deprecated.proto
@@ -0,0 +1,95 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_deprecated;
+option objc_class_prefix = "Dep";
+
+//
+// This file is like unittest_deprecated_file.proto, but uses message, enum,
+// enum value, and field level deprecation.
+//
+// The source generated from this file needs to be inspect to confirm it has
+// all of the expected annotations. It also will be compiled into the unittest
+// and that compile should be clean without errors.
+//
+
+// Mix of field types marked as deprecated.
+message Msg1 {
+ extensions 100 to max;
+
+ optional string string_field = 1 [deprecated=true];
+ required int32 int_field = 2 [deprecated=true];
+ repeated fixed32 fixed_field = 3 [deprecated=true];
+ optional Msg1 msg_field = 4 [deprecated=true];
+}
+
+// Mix of extension field types marked as deprecated.
+extend Msg1 {
+ optional string string_ext_field = 101 [deprecated=true];
+ optional int32 int_ext_field = 102 [deprecated=true];
+ repeated fixed32 fixed_ext_field = 103 [deprecated=true];
+ optional Msg1 msg_ext_field = 104 [deprecated=true];
+}
+
+// Mix of extension field types (scoped to a message) marked as deprecated.
+message Msg1A {
+ extend Msg1 {
+ optional string string_ext2_field = 201 [deprecated=true];
+ optional int32 int_ext2_field = 202 [deprecated=true];
+ repeated fixed32 fixed_ext2_field = 203 [deprecated=true];
+ optional Msg1 msg_ext2_field = 204 [deprecated=true];
+ }
+}
+
+// Enum value marked as deprecated.
+enum Enum1 {
+ ENUM1_ONE = 1;
+ ENUM1_TWO = 2;
+ ENUM1_THREE = 3 [deprecated=true];
+}
+
+// Message marked as deprecated.
+message Msg2 {
+ option deprecated = true;
+
+ optional string string_field = 1;
+ required int32 int_field = 2;
+ repeated fixed32 fixed_field = 3;
+}
+
+// Enum marked as deprecated.
+enum Enum2 {
+ option deprecated = true;
+
+ ENUM2_ONE = 1;
+ ENUM2_TWO = 2;
+ ENUM2_THREE = 3;
+}
diff --git a/objectivec/Tests/unittest_deprecated_file.proto b/objectivec/Tests/unittest_deprecated_file.proto
new file mode 100644
index 00000000..ef92e7de
--- /dev/null
+++ b/objectivec/Tests/unittest_deprecated_file.proto
@@ -0,0 +1,76 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_deprecated_file;
+option objc_class_prefix = "FileDep";
+
+//
+// This file is like unittest_deprecated.proto, but does NOT use message, enum,
+// enum value, or field level deprecation; instead it uses the file level option
+// to mark everything.
+//
+// The source generated from this file needs to be inspect to confirm it has
+// all of the expected annotations. It also will be compiled into the unittest
+// and that compile should be clean without errors.
+//
+option deprecated = true;
+
+// Message to catch the deprecation.
+message Msg1 {
+ extensions 100 to max;
+
+ optional string string_field = 1;
+}
+
+// Mix of extension field types to catch the deprecation.
+extend Msg1 {
+ optional string string_ext_field = 101;
+ optional int32 int_ext_field = 102;
+ repeated fixed32 fixed_ext_field = 103;
+ optional Msg1 msg_ext_field = 104;
+}
+
+// Mix of extension field types (scoped to a message) to catch the deprecation.
+message Msg1A {
+ extend Msg1 {
+ optional string string_ext2_field = 201;
+ optional int32 int_ext2_field = 202;
+ repeated fixed32 fixed_ext2_field = 203;
+ optional Msg1 msg_ext2_field = 204;
+ }
+}
+
+// Enum to catch the deprecation.
+enum Enum1 {
+ ENUM1_ONE = 1;
+ ENUM1_TWO = 2;
+ ENUM1_THREE = 3;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_a.proto b/objectivec/Tests/unittest_extension_chain_a.proto
new file mode 100644
index 00000000..6a227eb9
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_a.proto
@@ -0,0 +1,51 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+import "unittest_extension_chain_b.proto";
+import "unittest_extension_chain_c.proto";
+import "unittest_extension_chain_d.proto";
+
+// The Root for this file should end up adding the local extension and merging
+// in the extensions from D's Root (unittest and C will come via D's).
+
+message ChainAMessage {
+ optional ChainBMessage b = 1;
+ optional ChainCMessage c = 2;
+ optional ChainDMessage d = 3;
+}
+
+extend TestAllExtensions {
+ optional int32 chain_a_extension = 10001;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_b.proto b/objectivec/Tests/unittest_extension_chain_b.proto
new file mode 100644
index 00000000..0da7ed3e
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_b.proto
@@ -0,0 +1,47 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+import "unittest_extension_chain_c.proto";
+
+// The Root for this file should end up adding the local extension and merging
+// in the extensions from C's Root (unittest will come via C's).
+
+message ChainBMessage {
+ optional ChainCMessage c = 1;
+}
+
+extend TestAllExtensions {
+ optional int32 chain_b_extension = 10002;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_c.proto b/objectivec/Tests/unittest_extension_chain_c.proto
new file mode 100644
index 00000000..c702900a
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_c.proto
@@ -0,0 +1,45 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+// The Root for this file should end up adding the local extension and merging
+// in the extensions from unittest.proto's Root.
+
+message ChainCMessage {
+ optional int32 my_field = 1;
+}
+
+extend TestAllExtensions {
+ optional int32 chain_c_extension = 10003;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_d.proto b/objectivec/Tests/unittest_extension_chain_d.proto
new file mode 100644
index 00000000..f9abe3ba
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_d.proto
@@ -0,0 +1,49 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+import "unittest_extension_chain_b.proto";
+import "unittest_extension_chain_c.proto";
+
+// The root should end up needing to merge B (C will be merged into B, so it
+// doesn't need to be directly merged).
+
+message ChainDMessage {
+ optional ChainBMessage b = 1;
+ optional ChainCMessage c = 2;
+}
+
+extend TestAllExtensions {
+ optional int32 chain_d_extension = 10004;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_e.proto b/objectivec/Tests/unittest_extension_chain_e.proto
new file mode 100644
index 00000000..fe116631
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_e.proto
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+// The Root for this file should end up just merging in unittest's Root.
+
+message ChainEMessage {
+ optional TestAllTypes my_field = 1;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_f.proto b/objectivec/Tests/unittest_extension_chain_f.proto
new file mode 100644
index 00000000..b9bed723
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_f.proto
@@ -0,0 +1,44 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "unittest_extension_chain_g.proto";
+
+// The Root for this file should just be merging in the extensions from C's
+// Root (because G doens't define anything itself).
+
+// The generated source will also have to directly import C's .h file so it can
+// compile the reference to C's Root class.
+
+message ChainFMessage {
+ optional ChainGMessage g = 1;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_g.proto b/objectivec/Tests/unittest_extension_chain_g.proto
new file mode 100644
index 00000000..aee827b1
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_g.proto
@@ -0,0 +1,41 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "unittest_extension_chain_c.proto";
+
+// The Root for this file should just be merging in the extensions from C's
+// Root.
+
+message ChainGMessage {
+ optional ChainCMessage c = 1;
+}
diff --git a/objectivec/Tests/unittest_objc.proto b/objectivec/Tests/unittest_objc.proto
index 3bb92761..b0eb4723 100644
--- a/objectivec/Tests/unittest_objc.proto
+++ b/objectivec/Tests/unittest_objc.proto
@@ -29,10 +29,20 @@
syntax = "proto2";
+import "google/protobuf/any.proto";
import "google/protobuf/unittest.proto";
package protobuf_unittest;
+// Used to check that Headerdocs and appledoc work correctly. If these comments
+// are not handled correctly, Xcode will fail to build the tests.
+message TestGeneratedComments {
+ // This is a string that could contain stuff like
+ // mime types as image/* or */plain. Maybe twitter usernames
+ // like @protobuf, @google or @something.
+ optional string string_field = 1;
+}
+
// Using the messages in unittest.proto, setup for recursive cases for testing
// extensions at various depths.
extend TestAllExtensions {
@@ -48,6 +58,27 @@ message TestRecursiveMessageWithRepeatedField {
map<string, string> str_to_str = 5;
}
+// Message with a few types of maps to cover the different custom flows
+// in the runtime.
+message TestMessageOfMaps {
+ map<string, string> str_to_str = 1;
+
+ map<string, int32> str_to_int = 2;
+ map<int32, string> int_to_str = 3;
+ map<int32, int32> int_to_int = 4;
+
+ map<string, bool> str_to_bool = 5;
+ map<bool, string> bool_to_str = 6;
+ map<bool, bool> bool_to_bool = 7;
+
+ map<int32, bool> int_to_bool = 8;
+ map<bool, int32> bool_to_int = 9;
+
+ map<string, TestAllTypes> str_to_msg = 10;
+ map<int32, TestAllTypes> int_to_msg = 11;
+ map<bool, TestAllTypes> bool_to_msg = 12;
+}
+
// Recursive message and extension to for testing autocreators at different
// depths.
message TestRecursiveExtension {
@@ -112,6 +143,18 @@ enum retain {
serializedSize = 6;
}
+message ObjCPropertyNaming {
+ // Test that the properties properly get things all caps.
+ optional string url = 1;
+ optional string thumbnail_url = 2;
+ optional string url_foo = 3;
+ optional string some_url_blah = 4;
+ optional string http = 5;
+ optional string https = 6;
+ // This one doesn't.
+ repeated string urls = 7;
+}
+
// EnumValueShortName: The short names shouldn't get suffixes/prefixes.
enum Foo {
SERIALIZED_SIZE = 1;
@@ -389,3 +432,57 @@ message EnumTestMsg {
repeated MyEnum mumble = 4;
}
+
+// Test case for https://github.com/google/protobuf/issues/1453
+// Message with no explicit defaults, but a non zero default for an enum.
+message MessageWithOneBasedEnum {
+ enum OneBasedEnum {
+ ONE = 1;
+ TWO = 2;
+ }
+ optional OneBasedEnum enum_field = 1;
+}
+
+// Message with all bools for testing things related to bool storage.
+message BoolOnlyMessage {
+ optional bool bool_field_1 = 1;
+ optional bool bool_field_2 = 2;
+ optional bool bool_field_3 = 3;
+ optional bool bool_field_4 = 4;
+ optional bool bool_field_5 = 5;
+ optional bool bool_field_6 = 6;
+ optional bool bool_field_7 = 7;
+ optional bool bool_field_8 = 8;
+ optional bool bool_field_9 = 9;
+ optional bool bool_field_10 = 10;
+ optional bool bool_field_11 = 11;
+ optional bool bool_field_12 = 12;
+ optional bool bool_field_13 = 13;
+ optional bool bool_field_14 = 14;
+ optional bool bool_field_15 = 15;
+ optional bool bool_field_16 = 16;
+ optional bool bool_field_17 = 17;
+ optional bool bool_field_18 = 18;
+ optional bool bool_field_19 = 19;
+ optional bool bool_field_20 = 20;
+ optional bool bool_field_21 = 21;
+ optional bool bool_field_22 = 22;
+ optional bool bool_field_23 = 23;
+ optional bool bool_field_24 = 24;
+ optional bool bool_field_25 = 25;
+ optional bool bool_field_26 = 26;
+ optional bool bool_field_27 = 27;
+ optional bool bool_field_28 = 28;
+ optional bool bool_field_29 = 29;
+ optional bool bool_field_30 = 30;
+ optional bool bool_field_31 = 31;
+ optional bool bool_field_32 = 32;
+}
+
+// Reference to a WKT to test (via generated code inspection), the handling
+// of #imports. Within the WKTs, references to each other are just path
+// based imports, but when reference from another proto file, they should be
+// conditional to support the framework import style.
+message WKTRefereceMessage {
+ optional google.protobuf.Any an_any = 1;
+}
diff --git a/objectivec/generate_descriptors_proto.sh b/objectivec/generate_well_known_types.sh
index 84ba0738..36c34603 100755
--- a/objectivec/generate_descriptors_proto.sh
+++ b/objectivec/generate_well_known_types.sh
@@ -1,9 +1,9 @@
#!/bin/bash
-# Run this script to regenerate descriptor.pbobjc.{h,m} after the protocol
-# compiler changes.
+# Run this script to regenerate *.pbobjc.{h,m} for the well known types after
+# the protocol compiler changes.
-# HINT: Flags passed to generate_descriptor_proto.sh will be passed directly
+# HINT: Flags passed to generate_well_known_types.sh will be passed directly
# to make when building protoc. This is particularly useful for passing
# -j4 to run 4 jobs simultaneously.
@@ -12,6 +12,13 @@ set -eu
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/.."
+# Flag for continuous integration to check that everything is current.
+CHECK_ONLY=0
+if [[ $# -ge 1 && ( "$1" == "--check-only" ) ]] ; then
+ CHECK_ONLY=1
+ shift
+fi
+
pushd "${ProtoRootDir}" > /dev/null
if test ! -e src/google/protobuf/stubs/common.h; then
@@ -37,7 +44,6 @@ make $@ protoc
declare -a RUNTIME_PROTO_FILES=( \
google/protobuf/any.proto \
google/protobuf/api.proto \
- google/protobuf/descriptor.proto \
google/protobuf/duration.proto \
google/protobuf/empty.proto \
google/protobuf/field_mask.proto \
@@ -47,4 +53,24 @@ declare -a RUNTIME_PROTO_FILES=( \
google/protobuf/type.proto \
google/protobuf/wrappers.proto)
-./protoc --objc_out="${ProtoRootDir}/objectivec" ${RUNTIME_PROTO_FILES[@]}
+# Generate to a temp directory to see if they match.
+TMP_DIR=$(mktemp -d)
+trap "rm -rf ${TMP_DIR}" EXIT
+./protoc --objc_out="${TMP_DIR}" ${RUNTIME_PROTO_FILES[@]}
+set +e
+diff -r "${TMP_DIR}/google" "${ProtoRootDir}/objectivec/google" > /dev/null
+if [[ $? -eq 0 ]] ; then
+ echo "Generated source for WellKnownTypes is current."
+ exit 0
+fi
+set -e
+
+# If check only mode, error out.
+if [[ "${CHECK_ONLY}" == 1 ]] ; then
+ echo "ERROR: The WKTs need to be regenerated! Run $0"
+ exit 1
+fi
+
+# Copy them over.
+echo "Copying over updated WellKnownType sources."
+cp -r "${TMP_DIR}/google/." "${ProtoRootDir}/objectivec/google/"
diff --git a/objectivec/google/protobuf/Any.pbobjc.h b/objectivec/google/protobuf/Any.pbobjc.h
index 9866b5b1..ad261898 100644
--- a/objectivec/google/protobuf/Any.pbobjc.h
+++ b/objectivec/google/protobuf/Any.pbobjc.h
@@ -1,27 +1,51 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/any.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBAnyRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBAnyRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBAny
@@ -31,61 +55,120 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
GPBAny_FieldNumber_Value = 2,
};
-// `Any` contains an arbitrary serialized message along with a URL
-// that describes the type of the serialized message.
-//
-//
-// JSON
-// ====
-// The JSON representation of an `Any` value uses the regular
-// representation of the deserialized, embedded message, with an
-// additional field `@type` which contains the type URL. Example:
-//
-// package google.profile;
-// message Person {
-// string first_name = 1;
-// string last_name = 2;
-// }
-//
-// {
-// "@type": "type.googleapis.com/google.profile.Person",
-// "firstName": <string>,
-// "lastName": <string>
-// }
-//
-// If the embedded message type is well-known and has a custom JSON
-// representation, that representation will be embedded adding a field
-// `value` which holds the custom JSON in addition to the `@type`
-// field. Example (for message [google.protobuf.Duration][]):
-//
-// {
-// "@type": "type.googleapis.com/google.protobuf.Duration",
-// "value": "1.212s"
-// }
+/**
+ * `Any` contains an arbitrary serialized protocol buffer message along with a
+ * URL that describes the type of the serialized message.
+ *
+ * Protobuf library provides support to pack/unpack Any values in the form
+ * of utility functions or additional generated methods of the Any type.
+ *
+ * Example 1: Pack and unpack a message in C++.
+ *
+ * Foo foo = ...;
+ * Any any;
+ * any.PackFrom(foo);
+ * ...
+ * if (any.UnpackTo(&foo)) {
+ * ...
+ * }
+ *
+ * Example 2: Pack and unpack a message in Java.
+ *
+ * Foo foo = ...;
+ * Any any = Any.pack(foo);
+ * ...
+ * if (any.is(Foo.class)) {
+ * foo = any.unpack(Foo.class);
+ * }
+ *
+ * Example 3: Pack and unpack a message in Python.
+ *
+ * foo = Foo(...)
+ * any = Any()
+ * any.Pack(foo)
+ * ...
+ * if any.Is(Foo.DESCRIPTOR):
+ * any.Unpack(foo)
+ * ...
+ *
+ * Example 4: Pack and unpack a message in Go
+ *
+ * foo := &pb.Foo{...}
+ * any, err := ptypes.MarshalAny(foo)
+ * ...
+ * foo := &pb.Foo{}
+ * if err := ptypes.UnmarshalAny(any, foo); err != nil {
+ * ...
+ * }
+ *
+ * The pack methods provided by protobuf library will by default use
+ * 'type.googleapis.com/full.type.name' as the type URL and the unpack
+ * methods only use the fully qualified type name after the last '/'
+ * in the type URL, for example "foo.bar.com/x/y.z" will yield type
+ * name "y.z".
+ *
+ *
+ * JSON
+ * ====
+ * The JSON representation of an `Any` value uses the regular
+ * representation of the deserialized, embedded message, with an
+ * additional field `\@type` which contains the type URL. Example:
+ *
+ * package google.profile;
+ * message Person {
+ * string first_name = 1;
+ * string last_name = 2;
+ * }
+ *
+ * {
+ * "\@type": "type.googleapis.com/google.profile.Person",
+ * "firstName": <string>,
+ * "lastName": <string>
+ * }
+ *
+ * If the embedded message type is well-known and has a custom JSON
+ * representation, that representation will be embedded adding a field
+ * `value` which holds the custom JSON in addition to the `\@type`
+ * field. Example (for message [google.protobuf.Duration][]):
+ *
+ * {
+ * "\@type": "type.googleapis.com/google.protobuf.Duration",
+ * "value": "1.212s"
+ * }
+ **/
@interface GPBAny : GPBMessage
-// A URL/resource name whose content describes the type of the
-// serialized message.
-//
-// For URLs which use the schema `http`, `https`, or no schema, the
-// following restrictions and interpretations apply:
-//
-// * If no schema is provided, `https` is assumed.
-// * The last segment of the URL's path must represent the fully
-// qualified name of the type (as in `path/google.protobuf.Duration`).
-// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
-// value in binary format, or produce an error.
-// * Applications are allowed to cache lookup results based on the
-// URL, or have them precompiled into a binary to avoid any
-// lookup. Therefore, binary compatibility needs to be preserved
-// on changes to types. (Use versioned type names to manage
-// breaking changes.)
-//
-// Schemas other than `http`, `https` (or the empty schema) might be
-// used with implementation specific semantics.
+/**
+ * A URL/resource name that uniquely identifies the type of the serialized
+ * protocol buffer message. The last segment of the URL's path must represent
+ * the fully qualified name of the type (as in
+ * `path/google.protobuf.Duration`). The name should be in a canonical form
+ * (e.g., leading "." is not accepted).
+ *
+ * In practice, teams usually precompile into the binary all types that they
+ * expect it to use in the context of Any. However, for URLs which use the
+ * scheme `http`, `https`, or no scheme, one can optionally set up a type
+ * server that maps type URLs to message definitions as follows:
+ *
+ * * If no scheme is provided, `https` is assumed.
+ * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
+ * value in binary format, or produce an error.
+ * * Applications are allowed to cache lookup results based on the
+ * URL, or have them precompiled into a binary to avoid any
+ * lookup. Therefore, binary compatibility needs to be preserved
+ * on changes to types. (Use versioned type names to manage
+ * breaking changes.)
+ *
+ * Note: this functionality is not currently available in the official
+ * protobuf release, and it is not used for type URLs beginning with
+ * type.googleapis.com.
+ *
+ * Schemes other than `http`, `https` (or the empty scheme) might be
+ * used with implementation specific semantics.
+ **/
@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
-// Must be valid serialized data of the above specified type.
+/** Must be a valid serialized protocol buffer of the above specified type. */
@property(nonatomic, readwrite, copy, null_resettable) NSData *value;
@end
@@ -94,4 +177,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Any.pbobjc.m b/objectivec/google/protobuf/Any.pbobjc.m
index b41102a4..d210643f 100644
--- a/objectivec/google/protobuf/Any.pbobjc.m
+++ b/objectivec/google/protobuf/Any.pbobjc.m
@@ -1,14 +1,35 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/any.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/Any.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Any.pbobjc.h>
+#else
+ #import "google/protobuf/Any.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBAnyRoot
@implementation GPBAnyRoot
+// No extensions in the file and no imports, so no need to generate
+// +extensionRegistry.
+
@end
#pragma mark - GPBAnyRoot_FileDescriptor
@@ -18,8 +39,9 @@ static GPBFileDescriptor *GPBAnyRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -46,47 +68,36 @@ typedef struct GPBAny__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "typeURL",
+ .dataTypeSpecific.className = NULL,
.number = GPBAny_FieldNumber_TypeURL,
.hasIndex = 0,
- .flags = GPBFieldOptional | GPBFieldTextFormatNameCustom,
+ .offset = (uint32_t)offsetof(GPBAny__storage_, typeURL),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom),
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBAny__storage_, typeURL),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBAny_FieldNumber_Value,
.hasIndex = 1,
+ .offset = (uint32_t)offsetof(GPBAny__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeBytes,
- .offset = offsetof(GPBAny__storage_, value),
- .defaultValue.valueData = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
-#if GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
- const char *extraTextFormatInfo = NULL;
-#else
- static const char *extraTextFormatInfo = "\001\001\004\241!!\000";
-#endif // GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBAny class]
rootClass:[GPBAnyRoot class]
file:GPBAnyRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBAny__storage_)
- wireFormat:NO
- extraTextFormatInfo:extraTextFormatInfo];
+ flags:GPBDescriptorInitializationFlag_None];
+#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
+ static const char *extraTextFormatInfo =
+ "\001\001\004\241!!\000";
+ [localDescriptor setupExtraTextInfo:extraTextFormatInfo];
+#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -96,4 +107,6 @@ typedef struct GPBAny__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Api.pbobjc.h b/objectivec/google/protobuf/Api.pbobjc.h
index c3cf8e94..c93f3f15 100644
--- a/objectivec/google/protobuf/Api.pbobjc.h
+++ b/objectivec/google/protobuf/Api.pbobjc.h
@@ -1,16 +1,39 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/api.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
+
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
+@class GPBMethod;
+@class GPBMixin;
+@class GPBOption;
@class GPBSourceContext;
GPB_ENUM_FWD_DECLARE(GPBSyntax);
@@ -18,13 +41,17 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBApiRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBApiRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBApi
@@ -39,61 +66,86 @@ typedef GPB_ENUM(GPBApi_FieldNumber) {
GPBApi_FieldNumber_Syntax = 7,
};
-// Api is a light-weight descriptor for a protocol buffer service.
+/**
+ * Api is a light-weight descriptor for an API Interface.
+ *
+ * Interfaces are also described as "protocol buffer services" in some contexts,
+ * such as by the "service" keyword in a .proto file, but they are different
+ * from API Services, which represent a concrete implementation of an interface
+ * as opposed to simply a description of methods and bindings. They are also
+ * sometimes simply referred to as "APIs" in other contexts, such as the name of
+ * this message itself. See https://cloud.google.com/apis/design/glossary for
+ * detailed terminology.
+ **/
@interface GPBApi : GPBMessage
-// The fully qualified name of this api, including package name
-// followed by the api's simple name.
+/**
+ * The fully qualified name of this interface, including package name
+ * followed by the interface's simple name.
+ **/
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-// The methods of this api, in unspecified order.
-// |methodsArray| contains |GPBMethod|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *methodsArray;
+/** The methods of this interface, in unspecified order. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMethod*> *methodsArray;
+/** The number of items in @c methodsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger methodsArray_Count;
-// Any metadata attached to the API.
-// |optionsArray| contains |GPBOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
+/** Any metadata attached to the interface. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
-// A version string for this api. If specified, must have the form
-// `major-version.minor-version`, as in `1.10`. If the minor version
-// is omitted, it defaults to zero. If the entire version field is
-// empty, the major version is derived from the package name, as
-// outlined below. If the field is not empty, the version in the
-// package name will be verified to be consistent with what is
-// provided here.
-//
-// The versioning schema uses [semantic
-// versioning](http://semver.org) where the major version number
-// indicates a breaking change and the minor version an additive,
-// non-breaking change. Both version numbers are signals to users
-// what to expect from different versions, and should be carefully
-// chosen based on the product plan.
-//
-// The major version is also reflected in the package name of the
-// API, which must end in `v<major-version>`, as in
-// `google.feature.v1`. For major versions 0 and 1, the suffix can
-// be omitted. Zero major versions must only be used for
-// experimental, none-GA apis.
+/**
+ * A version string for this interface. If specified, must have the form
+ * `major-version.minor-version`, as in `1.10`. If the minor version is
+ * omitted, it defaults to zero. If the entire version field is empty, the
+ * major version is derived from the package name, as outlined below. If the
+ * field is not empty, the version in the package name will be verified to be
+ * consistent with what is provided here.
+ *
+ * The versioning schema uses [semantic
+ * versioning](http://semver.org) where the major version number
+ * indicates a breaking change and the minor version an additive,
+ * non-breaking change. Both version numbers are signals to users
+ * what to expect from different versions, and should be carefully
+ * chosen based on the product plan.
+ *
+ * The major version is also reflected in the package name of the
+ * interface, which must end in `v<major-version>`, as in
+ * `google.feature.v1`. For major versions 0 and 1, the suffix can
+ * be omitted. Zero major versions must only be used for
+ * experimental, non-GA interfaces.
+ **/
@property(nonatomic, readwrite, copy, null_resettable) NSString *version;
-// Source context for the protocol buffer service represented by this
-// message.
-@property(nonatomic, readwrite) BOOL hasSourceContext;
+/**
+ * Source context for the protocol buffer service represented by this
+ * message.
+ **/
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
+/** Test to see if @c sourceContext has been set. */
+@property(nonatomic, readwrite) BOOL hasSourceContext;
-// Included APIs. See [Mixin][].
-// |mixinsArray| contains |GPBMixin|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *mixinsArray;
+/** Included interfaces. See [Mixin][]. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMixin*> *mixinsArray;
+/** The number of items in @c mixinsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger mixinsArray_Count;
-// The source syntax of the service.
+/** The source syntax of the service. */
@property(nonatomic, readwrite) enum GPBSyntax syntax;
@end
+/**
+ * Fetches the raw value of a @c GPBApi's @c syntax property, even
+ * if the value was not defined by the enum at the time the code was generated.
+ **/
int32_t GPBApi_Syntax_RawValue(GPBApi *message);
+/**
+ * Sets the raw value of an @c GPBApi's @c syntax property, allowing
+ * it to be set to a value that was not defined by the enum at the time the code
+ * was generated.
+ **/
void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value);
#pragma mark - GPBMethod
@@ -108,35 +160,46 @@ typedef GPB_ENUM(GPBMethod_FieldNumber) {
GPBMethod_FieldNumber_Syntax = 7,
};
-// Method represents a method of an api.
+/**
+ * Method represents a method of an API interface.
+ **/
@interface GPBMethod : GPBMessage
-// The simple name of this method.
+/** The simple name of this method. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-// A URL of the input message type.
+/** A URL of the input message type. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *requestTypeURL;
-// If true, the request is streamed.
+/** If true, the request is streamed. */
@property(nonatomic, readwrite) BOOL requestStreaming;
-// The URL of the output message type.
+/** The URL of the output message type. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *responseTypeURL;
-// If true, the response is streamed.
+/** If true, the response is streamed. */
@property(nonatomic, readwrite) BOOL responseStreaming;
-// Any metadata attached to the method.
-// |optionsArray| contains |GPBOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
+/** Any metadata attached to the method. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
-// The source syntax of this method.
+/** The source syntax of this method. */
@property(nonatomic, readwrite) enum GPBSyntax syntax;
@end
+/**
+ * Fetches the raw value of a @c GPBMethod's @c syntax property, even
+ * if the value was not defined by the enum at the time the code was generated.
+ **/
int32_t GPBMethod_Syntax_RawValue(GPBMethod *message);
+/**
+ * Sets the raw value of an @c GPBMethod's @c syntax property, allowing
+ * it to be set to a value that was not defined by the enum at the time the code
+ * was generated.
+ **/
void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value);
#pragma mark - GPBMixin
@@ -146,90 +209,95 @@ typedef GPB_ENUM(GPBMixin_FieldNumber) {
GPBMixin_FieldNumber_Root = 2,
};
-// Declares an API to be included in this API. The including API must
-// redeclare all the methods from the included API, but documentation
-// and options are inherited as follows:
-//
-// - If after comment and whitespace stripping, the documentation
-// string of the redeclared method is empty, it will be inherited
-// from the original method.
-//
-// - Each annotation belonging to the service config (http,
-// visibility) which is not set in the redeclared method will be
-// inherited.
-//
-// - If an http annotation is inherited, the path pattern will be
-// modified as follows. Any version prefix will be replaced by the
-// version of the including API plus the [root][] path if specified.
-//
-// Example of a simple mixin:
-//
-// package google.acl.v1;
-// service AccessControl {
-// // Get the underlying ACL object.
-// rpc GetAcl(GetAclRequest) returns (Acl) {
-// option (google.api.http).get = "/v1/{resource=**}:getAcl";
-// }
-// }
-//
-// package google.storage.v2;
-// service Storage {
-// rpc GetAcl(GetAclRequest) returns (Acl);
-//
-// // Get a data record.
-// rpc GetData(GetDataRequest) returns (Data) {
-// option (google.api.http).get = "/v2/{resource=**}";
-// }
-// }
-//
-// Example of a mixin configuration:
-//
-// apis:
-// - name: google.storage.v2.Storage
-// mixins:
-// - name: google.acl.v1.AccessControl
-//
-// The mixin construct implies that all methods in `AccessControl` are
-// also declared with same name and request/response types in
-// `Storage`. A documentation generator or annotation processor will
-// see the effective `Storage.GetAcl` method after inherting
-// documentation and annotations as follows:
-//
-// service Storage {
-// // Get the underlying ACL object.
-// rpc GetAcl(GetAclRequest) returns (Acl) {
-// option (google.api.http).get = "/v2/{resource=**}:getAcl";
-// }
-// ...
-// }
-//
-// Note how the version in the path pattern changed from `v1` to `v2`.
-//
-// If the `root` field in the mixin is specified, it should be a
-// relative path under which inherited HTTP paths are placed. Example:
-//
-// apis:
-// - name: google.storage.v2.Storage
-// mixins:
-// - name: google.acl.v1.AccessControl
-// root: acls
-//
-// This implies the following inherited HTTP annotation:
-//
-// service Storage {
-// // Get the underlying ACL object.
-// rpc GetAcl(GetAclRequest) returns (Acl) {
-// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
-// }
-// ...
-// }
+/**
+ * Declares an API Interface to be included in this interface. The including
+ * interface must redeclare all the methods from the included interface, but
+ * documentation and options are inherited as follows:
+ *
+ * - If after comment and whitespace stripping, the documentation
+ * string of the redeclared method is empty, it will be inherited
+ * from the original method.
+ *
+ * - Each annotation belonging to the service config (http,
+ * visibility) which is not set in the redeclared method will be
+ * inherited.
+ *
+ * - If an http annotation is inherited, the path pattern will be
+ * modified as follows. Any version prefix will be replaced by the
+ * version of the including interface plus the [root][] path if
+ * specified.
+ *
+ * Example of a simple mixin:
+ *
+ * package google.acl.v1;
+ * service AccessControl {
+ * // Get the underlying ACL object.
+ * rpc GetAcl(GetAclRequest) returns (Acl) {
+ * option (google.api.http).get = "/v1/{resource=**}:getAcl";
+ * }
+ * }
+ *
+ * package google.storage.v2;
+ * service Storage {
+ * rpc GetAcl(GetAclRequest) returns (Acl);
+ *
+ * // Get a data record.
+ * rpc GetData(GetDataRequest) returns (Data) {
+ * option (google.api.http).get = "/v2/{resource=**}";
+ * }
+ * }
+ *
+ * Example of a mixin configuration:
+ *
+ * apis:
+ * - name: google.storage.v2.Storage
+ * mixins:
+ * - name: google.acl.v1.AccessControl
+ *
+ * The mixin construct implies that all methods in `AccessControl` are
+ * also declared with same name and request/response types in
+ * `Storage`. A documentation generator or annotation processor will
+ * see the effective `Storage.GetAcl` method after inherting
+ * documentation and annotations as follows:
+ *
+ * service Storage {
+ * // Get the underlying ACL object.
+ * rpc GetAcl(GetAclRequest) returns (Acl) {
+ * option (google.api.http).get = "/v2/{resource=**}:getAcl";
+ * }
+ * ...
+ * }
+ *
+ * Note how the version in the path pattern changed from `v1` to `v2`.
+ *
+ * If the `root` field in the mixin is specified, it should be a
+ * relative path under which inherited HTTP paths are placed. Example:
+ *
+ * apis:
+ * - name: google.storage.v2.Storage
+ * mixins:
+ * - name: google.acl.v1.AccessControl
+ * root: acls
+ *
+ * This implies the following inherited HTTP annotation:
+ *
+ * service Storage {
+ * // Get the underlying ACL object.
+ * rpc GetAcl(GetAclRequest) returns (Acl) {
+ * option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
+ * }
+ * ...
+ * }
+ **/
@interface GPBMixin : GPBMessage
-// The fully qualified name of the API which is included.
+/** The fully qualified name of the interface which is included. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-// If non-empty specifies a path under which inherited HTTP paths
-// are rooted.
+/**
+ * If non-empty specifies a path under which inherited HTTP paths
+ * are rooted.
+ **/
@property(nonatomic, readwrite, copy, null_resettable) NSString *root;
@end
@@ -238,4 +306,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Api.pbobjc.m b/objectivec/google/protobuf/Api.pbobjc.m
index d964ff41..58b47157 100644
--- a/objectivec/google/protobuf/Api.pbobjc.m
+++ b/objectivec/google/protobuf/Api.pbobjc.m
@@ -1,28 +1,38 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/api.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/Api.pbobjc.h"
-#import "google/protobuf/SourceContext.pbobjc.h"
-#import "google/protobuf/Type.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Api.pbobjc.h>
+ #import <Protobuf/SourceContext.pbobjc.h>
+ #import <Protobuf/Type.pbobjc.h>
+#else
+ #import "google/protobuf/Api.pbobjc.h"
+ #import "google/protobuf/SourceContext.pbobjc.h"
+ #import "google/protobuf/Type.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBApiRoot
@implementation GPBApiRoot
-+ (GPBExtensionRegistry*)extensionRegistry {
- // This is called by +initialize so there is no need to worry
- // about thread safety and initialization of registry.
- static GPBExtensionRegistry* registry = nil;
- if (!registry) {
- GPBDebugCheckRuntimeVersion();
- registry = [[GPBExtensionRegistry alloc] init];
- [registry addExtensions:[GPBSourceContextRoot extensionRegistry]];
- [registry addExtensions:[GPBTypeRoot extensionRegistry]];
- }
- return registry;
-}
+// No extensions in the file and none of the imports (direct or indirect)
+// defined extensions, so no need to generate +extensionRegistry.
@end
@@ -33,8 +43,9 @@ static GPBFileDescriptor *GPBApiRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -71,80 +82,66 @@ typedef struct GPBApi__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "name",
+ .dataTypeSpecific.className = NULL,
.number = GPBApi_FieldNumber_Name,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBApi__storage_, name),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBApi__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "methodsArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBMethod),
.number = GPBApi_FieldNumber_MethodsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBApi__storage_, methodsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBApi__storage_, methodsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBMethod),
- .fieldOptions = NULL,
},
{
.name = "optionsArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
.number = GPBApi_FieldNumber_OptionsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBApi__storage_, optionsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBApi__storage_, optionsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
- .fieldOptions = NULL,
},
{
.name = "version",
+ .dataTypeSpecific.className = NULL,
.number = GPBApi_FieldNumber_Version,
- .hasIndex = 3,
+ .hasIndex = 1,
+ .offset = (uint32_t)offsetof(GPBApi__storage_, version),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBApi__storage_, version),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "sourceContext",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext),
.number = GPBApi_FieldNumber_SourceContext,
- .hasIndex = 4,
+ .hasIndex = 2,
+ .offset = (uint32_t)offsetof(GPBApi__storage_, sourceContext),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBApi__storage_, sourceContext),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext),
- .fieldOptions = NULL,
},
{
.name = "mixinsArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBMixin),
.number = GPBApi_FieldNumber_MixinsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBApi__storage_, mixinsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBApi__storage_, mixinsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBMixin),
- .fieldOptions = NULL,
},
{
.name = "syntax",
+ .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
.number = GPBApi_FieldNumber_Syntax,
- .hasIndex = 6,
- .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
+ .hasIndex = 3,
+ .offset = (uint32_t)offsetof(GPBApi__storage_, syntax),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor),
.dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBApi__storage_, syntax),
- .defaultValue.valueEnum = GPBSyntax_SyntaxProto2,
- .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -152,15 +149,9 @@ typedef struct GPBApi__storage_ {
rootClass:[GPBApiRoot class]
file:GPBApiRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBApi__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -195,8 +186,6 @@ void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value) {
typedef struct GPBMethod__storage_ {
uint32_t _has_storage_[1];
- BOOL requestStreaming;
- BOOL responseStreaming;
GPBSyntax syntax;
NSString *name;
NSString *requestTypeURL;
@@ -212,102 +201,81 @@ typedef struct GPBMethod__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "name",
+ .dataTypeSpecific.className = NULL,
.number = GPBMethod_FieldNumber_Name,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBMethod__storage_, name),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBMethod__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "requestTypeURL",
+ .dataTypeSpecific.className = NULL,
.number = GPBMethod_FieldNumber_RequestTypeURL,
.hasIndex = 1,
- .flags = GPBFieldOptional | GPBFieldTextFormatNameCustom,
+ .offset = (uint32_t)offsetof(GPBMethod__storage_, requestTypeURL),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom),
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBMethod__storage_, requestTypeURL),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "requestStreaming",
+ .dataTypeSpecific.className = NULL,
.number = GPBMethod_FieldNumber_RequestStreaming,
.hasIndex = 2,
+ .offset = 3, // Stored in _has_storage_ to save space.
.flags = GPBFieldOptional,
.dataType = GPBDataTypeBool,
- .offset = offsetof(GPBMethod__storage_, requestStreaming),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "responseTypeURL",
+ .dataTypeSpecific.className = NULL,
.number = GPBMethod_FieldNumber_ResponseTypeURL,
- .hasIndex = 3,
- .flags = GPBFieldOptional | GPBFieldTextFormatNameCustom,
+ .hasIndex = 4,
+ .offset = (uint32_t)offsetof(GPBMethod__storage_, responseTypeURL),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom),
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBMethod__storage_, responseTypeURL),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "responseStreaming",
+ .dataTypeSpecific.className = NULL,
.number = GPBMethod_FieldNumber_ResponseStreaming,
- .hasIndex = 4,
+ .hasIndex = 5,
+ .offset = 6, // Stored in _has_storage_ to save space.
.flags = GPBFieldOptional,
.dataType = GPBDataTypeBool,
- .offset = offsetof(GPBMethod__storage_, responseStreaming),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "optionsArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
.number = GPBMethod_FieldNumber_OptionsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBMethod__storage_, optionsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBMethod__storage_, optionsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
- .fieldOptions = NULL,
},
{
.name = "syntax",
+ .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
.number = GPBMethod_FieldNumber_Syntax,
- .hasIndex = 6,
- .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
+ .hasIndex = 7,
+ .offset = (uint32_t)offsetof(GPBMethod__storage_, syntax),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor),
.dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBMethod__storage_, syntax),
- .defaultValue.valueEnum = GPBSyntax_SyntaxProto2,
- .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
- .fieldOptions = NULL,
},
};
-#if GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
- const char *extraTextFormatInfo = NULL;
-#else
- static const char *extraTextFormatInfo = "\002\002\007\244\241!!\000\004\010\244\241!!\000";
-#endif // GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBMethod class]
rootClass:[GPBApiRoot class]
file:GPBApiRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBMethod__storage_)
- wireFormat:NO
- extraTextFormatInfo:extraTextFormatInfo];
+ flags:GPBDescriptorInitializationFlag_None];
+#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
+ static const char *extraTextFormatInfo =
+ "\002\002\007\244\241!!\000\004\010\244\241!!\000";
+ [localDescriptor setupExtraTextInfo:extraTextFormatInfo];
+#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -349,25 +317,21 @@ typedef struct GPBMixin__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "name",
+ .dataTypeSpecific.className = NULL,
.number = GPBMixin_FieldNumber_Name,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBMixin__storage_, name),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBMixin__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "root",
+ .dataTypeSpecific.className = NULL,
.number = GPBMixin_FieldNumber_Root,
.hasIndex = 1,
+ .offset = (uint32_t)offsetof(GPBMixin__storage_, root),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBMixin__storage_, root),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -375,15 +339,9 @@ typedef struct GPBMixin__storage_ {
rootClass:[GPBApiRoot class]
file:GPBApiRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBMixin__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -393,4 +351,6 @@ typedef struct GPBMixin__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Descriptor.pbobjc.h b/objectivec/google/protobuf/Descriptor.pbobjc.h
deleted file mode 100644
index 9c43cfd2..00000000
--- a/objectivec/google/protobuf/Descriptor.pbobjc.h
+++ /dev/null
@@ -1,1212 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: google/protobuf/descriptor.proto
-
-#import "GPBProtocolBuffers.h"
-
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
-#endif
-
-// @@protoc_insertion_point(imports)
-
-CF_EXTERN_C_BEGIN
-
-@class GPBEnumOptions;
-@class GPBEnumValueOptions;
-@class GPBFieldOptions;
-@class GPBFileOptions;
-@class GPBMessageOptions;
-@class GPBMethodOptions;
-@class GPBServiceOptions;
-@class GPBSourceCodeInfo;
-
-NS_ASSUME_NONNULL_BEGIN
-
-#pragma mark - Enum GPBFieldDescriptorProto_Type
-
-typedef GPB_ENUM(GPBFieldDescriptorProto_Type) {
- // 0 is reserved for errors.
- // Order is weird for historical reasons.
- GPBFieldDescriptorProto_Type_TypeDouble = 1,
- GPBFieldDescriptorProto_Type_TypeFloat = 2,
-
- // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
- // negative values are likely.
- GPBFieldDescriptorProto_Type_TypeInt64 = 3,
- GPBFieldDescriptorProto_Type_TypeUint64 = 4,
-
- // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
- // negative values are likely.
- GPBFieldDescriptorProto_Type_TypeInt32 = 5,
- GPBFieldDescriptorProto_Type_TypeFixed64 = 6,
- GPBFieldDescriptorProto_Type_TypeFixed32 = 7,
- GPBFieldDescriptorProto_Type_TypeBool = 8,
- GPBFieldDescriptorProto_Type_TypeString = 9,
-
- // Tag-delimited aggregate.
- GPBFieldDescriptorProto_Type_TypeGroup = 10,
-
- // Length-delimited aggregate.
- GPBFieldDescriptorProto_Type_TypeMessage = 11,
-
- // New in version 2.
- GPBFieldDescriptorProto_Type_TypeBytes = 12,
- GPBFieldDescriptorProto_Type_TypeUint32 = 13,
- GPBFieldDescriptorProto_Type_TypeEnum = 14,
- GPBFieldDescriptorProto_Type_TypeSfixed32 = 15,
- GPBFieldDescriptorProto_Type_TypeSfixed64 = 16,
-
- // Uses ZigZag encoding.
- GPBFieldDescriptorProto_Type_TypeSint32 = 17,
-
- // Uses ZigZag encoding.
- GPBFieldDescriptorProto_Type_TypeSint64 = 18,
-};
-
-GPBEnumDescriptor *GPBFieldDescriptorProto_Type_EnumDescriptor(void);
-
-BOOL GPBFieldDescriptorProto_Type_IsValidValue(int32_t value);
-
-#pragma mark - Enum GPBFieldDescriptorProto_Label
-
-typedef GPB_ENUM(GPBFieldDescriptorProto_Label) {
- // 0 is reserved for errors
- GPBFieldDescriptorProto_Label_LabelOptional = 1,
- GPBFieldDescriptorProto_Label_LabelRequired = 2,
-
- // TODO(sanjay): Should we add LABEL_MAP?
- GPBFieldDescriptorProto_Label_LabelRepeated = 3,
-};
-
-GPBEnumDescriptor *GPBFieldDescriptorProto_Label_EnumDescriptor(void);
-
-BOOL GPBFieldDescriptorProto_Label_IsValidValue(int32_t value);
-
-#pragma mark - Enum GPBFileOptions_OptimizeMode
-
-// Generated classes can be optimized for speed or code size.
-typedef GPB_ENUM(GPBFileOptions_OptimizeMode) {
- // Generate complete code for parsing, serialization,
- GPBFileOptions_OptimizeMode_Speed = 1,
-
- // etc.
- GPBFileOptions_OptimizeMode_CodeSize = 2,
-
- // Generate code using MessageLite and the lite runtime.
- GPBFileOptions_OptimizeMode_LiteRuntime = 3,
-};
-
-GPBEnumDescriptor *GPBFileOptions_OptimizeMode_EnumDescriptor(void);
-
-BOOL GPBFileOptions_OptimizeMode_IsValidValue(int32_t value);
-
-#pragma mark - Enum GPBFieldOptions_CType
-
-typedef GPB_ENUM(GPBFieldOptions_CType) {
- // Default mode.
- GPBFieldOptions_CType_String = 0,
- GPBFieldOptions_CType_Cord = 1,
- GPBFieldOptions_CType_StringPiece = 2,
-};
-
-GPBEnumDescriptor *GPBFieldOptions_CType_EnumDescriptor(void);
-
-BOOL GPBFieldOptions_CType_IsValidValue(int32_t value);
-
-#pragma mark - Enum GPBFieldOptions_JSType
-
-typedef GPB_ENUM(GPBFieldOptions_JSType) {
- // Use the default type.
- GPBFieldOptions_JSType_JsNormal = 0,
-
- // Use JavaScript strings.
- GPBFieldOptions_JSType_JsString = 1,
-
- // Use JavaScript numbers.
- GPBFieldOptions_JSType_JsNumber = 2,
-};
-
-GPBEnumDescriptor *GPBFieldOptions_JSType_EnumDescriptor(void);
-
-BOOL GPBFieldOptions_JSType_IsValidValue(int32_t value);
-
-#pragma mark - GPBDescriptorRoot
-
-@interface GPBDescriptorRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
-@end
-
-#pragma mark - GPBFileDescriptorSet
-
-typedef GPB_ENUM(GPBFileDescriptorSet_FieldNumber) {
- GPBFileDescriptorSet_FieldNumber_FileArray = 1,
-};
-
-// The protocol compiler can output a FileDescriptorSet containing the .proto
-// files it parses.
-@interface GPBFileDescriptorSet : GPBMessage
-
-// |fileArray| contains |GPBFileDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fileArray;
-@property(nonatomic, readonly) NSUInteger fileArray_Count;
-
-@end
-
-#pragma mark - GPBFileDescriptorProto
-
-typedef GPB_ENUM(GPBFileDescriptorProto_FieldNumber) {
- GPBFileDescriptorProto_FieldNumber_Name = 1,
- GPBFileDescriptorProto_FieldNumber_Package = 2,
- GPBFileDescriptorProto_FieldNumber_DependencyArray = 3,
- GPBFileDescriptorProto_FieldNumber_MessageTypeArray = 4,
- GPBFileDescriptorProto_FieldNumber_EnumTypeArray = 5,
- GPBFileDescriptorProto_FieldNumber_ServiceArray = 6,
- GPBFileDescriptorProto_FieldNumber_ExtensionArray = 7,
- GPBFileDescriptorProto_FieldNumber_Options = 8,
- GPBFileDescriptorProto_FieldNumber_SourceCodeInfo = 9,
- GPBFileDescriptorProto_FieldNumber_PublicDependencyArray = 10,
- GPBFileDescriptorProto_FieldNumber_WeakDependencyArray = 11,
- GPBFileDescriptorProto_FieldNumber_Syntax = 12,
-};
-
-// Describes a complete .proto file.
-@interface GPBFileDescriptorProto : GPBMessage
-
-// file name, relative to root of source tree
-@property(nonatomic, readwrite) BOOL hasName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-
-// e.g. "foo", "foo.bar", etc.
-@property(nonatomic, readwrite) BOOL hasPackage;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *package;
-
-// Names of files imported by this file.
-// |dependencyArray| contains |NSString|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *dependencyArray;
-@property(nonatomic, readonly) NSUInteger dependencyArray_Count;
-
-// Indexes of the public imported files in the dependency list above.
-@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *publicDependencyArray;
-@property(nonatomic, readonly) NSUInteger publicDependencyArray_Count;
-
-// Indexes of the weak imported files in the dependency list.
-// For Google-internal migration only. Do not use.
-@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *weakDependencyArray;
-@property(nonatomic, readonly) NSUInteger weakDependencyArray_Count;
-
-// All top-level definitions in this file.
-// |messageTypeArray| contains |GPBDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *messageTypeArray;
-@property(nonatomic, readonly) NSUInteger messageTypeArray_Count;
-
-// |enumTypeArray| contains |GPBEnumDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumTypeArray;
-@property(nonatomic, readonly) NSUInteger enumTypeArray_Count;
-
-// |serviceArray| contains |GPBServiceDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *serviceArray;
-@property(nonatomic, readonly) NSUInteger serviceArray_Count;
-
-// |extensionArray| contains |GPBFieldDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *extensionArray;
-@property(nonatomic, readonly) NSUInteger extensionArray_Count;
-
-@property(nonatomic, readwrite) BOOL hasOptions;
-@property(nonatomic, readwrite, strong, null_resettable) GPBFileOptions *options;
-
-// This field contains optional information about the original source code.
-// You may safely remove this entire field without harming runtime
-// functionality of the descriptors -- the information is needed only by
-// development tools.
-@property(nonatomic, readwrite) BOOL hasSourceCodeInfo;
-@property(nonatomic, readwrite, strong, null_resettable) GPBSourceCodeInfo *sourceCodeInfo;
-
-// The syntax of the proto file.
-// The supported values are "proto2" and "proto3".
-@property(nonatomic, readwrite) BOOL hasSyntax;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *syntax;
-
-@end
-
-#pragma mark - GPBDescriptorProto
-
-typedef GPB_ENUM(GPBDescriptorProto_FieldNumber) {
- GPBDescriptorProto_FieldNumber_Name = 1,
- GPBDescriptorProto_FieldNumber_FieldArray = 2,
- GPBDescriptorProto_FieldNumber_NestedTypeArray = 3,
- GPBDescriptorProto_FieldNumber_EnumTypeArray = 4,
- GPBDescriptorProto_FieldNumber_ExtensionRangeArray = 5,
- GPBDescriptorProto_FieldNumber_ExtensionArray = 6,
- GPBDescriptorProto_FieldNumber_Options = 7,
- GPBDescriptorProto_FieldNumber_OneofDeclArray = 8,
- GPBDescriptorProto_FieldNumber_ReservedRangeArray = 9,
- GPBDescriptorProto_FieldNumber_ReservedNameArray = 10,
-};
-
-// Describes a message type.
-@interface GPBDescriptorProto : GPBMessage
-
-@property(nonatomic, readwrite) BOOL hasName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-
-// |fieldArray| contains |GPBFieldDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fieldArray;
-@property(nonatomic, readonly) NSUInteger fieldArray_Count;
-
-// |extensionArray| contains |GPBFieldDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *extensionArray;
-@property(nonatomic, readonly) NSUInteger extensionArray_Count;
-
-// |nestedTypeArray| contains |GPBDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *nestedTypeArray;
-@property(nonatomic, readonly) NSUInteger nestedTypeArray_Count;
-
-// |enumTypeArray| contains |GPBEnumDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumTypeArray;
-@property(nonatomic, readonly) NSUInteger enumTypeArray_Count;
-
-// |extensionRangeArray| contains |GPBDescriptorProto_ExtensionRange|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *extensionRangeArray;
-@property(nonatomic, readonly) NSUInteger extensionRangeArray_Count;
-
-// |oneofDeclArray| contains |GPBOneofDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *oneofDeclArray;
-@property(nonatomic, readonly) NSUInteger oneofDeclArray_Count;
-
-@property(nonatomic, readwrite) BOOL hasOptions;
-@property(nonatomic, readwrite, strong, null_resettable) GPBMessageOptions *options;
-
-// |reservedRangeArray| contains |GPBDescriptorProto_ReservedRange|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *reservedRangeArray;
-@property(nonatomic, readonly) NSUInteger reservedRangeArray_Count;
-
-// Reserved field names, which may not be used by fields in the same message.
-// A given name may only be reserved once.
-// |reservedNameArray| contains |NSString|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *reservedNameArray;
-@property(nonatomic, readonly) NSUInteger reservedNameArray_Count;
-
-@end
-
-#pragma mark - GPBDescriptorProto_ExtensionRange
-
-typedef GPB_ENUM(GPBDescriptorProto_ExtensionRange_FieldNumber) {
- GPBDescriptorProto_ExtensionRange_FieldNumber_Start = 1,
- GPBDescriptorProto_ExtensionRange_FieldNumber_End = 2,
-};
-
-@interface GPBDescriptorProto_ExtensionRange : GPBMessage
-
-@property(nonatomic, readwrite) BOOL hasStart;
-@property(nonatomic, readwrite) int32_t start;
-
-@property(nonatomic, readwrite) BOOL hasEnd;
-@property(nonatomic, readwrite) int32_t end;
-
-@end
-
-#pragma mark - GPBDescriptorProto_ReservedRange
-
-typedef GPB_ENUM(GPBDescriptorProto_ReservedRange_FieldNumber) {
- GPBDescriptorProto_ReservedRange_FieldNumber_Start = 1,
- GPBDescriptorProto_ReservedRange_FieldNumber_End = 2,
-};
-
-// Range of reserved tag numbers. Reserved tag numbers may not be used by
-// fields or extension ranges in the same message. Reserved ranges may
-// not overlap.
-@interface GPBDescriptorProto_ReservedRange : GPBMessage
-
-// Inclusive.
-@property(nonatomic, readwrite) BOOL hasStart;
-@property(nonatomic, readwrite) int32_t start;
-
-// Exclusive.
-@property(nonatomic, readwrite) BOOL hasEnd;
-@property(nonatomic, readwrite) int32_t end;
-
-@end
-
-#pragma mark - GPBFieldDescriptorProto
-
-typedef GPB_ENUM(GPBFieldDescriptorProto_FieldNumber) {
- GPBFieldDescriptorProto_FieldNumber_Name = 1,
- GPBFieldDescriptorProto_FieldNumber_Extendee = 2,
- GPBFieldDescriptorProto_FieldNumber_Number = 3,
- GPBFieldDescriptorProto_FieldNumber_Label = 4,
- GPBFieldDescriptorProto_FieldNumber_Type = 5,
- GPBFieldDescriptorProto_FieldNumber_TypeName = 6,
- GPBFieldDescriptorProto_FieldNumber_DefaultValue = 7,
- GPBFieldDescriptorProto_FieldNumber_Options = 8,
- GPBFieldDescriptorProto_FieldNumber_OneofIndex = 9,
- GPBFieldDescriptorProto_FieldNumber_JsonName = 10,
-};
-
-// Describes a field within a message.
-@interface GPBFieldDescriptorProto : GPBMessage
-
-@property(nonatomic, readwrite) BOOL hasName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-
-@property(nonatomic, readwrite) BOOL hasNumber;
-@property(nonatomic, readwrite) int32_t number;
-
-@property(nonatomic, readwrite) BOOL hasLabel;
-@property(nonatomic, readwrite) GPBFieldDescriptorProto_Label label;
-
-// If type_name is set, this need not be set. If both this and type_name
-// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
-@property(nonatomic, readwrite) BOOL hasType;
-@property(nonatomic, readwrite) GPBFieldDescriptorProto_Type type;
-
-// For message and enum types, this is the name of the type. If the name
-// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
-// rules are used to find the type (i.e. first the nested types within this
-// message are searched, then within the parent, on up to the root
-// namespace).
-@property(nonatomic, readwrite) BOOL hasTypeName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *typeName;
-
-// For extensions, this is the name of the type being extended. It is
-// resolved in the same manner as type_name.
-@property(nonatomic, readwrite) BOOL hasExtendee;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *extendee;
-
-// For numeric types, contains the original text representation of the value.
-// For booleans, "true" or "false".
-// For strings, contains the default text contents (not escaped in any way).
-// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
-// TODO(kenton): Base-64 encode?
-@property(nonatomic, readwrite) BOOL hasDefaultValue;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue;
-
-// If set, gives the index of a oneof in the containing type's oneof_decl
-// list. This field is a member of that oneof.
-@property(nonatomic, readwrite) BOOL hasOneofIndex;
-@property(nonatomic, readwrite) int32_t oneofIndex;
-
-// JSON name of this field. The value is set by protocol compiler. If the
-// user has set a "json_name" option on this field, that option's value
-// will be used. Otherwise, it's deduced from the field's name by converting
-// it to camelCase.
-@property(nonatomic, readwrite) BOOL hasJsonName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName;
-
-@property(nonatomic, readwrite) BOOL hasOptions;
-@property(nonatomic, readwrite, strong, null_resettable) GPBFieldOptions *options;
-
-@end
-
-#pragma mark - GPBOneofDescriptorProto
-
-typedef GPB_ENUM(GPBOneofDescriptorProto_FieldNumber) {
- GPBOneofDescriptorProto_FieldNumber_Name = 1,
-};
-
-// Describes a oneof.
-@interface GPBOneofDescriptorProto : GPBMessage
-
-@property(nonatomic, readwrite) BOOL hasName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-
-@end
-
-#pragma mark - GPBEnumDescriptorProto
-
-typedef GPB_ENUM(GPBEnumDescriptorProto_FieldNumber) {
- GPBEnumDescriptorProto_FieldNumber_Name = 1,
- GPBEnumDescriptorProto_FieldNumber_ValueArray = 2,
- GPBEnumDescriptorProto_FieldNumber_Options = 3,
-};
-
-// Describes an enum type.
-@interface GPBEnumDescriptorProto : GPBMessage
-
-@property(nonatomic, readwrite) BOOL hasName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-
-// |valueArray| contains |GPBEnumValueDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *valueArray;
-@property(nonatomic, readonly) NSUInteger valueArray_Count;
-
-@property(nonatomic, readwrite) BOOL hasOptions;
-@property(nonatomic, readwrite, strong, null_resettable) GPBEnumOptions *options;
-
-@end
-
-#pragma mark - GPBEnumValueDescriptorProto
-
-typedef GPB_ENUM(GPBEnumValueDescriptorProto_FieldNumber) {
- GPBEnumValueDescriptorProto_FieldNumber_Name = 1,
- GPBEnumValueDescriptorProto_FieldNumber_Number = 2,
- GPBEnumValueDescriptorProto_FieldNumber_Options = 3,
-};
-
-// Describes a value within an enum.
-@interface GPBEnumValueDescriptorProto : GPBMessage
-
-@property(nonatomic, readwrite) BOOL hasName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-
-@property(nonatomic, readwrite) BOOL hasNumber;
-@property(nonatomic, readwrite) int32_t number;
-
-@property(nonatomic, readwrite) BOOL hasOptions;
-@property(nonatomic, readwrite, strong, null_resettable) GPBEnumValueOptions *options;
-
-@end
-
-#pragma mark - GPBServiceDescriptorProto
-
-typedef GPB_ENUM(GPBServiceDescriptorProto_FieldNumber) {
- GPBServiceDescriptorProto_FieldNumber_Name = 1,
- GPBServiceDescriptorProto_FieldNumber_MethodArray = 2,
- GPBServiceDescriptorProto_FieldNumber_Options = 3,
-};
-
-// Describes a service.
-@interface GPBServiceDescriptorProto : GPBMessage
-
-@property(nonatomic, readwrite) BOOL hasName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-
-// |methodArray| contains |GPBMethodDescriptorProto|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *methodArray;
-@property(nonatomic, readonly) NSUInteger methodArray_Count;
-
-@property(nonatomic, readwrite) BOOL hasOptions;
-@property(nonatomic, readwrite, strong, null_resettable) GPBServiceOptions *options;
-
-@end
-
-#pragma mark - GPBMethodDescriptorProto
-
-typedef GPB_ENUM(GPBMethodDescriptorProto_FieldNumber) {
- GPBMethodDescriptorProto_FieldNumber_Name = 1,
- GPBMethodDescriptorProto_FieldNumber_InputType = 2,
- GPBMethodDescriptorProto_FieldNumber_OutputType = 3,
- GPBMethodDescriptorProto_FieldNumber_Options = 4,
- GPBMethodDescriptorProto_FieldNumber_ClientStreaming = 5,
- GPBMethodDescriptorProto_FieldNumber_ServerStreaming = 6,
-};
-
-// Describes a method of a service.
-@interface GPBMethodDescriptorProto : GPBMessage
-
-@property(nonatomic, readwrite) BOOL hasName;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-
-// Input and output type names. These are resolved in the same way as
-// FieldDescriptorProto.type_name, but must refer to a message type.
-@property(nonatomic, readwrite) BOOL hasInputType;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *inputType;
-
-@property(nonatomic, readwrite) BOOL hasOutputType;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *outputType;
-
-@property(nonatomic, readwrite) BOOL hasOptions;
-@property(nonatomic, readwrite, strong, null_resettable) GPBMethodOptions *options;
-
-// Identifies if client streams multiple client messages
-@property(nonatomic, readwrite) BOOL hasClientStreaming;
-@property(nonatomic, readwrite) BOOL clientStreaming;
-
-// Identifies if server streams multiple server messages
-@property(nonatomic, readwrite) BOOL hasServerStreaming;
-@property(nonatomic, readwrite) BOOL serverStreaming;
-
-@end
-
-#pragma mark - GPBFileOptions
-
-typedef GPB_ENUM(GPBFileOptions_FieldNumber) {
- GPBFileOptions_FieldNumber_JavaPackage = 1,
- GPBFileOptions_FieldNumber_JavaOuterClassname = 8,
- GPBFileOptions_FieldNumber_OptimizeFor = 9,
- GPBFileOptions_FieldNumber_JavaMultipleFiles = 10,
- GPBFileOptions_FieldNumber_GoPackage = 11,
- GPBFileOptions_FieldNumber_CcGenericServices = 16,
- GPBFileOptions_FieldNumber_JavaGenericServices = 17,
- GPBFileOptions_FieldNumber_PyGenericServices = 18,
- GPBFileOptions_FieldNumber_JavaGenerateEqualsAndHash = 20,
- GPBFileOptions_FieldNumber_Deprecated = 23,
- GPBFileOptions_FieldNumber_JavaStringCheckUtf8 = 27,
- GPBFileOptions_FieldNumber_CcEnableArenas = 31,
- GPBFileOptions_FieldNumber_ObjcClassPrefix = 36,
- GPBFileOptions_FieldNumber_CsharpNamespace = 37,
- GPBFileOptions_FieldNumber_JavananoUseDeprecatedPackage = 38,
- GPBFileOptions_FieldNumber_UninterpretedOptionArray = 999,
-};
-
-@interface GPBFileOptions : GPBMessage
-
-// Sets the Java package where classes generated from this .proto will be
-// placed. By default, the proto package is used, but this is often
-// inappropriate because proto packages do not normally start with backwards
-// domain names.
-@property(nonatomic, readwrite) BOOL hasJavaPackage;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *javaPackage;
-
-// If set, all the classes from the .proto file are wrapped in a single
-// outer class with the given name. This applies to both Proto1
-// (equivalent to the old "--one_java_file" option) and Proto2 (where
-// a .proto always translates to a single class, but you may want to
-// explicitly choose the class name).
-@property(nonatomic, readwrite) BOOL hasJavaOuterClassname;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *javaOuterClassname;
-
-// If set true, then the Java code generator will generate a separate .java
-// file for each top-level message, enum, and service defined in the .proto
-// file. Thus, these types will *not* be nested inside the outer class
-// named by java_outer_classname. However, the outer class will still be
-// generated to contain the file's getDescriptor() method as well as any
-// top-level extensions defined in the file.
-@property(nonatomic, readwrite) BOOL hasJavaMultipleFiles;
-@property(nonatomic, readwrite) BOOL javaMultipleFiles;
-
-// If set true, then the Java code generator will generate equals() and
-// hashCode() methods for all messages defined in the .proto file.
-// This increases generated code size, potentially substantially for large
-// protos, which may harm a memory-constrained application.
-// - In the full runtime this is a speed optimization, as the
-// AbstractMessage base class includes reflection-based implementations of
-// these methods.
-// - In the lite runtime, setting this option changes the semantics of
-// equals() and hashCode() to more closely match those of the full runtime;
-// the generated methods compute their results based on field values rather
-// than object identity. (Implementations should not assume that hashcodes
-// will be consistent across runtimes or versions of the protocol compiler.)
-@property(nonatomic, readwrite) BOOL hasJavaGenerateEqualsAndHash;
-@property(nonatomic, readwrite) BOOL javaGenerateEqualsAndHash;
-
-// If set true, then the Java2 code generator will generate code that
-// throws an exception whenever an attempt is made to assign a non-UTF-8
-// byte sequence to a string field.
-// Message reflection will do the same.
-// However, an extension field still accepts non-UTF-8 byte sequences.
-// This option has no effect on when used with the lite runtime.
-@property(nonatomic, readwrite) BOOL hasJavaStringCheckUtf8;
-@property(nonatomic, readwrite) BOOL javaStringCheckUtf8;
-
-@property(nonatomic, readwrite) BOOL hasOptimizeFor;
-@property(nonatomic, readwrite) GPBFileOptions_OptimizeMode optimizeFor;
-
-// Sets the Go package where structs generated from this .proto will be
-// placed. If omitted, the Go package will be derived from the following:
-// - The basename of the package import path, if provided.
-// - Otherwise, the package statement in the .proto file, if present.
-// - Otherwise, the basename of the .proto file, without extension.
-@property(nonatomic, readwrite) BOOL hasGoPackage;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *goPackage;
-
-// Should generic services be generated in each language? "Generic" services
-// are not specific to any particular RPC system. They are generated by the
-// main code generators in each language (without additional plugins).
-// Generic services were the only kind of service generation supported by
-// early versions of google.protobuf.
-//
-// Generic services are now considered deprecated in favor of using plugins
-// that generate code specific to your particular RPC system. Therefore,
-// these default to false. Old code which depends on generic services should
-// explicitly set them to true.
-@property(nonatomic, readwrite) BOOL hasCcGenericServices;
-@property(nonatomic, readwrite) BOOL ccGenericServices;
-
-@property(nonatomic, readwrite) BOOL hasJavaGenericServices;
-@property(nonatomic, readwrite) BOOL javaGenericServices;
-
-@property(nonatomic, readwrite) BOOL hasPyGenericServices;
-@property(nonatomic, readwrite) BOOL pyGenericServices;
-
-// Is this file deprecated?
-// Depending on the target platform, this can emit Deprecated annotations
-// for everything in the file, or it will be completely ignored; in the very
-// least, this is a formalization for deprecating files.
-@property(nonatomic, readwrite) BOOL hasDeprecated;
-@property(nonatomic, readwrite) BOOL deprecated;
-
-// Enables the use of arenas for the proto messages in this file. This applies
-// only to generated classes for C++.
-@property(nonatomic, readwrite) BOOL hasCcEnableArenas;
-@property(nonatomic, readwrite) BOOL ccEnableArenas;
-
-// Sets the objective c class prefix which is prepended to all objective c
-// generated classes from this .proto. There is no default.
-@property(nonatomic, readwrite) BOOL hasObjcClassPrefix;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *objcClassPrefix;
-
-// Namespace for generated classes; defaults to the package.
-@property(nonatomic, readwrite) BOOL hasCsharpNamespace;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *csharpNamespace;
-
-// Whether the nano proto compiler should generate in the deprecated non-nano
-// suffixed package.
-@property(nonatomic, readwrite) BOOL hasJavananoUseDeprecatedPackage;
-@property(nonatomic, readwrite) BOOL javananoUseDeprecatedPackage;
-
-// The parser stores options it doesn't recognize here. See above.
-// |uninterpretedOptionArray| contains |GPBUninterpretedOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray;
-@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count;
-
-@end
-
-#pragma mark - GPBMessageOptions
-
-typedef GPB_ENUM(GPBMessageOptions_FieldNumber) {
- GPBMessageOptions_FieldNumber_MessageSetWireFormat = 1,
- GPBMessageOptions_FieldNumber_NoStandardDescriptorAccessor = 2,
- GPBMessageOptions_FieldNumber_Deprecated = 3,
- GPBMessageOptions_FieldNumber_MapEntry = 7,
- GPBMessageOptions_FieldNumber_UninterpretedOptionArray = 999,
-};
-
-@interface GPBMessageOptions : GPBMessage
-
-// Set true to use the old proto1 MessageSet wire format for extensions.
-// This is provided for backwards-compatibility with the MessageSet wire
-// format. You should not use this for any other reason: It's less
-// efficient, has fewer features, and is more complicated.
-//
-// The message must be defined exactly as follows:
-// message Foo {
-// option message_set_wire_format = true;
-// extensions 4 to max;
-// }
-// Note that the message cannot have any defined fields; MessageSets only
-// have extensions.
-//
-// All extensions of your type must be singular messages; e.g. they cannot
-// be int32s, enums, or repeated messages.
-//
-// Because this is an option, the above two restrictions are not enforced by
-// the protocol compiler.
-@property(nonatomic, readwrite) BOOL hasMessageSetWireFormat;
-@property(nonatomic, readwrite) BOOL messageSetWireFormat;
-
-// Disables the generation of the standard "descriptor()" accessor, which can
-// conflict with a field of the same name. This is meant to make migration
-// from proto1 easier; new code should avoid fields named "descriptor".
-@property(nonatomic, readwrite) BOOL hasNoStandardDescriptorAccessor;
-@property(nonatomic, readwrite) BOOL noStandardDescriptorAccessor;
-
-// Is this message deprecated?
-// Depending on the target platform, this can emit Deprecated annotations
-// for the message, or it will be completely ignored; in the very least,
-// this is a formalization for deprecating messages.
-@property(nonatomic, readwrite) BOOL hasDeprecated;
-@property(nonatomic, readwrite) BOOL deprecated;
-
-// Whether the message is an automatically generated map entry type for the
-// maps field.
-//
-// For maps fields:
-// map<KeyType, ValueType> map_field = 1;
-// The parsed descriptor looks like:
-// message MapFieldEntry {
-// option map_entry = true;
-// optional KeyType key = 1;
-// optional ValueType value = 2;
-// }
-// repeated MapFieldEntry map_field = 1;
-//
-// Implementations may choose not to generate the map_entry=true message, but
-// use a native map in the target language to hold the keys and values.
-// The reflection APIs in such implementions still need to work as
-// if the field is a repeated message field.
-//
-// NOTE: Do not set the option in .proto files. Always use the maps syntax
-// instead. The option should only be implicitly set by the proto compiler
-// parser.
-@property(nonatomic, readwrite) BOOL hasMapEntry;
-@property(nonatomic, readwrite) BOOL mapEntry;
-
-// The parser stores options it doesn't recognize here. See above.
-// |uninterpretedOptionArray| contains |GPBUninterpretedOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray;
-@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count;
-
-@end
-
-#pragma mark - GPBFieldOptions
-
-typedef GPB_ENUM(GPBFieldOptions_FieldNumber) {
- GPBFieldOptions_FieldNumber_Ctype = 1,
- GPBFieldOptions_FieldNumber_Packed = 2,
- GPBFieldOptions_FieldNumber_Deprecated = 3,
- GPBFieldOptions_FieldNumber_Lazy = 5,
- GPBFieldOptions_FieldNumber_Jstype = 6,
- GPBFieldOptions_FieldNumber_Weak = 10,
- GPBFieldOptions_FieldNumber_UninterpretedOptionArray = 999,
-};
-
-@interface GPBFieldOptions : GPBMessage
-
-// The ctype option instructs the C++ code generator to use a different
-// representation of the field than it normally would. See the specific
-// options below. This option is not yet implemented in the open source
-// release -- sorry, we'll try to include it in a future version!
-@property(nonatomic, readwrite) BOOL hasCtype;
-@property(nonatomic, readwrite) GPBFieldOptions_CType ctype;
-
-// The packed option can be enabled for repeated primitive fields to enable
-// a more efficient representation on the wire. Rather than repeatedly
-// writing the tag and type for each element, the entire array is encoded as
-// a single length-delimited blob. In proto3, only explicit setting it to
-// false will avoid using packed encoding.
-@property(nonatomic, readwrite) BOOL hasPacked;
-@property(nonatomic, readwrite) BOOL packed;
-
-// The jstype option determines the JavaScript type used for values of the
-// field. The option is permitted only for 64 bit integral and fixed types
-// (int64, uint64, sint64, fixed64, sfixed64). By default these types are
-// represented as JavaScript strings. This avoids loss of precision that can
-// happen when a large value is converted to a floating point JavaScript
-// numbers. Specifying JS_NUMBER for the jstype causes the generated
-// JavaScript code to use the JavaScript "number" type instead of strings.
-// This option is an enum to permit additional types to be added,
-// e.g. goog.math.Integer.
-@property(nonatomic, readwrite) BOOL hasJstype;
-@property(nonatomic, readwrite) GPBFieldOptions_JSType jstype;
-
-// Should this field be parsed lazily? Lazy applies only to message-type
-// fields. It means that when the outer message is initially parsed, the
-// inner message's contents will not be parsed but instead stored in encoded
-// form. The inner message will actually be parsed when it is first accessed.
-//
-// This is only a hint. Implementations are free to choose whether to use
-// eager or lazy parsing regardless of the value of this option. However,
-// setting this option true suggests that the protocol author believes that
-// using lazy parsing on this field is worth the additional bookkeeping
-// overhead typically needed to implement it.
-//
-// This option does not affect the public interface of any generated code;
-// all method signatures remain the same. Furthermore, thread-safety of the
-// interface is not affected by this option; const methods remain safe to
-// call from multiple threads concurrently, while non-const methods continue
-// to require exclusive access.
-//
-//
-// Note that implementations may choose not to check required fields within
-// a lazy sub-message. That is, calling IsInitialized() on the outher message
-// may return true even if the inner message has missing required fields.
-// This is necessary because otherwise the inner message would have to be
-// parsed in order to perform the check, defeating the purpose of lazy
-// parsing. An implementation which chooses not to check required fields
-// must be consistent about it. That is, for any particular sub-message, the
-// implementation must either *always* check its required fields, or *never*
-// check its required fields, regardless of whether or not the message has
-// been parsed.
-@property(nonatomic, readwrite) BOOL hasLazy;
-@property(nonatomic, readwrite) BOOL lazy;
-
-// Is this field deprecated?
-// Depending on the target platform, this can emit Deprecated annotations
-// for accessors, or it will be completely ignored; in the very least, this
-// is a formalization for deprecating fields.
-@property(nonatomic, readwrite) BOOL hasDeprecated;
-@property(nonatomic, readwrite) BOOL deprecated;
-
-// For Google-internal migration only. Do not use.
-@property(nonatomic, readwrite) BOOL hasWeak;
-@property(nonatomic, readwrite) BOOL weak;
-
-// The parser stores options it doesn't recognize here. See above.
-// |uninterpretedOptionArray| contains |GPBUninterpretedOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray;
-@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count;
-
-@end
-
-#pragma mark - GPBEnumOptions
-
-typedef GPB_ENUM(GPBEnumOptions_FieldNumber) {
- GPBEnumOptions_FieldNumber_AllowAlias = 2,
- GPBEnumOptions_FieldNumber_Deprecated = 3,
- GPBEnumOptions_FieldNumber_UninterpretedOptionArray = 999,
-};
-
-@interface GPBEnumOptions : GPBMessage
-
-// Set this option to true to allow mapping different tag names to the same
-// value.
-@property(nonatomic, readwrite) BOOL hasAllowAlias;
-@property(nonatomic, readwrite) BOOL allowAlias;
-
-// Is this enum deprecated?
-// Depending on the target platform, this can emit Deprecated annotations
-// for the enum, or it will be completely ignored; in the very least, this
-// is a formalization for deprecating enums.
-@property(nonatomic, readwrite) BOOL hasDeprecated;
-@property(nonatomic, readwrite) BOOL deprecated;
-
-// The parser stores options it doesn't recognize here. See above.
-// |uninterpretedOptionArray| contains |GPBUninterpretedOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray;
-@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count;
-
-@end
-
-#pragma mark - GPBEnumValueOptions
-
-typedef GPB_ENUM(GPBEnumValueOptions_FieldNumber) {
- GPBEnumValueOptions_FieldNumber_Deprecated = 1,
- GPBEnumValueOptions_FieldNumber_UninterpretedOptionArray = 999,
-};
-
-@interface GPBEnumValueOptions : GPBMessage
-
-// Is this enum value deprecated?
-// Depending on the target platform, this can emit Deprecated annotations
-// for the enum value, or it will be completely ignored; in the very least,
-// this is a formalization for deprecating enum values.
-@property(nonatomic, readwrite) BOOL hasDeprecated;
-@property(nonatomic, readwrite) BOOL deprecated;
-
-// The parser stores options it doesn't recognize here. See above.
-// |uninterpretedOptionArray| contains |GPBUninterpretedOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray;
-@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count;
-
-@end
-
-#pragma mark - GPBServiceOptions
-
-typedef GPB_ENUM(GPBServiceOptions_FieldNumber) {
- GPBServiceOptions_FieldNumber_Deprecated = 33,
- GPBServiceOptions_FieldNumber_UninterpretedOptionArray = 999,
-};
-
-@interface GPBServiceOptions : GPBMessage
-
-// Is this service deprecated?
-// Depending on the target platform, this can emit Deprecated annotations
-// for the service, or it will be completely ignored; in the very least,
-// this is a formalization for deprecating services.
-@property(nonatomic, readwrite) BOOL hasDeprecated;
-@property(nonatomic, readwrite) BOOL deprecated;
-
-// The parser stores options it doesn't recognize here. See above.
-// |uninterpretedOptionArray| contains |GPBUninterpretedOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray;
-@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count;
-
-@end
-
-#pragma mark - GPBMethodOptions
-
-typedef GPB_ENUM(GPBMethodOptions_FieldNumber) {
- GPBMethodOptions_FieldNumber_Deprecated = 33,
- GPBMethodOptions_FieldNumber_UninterpretedOptionArray = 999,
-};
-
-@interface GPBMethodOptions : GPBMessage
-
-// Is this method deprecated?
-// Depending on the target platform, this can emit Deprecated annotations
-// for the method, or it will be completely ignored; in the very least,
-// this is a formalization for deprecating methods.
-@property(nonatomic, readwrite) BOOL hasDeprecated;
-@property(nonatomic, readwrite) BOOL deprecated;
-
-// The parser stores options it doesn't recognize here. See above.
-// |uninterpretedOptionArray| contains |GPBUninterpretedOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray;
-@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count;
-
-@end
-
-#pragma mark - GPBUninterpretedOption
-
-typedef GPB_ENUM(GPBUninterpretedOption_FieldNumber) {
- GPBUninterpretedOption_FieldNumber_NameArray = 2,
- GPBUninterpretedOption_FieldNumber_IdentifierValue = 3,
- GPBUninterpretedOption_FieldNumber_PositiveIntValue = 4,
- GPBUninterpretedOption_FieldNumber_NegativeIntValue = 5,
- GPBUninterpretedOption_FieldNumber_DoubleValue = 6,
- GPBUninterpretedOption_FieldNumber_StringValue = 7,
- GPBUninterpretedOption_FieldNumber_AggregateValue = 8,
-};
-
-// A message representing a option the parser does not recognize. This only
-// appears in options protos created by the compiler::Parser class.
-// DescriptorPool resolves these when building Descriptor objects. Therefore,
-// options protos in descriptor objects (e.g. returned by Descriptor::options(),
-// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
-// in them.
-@interface GPBUninterpretedOption : GPBMessage
-
-// |nameArray| contains |GPBUninterpretedOption_NamePart|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *nameArray;
-@property(nonatomic, readonly) NSUInteger nameArray_Count;
-
-// The value of the uninterpreted option, in whatever type the tokenizer
-// identified it as during parsing. Exactly one of these should be set.
-@property(nonatomic, readwrite) BOOL hasIdentifierValue;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *identifierValue;
-
-@property(nonatomic, readwrite) BOOL hasPositiveIntValue;
-@property(nonatomic, readwrite) uint64_t positiveIntValue;
-
-@property(nonatomic, readwrite) BOOL hasNegativeIntValue;
-@property(nonatomic, readwrite) int64_t negativeIntValue;
-
-@property(nonatomic, readwrite) BOOL hasDoubleValue;
-@property(nonatomic, readwrite) double doubleValue;
-
-@property(nonatomic, readwrite) BOOL hasStringValue;
-@property(nonatomic, readwrite, copy, null_resettable) NSData *stringValue;
-
-@property(nonatomic, readwrite) BOOL hasAggregateValue;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *aggregateValue;
-
-@end
-
-#pragma mark - GPBUninterpretedOption_NamePart
-
-typedef GPB_ENUM(GPBUninterpretedOption_NamePart_FieldNumber) {
- GPBUninterpretedOption_NamePart_FieldNumber_NamePart = 1,
- GPBUninterpretedOption_NamePart_FieldNumber_IsExtension = 2,
-};
-
-// The name of the uninterpreted option. Each string represents a segment in
-// a dot-separated name. is_extension is true iff a segment represents an
-// extension (denoted with parentheses in options specs in .proto files).
-// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
-// "foo.(bar.baz).qux".
-@interface GPBUninterpretedOption_NamePart : GPBMessage
-
-@property(nonatomic, readwrite) BOOL hasNamePart;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *namePart;
-
-@property(nonatomic, readwrite) BOOL hasIsExtension;
-@property(nonatomic, readwrite) BOOL isExtension;
-
-@end
-
-#pragma mark - GPBSourceCodeInfo
-
-typedef GPB_ENUM(GPBSourceCodeInfo_FieldNumber) {
- GPBSourceCodeInfo_FieldNumber_LocationArray = 1,
-};
-
-// Encapsulates information about the original source file from which a
-// FileDescriptorProto was generated.
-@interface GPBSourceCodeInfo : GPBMessage
-
-// A Location identifies a piece of source code in a .proto file which
-// corresponds to a particular definition. This information is intended
-// to be useful to IDEs, code indexers, documentation generators, and similar
-// tools.
-//
-// For example, say we have a file like:
-// message Foo {
-// optional string foo = 1;
-// }
-// Let's look at just the field definition:
-// optional string foo = 1;
-// ^ ^^ ^^ ^ ^^^
-// a bc de f ghi
-// We have the following locations:
-// span path represents
-// [a,i) [ 4, 0, 2, 0 ] The whole field definition.
-// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
-// [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
-// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
-// [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
-//
-// Notes:
-// - A location may refer to a repeated field itself (i.e. not to any
-// particular index within it). This is used whenever a set of elements are
-// logically enclosed in a single code segment. For example, an entire
-// extend block (possibly containing multiple extension definitions) will
-// have an outer location whose path refers to the "extensions" repeated
-// field without an index.
-// - Multiple locations may have the same path. This happens when a single
-// logical declaration is spread out across multiple places. The most
-// obvious example is the "extend" block again -- there may be multiple
-// extend blocks in the same scope, each of which will have the same path.
-// - A location's span is not always a subset of its parent's span. For
-// example, the "extendee" of an extension declaration appears at the
-// beginning of the "extend" block and is shared by all extensions within
-// the block.
-// - Just because a location's span is a subset of some other location's span
-// does not mean that it is a descendent. For example, a "group" defines
-// both a type and a field in a single declaration. Thus, the locations
-// corresponding to the type and field and their components will overlap.
-// - Code which tries to interpret locations should probably be designed to
-// ignore those that it doesn't understand, as more types of locations could
-// be recorded in the future.
-// |locationArray| contains |GPBSourceCodeInfo_Location|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *locationArray;
-@property(nonatomic, readonly) NSUInteger locationArray_Count;
-
-@end
-
-#pragma mark - GPBSourceCodeInfo_Location
-
-typedef GPB_ENUM(GPBSourceCodeInfo_Location_FieldNumber) {
- GPBSourceCodeInfo_Location_FieldNumber_PathArray = 1,
- GPBSourceCodeInfo_Location_FieldNumber_SpanArray = 2,
- GPBSourceCodeInfo_Location_FieldNumber_LeadingComments = 3,
- GPBSourceCodeInfo_Location_FieldNumber_TrailingComments = 4,
- GPBSourceCodeInfo_Location_FieldNumber_LeadingDetachedCommentsArray = 6,
-};
-
-@interface GPBSourceCodeInfo_Location : GPBMessage
-
-// Identifies which part of the FileDescriptorProto was defined at this
-// location.
-//
-// Each element is a field number or an index. They form a path from
-// the root FileDescriptorProto to the place where the definition. For
-// example, this path:
-// [ 4, 3, 2, 7, 1 ]
-// refers to:
-// file.message_type(3) // 4, 3
-// .field(7) // 2, 7
-// .name() // 1
-// This is because FileDescriptorProto.message_type has field number 4:
-// repeated DescriptorProto message_type = 4;
-// and DescriptorProto.field has field number 2:
-// repeated FieldDescriptorProto field = 2;
-// and FieldDescriptorProto.name has field number 1:
-// optional string name = 1;
-//
-// Thus, the above path gives the location of a field name. If we removed
-// the last element:
-// [ 4, 3, 2, 7 ]
-// this path refers to the whole field declaration (from the beginning
-// of the label to the terminating semicolon).
-@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *pathArray;
-@property(nonatomic, readonly) NSUInteger pathArray_Count;
-
-// Always has exactly three or four elements: start line, start column,
-// end line (optional, otherwise assumed same as start line), end column.
-// These are packed into a single field for efficiency. Note that line
-// and column numbers are zero-based -- typically you will want to add
-// 1 to each before displaying to a user.
-@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *spanArray;
-@property(nonatomic, readonly) NSUInteger spanArray_Count;
-
-// If this SourceCodeInfo represents a complete declaration, these are any
-// comments appearing before and after the declaration which appear to be
-// attached to the declaration.
-//
-// A series of line comments appearing on consecutive lines, with no other
-// tokens appearing on those lines, will be treated as a single comment.
-//
-// leading_detached_comments will keep paragraphs of comments that appear
-// before (but not connected to) the current element. Each paragraph,
-// separated by empty lines, will be one comment element in the repeated
-// field.
-//
-// Only the comment content is provided; comment markers (e.g. //) are
-// stripped out. For block comments, leading whitespace and an asterisk
-// will be stripped from the beginning of each line other than the first.
-// Newlines are included in the output.
-//
-// Examples:
-//
-// optional int32 foo = 1; // Comment attached to foo.
-// // Comment attached to bar.
-// optional int32 bar = 2;
-//
-// optional string baz = 3;
-// // Comment attached to baz.
-// // Another line attached to baz.
-//
-// // Comment attached to qux.
-// //
-// // Another line attached to qux.
-// optional double qux = 4;
-//
-// // Detached comment for corge. This is not leading or trailing comments
-// // to qux or corge because there are blank lines separating it from
-// // both.
-//
-// // Detached comment for corge paragraph 2.
-//
-// optional string corge = 5;
-// /* Block comment attached
-// * to corge. Leading asterisks
-// * will be removed. */
-// /* Block comment attached to
-// * grault. */
-// optional int32 grault = 6;
-//
-// // ignored detached comments.
-@property(nonatomic, readwrite) BOOL hasLeadingComments;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *leadingComments;
-
-@property(nonatomic, readwrite) BOOL hasTrailingComments;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *trailingComments;
-
-// |leadingDetachedCommentsArray| contains |NSString|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *leadingDetachedCommentsArray;
-@property(nonatomic, readonly) NSUInteger leadingDetachedCommentsArray_Count;
-
-@end
-
-#pragma mark - GPBGeneratedCodeInfo
-
-typedef GPB_ENUM(GPBGeneratedCodeInfo_FieldNumber) {
- GPBGeneratedCodeInfo_FieldNumber_AnnotationArray = 1,
-};
-
-// Describes the relationship between generated code and its original source
-// file. A GeneratedCodeInfo message is associated with only one generated
-// source file, but may contain references to different source .proto files.
-@interface GPBGeneratedCodeInfo : GPBMessage
-
-// An Annotation connects some span of text in generated code to an element
-// of its generating .proto file.
-// |annotationArray| contains |GPBGeneratedCodeInfo_Annotation|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *annotationArray;
-@property(nonatomic, readonly) NSUInteger annotationArray_Count;
-
-@end
-
-#pragma mark - GPBGeneratedCodeInfo_Annotation
-
-typedef GPB_ENUM(GPBGeneratedCodeInfo_Annotation_FieldNumber) {
- GPBGeneratedCodeInfo_Annotation_FieldNumber_PathArray = 1,
- GPBGeneratedCodeInfo_Annotation_FieldNumber_SourceFile = 2,
- GPBGeneratedCodeInfo_Annotation_FieldNumber_Begin = 3,
- GPBGeneratedCodeInfo_Annotation_FieldNumber_End = 4,
-};
-
-@interface GPBGeneratedCodeInfo_Annotation : GPBMessage
-
-// Identifies the element in the original source .proto file. This field
-// is formatted the same as SourceCodeInfo.Location.path.
-@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *pathArray;
-@property(nonatomic, readonly) NSUInteger pathArray_Count;
-
-// Identifies the filesystem path to the original source .proto.
-@property(nonatomic, readwrite) BOOL hasSourceFile;
-@property(nonatomic, readwrite, copy, null_resettable) NSString *sourceFile;
-
-// Identifies the starting offset in bytes in the generated code
-// that relates to the identified object.
-@property(nonatomic, readwrite) BOOL hasBegin;
-@property(nonatomic, readwrite) int32_t begin;
-
-// Identifies the ending offset in bytes in the generated code that
-// relates to the identified offset. The end offset should be one past
-// the last relevant byte (so the length of the text = end - begin).
-@property(nonatomic, readwrite) BOOL hasEnd;
-@property(nonatomic, readwrite) int32_t end;
-
-@end
-
-NS_ASSUME_NONNULL_END
-
-CF_EXTERN_C_END
-
-// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Descriptor.pbobjc.m b/objectivec/google/protobuf/Descriptor.pbobjc.m
deleted file mode 100644
index 40309893..00000000
--- a/objectivec/google/protobuf/Descriptor.pbobjc.m
+++ /dev/null
@@ -1,2594 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: google/protobuf/descriptor.proto
-
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/Descriptor.pbobjc.h"
-// @@protoc_insertion_point(imports)
-
-#pragma mark - GPBDescriptorRoot
-
-@implementation GPBDescriptorRoot
-
-@end
-
-#pragma mark - GPBDescriptorRoot_FileDescriptor
-
-static GPBFileDescriptor *GPBDescriptorRoot_FileDescriptor(void) {
- // This is called by +initialize so there is no need to worry
- // about thread safety of the singleton.
- static GPBFileDescriptor *descriptor = NULL;
- if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
- descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
- syntax:GPBFileSyntaxProto2];
- }
- return descriptor;
-}
-
-#pragma mark - GPBFileDescriptorSet
-
-@implementation GPBFileDescriptorSet
-
-@dynamic fileArray, fileArray_Count;
-
-typedef struct GPBFileDescriptorSet__storage_ {
- uint32_t _has_storage_[1];
- NSMutableArray *fileArray;
-} GPBFileDescriptorSet__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "fileArray",
- .number = GPBFileDescriptorSet_FieldNumber_FileArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFileDescriptorSet__storage_, fileArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBFileDescriptorProto),
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBFileDescriptorSet class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBFileDescriptorSet__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBFileDescriptorProto
-
-@implementation GPBFileDescriptorProto
-
-@dynamic hasName, name;
-@dynamic hasPackage, package;
-@dynamic dependencyArray, dependencyArray_Count;
-@dynamic publicDependencyArray, publicDependencyArray_Count;
-@dynamic weakDependencyArray, weakDependencyArray_Count;
-@dynamic messageTypeArray, messageTypeArray_Count;
-@dynamic enumTypeArray, enumTypeArray_Count;
-@dynamic serviceArray, serviceArray_Count;
-@dynamic extensionArray, extensionArray_Count;
-@dynamic hasOptions, options;
-@dynamic hasSourceCodeInfo, sourceCodeInfo;
-@dynamic hasSyntax, syntax;
-
-typedef struct GPBFileDescriptorProto__storage_ {
- uint32_t _has_storage_[1];
- NSString *name;
- NSString *package;
- NSMutableArray *dependencyArray;
- NSMutableArray *messageTypeArray;
- NSMutableArray *enumTypeArray;
- NSMutableArray *serviceArray;
- NSMutableArray *extensionArray;
- GPBFileOptions *options;
- GPBSourceCodeInfo *sourceCodeInfo;
- GPBInt32Array *publicDependencyArray;
- GPBInt32Array *weakDependencyArray;
- NSString *syntax;
-} GPBFileDescriptorProto__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "name",
- .number = GPBFileDescriptorProto_FieldNumber_Name,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFileDescriptorProto__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "package",
- .number = GPBFileDescriptorProto_FieldNumber_Package,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFileDescriptorProto__storage_, package),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "dependencyArray",
- .number = GPBFileDescriptorProto_FieldNumber_DependencyArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFileDescriptorProto__storage_, dependencyArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "messageTypeArray",
- .number = GPBFileDescriptorProto_FieldNumber_MessageTypeArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFileDescriptorProto__storage_, messageTypeArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "enumTypeArray",
- .number = GPBFileDescriptorProto_FieldNumber_EnumTypeArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFileDescriptorProto__storage_, enumTypeArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "serviceArray",
- .number = GPBFileDescriptorProto_FieldNumber_ServiceArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFileDescriptorProto__storage_, serviceArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBServiceDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "extensionArray",
- .number = GPBFileDescriptorProto_FieldNumber_ExtensionArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFileDescriptorProto__storage_, extensionArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBFieldDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "options",
- .number = GPBFileDescriptorProto_FieldNumber_Options,
- .hasIndex = 9,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFileDescriptorProto__storage_, options),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBFileOptions),
- .fieldOptions = NULL,
- },
- {
- .name = "sourceCodeInfo",
- .number = GPBFileDescriptorProto_FieldNumber_SourceCodeInfo,
- .hasIndex = 10,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFileDescriptorProto__storage_, sourceCodeInfo),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceCodeInfo),
- .fieldOptions = NULL,
- },
- {
- .name = "publicDependencyArray",
- .number = GPBFileDescriptorProto_FieldNumber_PublicDependencyArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBFileDescriptorProto__storage_, publicDependencyArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "weakDependencyArray",
- .number = GPBFileDescriptorProto_FieldNumber_WeakDependencyArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBFileDescriptorProto__storage_, weakDependencyArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "syntax",
- .number = GPBFileDescriptorProto_FieldNumber_Syntax,
- .hasIndex = 11,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFileDescriptorProto__storage_, syntax),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBFileDescriptorProto class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBFileDescriptorProto__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBDescriptorProto
-
-@implementation GPBDescriptorProto
-
-@dynamic hasName, name;
-@dynamic fieldArray, fieldArray_Count;
-@dynamic extensionArray, extensionArray_Count;
-@dynamic nestedTypeArray, nestedTypeArray_Count;
-@dynamic enumTypeArray, enumTypeArray_Count;
-@dynamic extensionRangeArray, extensionRangeArray_Count;
-@dynamic oneofDeclArray, oneofDeclArray_Count;
-@dynamic hasOptions, options;
-@dynamic reservedRangeArray, reservedRangeArray_Count;
-@dynamic reservedNameArray, reservedNameArray_Count;
-
-typedef struct GPBDescriptorProto__storage_ {
- uint32_t _has_storage_[1];
- NSString *name;
- NSMutableArray *fieldArray;
- NSMutableArray *nestedTypeArray;
- NSMutableArray *enumTypeArray;
- NSMutableArray *extensionRangeArray;
- NSMutableArray *extensionArray;
- GPBMessageOptions *options;
- NSMutableArray *oneofDeclArray;
- NSMutableArray *reservedRangeArray;
- NSMutableArray *reservedNameArray;
-} GPBDescriptorProto__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "name",
- .number = GPBDescriptorProto_FieldNumber_Name,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBDescriptorProto__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "fieldArray",
- .number = GPBDescriptorProto_FieldNumber_FieldArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBDescriptorProto__storage_, fieldArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBFieldDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "nestedTypeArray",
- .number = GPBDescriptorProto_FieldNumber_NestedTypeArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBDescriptorProto__storage_, nestedTypeArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "enumTypeArray",
- .number = GPBDescriptorProto_FieldNumber_EnumTypeArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBDescriptorProto__storage_, enumTypeArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "extensionRangeArray",
- .number = GPBDescriptorProto_FieldNumber_ExtensionRangeArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBDescriptorProto__storage_, extensionRangeArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBDescriptorProto_ExtensionRange),
- .fieldOptions = NULL,
- },
- {
- .name = "extensionArray",
- .number = GPBDescriptorProto_FieldNumber_ExtensionArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBDescriptorProto__storage_, extensionArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBFieldDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "options",
- .number = GPBDescriptorProto_FieldNumber_Options,
- .hasIndex = 7,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBDescriptorProto__storage_, options),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBMessageOptions),
- .fieldOptions = NULL,
- },
- {
- .name = "oneofDeclArray",
- .number = GPBDescriptorProto_FieldNumber_OneofDeclArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBDescriptorProto__storage_, oneofDeclArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBOneofDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "reservedRangeArray",
- .number = GPBDescriptorProto_FieldNumber_ReservedRangeArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBDescriptorProto__storage_, reservedRangeArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBDescriptorProto_ReservedRange),
- .fieldOptions = NULL,
- },
- {
- .name = "reservedNameArray",
- .number = GPBDescriptorProto_FieldNumber_ReservedNameArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBDescriptorProto__storage_, reservedNameArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBDescriptorProto class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBDescriptorProto__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBDescriptorProto_ExtensionRange
-
-@implementation GPBDescriptorProto_ExtensionRange
-
-@dynamic hasStart, start;
-@dynamic hasEnd, end;
-
-typedef struct GPBDescriptorProto_ExtensionRange__storage_ {
- uint32_t _has_storage_[1];
- int32_t start;
- int32_t end;
-} GPBDescriptorProto_ExtensionRange__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "start",
- .number = GPBDescriptorProto_ExtensionRange_FieldNumber_Start,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBDescriptorProto_ExtensionRange__storage_, start),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "end",
- .number = GPBDescriptorProto_ExtensionRange_FieldNumber_End,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBDescriptorProto_ExtensionRange__storage_, end),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBDescriptorProto_ExtensionRange class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBDescriptorProto_ExtensionRange__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBDescriptorProto_ReservedRange
-
-@implementation GPBDescriptorProto_ReservedRange
-
-@dynamic hasStart, start;
-@dynamic hasEnd, end;
-
-typedef struct GPBDescriptorProto_ReservedRange__storage_ {
- uint32_t _has_storage_[1];
- int32_t start;
- int32_t end;
-} GPBDescriptorProto_ReservedRange__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "start",
- .number = GPBDescriptorProto_ReservedRange_FieldNumber_Start,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBDescriptorProto_ReservedRange__storage_, start),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "end",
- .number = GPBDescriptorProto_ReservedRange_FieldNumber_End,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBDescriptorProto_ReservedRange__storage_, end),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBDescriptorProto_ReservedRange class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBDescriptorProto_ReservedRange__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBFieldDescriptorProto
-
-@implementation GPBFieldDescriptorProto
-
-@dynamic hasName, name;
-@dynamic hasNumber, number;
-@dynamic hasLabel, label;
-@dynamic hasType, type;
-@dynamic hasTypeName, typeName;
-@dynamic hasExtendee, extendee;
-@dynamic hasDefaultValue, defaultValue;
-@dynamic hasOneofIndex, oneofIndex;
-@dynamic hasJsonName, jsonName;
-@dynamic hasOptions, options;
-
-typedef struct GPBFieldDescriptorProto__storage_ {
- uint32_t _has_storage_[1];
- int32_t number;
- GPBFieldDescriptorProto_Label label;
- GPBFieldDescriptorProto_Type type;
- int32_t oneofIndex;
- NSString *name;
- NSString *extendee;
- NSString *typeName;
- NSString *defaultValue;
- GPBFieldOptions *options;
- NSString *jsonName;
-} GPBFieldDescriptorProto__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "name",
- .number = GPBFieldDescriptorProto_FieldNumber_Name,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "extendee",
- .number = GPBFieldDescriptorProto_FieldNumber_Extendee,
- .hasIndex = 5,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, extendee),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "number",
- .number = GPBFieldDescriptorProto_FieldNumber_Number,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, number),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "label",
- .number = GPBFieldDescriptorProto_FieldNumber_Label,
- .hasIndex = 2,
- .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
- .dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, label),
- .defaultValue.valueEnum = GPBFieldDescriptorProto_Label_LabelOptional,
- .dataTypeSpecific.enumDescFunc = GPBFieldDescriptorProto_Label_EnumDescriptor,
- .fieldOptions = NULL,
- },
- {
- .name = "type",
- .number = GPBFieldDescriptorProto_FieldNumber_Type,
- .hasIndex = 3,
- .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
- .dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, type),
- .defaultValue.valueEnum = GPBFieldDescriptorProto_Type_TypeDouble,
- .dataTypeSpecific.enumDescFunc = GPBFieldDescriptorProto_Type_EnumDescriptor,
- .fieldOptions = NULL,
- },
- {
- .name = "typeName",
- .number = GPBFieldDescriptorProto_FieldNumber_TypeName,
- .hasIndex = 4,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, typeName),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "defaultValue",
- .number = GPBFieldDescriptorProto_FieldNumber_DefaultValue,
- .hasIndex = 6,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, defaultValue),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "options",
- .number = GPBFieldDescriptorProto_FieldNumber_Options,
- .hasIndex = 9,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, options),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBFieldOptions),
- .fieldOptions = NULL,
- },
- {
- .name = "oneofIndex",
- .number = GPBFieldDescriptorProto_FieldNumber_OneofIndex,
- .hasIndex = 7,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, oneofIndex),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "jsonName",
- .number = GPBFieldDescriptorProto_FieldNumber_JsonName,
- .hasIndex = 8,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFieldDescriptorProto__storage_, jsonName),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- static GPBMessageEnumDescription enums[] = {
- { .enumDescriptorFunc = GPBFieldDescriptorProto_Type_EnumDescriptor },
- { .enumDescriptorFunc = GPBFieldDescriptorProto_Label_EnumDescriptor },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBFieldDescriptorProto class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:enums
- enumCount:sizeof(enums) / sizeof(GPBMessageEnumDescription)
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBFieldDescriptorProto__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - Enum GPBFieldDescriptorProto_Type
-
-GPBEnumDescriptor *GPBFieldDescriptorProto_Type_EnumDescriptor(void) {
- static GPBEnumDescriptor *descriptor = NULL;
- if (!descriptor) {
- static GPBMessageEnumValueDescription values[] = {
- { .name = "TypeDouble", .number = GPBFieldDescriptorProto_Type_TypeDouble },
- { .name = "TypeFloat", .number = GPBFieldDescriptorProto_Type_TypeFloat },
- { .name = "TypeInt64", .number = GPBFieldDescriptorProto_Type_TypeInt64 },
- { .name = "TypeUint64", .number = GPBFieldDescriptorProto_Type_TypeUint64 },
- { .name = "TypeInt32", .number = GPBFieldDescriptorProto_Type_TypeInt32 },
- { .name = "TypeFixed64", .number = GPBFieldDescriptorProto_Type_TypeFixed64 },
- { .name = "TypeFixed32", .number = GPBFieldDescriptorProto_Type_TypeFixed32 },
- { .name = "TypeBool", .number = GPBFieldDescriptorProto_Type_TypeBool },
- { .name = "TypeString", .number = GPBFieldDescriptorProto_Type_TypeString },
- { .name = "TypeGroup", .number = GPBFieldDescriptorProto_Type_TypeGroup },
- { .name = "TypeMessage", .number = GPBFieldDescriptorProto_Type_TypeMessage },
- { .name = "TypeBytes", .number = GPBFieldDescriptorProto_Type_TypeBytes },
- { .name = "TypeUint32", .number = GPBFieldDescriptorProto_Type_TypeUint32 },
- { .name = "TypeEnum", .number = GPBFieldDescriptorProto_Type_TypeEnum },
- { .name = "TypeSfixed32", .number = GPBFieldDescriptorProto_Type_TypeSfixed32 },
- { .name = "TypeSfixed64", .number = GPBFieldDescriptorProto_Type_TypeSfixed64 },
- { .name = "TypeSint32", .number = GPBFieldDescriptorProto_Type_TypeSint32 },
- { .name = "TypeSint64", .number = GPBFieldDescriptorProto_Type_TypeSint64 },
- };
- descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFieldDescriptorProto_Type)
- values:values
- valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
- enumVerifier:GPBFieldDescriptorProto_Type_IsValidValue];
- }
- return descriptor;
-}
-
-BOOL GPBFieldDescriptorProto_Type_IsValidValue(int32_t value__) {
- switch (value__) {
- case GPBFieldDescriptorProto_Type_TypeDouble:
- case GPBFieldDescriptorProto_Type_TypeFloat:
- case GPBFieldDescriptorProto_Type_TypeInt64:
- case GPBFieldDescriptorProto_Type_TypeUint64:
- case GPBFieldDescriptorProto_Type_TypeInt32:
- case GPBFieldDescriptorProto_Type_TypeFixed64:
- case GPBFieldDescriptorProto_Type_TypeFixed32:
- case GPBFieldDescriptorProto_Type_TypeBool:
- case GPBFieldDescriptorProto_Type_TypeString:
- case GPBFieldDescriptorProto_Type_TypeGroup:
- case GPBFieldDescriptorProto_Type_TypeMessage:
- case GPBFieldDescriptorProto_Type_TypeBytes:
- case GPBFieldDescriptorProto_Type_TypeUint32:
- case GPBFieldDescriptorProto_Type_TypeEnum:
- case GPBFieldDescriptorProto_Type_TypeSfixed32:
- case GPBFieldDescriptorProto_Type_TypeSfixed64:
- case GPBFieldDescriptorProto_Type_TypeSint32:
- case GPBFieldDescriptorProto_Type_TypeSint64:
- return YES;
- default:
- return NO;
- }
-}
-
-#pragma mark - Enum GPBFieldDescriptorProto_Label
-
-GPBEnumDescriptor *GPBFieldDescriptorProto_Label_EnumDescriptor(void) {
- static GPBEnumDescriptor *descriptor = NULL;
- if (!descriptor) {
- static GPBMessageEnumValueDescription values[] = {
- { .name = "LabelOptional", .number = GPBFieldDescriptorProto_Label_LabelOptional },
- { .name = "LabelRequired", .number = GPBFieldDescriptorProto_Label_LabelRequired },
- { .name = "LabelRepeated", .number = GPBFieldDescriptorProto_Label_LabelRepeated },
- };
- descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFieldDescriptorProto_Label)
- values:values
- valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
- enumVerifier:GPBFieldDescriptorProto_Label_IsValidValue];
- }
- return descriptor;
-}
-
-BOOL GPBFieldDescriptorProto_Label_IsValidValue(int32_t value__) {
- switch (value__) {
- case GPBFieldDescriptorProto_Label_LabelOptional:
- case GPBFieldDescriptorProto_Label_LabelRequired:
- case GPBFieldDescriptorProto_Label_LabelRepeated:
- return YES;
- default:
- return NO;
- }
-}
-
-#pragma mark - GPBOneofDescriptorProto
-
-@implementation GPBOneofDescriptorProto
-
-@dynamic hasName, name;
-
-typedef struct GPBOneofDescriptorProto__storage_ {
- uint32_t _has_storage_[1];
- NSString *name;
-} GPBOneofDescriptorProto__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "name",
- .number = GPBOneofDescriptorProto_FieldNumber_Name,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBOneofDescriptorProto__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBOneofDescriptorProto class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBOneofDescriptorProto__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBEnumDescriptorProto
-
-@implementation GPBEnumDescriptorProto
-
-@dynamic hasName, name;
-@dynamic valueArray, valueArray_Count;
-@dynamic hasOptions, options;
-
-typedef struct GPBEnumDescriptorProto__storage_ {
- uint32_t _has_storage_[1];
- NSString *name;
- NSMutableArray *valueArray;
- GPBEnumOptions *options;
-} GPBEnumDescriptorProto__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "name",
- .number = GPBEnumDescriptorProto_FieldNumber_Name,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBEnumDescriptorProto__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "valueArray",
- .number = GPBEnumDescriptorProto_FieldNumber_ValueArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBEnumDescriptorProto__storage_, valueArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumValueDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "options",
- .number = GPBEnumDescriptorProto_FieldNumber_Options,
- .hasIndex = 2,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBEnumDescriptorProto__storage_, options),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumOptions),
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBEnumDescriptorProto class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBEnumDescriptorProto__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBEnumValueDescriptorProto
-
-@implementation GPBEnumValueDescriptorProto
-
-@dynamic hasName, name;
-@dynamic hasNumber, number;
-@dynamic hasOptions, options;
-
-typedef struct GPBEnumValueDescriptorProto__storage_ {
- uint32_t _has_storage_[1];
- int32_t number;
- NSString *name;
- GPBEnumValueOptions *options;
-} GPBEnumValueDescriptorProto__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "name",
- .number = GPBEnumValueDescriptorProto_FieldNumber_Name,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBEnumValueDescriptorProto__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "number",
- .number = GPBEnumValueDescriptorProto_FieldNumber_Number,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBEnumValueDescriptorProto__storage_, number),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "options",
- .number = GPBEnumValueDescriptorProto_FieldNumber_Options,
- .hasIndex = 2,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBEnumValueDescriptorProto__storage_, options),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumValueOptions),
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBEnumValueDescriptorProto class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBEnumValueDescriptorProto__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBServiceDescriptorProto
-
-@implementation GPBServiceDescriptorProto
-
-@dynamic hasName, name;
-@dynamic methodArray, methodArray_Count;
-@dynamic hasOptions, options;
-
-typedef struct GPBServiceDescriptorProto__storage_ {
- uint32_t _has_storage_[1];
- NSString *name;
- NSMutableArray *methodArray;
- GPBServiceOptions *options;
-} GPBServiceDescriptorProto__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "name",
- .number = GPBServiceDescriptorProto_FieldNumber_Name,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBServiceDescriptorProto__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "methodArray",
- .number = GPBServiceDescriptorProto_FieldNumber_MethodArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBServiceDescriptorProto__storage_, methodArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBMethodDescriptorProto),
- .fieldOptions = NULL,
- },
- {
- .name = "options",
- .number = GPBServiceDescriptorProto_FieldNumber_Options,
- .hasIndex = 2,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBServiceDescriptorProto__storage_, options),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBServiceOptions),
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBServiceDescriptorProto class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBServiceDescriptorProto__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBMethodDescriptorProto
-
-@implementation GPBMethodDescriptorProto
-
-@dynamic hasName, name;
-@dynamic hasInputType, inputType;
-@dynamic hasOutputType, outputType;
-@dynamic hasOptions, options;
-@dynamic hasClientStreaming, clientStreaming;
-@dynamic hasServerStreaming, serverStreaming;
-
-typedef struct GPBMethodDescriptorProto__storage_ {
- uint32_t _has_storage_[1];
- BOOL clientStreaming;
- BOOL serverStreaming;
- NSString *name;
- NSString *inputType;
- NSString *outputType;
- GPBMethodOptions *options;
-} GPBMethodDescriptorProto__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "name",
- .number = GPBMethodDescriptorProto_FieldNumber_Name,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBMethodDescriptorProto__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "inputType",
- .number = GPBMethodDescriptorProto_FieldNumber_InputType,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBMethodDescriptorProto__storage_, inputType),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "outputType",
- .number = GPBMethodDescriptorProto_FieldNumber_OutputType,
- .hasIndex = 2,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBMethodDescriptorProto__storage_, outputType),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "options",
- .number = GPBMethodDescriptorProto_FieldNumber_Options,
- .hasIndex = 3,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBMethodDescriptorProto__storage_, options),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBMethodOptions),
- .fieldOptions = NULL,
- },
- {
- .name = "clientStreaming",
- .number = GPBMethodDescriptorProto_FieldNumber_ClientStreaming,
- .hasIndex = 4,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBMethodDescriptorProto__storage_, clientStreaming),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "serverStreaming",
- .number = GPBMethodDescriptorProto_FieldNumber_ServerStreaming,
- .hasIndex = 5,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBMethodDescriptorProto__storage_, serverStreaming),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBMethodDescriptorProto class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBMethodDescriptorProto__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBFileOptions
-
-@implementation GPBFileOptions
-
-@dynamic hasJavaPackage, javaPackage;
-@dynamic hasJavaOuterClassname, javaOuterClassname;
-@dynamic hasJavaMultipleFiles, javaMultipleFiles;
-@dynamic hasJavaGenerateEqualsAndHash, javaGenerateEqualsAndHash;
-@dynamic hasJavaStringCheckUtf8, javaStringCheckUtf8;
-@dynamic hasOptimizeFor, optimizeFor;
-@dynamic hasGoPackage, goPackage;
-@dynamic hasCcGenericServices, ccGenericServices;
-@dynamic hasJavaGenericServices, javaGenericServices;
-@dynamic hasPyGenericServices, pyGenericServices;
-@dynamic hasDeprecated, deprecated;
-@dynamic hasCcEnableArenas, ccEnableArenas;
-@dynamic hasObjcClassPrefix, objcClassPrefix;
-@dynamic hasCsharpNamespace, csharpNamespace;
-@dynamic hasJavananoUseDeprecatedPackage, javananoUseDeprecatedPackage;
-@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count;
-
-typedef struct GPBFileOptions__storage_ {
- uint32_t _has_storage_[1];
- BOOL javaMultipleFiles;
- BOOL ccGenericServices;
- BOOL javaGenericServices;
- BOOL pyGenericServices;
- BOOL javaGenerateEqualsAndHash;
- BOOL deprecated;
- BOOL javaStringCheckUtf8;
- BOOL ccEnableArenas;
- BOOL javananoUseDeprecatedPackage;
- GPBFileOptions_OptimizeMode optimizeFor;
- NSString *javaPackage;
- NSString *javaOuterClassname;
- NSString *goPackage;
- NSString *objcClassPrefix;
- NSString *csharpNamespace;
- NSMutableArray *uninterpretedOptionArray;
-} GPBFileOptions__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "javaPackage",
- .number = GPBFileOptions_FieldNumber_JavaPackage,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFileOptions__storage_, javaPackage),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "javaOuterClassname",
- .number = GPBFileOptions_FieldNumber_JavaOuterClassname,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFileOptions__storage_, javaOuterClassname),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "optimizeFor",
- .number = GPBFileOptions_FieldNumber_OptimizeFor,
- .hasIndex = 5,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue | GPBFieldHasEnumDescriptor,
- .dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBFileOptions__storage_, optimizeFor),
- .defaultValue.valueEnum = GPBFileOptions_OptimizeMode_Speed,
- .dataTypeSpecific.enumDescFunc = GPBFileOptions_OptimizeMode_EnumDescriptor,
- .fieldOptions = NULL,
- },
- {
- .name = "javaMultipleFiles",
- .number = GPBFileOptions_FieldNumber_JavaMultipleFiles,
- .hasIndex = 2,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFileOptions__storage_, javaMultipleFiles),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "goPackage",
- .number = GPBFileOptions_FieldNumber_GoPackage,
- .hasIndex = 6,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFileOptions__storage_, goPackage),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "ccGenericServices",
- .number = GPBFileOptions_FieldNumber_CcGenericServices,
- .hasIndex = 7,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFileOptions__storage_, ccGenericServices),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "javaGenericServices",
- .number = GPBFileOptions_FieldNumber_JavaGenericServices,
- .hasIndex = 8,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFileOptions__storage_, javaGenericServices),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "pyGenericServices",
- .number = GPBFileOptions_FieldNumber_PyGenericServices,
- .hasIndex = 9,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFileOptions__storage_, pyGenericServices),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "javaGenerateEqualsAndHash",
- .number = GPBFileOptions_FieldNumber_JavaGenerateEqualsAndHash,
- .hasIndex = 3,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFileOptions__storage_, javaGenerateEqualsAndHash),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "deprecated",
- .number = GPBFileOptions_FieldNumber_Deprecated,
- .hasIndex = 10,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFileOptions__storage_, deprecated),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "javaStringCheckUtf8",
- .number = GPBFileOptions_FieldNumber_JavaStringCheckUtf8,
- .hasIndex = 4,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFileOptions__storage_, javaStringCheckUtf8),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "ccEnableArenas",
- .number = GPBFileOptions_FieldNumber_CcEnableArenas,
- .hasIndex = 11,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFileOptions__storage_, ccEnableArenas),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "objcClassPrefix",
- .number = GPBFileOptions_FieldNumber_ObjcClassPrefix,
- .hasIndex = 12,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFileOptions__storage_, objcClassPrefix),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "csharpNamespace",
- .number = GPBFileOptions_FieldNumber_CsharpNamespace,
- .hasIndex = 13,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBFileOptions__storage_, csharpNamespace),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "javananoUseDeprecatedPackage",
- .number = GPBFileOptions_FieldNumber_JavananoUseDeprecatedPackage,
- .hasIndex = 14,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFileOptions__storage_, javananoUseDeprecatedPackage),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- #if GPBOBJC_INCLUDE_FIELD_OPTIONS
- .fieldOptions = "\000\000\000\002\030\001",
- #else
- .fieldOptions = NULL,
- #endif // GPBOBJC_INCLUDE_FIELD_OPTIONS
- },
- {
- .name = "uninterpretedOptionArray",
- .number = GPBFileOptions_FieldNumber_UninterpretedOptionArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFileOptions__storage_, uninterpretedOptionArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption),
- .fieldOptions = NULL,
- },
- };
- static GPBMessageEnumDescription enums[] = {
- { .enumDescriptorFunc = GPBFileOptions_OptimizeMode_EnumDescriptor },
- };
- static GPBExtensionRange ranges[] = {
- { .start = 1000, .end = 536870912 },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBFileOptions class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:enums
- enumCount:sizeof(enums) / sizeof(GPBMessageEnumDescription)
- ranges:ranges
- rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange)
- storageSize:sizeof(GPBFileOptions__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - Enum GPBFileOptions_OptimizeMode
-
-GPBEnumDescriptor *GPBFileOptions_OptimizeMode_EnumDescriptor(void) {
- static GPBEnumDescriptor *descriptor = NULL;
- if (!descriptor) {
- static GPBMessageEnumValueDescription values[] = {
- { .name = "Speed", .number = GPBFileOptions_OptimizeMode_Speed },
- { .name = "CodeSize", .number = GPBFileOptions_OptimizeMode_CodeSize },
- { .name = "LiteRuntime", .number = GPBFileOptions_OptimizeMode_LiteRuntime },
- };
- descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFileOptions_OptimizeMode)
- values:values
- valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
- enumVerifier:GPBFileOptions_OptimizeMode_IsValidValue];
- }
- return descriptor;
-}
-
-BOOL GPBFileOptions_OptimizeMode_IsValidValue(int32_t value__) {
- switch (value__) {
- case GPBFileOptions_OptimizeMode_Speed:
- case GPBFileOptions_OptimizeMode_CodeSize:
- case GPBFileOptions_OptimizeMode_LiteRuntime:
- return YES;
- default:
- return NO;
- }
-}
-
-#pragma mark - GPBMessageOptions
-
-@implementation GPBMessageOptions
-
-@dynamic hasMessageSetWireFormat, messageSetWireFormat;
-@dynamic hasNoStandardDescriptorAccessor, noStandardDescriptorAccessor;
-@dynamic hasDeprecated, deprecated;
-@dynamic hasMapEntry, mapEntry;
-@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count;
-
-typedef struct GPBMessageOptions__storage_ {
- uint32_t _has_storage_[1];
- BOOL messageSetWireFormat;
- BOOL noStandardDescriptorAccessor;
- BOOL deprecated;
- BOOL mapEntry;
- NSMutableArray *uninterpretedOptionArray;
-} GPBMessageOptions__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "messageSetWireFormat",
- .number = GPBMessageOptions_FieldNumber_MessageSetWireFormat,
- .hasIndex = 0,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBMessageOptions__storage_, messageSetWireFormat),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "noStandardDescriptorAccessor",
- .number = GPBMessageOptions_FieldNumber_NoStandardDescriptorAccessor,
- .hasIndex = 1,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBMessageOptions__storage_, noStandardDescriptorAccessor),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "deprecated",
- .number = GPBMessageOptions_FieldNumber_Deprecated,
- .hasIndex = 2,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBMessageOptions__storage_, deprecated),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "mapEntry",
- .number = GPBMessageOptions_FieldNumber_MapEntry,
- .hasIndex = 3,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBMessageOptions__storage_, mapEntry),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "uninterpretedOptionArray",
- .number = GPBMessageOptions_FieldNumber_UninterpretedOptionArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBMessageOptions__storage_, uninterpretedOptionArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption),
- .fieldOptions = NULL,
- },
- };
- static GPBExtensionRange ranges[] = {
- { .start = 1000, .end = 536870912 },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBMessageOptions class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:ranges
- rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange)
- storageSize:sizeof(GPBMessageOptions__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBFieldOptions
-
-@implementation GPBFieldOptions
-
-@dynamic hasCtype, ctype;
-@dynamic hasPacked, packed;
-@dynamic hasJstype, jstype;
-@dynamic hasLazy, lazy;
-@dynamic hasDeprecated, deprecated;
-@dynamic hasWeak, weak;
-@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count;
-
-typedef struct GPBFieldOptions__storage_ {
- uint32_t _has_storage_[1];
- BOOL packed;
- BOOL deprecated;
- BOOL lazy;
- BOOL weak;
- GPBFieldOptions_CType ctype;
- GPBFieldOptions_JSType jstype;
- NSMutableArray *uninterpretedOptionArray;
-} GPBFieldOptions__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "ctype",
- .number = GPBFieldOptions_FieldNumber_Ctype,
- .hasIndex = 0,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue | GPBFieldHasEnumDescriptor,
- .dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBFieldOptions__storage_, ctype),
- .defaultValue.valueEnum = GPBFieldOptions_CType_String,
- .dataTypeSpecific.enumDescFunc = GPBFieldOptions_CType_EnumDescriptor,
- .fieldOptions = NULL,
- },
- {
- .name = "packed",
- .number = GPBFieldOptions_FieldNumber_Packed,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFieldOptions__storage_, packed),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "deprecated",
- .number = GPBFieldOptions_FieldNumber_Deprecated,
- .hasIndex = 4,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFieldOptions__storage_, deprecated),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "lazy",
- .number = GPBFieldOptions_FieldNumber_Lazy,
- .hasIndex = 3,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFieldOptions__storage_, lazy),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "jstype",
- .number = GPBFieldOptions_FieldNumber_Jstype,
- .hasIndex = 2,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue | GPBFieldHasEnumDescriptor,
- .dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBFieldOptions__storage_, jstype),
- .defaultValue.valueEnum = GPBFieldOptions_JSType_JsNormal,
- .dataTypeSpecific.enumDescFunc = GPBFieldOptions_JSType_EnumDescriptor,
- .fieldOptions = NULL,
- },
- {
- .name = "weak",
- .number = GPBFieldOptions_FieldNumber_Weak,
- .hasIndex = 5,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBFieldOptions__storage_, weak),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "uninterpretedOptionArray",
- .number = GPBFieldOptions_FieldNumber_UninterpretedOptionArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBFieldOptions__storage_, uninterpretedOptionArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption),
- .fieldOptions = NULL,
- },
- };
- static GPBMessageEnumDescription enums[] = {
- { .enumDescriptorFunc = GPBFieldOptions_CType_EnumDescriptor },
- { .enumDescriptorFunc = GPBFieldOptions_JSType_EnumDescriptor },
- };
- static GPBExtensionRange ranges[] = {
- { .start = 1000, .end = 536870912 },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBFieldOptions class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:enums
- enumCount:sizeof(enums) / sizeof(GPBMessageEnumDescription)
- ranges:ranges
- rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange)
- storageSize:sizeof(GPBFieldOptions__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - Enum GPBFieldOptions_CType
-
-GPBEnumDescriptor *GPBFieldOptions_CType_EnumDescriptor(void) {
- static GPBEnumDescriptor *descriptor = NULL;
- if (!descriptor) {
- static GPBMessageEnumValueDescription values[] = {
- { .name = "String", .number = GPBFieldOptions_CType_String },
- { .name = "Cord", .number = GPBFieldOptions_CType_Cord },
- { .name = "StringPiece", .number = GPBFieldOptions_CType_StringPiece },
- };
- descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFieldOptions_CType)
- values:values
- valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
- enumVerifier:GPBFieldOptions_CType_IsValidValue];
- }
- return descriptor;
-}
-
-BOOL GPBFieldOptions_CType_IsValidValue(int32_t value__) {
- switch (value__) {
- case GPBFieldOptions_CType_String:
- case GPBFieldOptions_CType_Cord:
- case GPBFieldOptions_CType_StringPiece:
- return YES;
- default:
- return NO;
- }
-}
-
-#pragma mark - Enum GPBFieldOptions_JSType
-
-GPBEnumDescriptor *GPBFieldOptions_JSType_EnumDescriptor(void) {
- static GPBEnumDescriptor *descriptor = NULL;
- if (!descriptor) {
- static GPBMessageEnumValueDescription values[] = {
- { .name = "JsNormal", .number = GPBFieldOptions_JSType_JsNormal },
- { .name = "JsString", .number = GPBFieldOptions_JSType_JsString },
- { .name = "JsNumber", .number = GPBFieldOptions_JSType_JsNumber },
- };
- descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFieldOptions_JSType)
- values:values
- valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
- enumVerifier:GPBFieldOptions_JSType_IsValidValue];
- }
- return descriptor;
-}
-
-BOOL GPBFieldOptions_JSType_IsValidValue(int32_t value__) {
- switch (value__) {
- case GPBFieldOptions_JSType_JsNormal:
- case GPBFieldOptions_JSType_JsString:
- case GPBFieldOptions_JSType_JsNumber:
- return YES;
- default:
- return NO;
- }
-}
-
-#pragma mark - GPBEnumOptions
-
-@implementation GPBEnumOptions
-
-@dynamic hasAllowAlias, allowAlias;
-@dynamic hasDeprecated, deprecated;
-@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count;
-
-typedef struct GPBEnumOptions__storage_ {
- uint32_t _has_storage_[1];
- BOOL allowAlias;
- BOOL deprecated;
- NSMutableArray *uninterpretedOptionArray;
-} GPBEnumOptions__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "allowAlias",
- .number = GPBEnumOptions_FieldNumber_AllowAlias,
- .hasIndex = 0,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBEnumOptions__storage_, allowAlias),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "deprecated",
- .number = GPBEnumOptions_FieldNumber_Deprecated,
- .hasIndex = 1,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBEnumOptions__storage_, deprecated),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "uninterpretedOptionArray",
- .number = GPBEnumOptions_FieldNumber_UninterpretedOptionArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBEnumOptions__storage_, uninterpretedOptionArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption),
- .fieldOptions = NULL,
- },
- };
- static GPBExtensionRange ranges[] = {
- { .start = 1000, .end = 536870912 },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBEnumOptions class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:ranges
- rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange)
- storageSize:sizeof(GPBEnumOptions__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBEnumValueOptions
-
-@implementation GPBEnumValueOptions
-
-@dynamic hasDeprecated, deprecated;
-@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count;
-
-typedef struct GPBEnumValueOptions__storage_ {
- uint32_t _has_storage_[1];
- BOOL deprecated;
- NSMutableArray *uninterpretedOptionArray;
-} GPBEnumValueOptions__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "deprecated",
- .number = GPBEnumValueOptions_FieldNumber_Deprecated,
- .hasIndex = 0,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBEnumValueOptions__storage_, deprecated),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "uninterpretedOptionArray",
- .number = GPBEnumValueOptions_FieldNumber_UninterpretedOptionArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBEnumValueOptions__storage_, uninterpretedOptionArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption),
- .fieldOptions = NULL,
- },
- };
- static GPBExtensionRange ranges[] = {
- { .start = 1000, .end = 536870912 },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBEnumValueOptions class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:ranges
- rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange)
- storageSize:sizeof(GPBEnumValueOptions__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBServiceOptions
-
-@implementation GPBServiceOptions
-
-@dynamic hasDeprecated, deprecated;
-@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count;
-
-typedef struct GPBServiceOptions__storage_ {
- uint32_t _has_storage_[1];
- BOOL deprecated;
- NSMutableArray *uninterpretedOptionArray;
-} GPBServiceOptions__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "deprecated",
- .number = GPBServiceOptions_FieldNumber_Deprecated,
- .hasIndex = 0,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBServiceOptions__storage_, deprecated),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "uninterpretedOptionArray",
- .number = GPBServiceOptions_FieldNumber_UninterpretedOptionArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBServiceOptions__storage_, uninterpretedOptionArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption),
- .fieldOptions = NULL,
- },
- };
- static GPBExtensionRange ranges[] = {
- { .start = 1000, .end = 536870912 },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBServiceOptions class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:ranges
- rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange)
- storageSize:sizeof(GPBServiceOptions__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBMethodOptions
-
-@implementation GPBMethodOptions
-
-@dynamic hasDeprecated, deprecated;
-@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count;
-
-typedef struct GPBMethodOptions__storage_ {
- uint32_t _has_storage_[1];
- BOOL deprecated;
- NSMutableArray *uninterpretedOptionArray;
-} GPBMethodOptions__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "deprecated",
- .number = GPBMethodOptions_FieldNumber_Deprecated,
- .hasIndex = 0,
- .flags = GPBFieldOptional | GPBFieldHasDefaultValue,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBMethodOptions__storage_, deprecated),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "uninterpretedOptionArray",
- .number = GPBMethodOptions_FieldNumber_UninterpretedOptionArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBMethodOptions__storage_, uninterpretedOptionArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption),
- .fieldOptions = NULL,
- },
- };
- static GPBExtensionRange ranges[] = {
- { .start = 1000, .end = 536870912 },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBMethodOptions class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:ranges
- rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange)
- storageSize:sizeof(GPBMethodOptions__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBUninterpretedOption
-
-@implementation GPBUninterpretedOption
-
-@dynamic nameArray, nameArray_Count;
-@dynamic hasIdentifierValue, identifierValue;
-@dynamic hasPositiveIntValue, positiveIntValue;
-@dynamic hasNegativeIntValue, negativeIntValue;
-@dynamic hasDoubleValue, doubleValue;
-@dynamic hasStringValue, stringValue;
-@dynamic hasAggregateValue, aggregateValue;
-
-typedef struct GPBUninterpretedOption__storage_ {
- uint32_t _has_storage_[1];
- NSMutableArray *nameArray;
- NSString *identifierValue;
- NSData *stringValue;
- NSString *aggregateValue;
- uint64_t positiveIntValue;
- int64_t negativeIntValue;
- double doubleValue;
-} GPBUninterpretedOption__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "nameArray",
- .number = GPBUninterpretedOption_FieldNumber_NameArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBUninterpretedOption__storage_, nameArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption_NamePart),
- .fieldOptions = NULL,
- },
- {
- .name = "identifierValue",
- .number = GPBUninterpretedOption_FieldNumber_IdentifierValue,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBUninterpretedOption__storage_, identifierValue),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "positiveIntValue",
- .number = GPBUninterpretedOption_FieldNumber_PositiveIntValue,
- .hasIndex = 2,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeUInt64,
- .offset = offsetof(GPBUninterpretedOption__storage_, positiveIntValue),
- .defaultValue.valueUInt64 = 0ULL,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "negativeIntValue",
- .number = GPBUninterpretedOption_FieldNumber_NegativeIntValue,
- .hasIndex = 3,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt64,
- .offset = offsetof(GPBUninterpretedOption__storage_, negativeIntValue),
- .defaultValue.valueInt64 = 0LL,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "doubleValue",
- .number = GPBUninterpretedOption_FieldNumber_DoubleValue,
- .hasIndex = 4,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeDouble,
- .offset = offsetof(GPBUninterpretedOption__storage_, doubleValue),
- .defaultValue.valueDouble = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "stringValue",
- .number = GPBUninterpretedOption_FieldNumber_StringValue,
- .hasIndex = 5,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeBytes,
- .offset = offsetof(GPBUninterpretedOption__storage_, stringValue),
- .defaultValue.valueData = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "aggregateValue",
- .number = GPBUninterpretedOption_FieldNumber_AggregateValue,
- .hasIndex = 6,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBUninterpretedOption__storage_, aggregateValue),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBUninterpretedOption class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBUninterpretedOption__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBUninterpretedOption_NamePart
-
-@implementation GPBUninterpretedOption_NamePart
-
-@dynamic hasNamePart, namePart;
-@dynamic hasIsExtension, isExtension;
-
-typedef struct GPBUninterpretedOption_NamePart__storage_ {
- uint32_t _has_storage_[1];
- BOOL isExtension;
- NSString *namePart;
-} GPBUninterpretedOption_NamePart__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "namePart",
- .number = GPBUninterpretedOption_NamePart_FieldNumber_NamePart,
- .hasIndex = 0,
- .flags = GPBFieldRequired,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBUninterpretedOption_NamePart__storage_, namePart),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "isExtension",
- .number = GPBUninterpretedOption_NamePart_FieldNumber_IsExtension,
- .hasIndex = 1,
- .flags = GPBFieldRequired,
- .dataType = GPBDataTypeBool,
- .offset = offsetof(GPBUninterpretedOption_NamePart__storage_, isExtension),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBUninterpretedOption_NamePart class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBUninterpretedOption_NamePart__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBSourceCodeInfo
-
-@implementation GPBSourceCodeInfo
-
-@dynamic locationArray, locationArray_Count;
-
-typedef struct GPBSourceCodeInfo__storage_ {
- uint32_t _has_storage_[1];
- NSMutableArray *locationArray;
-} GPBSourceCodeInfo__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "locationArray",
- .number = GPBSourceCodeInfo_FieldNumber_LocationArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBSourceCodeInfo__storage_, locationArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceCodeInfo_Location),
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBSourceCodeInfo class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBSourceCodeInfo__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBSourceCodeInfo_Location
-
-@implementation GPBSourceCodeInfo_Location
-
-@dynamic pathArray, pathArray_Count;
-@dynamic spanArray, spanArray_Count;
-@dynamic hasLeadingComments, leadingComments;
-@dynamic hasTrailingComments, trailingComments;
-@dynamic leadingDetachedCommentsArray, leadingDetachedCommentsArray_Count;
-
-typedef struct GPBSourceCodeInfo_Location__storage_ {
- uint32_t _has_storage_[1];
- GPBInt32Array *pathArray;
- GPBInt32Array *spanArray;
- NSString *leadingComments;
- NSString *trailingComments;
- NSMutableArray *leadingDetachedCommentsArray;
-} GPBSourceCodeInfo_Location__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "pathArray",
- .number = GPBSourceCodeInfo_Location_FieldNumber_PathArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated | GPBFieldPacked,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBSourceCodeInfo_Location__storage_, pathArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- #if GPBOBJC_INCLUDE_FIELD_OPTIONS
- .fieldOptions = "\000\000\000\002\020\001",
- #else
- .fieldOptions = NULL,
- #endif // GPBOBJC_INCLUDE_FIELD_OPTIONS
- },
- {
- .name = "spanArray",
- .number = GPBSourceCodeInfo_Location_FieldNumber_SpanArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated | GPBFieldPacked,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBSourceCodeInfo_Location__storage_, spanArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- #if GPBOBJC_INCLUDE_FIELD_OPTIONS
- .fieldOptions = "\000\000\000\002\020\001",
- #else
- .fieldOptions = NULL,
- #endif // GPBOBJC_INCLUDE_FIELD_OPTIONS
- },
- {
- .name = "leadingComments",
- .number = GPBSourceCodeInfo_Location_FieldNumber_LeadingComments,
- .hasIndex = 2,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBSourceCodeInfo_Location__storage_, leadingComments),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "trailingComments",
- .number = GPBSourceCodeInfo_Location_FieldNumber_TrailingComments,
- .hasIndex = 3,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBSourceCodeInfo_Location__storage_, trailingComments),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "leadingDetachedCommentsArray",
- .number = GPBSourceCodeInfo_Location_FieldNumber_LeadingDetachedCommentsArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBSourceCodeInfo_Location__storage_, leadingDetachedCommentsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBSourceCodeInfo_Location class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBSourceCodeInfo_Location__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBGeneratedCodeInfo
-
-@implementation GPBGeneratedCodeInfo
-
-@dynamic annotationArray, annotationArray_Count;
-
-typedef struct GPBGeneratedCodeInfo__storage_ {
- uint32_t _has_storage_[1];
- NSMutableArray *annotationArray;
-} GPBGeneratedCodeInfo__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "annotationArray",
- .number = GPBGeneratedCodeInfo_FieldNumber_AnnotationArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated,
- .dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBGeneratedCodeInfo__storage_, annotationArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBGeneratedCodeInfo_Annotation),
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBGeneratedCodeInfo class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBGeneratedCodeInfo__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-#pragma mark - GPBGeneratedCodeInfo_Annotation
-
-@implementation GPBGeneratedCodeInfo_Annotation
-
-@dynamic pathArray, pathArray_Count;
-@dynamic hasSourceFile, sourceFile;
-@dynamic hasBegin, begin;
-@dynamic hasEnd, end;
-
-typedef struct GPBGeneratedCodeInfo_Annotation__storage_ {
- uint32_t _has_storage_[1];
- int32_t begin;
- int32_t end;
- GPBInt32Array *pathArray;
- NSString *sourceFile;
-} GPBGeneratedCodeInfo_Annotation__storage_;
-
-// This method is threadsafe because it is initially called
-// in +initialize for each subclass.
-+ (GPBDescriptor *)descriptor {
- static GPBDescriptor *descriptor = nil;
- if (!descriptor) {
- static GPBMessageFieldDescription fields[] = {
- {
- .name = "pathArray",
- .number = GPBGeneratedCodeInfo_Annotation_FieldNumber_PathArray,
- .hasIndex = GPBNoHasBit,
- .flags = GPBFieldRepeated | GPBFieldPacked,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBGeneratedCodeInfo_Annotation__storage_, pathArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- #if GPBOBJC_INCLUDE_FIELD_OPTIONS
- .fieldOptions = "\000\000\000\002\020\001",
- #else
- .fieldOptions = NULL,
- #endif // GPBOBJC_INCLUDE_FIELD_OPTIONS
- },
- {
- .name = "sourceFile",
- .number = GPBGeneratedCodeInfo_Annotation_FieldNumber_SourceFile,
- .hasIndex = 1,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeString,
- .offset = offsetof(GPBGeneratedCodeInfo_Annotation__storage_, sourceFile),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "begin",
- .number = GPBGeneratedCodeInfo_Annotation_FieldNumber_Begin,
- .hasIndex = 2,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBGeneratedCodeInfo_Annotation__storage_, begin),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- {
- .name = "end",
- .number = GPBGeneratedCodeInfo_Annotation_FieldNumber_End,
- .hasIndex = 3,
- .flags = GPBFieldOptional,
- .dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBGeneratedCodeInfo_Annotation__storage_, end),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
- },
- };
- GPBDescriptor *localDescriptor =
- [GPBDescriptor allocDescriptorForClass:[GPBGeneratedCodeInfo_Annotation class]
- rootClass:[GPBDescriptorRoot class]
- file:GPBDescriptorRoot_FileDescriptor()
- fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
- storageSize:sizeof(GPBGeneratedCodeInfo_Annotation__storage_)
- wireFormat:NO];
- NSAssert(descriptor == nil, @"Startup recursed!");
- descriptor = localDescriptor;
- }
- return descriptor;
-}
-
-@end
-
-
-// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Duration.pbobjc.h b/objectivec/google/protobuf/Duration.pbobjc.h
index b592640b..3e367590 100644
--- a/objectivec/google/protobuf/Duration.pbobjc.h
+++ b/objectivec/google/protobuf/Duration.pbobjc.h
@@ -1,27 +1,51 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/duration.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBDurationRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBDurationRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBDuration
@@ -31,58 +55,83 @@ typedef GPB_ENUM(GPBDuration_FieldNumber) {
GPBDuration_FieldNumber_Nanos = 2,
};
-// A Duration represents a signed, fixed-length span of time represented
-// as a count of seconds and fractions of seconds at nanosecond
-// resolution. It is independent of any calendar and concepts like "day"
-// or "month". It is related to Timestamp in that the difference between
-// two Timestamp values is a Duration and it can be added or subtracted
-// from a Timestamp. Range is approximately +-10,000 years.
-//
-// Example 1: Compute Duration from two Timestamps in pseudo code.
-//
-// Timestamp start = ...;
-// Timestamp end = ...;
-// Duration duration = ...;
-//
-// duration.seconds = end.seconds - start.seconds;
-// duration.nanos = end.nanos - start.nanos;
-//
-// if (duration.seconds < 0 && duration.nanos > 0) {
-// duration.seconds += 1;
-// duration.nanos -= 1000000000;
-// } else if (durations.seconds > 0 && duration.nanos < 0) {
-// duration.seconds -= 1;
-// duration.nanos += 1000000000;
-// }
-//
-// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
-//
-// Timestamp start = ...;
-// Duration duration = ...;
-// Timestamp end = ...;
-//
-// end.seconds = start.seconds + duration.seconds;
-// end.nanos = start.nanos + duration.nanos;
-//
-// if (end.nanos < 0) {
-// end.seconds -= 1;
-// end.nanos += 1000000000;
-// } else if (end.nanos >= 1000000000) {
-// end.seconds += 1;
-// end.nanos -= 1000000000;
-// }
+/**
+ * A Duration represents a signed, fixed-length span of time represented
+ * as a count of seconds and fractions of seconds at nanosecond
+ * resolution. It is independent of any calendar and concepts like "day"
+ * or "month". It is related to Timestamp in that the difference between
+ * two Timestamp values is a Duration and it can be added or subtracted
+ * from a Timestamp. Range is approximately +-10,000 years.
+ *
+ * # Examples
+ *
+ * Example 1: Compute Duration from two Timestamps in pseudo code.
+ *
+ * Timestamp start = ...;
+ * Timestamp end = ...;
+ * Duration duration = ...;
+ *
+ * duration.seconds = end.seconds - start.seconds;
+ * duration.nanos = end.nanos - start.nanos;
+ *
+ * if (duration.seconds < 0 && duration.nanos > 0) {
+ * duration.seconds += 1;
+ * duration.nanos -= 1000000000;
+ * } else if (durations.seconds > 0 && duration.nanos < 0) {
+ * duration.seconds -= 1;
+ * duration.nanos += 1000000000;
+ * }
+ *
+ * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
+ *
+ * Timestamp start = ...;
+ * Duration duration = ...;
+ * Timestamp end = ...;
+ *
+ * end.seconds = start.seconds + duration.seconds;
+ * end.nanos = start.nanos + duration.nanos;
+ *
+ * if (end.nanos < 0) {
+ * end.seconds -= 1;
+ * end.nanos += 1000000000;
+ * } else if (end.nanos >= 1000000000) {
+ * end.seconds += 1;
+ * end.nanos -= 1000000000;
+ * }
+ *
+ * Example 3: Compute Duration from datetime.timedelta in Python.
+ *
+ * td = datetime.timedelta(days=3, minutes=10)
+ * duration = Duration()
+ * duration.FromTimedelta(td)
+ *
+ * # JSON Mapping
+ *
+ * In JSON format, the Duration type is encoded as a string rather than an
+ * object, where the string ends in the suffix "s" (indicating seconds) and
+ * is preceded by the number of seconds, with nanoseconds expressed as
+ * fractional seconds. For example, 3 seconds with 0 nanoseconds should be
+ * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
+ * be expressed in JSON format as "3.000000001s", and 3 seconds and 1
+ * microsecond should be expressed in JSON format as "3.000001s".
+ **/
@interface GPBDuration : GPBMessage
-// Signed seconds of the span of time. Must be from -315,576,000,000
-// to +315,576,000,000 inclusive.
+/**
+ * Signed seconds of the span of time. Must be from -315,576,000,000
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
+ **/
@property(nonatomic, readwrite) int64_t seconds;
-// Signed fractions of a second at nanosecond resolution of the span
-// of time. Durations less than one second are represented with a 0
-// `seconds` field and a positive or negative `nanos` field. For durations
-// of one second or more, a non-zero value for the `nanos` field must be
-// of the same sign as the `seconds` field. Must be from -999,999,999
-// to +999,999,999 inclusive.
+/**
+ * Signed fractions of a second at nanosecond resolution of the span
+ * of time. Durations less than one second are represented with a 0
+ * `seconds` field and a positive or negative `nanos` field. For durations
+ * of one second or more, a non-zero value for the `nanos` field must be
+ * of the same sign as the `seconds` field. Must be from -999,999,999
+ * to +999,999,999 inclusive.
+ **/
@property(nonatomic, readwrite) int32_t nanos;
@end
@@ -91,4 +140,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Duration.pbobjc.m b/objectivec/google/protobuf/Duration.pbobjc.m
index e4fd4951..bafb64a0 100644
--- a/objectivec/google/protobuf/Duration.pbobjc.m
+++ b/objectivec/google/protobuf/Duration.pbobjc.m
@@ -1,14 +1,35 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/duration.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/Duration.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Duration.pbobjc.h>
+#else
+ #import "google/protobuf/Duration.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBDurationRoot
@implementation GPBDurationRoot
+// No extensions in the file and no imports, so no need to generate
+// +extensionRegistry.
+
@end
#pragma mark - GPBDurationRoot_FileDescriptor
@@ -18,8 +39,9 @@ static GPBFileDescriptor *GPBDurationRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -46,25 +68,21 @@ typedef struct GPBDuration__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "seconds",
+ .dataTypeSpecific.className = NULL,
.number = GPBDuration_FieldNumber_Seconds,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBDuration__storage_, seconds),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt64,
- .offset = offsetof(GPBDuration__storage_, seconds),
- .defaultValue.valueInt64 = 0LL,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "nanos",
+ .dataTypeSpecific.className = NULL,
.number = GPBDuration_FieldNumber_Nanos,
.hasIndex = 1,
+ .offset = (uint32_t)offsetof(GPBDuration__storage_, nanos),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBDuration__storage_, nanos),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -72,15 +90,9 @@ typedef struct GPBDuration__storage_ {
rootClass:[GPBDurationRoot class]
file:GPBDurationRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBDuration__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -90,4 +102,6 @@ typedef struct GPBDuration__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Empty.pbobjc.h b/objectivec/google/protobuf/Empty.pbobjc.h
index bace614d..fdc247ae 100644
--- a/objectivec/google/protobuf/Empty.pbobjc.h
+++ b/objectivec/google/protobuf/Empty.pbobjc.h
@@ -1,40 +1,66 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/empty.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBEmptyRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBEmptyRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBEmpty
-// A generic empty message that you can re-use to avoid defining duplicated
-// empty messages in your APIs. A typical example is to use it as the request
-// or the response type of an API method. For instance:
-//
-// service Foo {
-// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
-// }
-//
-// The JSON representation for `Empty` is empty JSON object `{}`.
+/**
+ * A generic empty message that you can re-use to avoid defining duplicated
+ * empty messages in your APIs. A typical example is to use it as the request
+ * or the response type of an API method. For instance:
+ *
+ * service Foo {
+ * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+ * }
+ *
+ * The JSON representation for `Empty` is empty JSON object `{}`.
+ **/
@interface GPBEmpty : GPBMessage
@end
@@ -43,4 +69,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Empty.pbobjc.m b/objectivec/google/protobuf/Empty.pbobjc.m
index 17f0c1ac..506b500e 100644
--- a/objectivec/google/protobuf/Empty.pbobjc.m
+++ b/objectivec/google/protobuf/Empty.pbobjc.m
@@ -1,14 +1,35 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/empty.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/Empty.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Empty.pbobjc.h>
+#else
+ #import "google/protobuf/Empty.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBEmptyRoot
@implementation GPBEmptyRoot
+// No extensions in the file and no imports, so no need to generate
+// +extensionRegistry.
+
@end
#pragma mark - GPBEmptyRoot_FileDescriptor
@@ -18,8 +39,9 @@ static GPBFileDescriptor *GPBEmptyRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -31,7 +53,7 @@ static GPBFileDescriptor *GPBEmptyRoot_FileDescriptor(void) {
typedef struct GPBEmpty__storage_ {
- uint32_t _has_storage_[0];
+ uint32_t _has_storage_[1];
} GPBEmpty__storage_;
// This method is threadsafe because it is initially called
@@ -45,14 +67,8 @@ typedef struct GPBEmpty__storage_ {
file:GPBEmptyRoot_FileDescriptor()
fields:NULL
fieldCount:0
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
storageSize:sizeof(GPBEmpty__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -62,4 +78,6 @@ typedef struct GPBEmpty__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/FieldMask.pbobjc.h b/objectivec/google/protobuf/FieldMask.pbobjc.h
index 4e4ec387..73296d57 100644
--- a/objectivec/google/protobuf/FieldMask.pbobjc.h
+++ b/objectivec/google/protobuf/FieldMask.pbobjc.h
@@ -1,27 +1,51 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/field_mask.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBFieldMaskRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBFieldMaskRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBFieldMask
@@ -30,133 +54,220 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
GPBFieldMask_FieldNumber_PathsArray = 1,
};
-// `FieldMask` represents a set of symbolic field paths, for example:
-//
-// paths: "f.a"
-// paths: "f.b.d"
-//
-// Here `f` represents a field in some root message, `a` and `b`
-// fields in the message found in `f`, and `d` a field found in the
-// message in `f.b`.
-//
-// Field masks are used to specify a subset of fields that should be
-// returned by a get operation or modified by an update operation.
-// Field masks also have a custom JSON encoding (see below).
-//
-// # Field Masks in Projections
-//
-// When used in the context of a projection, a response message or
-// sub-message is filtered by the API to only contain those fields as
-// specified in the mask. For example, if the mask in the previous
-// example is applied to a response message as follows:
-//
-// f {
-// a : 22
-// b {
-// d : 1
-// x : 2
-// }
-// y : 13
-// }
-// z: 8
-//
-// The result will not contain specific values for fields x,y and z
-// (their value will be set to the default, and omitted in proto text
-// output):
-//
-//
-// f {
-// a : 22
-// b {
-// d : 1
-// }
-// }
-//
-// A repeated field is not allowed except at the last position of a
-// field mask.
-//
-// If a FieldMask object is not present in a get operation, the
-// operation applies to all fields (as if a FieldMask of all fields
-// had been specified).
-//
-// Note that a field mask does not necessarily applies to the
-// top-level response message. In case of a REST get operation, the
-// field mask applies directly to the response, but in case of a REST
-// list operation, the mask instead applies to each individual message
-// in the returned resource list. In case of a REST custom method,
-// other definitions may be used. Where the mask applies will be
-// clearly documented together with its declaration in the API. In
-// any case, the effect on the returned resource/resources is required
-// behavior for APIs.
-//
-// # Field Masks in Update Operations
-//
-// A field mask in update operations specifies which fields of the
-// targeted resource are going to be updated. The API is required
-// to only change the values of the fields as specified in the mask
-// and leave the others untouched. If a resource is passed in to
-// describe the updated values, the API ignores the values of all
-// fields not covered by the mask.
-//
-// In order to reset a field's value to the default, the field must
-// be in the mask and set to the default value in the provided resource.
-// Hence, in order to reset all fields of a resource, provide a default
-// instance of the resource and set all fields in the mask, or do
-// not provide a mask as described below.
-//
-// If a field mask is not present on update, the operation applies to
-// all fields (as if a field mask of all fields has been specified).
-// Note that in the presence of schema evolution, this may mean that
-// fields the client does not know and has therefore not filled into
-// the request will be reset to their default. If this is unwanted
-// behavior, a specific service may require a client to always specify
-// a field mask, producing an error if not.
-//
-// As with get operations, the location of the resource which
-// describes the updated values in the request message depends on the
-// operation kind. In any case, the effect of the field mask is
-// required to be honored by the API.
-//
-// ## Considerations for HTTP REST
-//
-// The HTTP kind of an update operation which uses a field mask must
-// be set to PATCH instead of PUT in order to satisfy HTTP semantics
-// (PUT must only be used for full updates).
-//
-// # JSON Encoding of Field Masks
-//
-// In JSON, a field mask is encoded as a single string where paths are
-// separated by a comma. Fields name in each path are converted
-// to/from lower-camel naming conventions.
-//
-// As an example, consider the following message declarations:
-//
-// message Profile {
-// User user = 1;
-// Photo photo = 2;
-// }
-// message User {
-// string display_name = 1;
-// string address = 2;
-// }
-//
-// In proto a field mask for `Profile` may look as such:
-//
-// mask {
-// paths: "user.display_name"
-// paths: "photo"
-// }
-//
-// In JSON, the same mask is represented as below:
-//
-// {
-// mask: "user.displayName,photo"
-// }
+/**
+ * `FieldMask` represents a set of symbolic field paths, for example:
+ *
+ * paths: "f.a"
+ * paths: "f.b.d"
+ *
+ * Here `f` represents a field in some root message, `a` and `b`
+ * fields in the message found in `f`, and `d` a field found in the
+ * message in `f.b`.
+ *
+ * Field masks are used to specify a subset of fields that should be
+ * returned by a get operation or modified by an update operation.
+ * Field masks also have a custom JSON encoding (see below).
+ *
+ * # Field Masks in Projections
+ *
+ * When used in the context of a projection, a response message or
+ * sub-message is filtered by the API to only contain those fields as
+ * specified in the mask. For example, if the mask in the previous
+ * example is applied to a response message as follows:
+ *
+ * f {
+ * a : 22
+ * b {
+ * d : 1
+ * x : 2
+ * }
+ * y : 13
+ * }
+ * z: 8
+ *
+ * The result will not contain specific values for fields x,y and z
+ * (their value will be set to the default, and omitted in proto text
+ * output):
+ *
+ *
+ * f {
+ * a : 22
+ * b {
+ * d : 1
+ * }
+ * }
+ *
+ * A repeated field is not allowed except at the last position of a
+ * paths string.
+ *
+ * If a FieldMask object is not present in a get operation, the
+ * operation applies to all fields (as if a FieldMask of all fields
+ * had been specified).
+ *
+ * Note that a field mask does not necessarily apply to the
+ * top-level response message. In case of a REST get operation, the
+ * field mask applies directly to the response, but in case of a REST
+ * list operation, the mask instead applies to each individual message
+ * in the returned resource list. In case of a REST custom method,
+ * other definitions may be used. Where the mask applies will be
+ * clearly documented together with its declaration in the API. In
+ * any case, the effect on the returned resource/resources is required
+ * behavior for APIs.
+ *
+ * # Field Masks in Update Operations
+ *
+ * A field mask in update operations specifies which fields of the
+ * targeted resource are going to be updated. The API is required
+ * to only change the values of the fields as specified in the mask
+ * and leave the others untouched. If a resource is passed in to
+ * describe the updated values, the API ignores the values of all
+ * fields not covered by the mask.
+ *
+ * If a repeated field is specified for an update operation, the existing
+ * repeated values in the target resource will be overwritten by the new values.
+ * Note that a repeated field is only allowed in the last position of a `paths`
+ * string.
+ *
+ * If a sub-message is specified in the last position of the field mask for an
+ * update operation, then the existing sub-message in the target resource is
+ * overwritten. Given the target message:
+ *
+ * f {
+ * b {
+ * d : 1
+ * x : 2
+ * }
+ * c : 1
+ * }
+ *
+ * And an update message:
+ *
+ * f {
+ * b {
+ * d : 10
+ * }
+ * }
+ *
+ * then if the field mask is:
+ *
+ * paths: "f.b"
+ *
+ * then the result will be:
+ *
+ * f {
+ * b {
+ * d : 10
+ * }
+ * c : 1
+ * }
+ *
+ * However, if the update mask was:
+ *
+ * paths: "f.b.d"
+ *
+ * then the result would be:
+ *
+ * f {
+ * b {
+ * d : 10
+ * x : 2
+ * }
+ * c : 1
+ * }
+ *
+ * In order to reset a field's value to the default, the field must
+ * be in the mask and set to the default value in the provided resource.
+ * Hence, in order to reset all fields of a resource, provide a default
+ * instance of the resource and set all fields in the mask, or do
+ * not provide a mask as described below.
+ *
+ * If a field mask is not present on update, the operation applies to
+ * all fields (as if a field mask of all fields has been specified).
+ * Note that in the presence of schema evolution, this may mean that
+ * fields the client does not know and has therefore not filled into
+ * the request will be reset to their default. If this is unwanted
+ * behavior, a specific service may require a client to always specify
+ * a field mask, producing an error if not.
+ *
+ * As with get operations, the location of the resource which
+ * describes the updated values in the request message depends on the
+ * operation kind. In any case, the effect of the field mask is
+ * required to be honored by the API.
+ *
+ * ## Considerations for HTTP REST
+ *
+ * The HTTP kind of an update operation which uses a field mask must
+ * be set to PATCH instead of PUT in order to satisfy HTTP semantics
+ * (PUT must only be used for full updates).
+ *
+ * # JSON Encoding of Field Masks
+ *
+ * In JSON, a field mask is encoded as a single string where paths are
+ * separated by a comma. Fields name in each path are converted
+ * to/from lower-camel naming conventions.
+ *
+ * As an example, consider the following message declarations:
+ *
+ * message Profile {
+ * User user = 1;
+ * Photo photo = 2;
+ * }
+ * message User {
+ * string display_name = 1;
+ * string address = 2;
+ * }
+ *
+ * In proto a field mask for `Profile` may look as such:
+ *
+ * mask {
+ * paths: "user.display_name"
+ * paths: "photo"
+ * }
+ *
+ * In JSON, the same mask is represented as below:
+ *
+ * {
+ * mask: "user.displayName,photo"
+ * }
+ *
+ * # Field Masks and Oneof Fields
+ *
+ * Field masks treat fields in oneofs just as regular fields. Consider the
+ * following message:
+ *
+ * message SampleMessage {
+ * oneof test_oneof {
+ * string name = 4;
+ * SubMessage sub_message = 9;
+ * }
+ * }
+ *
+ * The field mask can be:
+ *
+ * mask {
+ * paths: "name"
+ * }
+ *
+ * Or:
+ *
+ * mask {
+ * paths: "sub_message"
+ * }
+ *
+ * Note that oneof type names ("test_oneof" in this case) cannot be used in
+ * paths.
+ *
+ * ## Field Mask Verification
+ *
+ * The implementation of any API method which has a FieldMask type field in the
+ * request should verify the included field paths, and return an
+ * `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
+ **/
@interface GPBFieldMask : GPBMessage
-// The set of field mask paths.
-// |pathsArray| contains |NSString|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *pathsArray;
+/** The set of field mask paths. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *pathsArray;
+/** The number of items in @c pathsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger pathsArray_Count;
@end
@@ -165,4 +276,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/FieldMask.pbobjc.m b/objectivec/google/protobuf/FieldMask.pbobjc.m
index f9684f51..b0915af4 100644
--- a/objectivec/google/protobuf/FieldMask.pbobjc.m
+++ b/objectivec/google/protobuf/FieldMask.pbobjc.m
@@ -1,14 +1,35 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/field_mask.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/FieldMask.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/FieldMask.pbobjc.h>
+#else
+ #import "google/protobuf/FieldMask.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBFieldMaskRoot
@implementation GPBFieldMaskRoot
+// No extensions in the file and no imports, so no need to generate
+// +extensionRegistry.
+
@end
#pragma mark - GPBFieldMaskRoot_FileDescriptor
@@ -18,8 +39,9 @@ static GPBFileDescriptor *GPBFieldMaskRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -44,14 +66,12 @@ typedef struct GPBFieldMask__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "pathsArray",
+ .dataTypeSpecific.className = NULL,
.number = GPBFieldMask_FieldNumber_PathsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBFieldMask__storage_, pathsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBFieldMask__storage_, pathsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -59,15 +79,9 @@ typedef struct GPBFieldMask__storage_ {
rootClass:[GPBFieldMaskRoot class]
file:GPBFieldMaskRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBFieldMask__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -77,4 +91,6 @@ typedef struct GPBFieldMask__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/SourceContext.pbobjc.h b/objectivec/google/protobuf/SourceContext.pbobjc.h
index 8480db1d..e4923959 100644
--- a/objectivec/google/protobuf/SourceContext.pbobjc.h
+++ b/objectivec/google/protobuf/SourceContext.pbobjc.h
@@ -1,27 +1,51 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/source_context.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBSourceContextRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBSourceContextRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBSourceContext
@@ -30,12 +54,16 @@ typedef GPB_ENUM(GPBSourceContext_FieldNumber) {
GPBSourceContext_FieldNumber_FileName = 1,
};
-// `SourceContext` represents information about the source of a
-// protobuf element, like the file in which it is defined.
+/**
+ * `SourceContext` represents information about the source of a
+ * protobuf element, like the file in which it is defined.
+ **/
@interface GPBSourceContext : GPBMessage
-// The path-qualified name of the .proto file that contained the associated
-// protobuf element. For example: `"google/protobuf/source.proto"`.
+/**
+ * The path-qualified name of the .proto file that contained the associated
+ * protobuf element. For example: `"google/protobuf/source_context.proto"`.
+ **/
@property(nonatomic, readwrite, copy, null_resettable) NSString *fileName;
@end
@@ -44,4 +72,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/SourceContext.pbobjc.m b/objectivec/google/protobuf/SourceContext.pbobjc.m
index ac1827fc..83bfa346 100644
--- a/objectivec/google/protobuf/SourceContext.pbobjc.m
+++ b/objectivec/google/protobuf/SourceContext.pbobjc.m
@@ -1,14 +1,35 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/source_context.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/SourceContext.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/SourceContext.pbobjc.h>
+#else
+ #import "google/protobuf/SourceContext.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBSourceContextRoot
@implementation GPBSourceContextRoot
+// No extensions in the file and no imports, so no need to generate
+// +extensionRegistry.
+
@end
#pragma mark - GPBSourceContextRoot_FileDescriptor
@@ -18,8 +39,9 @@ static GPBFileDescriptor *GPBSourceContextRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -44,14 +66,12 @@ typedef struct GPBSourceContext__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "fileName",
+ .dataTypeSpecific.className = NULL,
.number = GPBSourceContext_FieldNumber_FileName,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBSourceContext__storage_, fileName),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBSourceContext__storage_, fileName),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -59,15 +79,9 @@ typedef struct GPBSourceContext__storage_ {
rootClass:[GPBSourceContextRoot class]
file:GPBSourceContextRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBSourceContext__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -77,4 +91,6 @@ typedef struct GPBSourceContext__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Struct.pbobjc.h b/objectivec/google/protobuf/Struct.pbobjc.h
index f40414fa..fb204251 100644
--- a/objectivec/google/protobuf/Struct.pbobjc.h
+++ b/objectivec/google/protobuf/Struct.pbobjc.h
@@ -1,46 +1,82 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/struct.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
@class GPBListValue;
@class GPBStruct;
+@class GPBValue;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum GPBNullValue
-// `NullValue` is a singleton enumeration to represent the null value for the
-// `Value` type union.
-//
-// The JSON representation for `NullValue` is JSON `null`.
+/**
+ * `NullValue` is a singleton enumeration to represent the null value for the
+ * `Value` type union.
+ *
+ * The JSON representation for `NullValue` is JSON `null`.
+ **/
typedef GPB_ENUM(GPBNullValue) {
+ /**
+ * Value used if any message's field encounters a value that is not defined
+ * by this enum. The message will also have C functions to get/set the rawValue
+ * of the field.
+ **/
GPBNullValue_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
- // Null value.
+ /** Null value. */
GPBNullValue_NullValue = 0,
};
GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void);
+/**
+ * Checks to see if the given value is defined by the enum or was not known at
+ * the time this source was generated.
+ **/
BOOL GPBNullValue_IsValidValue(int32_t value);
#pragma mark - GPBStructRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBStructRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBStruct
@@ -49,19 +85,21 @@ typedef GPB_ENUM(GPBStruct_FieldNumber) {
GPBStruct_FieldNumber_Fields = 1,
};
-// `Struct` represents a structured data value, consisting of fields
-// which map to dynamically typed values. In some languages, `Struct`
-// might be supported by a native representation. For example, in
-// scripting languages like JS a struct is represented as an
-// object. The details of that representation are described together
-// with the proto support for the language.
-//
-// The JSON representation for `Struct` is JSON object.
+/**
+ * `Struct` represents a structured data value, consisting of fields
+ * which map to dynamically typed values. In some languages, `Struct`
+ * might be supported by a native representation. For example, in
+ * scripting languages like JS a struct is represented as an
+ * object. The details of that representation are described together
+ * with the proto support for the language.
+ *
+ * The JSON representation for `Struct` is JSON object.
+ **/
@interface GPBStruct : GPBMessage
-// Map of dynamically typed values.
-// |fields| values are |GPBValue|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary *fields;
+/** Unordered map of dynamically typed values. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, GPBValue*> *fields;
+/** The number of items in @c fields without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger fields_Count;
@end
@@ -87,40 +125,54 @@ typedef GPB_ENUM(GPBValue_Kind_OneOfCase) {
GPBValue_Kind_OneOfCase_ListValue = 6,
};
-// `Value` represents a dynamically typed value which can be either
-// null, a number, a string, a boolean, a recursive struct value, or a
-// list of values. A producer of value is expected to set one of that
-// variants, absence of any variant indicates an error.
-//
-// The JSON representation for `Value` is JSON value.
+/**
+ * `Value` represents a dynamically typed value which can be either
+ * null, a number, a string, a boolean, a recursive struct value, or a
+ * list of values. A producer of value is expected to set one of that
+ * variants, absence of any variant indicates an error.
+ *
+ * The JSON representation for `Value` is JSON value.
+ **/
@interface GPBValue : GPBMessage
-// The kind of value.
+/** The kind of value. */
@property(nonatomic, readonly) GPBValue_Kind_OneOfCase kindOneOfCase;
-// Represents a null value.
+/** Represents a null value. */
@property(nonatomic, readwrite) GPBNullValue nullValue;
-// Represents a double value.
+/** Represents a double value. */
@property(nonatomic, readwrite) double numberValue;
-// Represents a string value.
+/** Represents a string value. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *stringValue;
-// Represents a boolean value.
+/** Represents a boolean value. */
@property(nonatomic, readwrite) BOOL boolValue;
-// Represents a structured value.
+/** Represents a structured value. */
@property(nonatomic, readwrite, strong, null_resettable) GPBStruct *structValue;
-// Represents a repeated `Value`.
+/** Represents a repeated `Value`. */
@property(nonatomic, readwrite, strong, null_resettable) GPBListValue *listValue;
@end
+/**
+ * Fetches the raw value of a @c GPBValue's @c nullValue property, even
+ * if the value was not defined by the enum at the time the code was generated.
+ **/
int32_t GPBValue_NullValue_RawValue(GPBValue *message);
+/**
+ * Sets the raw value of an @c GPBValue's @c nullValue property, allowing
+ * it to be set to a value that was not defined by the enum at the time the code
+ * was generated.
+ **/
void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value);
+/**
+ * Clears whatever value was set for the oneof 'kind'.
+ **/
void GPBValue_ClearKindOneOfCase(GPBValue *message);
#pragma mark - GPBListValue
@@ -129,14 +181,16 @@ typedef GPB_ENUM(GPBListValue_FieldNumber) {
GPBListValue_FieldNumber_ValuesArray = 1,
};
-// `ListValue` is a wrapper around a repeated field of values.
-//
-// The JSON representation for `ListValue` is JSON array.
+/**
+ * `ListValue` is a wrapper around a repeated field of values.
+ *
+ * The JSON representation for `ListValue` is JSON array.
+ **/
@interface GPBListValue : GPBMessage
-// Repeated field of dynamically typed values.
-// |valuesArray| contains |GPBValue|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *valuesArray;
+/** Repeated field of dynamically typed values. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBValue*> *valuesArray;
+/** The number of items in @c valuesArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger valuesArray_Count;
@end
@@ -145,4 +199,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Struct.pbobjc.m b/objectivec/google/protobuf/Struct.pbobjc.m
index 14b8f271..816fd6df 100644
--- a/objectivec/google/protobuf/Struct.pbobjc.m
+++ b/objectivec/google/protobuf/Struct.pbobjc.m
@@ -1,14 +1,38 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/struct.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/Struct.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#import <stdatomic.h>
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Struct.pbobjc.h>
+#else
+ #import "google/protobuf/Struct.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
#pragma mark - GPBStructRoot
@implementation GPBStructRoot
+// No extensions in the file and no imports, so no need to generate
+// +extensionRegistry.
+
@end
#pragma mark - GPBStructRoot_FileDescriptor
@@ -18,8 +42,9 @@ static GPBFileDescriptor *GPBStructRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -28,15 +53,23 @@ static GPBFileDescriptor *GPBStructRoot_FileDescriptor(void) {
#pragma mark - Enum GPBNullValue
GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void) {
- static GPBEnumDescriptor *descriptor = NULL;
+ static _Atomic(GPBEnumDescriptor*) descriptor = nil;
if (!descriptor) {
- static GPBMessageEnumValueDescription values[] = {
- { .name = "NullValue", .number = GPBNullValue_NullValue },
+ static const char *valueNames =
+ "NullValue\000";
+ static const int32_t values[] = {
+ GPBNullValue_NullValue,
};
- descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBNullValue)
- values:values
- valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
- enumVerifier:GPBNullValue_IsValidValue];
+ GPBEnumDescriptor *worker =
+ [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBNullValue)
+ valueNames:valueNames
+ values:values
+ count:(uint32_t)(sizeof(values) / sizeof(int32_t))
+ enumVerifier:GPBNullValue_IsValidValue];
+ GPBEnumDescriptor *expected = nil;
+ if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {
+ [worker release];
+ }
}
return descriptor;
}
@@ -69,14 +102,12 @@ typedef struct GPBStruct__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "fields",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBValue),
.number = GPBStruct_FieldNumber_Fields,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBStruct__storage_, fields),
.flags = GPBFieldMapKeyString,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBStruct__storage_, fields),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBValue),
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -84,15 +115,9 @@ typedef struct GPBStruct__storage_ {
rootClass:[GPBStructRoot class]
file:GPBStructRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBStruct__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -115,7 +140,6 @@ typedef struct GPBStruct__storage_ {
typedef struct GPBValue__storage_ {
uint32_t _has_storage_[2];
- BOOL boolValue;
GPBNullValue nullValue;
NSString *stringValue;
GPBStruct *structValue;
@@ -128,78 +152,60 @@ typedef struct GPBValue__storage_ {
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = nil;
if (!descriptor) {
- static GPBMessageOneofDescription oneofs[] = {
- {
- .name = "kind",
- .index = -1,
- },
- };
static GPBMessageFieldDescription fields[] = {
{
.name = "nullValue",
+ .dataTypeSpecific.enumDescFunc = GPBNullValue_EnumDescriptor,
.number = GPBValue_FieldNumber_NullValue,
.hasIndex = -1,
- .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
+ .offset = (uint32_t)offsetof(GPBValue__storage_, nullValue),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor),
.dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBValue__storage_, nullValue),
- .defaultValue.valueEnum = GPBNullValue_NullValue,
- .dataTypeSpecific.enumDescFunc = GPBNullValue_EnumDescriptor,
- .fieldOptions = NULL,
},
{
.name = "numberValue",
+ .dataTypeSpecific.className = NULL,
.number = GPBValue_FieldNumber_NumberValue,
.hasIndex = -1,
+ .offset = (uint32_t)offsetof(GPBValue__storage_, numberValue),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeDouble,
- .offset = offsetof(GPBValue__storage_, numberValue),
- .defaultValue.valueDouble = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "stringValue",
+ .dataTypeSpecific.className = NULL,
.number = GPBValue_FieldNumber_StringValue,
.hasIndex = -1,
+ .offset = (uint32_t)offsetof(GPBValue__storage_, stringValue),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBValue__storage_, stringValue),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "boolValue",
+ .dataTypeSpecific.className = NULL,
.number = GPBValue_FieldNumber_BoolValue,
.hasIndex = -1,
+ .offset = 0, // Stored in _has_storage_ to save space.
.flags = GPBFieldOptional,
.dataType = GPBDataTypeBool,
- .offset = offsetof(GPBValue__storage_, boolValue),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "structValue",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBStruct),
.number = GPBValue_FieldNumber_StructValue,
.hasIndex = -1,
+ .offset = (uint32_t)offsetof(GPBValue__storage_, structValue),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBValue__storage_, structValue),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBStruct),
- .fieldOptions = NULL,
},
{
.name = "listValue",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBListValue),
.number = GPBValue_FieldNumber_ListValue,
.hasIndex = -1,
+ .offset = (uint32_t)offsetof(GPBValue__storage_, listValue),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBValue__storage_, listValue),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBListValue),
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -207,15 +213,15 @@ typedef struct GPBValue__storage_ {
rootClass:[GPBStructRoot class]
file:GPBStructRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:oneofs
- oneofCount:sizeof(oneofs) / sizeof(GPBMessageOneofDescription)
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBValue__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
+ static const char *oneofs[] = {
+ "kind",
+ };
+ [localDescriptor setupOneofs:oneofs
+ count:(uint32_t)(sizeof(oneofs) / sizeof(char*))
+ firstHasIndex:-1];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -238,8 +244,8 @@ void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value) {
void GPBValue_ClearKindOneOfCase(GPBValue *message) {
GPBDescriptor *descriptor = [message descriptor];
- GPBOneofDescriptor *oneof = descriptor->oneofs_[0];
- GPBMaybeClearOneof(message, oneof, 0);
+ GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0];
+ GPBMaybeClearOneof(message, oneof, -1, 0);
}
#pragma mark - GPBListValue
@@ -260,14 +266,12 @@ typedef struct GPBListValue__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "valuesArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBValue),
.number = GPBListValue_FieldNumber_ValuesArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBListValue__storage_, valuesArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBListValue__storage_, valuesArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBValue),
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -275,15 +279,9 @@ typedef struct GPBListValue__storage_ {
rootClass:[GPBStructRoot class]
file:GPBStructRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBListValue__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -293,4 +291,6 @@ typedef struct GPBListValue__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Timestamp.pbobjc.h b/objectivec/google/protobuf/Timestamp.pbobjc.h
index 79b24ec6..2c4b8b20 100644
--- a/objectivec/google/protobuf/Timestamp.pbobjc.h
+++ b/objectivec/google/protobuf/Timestamp.pbobjc.h
@@ -1,27 +1,51 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/timestamp.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBTimestampRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBTimestampRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBTimestamp
@@ -31,70 +55,101 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
GPBTimestamp_FieldNumber_Nanos = 2,
};
-// A Timestamp represents a point in time independent of any time zone
-// or calendar, represented as seconds and fractions of seconds at
-// nanosecond resolution in UTC Epoch time. It is encoded using the
-// Proleptic Gregorian Calendar which extends the Gregorian calendar
-// backwards to year one. It is encoded assuming all minutes are 60
-// seconds long, i.e. leap seconds are "smeared" so that no leap second
-// table is needed for interpretation. Range is from
-// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
-// By restricting to that range, we ensure that we can convert to
-// and from RFC 3339 date strings.
-// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
-//
-// Example 1: Compute Timestamp from POSIX `time()`.
-//
-// Timestamp timestamp;
-// timestamp.set_seconds(time(NULL));
-// timestamp.set_nanos(0);
-//
-// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
-//
-// struct timeval tv;
-// gettimeofday(&tv, NULL);
-//
-// Timestamp timestamp;
-// timestamp.set_seconds(tv.tv_sec);
-// timestamp.set_nanos(tv.tv_usec * 1000);
-//
-// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
-//
-// FILETIME ft;
-// GetSystemTimeAsFileTime(&ft);
-// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
-//
-// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
-// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
-// Timestamp timestamp;
-// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
-// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
-//
-// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
-//
-// long millis = System.currentTimeMillis();
-//
-// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
-// .setNanos((int) ((millis % 1000) * 1000000)).build();
-//
-//
-// Example 5: Compute Timestamp from current time in Python.
-//
-// now = time.time()
-// seconds = int(now)
-// nanos = int((now - seconds) * 10**9)
-// timestamp = Timestamp(seconds=seconds, nanos=nanos)
+/**
+ * A Timestamp represents a point in time independent of any time zone
+ * or calendar, represented as seconds and fractions of seconds at
+ * nanosecond resolution in UTC Epoch time. It is encoded using the
+ * Proleptic Gregorian Calendar which extends the Gregorian calendar
+ * backwards to year one. It is encoded assuming all minutes are 60
+ * seconds long, i.e. leap seconds are "smeared" so that no leap second
+ * table is needed for interpretation. Range is from
+ * 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
+ * By restricting to that range, we ensure that we can convert to
+ * and from RFC 3339 date strings.
+ * See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
+ *
+ * # Examples
+ *
+ * Example 1: Compute Timestamp from POSIX `time()`.
+ *
+ * Timestamp timestamp;
+ * timestamp.set_seconds(time(NULL));
+ * timestamp.set_nanos(0);
+ *
+ * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
+ *
+ * struct timeval tv;
+ * gettimeofday(&tv, NULL);
+ *
+ * Timestamp timestamp;
+ * timestamp.set_seconds(tv.tv_sec);
+ * timestamp.set_nanos(tv.tv_usec * 1000);
+ *
+ * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
+ *
+ * FILETIME ft;
+ * GetSystemTimeAsFileTime(&ft);
+ * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
+ *
+ * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
+ * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
+ * Timestamp timestamp;
+ * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
+ * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
+ *
+ * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
+ *
+ * long millis = System.currentTimeMillis();
+ *
+ * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
+ * .setNanos((int) ((millis % 1000) * 1000000)).build();
+ *
+ *
+ * Example 5: Compute Timestamp from current time in Python.
+ *
+ * timestamp = Timestamp()
+ * timestamp.GetCurrentTime()
+ *
+ * # JSON Mapping
+ *
+ * In JSON format, the Timestamp type is encoded as a string in the
+ * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
+ * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
+ * where {year} is always expressed using four digits while {month}, {day},
+ * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
+ * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
+ * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
+ * is required. A proto3 JSON serializer should always use UTC (as indicated by
+ * "Z") when printing the Timestamp type and a proto3 JSON parser should be
+ * able to accept both UTC and other timezones (as indicated by an offset).
+ *
+ * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
+ * 01:30 UTC on January 15, 2017.
+ *
+ * In JavaScript, one can convert a Date object to this format using the
+ * standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
+ * method. In Python, a standard `datetime.datetime` object can be converted
+ * to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
+ * with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
+ * can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
+ * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
+ * ) to obtain a formatter capable of generating timestamps in this format.
+ **/
@interface GPBTimestamp : GPBMessage
-// Represents seconds of UTC time since Unix epoch
-// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
-// 9999-12-31T23:59:59Z inclusive.
+/**
+ * Represents seconds of UTC time since Unix epoch
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
+ * 9999-12-31T23:59:59Z inclusive.
+ **/
@property(nonatomic, readwrite) int64_t seconds;
-// Non-negative fractions of a second at nanosecond resolution. Negative
-// second values with fractions must still have non-negative nanos values
-// that count forward in time. Must be from 0 to 999,999,999
-// inclusive.
+/**
+ * Non-negative fractions of a second at nanosecond resolution. Negative
+ * second values with fractions must still have non-negative nanos values
+ * that count forward in time. Must be from 0 to 999,999,999
+ * inclusive.
+ **/
@property(nonatomic, readwrite) int32_t nanos;
@end
@@ -103,4 +158,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Timestamp.pbobjc.m b/objectivec/google/protobuf/Timestamp.pbobjc.m
index a206f159..4ab159fb 100644
--- a/objectivec/google/protobuf/Timestamp.pbobjc.m
+++ b/objectivec/google/protobuf/Timestamp.pbobjc.m
@@ -1,14 +1,35 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/timestamp.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/Timestamp.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Timestamp.pbobjc.h>
+#else
+ #import "google/protobuf/Timestamp.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBTimestampRoot
@implementation GPBTimestampRoot
+// No extensions in the file and no imports, so no need to generate
+// +extensionRegistry.
+
@end
#pragma mark - GPBTimestampRoot_FileDescriptor
@@ -18,8 +39,9 @@ static GPBFileDescriptor *GPBTimestampRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -46,25 +68,21 @@ typedef struct GPBTimestamp__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "seconds",
+ .dataTypeSpecific.className = NULL,
.number = GPBTimestamp_FieldNumber_Seconds,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBTimestamp__storage_, seconds),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt64,
- .offset = offsetof(GPBTimestamp__storage_, seconds),
- .defaultValue.valueInt64 = 0LL,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "nanos",
+ .dataTypeSpecific.className = NULL,
.number = GPBTimestamp_FieldNumber_Nanos,
.hasIndex = 1,
+ .offset = (uint32_t)offsetof(GPBTimestamp__storage_, nanos),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBTimestamp__storage_, nanos),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -72,15 +90,9 @@ typedef struct GPBTimestamp__storage_ {
rootClass:[GPBTimestampRoot class]
file:GPBTimestampRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBTimestamp__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -90,4 +102,6 @@ typedef struct GPBTimestamp__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Type.pbobjc.h b/objectivec/google/protobuf/Type.pbobjc.h
index e4c7a251..e14d15df 100644
--- a/objectivec/google/protobuf/Type.pbobjc.h
+++ b/objectivec/google/protobuf/Type.pbobjc.h
@@ -1,135 +1,189 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/type.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
@class GPBAny;
+@class GPBEnumValue;
+@class GPBField;
+@class GPBOption;
@class GPBSourceContext;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum GPBSyntax
-// The syntax in which a protocol buffer element is defined.
+/** The syntax in which a protocol buffer element is defined. */
typedef GPB_ENUM(GPBSyntax) {
+ /**
+ * Value used if any message's field encounters a value that is not defined
+ * by this enum. The message will also have C functions to get/set the rawValue
+ * of the field.
+ **/
GPBSyntax_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
- // Syntax `proto2`.
+ /** Syntax `proto2`. */
GPBSyntax_SyntaxProto2 = 0,
- // Syntax `proto3`.
+ /** Syntax `proto3`. */
GPBSyntax_SyntaxProto3 = 1,
};
GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void);
+/**
+ * Checks to see if the given value is defined by the enum or was not known at
+ * the time this source was generated.
+ **/
BOOL GPBSyntax_IsValidValue(int32_t value);
#pragma mark - Enum GPBField_Kind
-// Basic field types.
+/** Basic field types. */
typedef GPB_ENUM(GPBField_Kind) {
+ /**
+ * Value used if any message's field encounters a value that is not defined
+ * by this enum. The message will also have C functions to get/set the rawValue
+ * of the field.
+ **/
GPBField_Kind_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
- // Field type unknown.
+ /** Field type unknown. */
GPBField_Kind_TypeUnknown = 0,
- // Field type double.
+ /** Field type double. */
GPBField_Kind_TypeDouble = 1,
- // Field type float.
+ /** Field type float. */
GPBField_Kind_TypeFloat = 2,
- // Field type int64.
+ /** Field type int64. */
GPBField_Kind_TypeInt64 = 3,
- // Field type uint64.
+ /** Field type uint64. */
GPBField_Kind_TypeUint64 = 4,
- // Field type int32.
+ /** Field type int32. */
GPBField_Kind_TypeInt32 = 5,
- // Field type fixed64.
+ /** Field type fixed64. */
GPBField_Kind_TypeFixed64 = 6,
- // Field type fixed32.
+ /** Field type fixed32. */
GPBField_Kind_TypeFixed32 = 7,
- // Field type bool.
+ /** Field type bool. */
GPBField_Kind_TypeBool = 8,
- // Field type string.
+ /** Field type string. */
GPBField_Kind_TypeString = 9,
- // Field type group. Proto2 syntax only, and deprecated.
+ /** Field type group. Proto2 syntax only, and deprecated. */
GPBField_Kind_TypeGroup = 10,
- // Field type message.
+ /** Field type message. */
GPBField_Kind_TypeMessage = 11,
- // Field type bytes.
+ /** Field type bytes. */
GPBField_Kind_TypeBytes = 12,
- // Field type uint32.
+ /** Field type uint32. */
GPBField_Kind_TypeUint32 = 13,
- // Field type enum.
+ /** Field type enum. */
GPBField_Kind_TypeEnum = 14,
- // Field type sfixed32.
+ /** Field type sfixed32. */
GPBField_Kind_TypeSfixed32 = 15,
- // Field type sfixed64.
+ /** Field type sfixed64. */
GPBField_Kind_TypeSfixed64 = 16,
- // Field type sint32.
+ /** Field type sint32. */
GPBField_Kind_TypeSint32 = 17,
- // Field type sint64.
+ /** Field type sint64. */
GPBField_Kind_TypeSint64 = 18,
};
GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void);
+/**
+ * Checks to see if the given value is defined by the enum or was not known at
+ * the time this source was generated.
+ **/
BOOL GPBField_Kind_IsValidValue(int32_t value);
#pragma mark - Enum GPBField_Cardinality
-// Whether a field is optional, required, or repeated.
+/** Whether a field is optional, required, or repeated. */
typedef GPB_ENUM(GPBField_Cardinality) {
+ /**
+ * Value used if any message's field encounters a value that is not defined
+ * by this enum. The message will also have C functions to get/set the rawValue
+ * of the field.
+ **/
GPBField_Cardinality_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
- // For fields with unknown cardinality.
+ /** For fields with unknown cardinality. */
GPBField_Cardinality_CardinalityUnknown = 0,
- // For optional fields.
+ /** For optional fields. */
GPBField_Cardinality_CardinalityOptional = 1,
- // For required fields. Proto2 syntax only.
+ /** For required fields. Proto2 syntax only. */
GPBField_Cardinality_CardinalityRequired = 2,
- // For repeated fields.
+ /** For repeated fields. */
GPBField_Cardinality_CardinalityRepeated = 3,
};
GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void);
+/**
+ * Checks to see if the given value is defined by the enum or was not known at
+ * the time this source was generated.
+ **/
BOOL GPBField_Cardinality_IsValidValue(int32_t value);
#pragma mark - GPBTypeRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBTypeRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBType
@@ -143,37 +197,49 @@ typedef GPB_ENUM(GPBType_FieldNumber) {
GPBType_FieldNumber_Syntax = 6,
};
-// A protocol buffer message type.
+/**
+ * A protocol buffer message type.
+ **/
@interface GPBType : GPBMessage
-// The fully qualified message name.
+/** The fully qualified message name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-// The list of fields.
-// |fieldsArray| contains |GPBField|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fieldsArray;
+/** The list of fields. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBField*> *fieldsArray;
+/** The number of items in @c fieldsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger fieldsArray_Count;
-// The list of types appearing in `oneof` definitions in this type.
-// |oneofsArray| contains |NSString|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *oneofsArray;
+/** The list of types appearing in `oneof` definitions in this type. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *oneofsArray;
+/** The number of items in @c oneofsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger oneofsArray_Count;
-// The protocol buffer options.
-// |optionsArray| contains |GPBOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
+/** The protocol buffer options. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
-// The source context.
-@property(nonatomic, readwrite) BOOL hasSourceContext;
+/** The source context. */
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
+/** Test to see if @c sourceContext has been set. */
+@property(nonatomic, readwrite) BOOL hasSourceContext;
-// The source syntax.
+/** The source syntax. */
@property(nonatomic, readwrite) GPBSyntax syntax;
@end
+/**
+ * Fetches the raw value of a @c GPBType's @c syntax property, even
+ * if the value was not defined by the enum at the time the code was generated.
+ **/
int32_t GPBType_Syntax_RawValue(GPBType *message);
+/**
+ * Sets the raw value of an @c GPBType's @c syntax property, allowing
+ * it to be set to a value that was not defined by the enum at the time the code
+ * was generated.
+ **/
void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value);
#pragma mark - GPBField
@@ -191,49 +257,73 @@ typedef GPB_ENUM(GPBField_FieldNumber) {
GPBField_FieldNumber_DefaultValue = 11,
};
-// A single field of a message type.
+/**
+ * A single field of a message type.
+ **/
@interface GPBField : GPBMessage
-// The field type.
+/** The field type. */
@property(nonatomic, readwrite) GPBField_Kind kind;
-// The field cardinality.
+/** The field cardinality. */
@property(nonatomic, readwrite) GPBField_Cardinality cardinality;
-// The field number.
+/** The field number. */
@property(nonatomic, readwrite) int32_t number;
-// The field name.
+/** The field name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-// The field type URL, without the scheme, for message or enumeration
-// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
+/**
+ * The field type URL, without the scheme, for message or enumeration
+ * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
+ **/
@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
-// The index of the field type in `Type.oneofs`, for message or enumeration
-// types. The first type has index 1; zero means the type is not in the list.
+/**
+ * The index of the field type in `Type.oneofs`, for message or enumeration
+ * types. The first type has index 1; zero means the type is not in the list.
+ **/
@property(nonatomic, readwrite) int32_t oneofIndex;
-// Whether to use alternative packed wire representation.
+/** Whether to use alternative packed wire representation. */
@property(nonatomic, readwrite) BOOL packed;
-// The protocol buffer options.
-// |optionsArray| contains |GPBOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
+/** The protocol buffer options. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
-// The field JSON name.
+/** The field JSON name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName;
-// The string value of the default value of this field. Proto2 syntax only.
+/** The string value of the default value of this field. Proto2 syntax only. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue;
@end
+/**
+ * Fetches the raw value of a @c GPBField's @c kind property, even
+ * if the value was not defined by the enum at the time the code was generated.
+ **/
int32_t GPBField_Kind_RawValue(GPBField *message);
+/**
+ * Sets the raw value of an @c GPBField's @c kind property, allowing
+ * it to be set to a value that was not defined by the enum at the time the code
+ * was generated.
+ **/
void SetGPBField_Kind_RawValue(GPBField *message, int32_t value);
+/**
+ * Fetches the raw value of a @c GPBField's @c cardinality property, even
+ * if the value was not defined by the enum at the time the code was generated.
+ **/
int32_t GPBField_Cardinality_RawValue(GPBField *message);
+/**
+ * Sets the raw value of an @c GPBField's @c cardinality property, allowing
+ * it to be set to a value that was not defined by the enum at the time the code
+ * was generated.
+ **/
void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value);
#pragma mark - GPBEnum
@@ -246,32 +336,44 @@ typedef GPB_ENUM(GPBEnum_FieldNumber) {
GPBEnum_FieldNumber_Syntax = 5,
};
-// Enum type definition.
+/**
+ * Enum type definition.
+ **/
@interface GPBEnum : GPBMessage
-// Enum type name.
+/** Enum type name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-// Enum value definitions.
-// |enumvalueArray| contains |GPBEnumValue|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumvalueArray;
+/** Enum value definitions. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBEnumValue*> *enumvalueArray;
+/** The number of items in @c enumvalueArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger enumvalueArray_Count;
-// Protocol buffer options.
-// |optionsArray| contains |GPBOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
+/** Protocol buffer options. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
-// The source context.
-@property(nonatomic, readwrite) BOOL hasSourceContext;
+/** The source context. */
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
+/** Test to see if @c sourceContext has been set. */
+@property(nonatomic, readwrite) BOOL hasSourceContext;
-// The source syntax.
+/** The source syntax. */
@property(nonatomic, readwrite) GPBSyntax syntax;
@end
+/**
+ * Fetches the raw value of a @c GPBEnum's @c syntax property, even
+ * if the value was not defined by the enum at the time the code was generated.
+ **/
int32_t GPBEnum_Syntax_RawValue(GPBEnum *message);
+/**
+ * Sets the raw value of an @c GPBEnum's @c syntax property, allowing
+ * it to be set to a value that was not defined by the enum at the time the code
+ * was generated.
+ **/
void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value);
#pragma mark - GPBEnumValue
@@ -282,18 +384,20 @@ typedef GPB_ENUM(GPBEnumValue_FieldNumber) {
GPBEnumValue_FieldNumber_OptionsArray = 3,
};
-// Enum value definition.
+/**
+ * Enum value definition.
+ **/
@interface GPBEnumValue : GPBMessage
-// Enum value name.
+/** Enum value name. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-// Enum value number.
+/** Enum value number. */
@property(nonatomic, readwrite) int32_t number;
-// Protocol buffer options.
-// |optionsArray| contains |GPBOption|
-@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
+/** Protocol buffer options. */
+@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/** The number of items in @c optionsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
@end
@@ -305,16 +409,29 @@ typedef GPB_ENUM(GPBOption_FieldNumber) {
GPBOption_FieldNumber_Value = 2,
};
-// A protocol buffer option, which can be attached to a message, field,
-// enumeration, etc.
+/**
+ * A protocol buffer option, which can be attached to a message, field,
+ * enumeration, etc.
+ **/
@interface GPBOption : GPBMessage
-// The option's name. For example, `"java_package"`.
+/**
+ * The option's name. For protobuf built-in options (options defined in
+ * descriptor.proto), this is the short name. For example, `"map_entry"`.
+ * For custom options, it should be the fully-qualified name. For example,
+ * `"google.api.http"`.
+ **/
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-// The option's value. For example, `"com.google.protobuf"`.
-@property(nonatomic, readwrite) BOOL hasValue;
+/**
+ * The option's value packed in an Any message. If the value is a primitive,
+ * the corresponding wrapper type defined in google/protobuf/wrappers.proto
+ * should be used. If the value is an enum, it should be stored as an int32
+ * value using the google.protobuf.Int32Value type.
+ **/
@property(nonatomic, readwrite, strong, null_resettable) GPBAny *value;
+/** Test to see if @c value has been set. */
+@property(nonatomic, readwrite) BOOL hasValue;
@end
@@ -322,4 +439,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Type.pbobjc.m b/objectivec/google/protobuf/Type.pbobjc.m
index b4e0a5f6..bb64d876 100644
--- a/objectivec/google/protobuf/Type.pbobjc.m
+++ b/objectivec/google/protobuf/Type.pbobjc.m
@@ -1,28 +1,40 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/type.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/Type.pbobjc.h"
-#import "google/protobuf/Any.pbobjc.h"
-#import "google/protobuf/SourceContext.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#import <stdatomic.h>
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Type.pbobjc.h>
+ #import <Protobuf/Any.pbobjc.h>
+ #import <Protobuf/SourceContext.pbobjc.h>
+#else
+ #import "google/protobuf/Type.pbobjc.h"
+ #import "google/protobuf/Any.pbobjc.h"
+ #import "google/protobuf/SourceContext.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBTypeRoot
@implementation GPBTypeRoot
-+ (GPBExtensionRegistry*)extensionRegistry {
- // This is called by +initialize so there is no need to worry
- // about thread safety and initialization of registry.
- static GPBExtensionRegistry* registry = nil;
- if (!registry) {
- GPBDebugCheckRuntimeVersion();
- registry = [[GPBExtensionRegistry alloc] init];
- [registry addExtensions:[GPBAnyRoot extensionRegistry]];
- [registry addExtensions:[GPBSourceContextRoot extensionRegistry]];
- }
- return registry;
-}
+// No extensions in the file and none of the imports (direct or indirect)
+// defined extensions, so no need to generate +extensionRegistry.
@end
@@ -33,8 +45,9 @@ static GPBFileDescriptor *GPBTypeRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -43,16 +56,24 @@ static GPBFileDescriptor *GPBTypeRoot_FileDescriptor(void) {
#pragma mark - Enum GPBSyntax
GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void) {
- static GPBEnumDescriptor *descriptor = NULL;
+ static _Atomic(GPBEnumDescriptor*) descriptor = nil;
if (!descriptor) {
- static GPBMessageEnumValueDescription values[] = {
- { .name = "SyntaxProto2", .number = GPBSyntax_SyntaxProto2 },
- { .name = "SyntaxProto3", .number = GPBSyntax_SyntaxProto3 },
+ static const char *valueNames =
+ "SyntaxProto2\000SyntaxProto3\000";
+ static const int32_t values[] = {
+ GPBSyntax_SyntaxProto2,
+ GPBSyntax_SyntaxProto3,
};
- descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBSyntax)
- values:values
- valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
- enumVerifier:GPBSyntax_IsValidValue];
+ GPBEnumDescriptor *worker =
+ [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBSyntax)
+ valueNames:valueNames
+ values:values
+ count:(uint32_t)(sizeof(values) / sizeof(int32_t))
+ enumVerifier:GPBSyntax_IsValidValue];
+ GPBEnumDescriptor *expected = nil;
+ if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {
+ [worker release];
+ }
}
return descriptor;
}
@@ -96,69 +117,57 @@ typedef struct GPBType__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "name",
+ .dataTypeSpecific.className = NULL,
.number = GPBType_FieldNumber_Name,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBType__storage_, name),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBType__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "fieldsArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBField),
.number = GPBType_FieldNumber_FieldsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBType__storage_, fieldsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBType__storage_, fieldsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBField),
- .fieldOptions = NULL,
},
{
.name = "oneofsArray",
+ .dataTypeSpecific.className = NULL,
.number = GPBType_FieldNumber_OneofsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBType__storage_, oneofsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBType__storage_, oneofsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "optionsArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
.number = GPBType_FieldNumber_OptionsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBType__storage_, optionsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBType__storage_, optionsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
- .fieldOptions = NULL,
},
{
.name = "sourceContext",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext),
.number = GPBType_FieldNumber_SourceContext,
- .hasIndex = 4,
+ .hasIndex = 1,
+ .offset = (uint32_t)offsetof(GPBType__storage_, sourceContext),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBType__storage_, sourceContext),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext),
- .fieldOptions = NULL,
},
{
.name = "syntax",
+ .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
.number = GPBType_FieldNumber_Syntax,
- .hasIndex = 5,
- .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
+ .hasIndex = 2,
+ .offset = (uint32_t)offsetof(GPBType__storage_, syntax),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor),
.dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBType__storage_, syntax),
- .defaultValue.valueEnum = GPBSyntax_SyntaxProto2,
- .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -166,15 +175,9 @@ typedef struct GPBType__storage_ {
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBType__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -212,7 +215,6 @@ void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value) {
typedef struct GPBField__storage_ {
uint32_t _has_storage_[1];
- BOOL packed;
GPBField_Kind kind;
GPBField_Cardinality cardinality;
int32_t number;
@@ -232,139 +234,108 @@ typedef struct GPBField__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "kind",
+ .dataTypeSpecific.enumDescFunc = GPBField_Kind_EnumDescriptor,
.number = GPBField_FieldNumber_Kind,
.hasIndex = 0,
- .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
+ .offset = (uint32_t)offsetof(GPBField__storage_, kind),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor),
.dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBField__storage_, kind),
- .defaultValue.valueEnum = GPBField_Kind_TypeUnknown,
- .dataTypeSpecific.enumDescFunc = GPBField_Kind_EnumDescriptor,
- .fieldOptions = NULL,
},
{
.name = "cardinality",
+ .dataTypeSpecific.enumDescFunc = GPBField_Cardinality_EnumDescriptor,
.number = GPBField_FieldNumber_Cardinality,
.hasIndex = 1,
- .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
+ .offset = (uint32_t)offsetof(GPBField__storage_, cardinality),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor),
.dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBField__storage_, cardinality),
- .defaultValue.valueEnum = GPBField_Cardinality_CardinalityUnknown,
- .dataTypeSpecific.enumDescFunc = GPBField_Cardinality_EnumDescriptor,
- .fieldOptions = NULL,
},
{
.name = "number",
+ .dataTypeSpecific.className = NULL,
.number = GPBField_FieldNumber_Number,
.hasIndex = 2,
+ .offset = (uint32_t)offsetof(GPBField__storage_, number),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBField__storage_, number),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "name",
+ .dataTypeSpecific.className = NULL,
.number = GPBField_FieldNumber_Name,
.hasIndex = 3,
+ .offset = (uint32_t)offsetof(GPBField__storage_, name),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBField__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "typeURL",
+ .dataTypeSpecific.className = NULL,
.number = GPBField_FieldNumber_TypeURL,
.hasIndex = 4,
- .flags = GPBFieldOptional | GPBFieldTextFormatNameCustom,
+ .offset = (uint32_t)offsetof(GPBField__storage_, typeURL),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom),
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBField__storage_, typeURL),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "oneofIndex",
+ .dataTypeSpecific.className = NULL,
.number = GPBField_FieldNumber_OneofIndex,
.hasIndex = 5,
+ .offset = (uint32_t)offsetof(GPBField__storage_, oneofIndex),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBField__storage_, oneofIndex),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "packed",
+ .dataTypeSpecific.className = NULL,
.number = GPBField_FieldNumber_Packed,
.hasIndex = 6,
+ .offset = 7, // Stored in _has_storage_ to save space.
.flags = GPBFieldOptional,
.dataType = GPBDataTypeBool,
- .offset = offsetof(GPBField__storage_, packed),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "optionsArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
.number = GPBField_FieldNumber_OptionsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBField__storage_, optionsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBField__storage_, optionsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
- .fieldOptions = NULL,
},
{
.name = "jsonName",
+ .dataTypeSpecific.className = NULL,
.number = GPBField_FieldNumber_JsonName,
.hasIndex = 8,
+ .offset = (uint32_t)offsetof(GPBField__storage_, jsonName),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBField__storage_, jsonName),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "defaultValue",
+ .dataTypeSpecific.className = NULL,
.number = GPBField_FieldNumber_DefaultValue,
.hasIndex = 9,
+ .offset = (uint32_t)offsetof(GPBField__storage_, defaultValue),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBField__storage_, defaultValue),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
- static GPBMessageEnumDescription enums[] = {
- { .enumDescriptorFunc = GPBField_Kind_EnumDescriptor },
- { .enumDescriptorFunc = GPBField_Cardinality_EnumDescriptor },
- };
-#if GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
- const char *extraTextFormatInfo = NULL;
-#else
- static const char *extraTextFormatInfo = "\001\006\004\241!!\000";
-#endif // GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBField class]
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:enums
- enumCount:sizeof(enums) / sizeof(GPBMessageEnumDescription)
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBField__storage_)
- wireFormat:NO
- extraTextFormatInfo:extraTextFormatInfo];
+ flags:GPBDescriptorInitializationFlag_None];
+#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
+ static const char *extraTextFormatInfo =
+ "\001\006\004\241!!\000";
+ [localDescriptor setupExtraTextInfo:extraTextFormatInfo];
+#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -400,33 +371,46 @@ void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value) {
#pragma mark - Enum GPBField_Kind
GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void) {
- static GPBEnumDescriptor *descriptor = NULL;
+ static _Atomic(GPBEnumDescriptor*) descriptor = nil;
if (!descriptor) {
- static GPBMessageEnumValueDescription values[] = {
- { .name = "TypeUnknown", .number = GPBField_Kind_TypeUnknown },
- { .name = "TypeDouble", .number = GPBField_Kind_TypeDouble },
- { .name = "TypeFloat", .number = GPBField_Kind_TypeFloat },
- { .name = "TypeInt64", .number = GPBField_Kind_TypeInt64 },
- { .name = "TypeUint64", .number = GPBField_Kind_TypeUint64 },
- { .name = "TypeInt32", .number = GPBField_Kind_TypeInt32 },
- { .name = "TypeFixed64", .number = GPBField_Kind_TypeFixed64 },
- { .name = "TypeFixed32", .number = GPBField_Kind_TypeFixed32 },
- { .name = "TypeBool", .number = GPBField_Kind_TypeBool },
- { .name = "TypeString", .number = GPBField_Kind_TypeString },
- { .name = "TypeGroup", .number = GPBField_Kind_TypeGroup },
- { .name = "TypeMessage", .number = GPBField_Kind_TypeMessage },
- { .name = "TypeBytes", .number = GPBField_Kind_TypeBytes },
- { .name = "TypeUint32", .number = GPBField_Kind_TypeUint32 },
- { .name = "TypeEnum", .number = GPBField_Kind_TypeEnum },
- { .name = "TypeSfixed32", .number = GPBField_Kind_TypeSfixed32 },
- { .name = "TypeSfixed64", .number = GPBField_Kind_TypeSfixed64 },
- { .name = "TypeSint32", .number = GPBField_Kind_TypeSint32 },
- { .name = "TypeSint64", .number = GPBField_Kind_TypeSint64 },
+ static const char *valueNames =
+ "TypeUnknown\000TypeDouble\000TypeFloat\000TypeInt"
+ "64\000TypeUint64\000TypeInt32\000TypeFixed64\000Type"
+ "Fixed32\000TypeBool\000TypeString\000TypeGroup\000Ty"
+ "peMessage\000TypeBytes\000TypeUint32\000TypeEnum\000"
+ "TypeSfixed32\000TypeSfixed64\000TypeSint32\000Typ"
+ "eSint64\000";
+ static const int32_t values[] = {
+ GPBField_Kind_TypeUnknown,
+ GPBField_Kind_TypeDouble,
+ GPBField_Kind_TypeFloat,
+ GPBField_Kind_TypeInt64,
+ GPBField_Kind_TypeUint64,
+ GPBField_Kind_TypeInt32,
+ GPBField_Kind_TypeFixed64,
+ GPBField_Kind_TypeFixed32,
+ GPBField_Kind_TypeBool,
+ GPBField_Kind_TypeString,
+ GPBField_Kind_TypeGroup,
+ GPBField_Kind_TypeMessage,
+ GPBField_Kind_TypeBytes,
+ GPBField_Kind_TypeUint32,
+ GPBField_Kind_TypeEnum,
+ GPBField_Kind_TypeSfixed32,
+ GPBField_Kind_TypeSfixed64,
+ GPBField_Kind_TypeSint32,
+ GPBField_Kind_TypeSint64,
};
- descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Kind)
- values:values
- valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
- enumVerifier:GPBField_Kind_IsValidValue];
+ GPBEnumDescriptor *worker =
+ [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Kind)
+ valueNames:valueNames
+ values:values
+ count:(uint32_t)(sizeof(values) / sizeof(int32_t))
+ enumVerifier:GPBField_Kind_IsValidValue];
+ GPBEnumDescriptor *expected = nil;
+ if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {
+ [worker release];
+ }
}
return descriptor;
}
@@ -461,18 +445,27 @@ BOOL GPBField_Kind_IsValidValue(int32_t value__) {
#pragma mark - Enum GPBField_Cardinality
GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void) {
- static GPBEnumDescriptor *descriptor = NULL;
+ static _Atomic(GPBEnumDescriptor*) descriptor = nil;
if (!descriptor) {
- static GPBMessageEnumValueDescription values[] = {
- { .name = "CardinalityUnknown", .number = GPBField_Cardinality_CardinalityUnknown },
- { .name = "CardinalityOptional", .number = GPBField_Cardinality_CardinalityOptional },
- { .name = "CardinalityRequired", .number = GPBField_Cardinality_CardinalityRequired },
- { .name = "CardinalityRepeated", .number = GPBField_Cardinality_CardinalityRepeated },
+ static const char *valueNames =
+ "CardinalityUnknown\000CardinalityOptional\000C"
+ "ardinalityRequired\000CardinalityRepeated\000";
+ static const int32_t values[] = {
+ GPBField_Cardinality_CardinalityUnknown,
+ GPBField_Cardinality_CardinalityOptional,
+ GPBField_Cardinality_CardinalityRequired,
+ GPBField_Cardinality_CardinalityRepeated,
};
- descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Cardinality)
- values:values
- valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
- enumVerifier:GPBField_Cardinality_IsValidValue];
+ GPBEnumDescriptor *worker =
+ [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Cardinality)
+ valueNames:valueNames
+ values:values
+ count:(uint32_t)(sizeof(values) / sizeof(int32_t))
+ enumVerifier:GPBField_Cardinality_IsValidValue];
+ GPBEnumDescriptor *expected = nil;
+ if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {
+ [worker release];
+ }
}
return descriptor;
}
@@ -516,58 +509,48 @@ typedef struct GPBEnum__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "name",
+ .dataTypeSpecific.className = NULL,
.number = GPBEnum_FieldNumber_Name,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBEnum__storage_, name),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBEnum__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "enumvalueArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumValue),
.number = GPBEnum_FieldNumber_EnumvalueArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBEnum__storage_, enumvalueArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBEnum__storage_, enumvalueArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumValue),
- .fieldOptions = NULL,
},
{
.name = "optionsArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
.number = GPBEnum_FieldNumber_OptionsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBEnum__storage_, optionsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBEnum__storage_, optionsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
- .fieldOptions = NULL,
},
{
.name = "sourceContext",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext),
.number = GPBEnum_FieldNumber_SourceContext,
- .hasIndex = 3,
+ .hasIndex = 1,
+ .offset = (uint32_t)offsetof(GPBEnum__storage_, sourceContext),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBEnum__storage_, sourceContext),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext),
- .fieldOptions = NULL,
},
{
.name = "syntax",
+ .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
.number = GPBEnum_FieldNumber_Syntax,
- .hasIndex = 4,
- .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
+ .hasIndex = 2,
+ .offset = (uint32_t)offsetof(GPBEnum__storage_, syntax),
+ .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor),
.dataType = GPBDataTypeEnum,
- .offset = offsetof(GPBEnum__storage_, syntax),
- .defaultValue.valueEnum = GPBSyntax_SyntaxProto2,
- .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -575,15 +558,9 @@ typedef struct GPBEnum__storage_ {
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBEnum__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -627,36 +604,30 @@ typedef struct GPBEnumValue__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "name",
+ .dataTypeSpecific.className = NULL,
.number = GPBEnumValue_FieldNumber_Name,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBEnumValue__storage_, name),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBEnumValue__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "number",
+ .dataTypeSpecific.className = NULL,
.number = GPBEnumValue_FieldNumber_Number,
.hasIndex = 1,
+ .offset = (uint32_t)offsetof(GPBEnumValue__storage_, number),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBEnumValue__storage_, number),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "optionsArray",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
.number = GPBEnumValue_FieldNumber_OptionsArray,
.hasIndex = GPBNoHasBit,
+ .offset = (uint32_t)offsetof(GPBEnumValue__storage_, optionsArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBEnumValue__storage_, optionsArray),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -664,15 +635,9 @@ typedef struct GPBEnumValue__storage_ {
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBEnumValue__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -702,25 +667,21 @@ typedef struct GPBOption__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "name",
+ .dataTypeSpecific.className = NULL,
.number = GPBOption_FieldNumber_Name,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBOption__storage_, name),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBOption__storage_, name),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
{
.name = "value",
+ .dataTypeSpecific.className = GPBStringifySymbol(GPBAny),
.number = GPBOption_FieldNumber_Value,
.hasIndex = 1,
+ .offset = (uint32_t)offsetof(GPBOption__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeMessage,
- .offset = offsetof(GPBOption__storage_, value),
- .defaultValue.valueMessage = nil,
- .dataTypeSpecific.className = GPBStringifySymbol(GPBAny),
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -728,15 +689,9 @@ typedef struct GPBOption__storage_ {
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBOption__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -746,4 +701,6 @@ typedef struct GPBOption__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Wrappers.pbobjc.h b/objectivec/google/protobuf/Wrappers.pbobjc.h
index 580945c4..0411e1ec 100644
--- a/objectivec/google/protobuf/Wrappers.pbobjc.h
+++ b/objectivec/google/protobuf/Wrappers.pbobjc.h
@@ -1,27 +1,51 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/wrappers.proto
-#import "GPBProtocolBuffers.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBDescriptor.h>
+ #import <Protobuf/GPBMessage.h>
+ #import <Protobuf/GPBRootObject.h>
+#else
+ #import "GPBDescriptor.h"
+ #import "GPBMessage.h"
+ #import "GPBRootObject.h"
+#endif
-#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
-#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.
+#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
+#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
+#endif
+#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
+#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - GPBWrappersRoot
+/**
+ * Exposes the extension registry for this file.
+ *
+ * The base class provides:
+ * @code
+ * + (GPBExtensionRegistry *)extensionRegistry;
+ * @endcode
+ * which is a @c GPBExtensionRegistry that includes all the extensions defined by
+ * this file and all files that it depends on.
+ **/
@interface GPBWrappersRoot : GPBRootObject
-
-// The base class provides:
-// + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
@end
#pragma mark - GPBDoubleValue
@@ -30,12 +54,14 @@ typedef GPB_ENUM(GPBDoubleValue_FieldNumber) {
GPBDoubleValue_FieldNumber_Value = 1,
};
-// Wrapper message for `double`.
-//
-// The JSON representation for `DoubleValue` is JSON number.
+/**
+ * Wrapper message for `double`.
+ *
+ * The JSON representation for `DoubleValue` is JSON number.
+ **/
@interface GPBDoubleValue : GPBMessage
-// The double value.
+/** The double value. */
@property(nonatomic, readwrite) double value;
@end
@@ -46,12 +72,14 @@ typedef GPB_ENUM(GPBFloatValue_FieldNumber) {
GPBFloatValue_FieldNumber_Value = 1,
};
-// Wrapper message for `float`.
-//
-// The JSON representation for `FloatValue` is JSON number.
+/**
+ * Wrapper message for `float`.
+ *
+ * The JSON representation for `FloatValue` is JSON number.
+ **/
@interface GPBFloatValue : GPBMessage
-// The float value.
+/** The float value. */
@property(nonatomic, readwrite) float value;
@end
@@ -62,12 +90,14 @@ typedef GPB_ENUM(GPBInt64Value_FieldNumber) {
GPBInt64Value_FieldNumber_Value = 1,
};
-// Wrapper message for `int64`.
-//
-// The JSON representation for `Int64Value` is JSON string.
+/**
+ * Wrapper message for `int64`.
+ *
+ * The JSON representation for `Int64Value` is JSON string.
+ **/
@interface GPBInt64Value : GPBMessage
-// The int64 value.
+/** The int64 value. */
@property(nonatomic, readwrite) int64_t value;
@end
@@ -78,12 +108,14 @@ typedef GPB_ENUM(GPBUInt64Value_FieldNumber) {
GPBUInt64Value_FieldNumber_Value = 1,
};
-// Wrapper message for `uint64`.
-//
-// The JSON representation for `UInt64Value` is JSON string.
+/**
+ * Wrapper message for `uint64`.
+ *
+ * The JSON representation for `UInt64Value` is JSON string.
+ **/
@interface GPBUInt64Value : GPBMessage
-// The uint64 value.
+/** The uint64 value. */
@property(nonatomic, readwrite) uint64_t value;
@end
@@ -94,12 +126,14 @@ typedef GPB_ENUM(GPBInt32Value_FieldNumber) {
GPBInt32Value_FieldNumber_Value = 1,
};
-// Wrapper message for `int32`.
-//
-// The JSON representation for `Int32Value` is JSON number.
+/**
+ * Wrapper message for `int32`.
+ *
+ * The JSON representation for `Int32Value` is JSON number.
+ **/
@interface GPBInt32Value : GPBMessage
-// The int32 value.
+/** The int32 value. */
@property(nonatomic, readwrite) int32_t value;
@end
@@ -110,12 +144,14 @@ typedef GPB_ENUM(GPBUInt32Value_FieldNumber) {
GPBUInt32Value_FieldNumber_Value = 1,
};
-// Wrapper message for `uint32`.
-//
-// The JSON representation for `UInt32Value` is JSON number.
+/**
+ * Wrapper message for `uint32`.
+ *
+ * The JSON representation for `UInt32Value` is JSON number.
+ **/
@interface GPBUInt32Value : GPBMessage
-// The uint32 value.
+/** The uint32 value. */
@property(nonatomic, readwrite) uint32_t value;
@end
@@ -126,12 +162,14 @@ typedef GPB_ENUM(GPBBoolValue_FieldNumber) {
GPBBoolValue_FieldNumber_Value = 1,
};
-// Wrapper message for `bool`.
-//
-// The JSON representation for `BoolValue` is JSON `true` and `false`.
+/**
+ * Wrapper message for `bool`.
+ *
+ * The JSON representation for `BoolValue` is JSON `true` and `false`.
+ **/
@interface GPBBoolValue : GPBMessage
-// The bool value.
+/** The bool value. */
@property(nonatomic, readwrite) BOOL value;
@end
@@ -142,12 +180,14 @@ typedef GPB_ENUM(GPBStringValue_FieldNumber) {
GPBStringValue_FieldNumber_Value = 1,
};
-// Wrapper message for `string`.
-//
-// The JSON representation for `StringValue` is JSON string.
+/**
+ * Wrapper message for `string`.
+ *
+ * The JSON representation for `StringValue` is JSON string.
+ **/
@interface GPBStringValue : GPBMessage
-// The string value.
+/** The string value. */
@property(nonatomic, readwrite, copy, null_resettable) NSString *value;
@end
@@ -158,12 +198,14 @@ typedef GPB_ENUM(GPBBytesValue_FieldNumber) {
GPBBytesValue_FieldNumber_Value = 1,
};
-// Wrapper message for `bytes`.
-//
-// The JSON representation for `BytesValue` is JSON string.
+/**
+ * Wrapper message for `bytes`.
+ *
+ * The JSON representation for `BytesValue` is JSON string.
+ **/
@interface GPBBytesValue : GPBMessage
-// The bytes value.
+/** The bytes value. */
@property(nonatomic, readwrite, copy, null_resettable) NSData *value;
@end
@@ -172,4 +214,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Wrappers.pbobjc.m b/objectivec/google/protobuf/Wrappers.pbobjc.m
index 0403b464..5479eb12 100644
--- a/objectivec/google/protobuf/Wrappers.pbobjc.m
+++ b/objectivec/google/protobuf/Wrappers.pbobjc.m
@@ -1,14 +1,35 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/wrappers.proto
-#import "GPBProtocolBuffers_RuntimeSupport.h"
-#import "google/protobuf/Wrappers.pbobjc.h"
+// This CPP symbol can be defined to use imports that match up to the framework
+// imports needed when using CocoaPods.
+#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
+ #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
+#else
+ #import "GPBProtocolBuffers_RuntimeSupport.h"
+#endif
+
+#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
+ #import <Protobuf/Wrappers.pbobjc.h>
+#else
+ #import "google/protobuf/Wrappers.pbobjc.h"
+#endif
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBWrappersRoot
@implementation GPBWrappersRoot
+// No extensions in the file and no imports, so no need to generate
+// +extensionRegistry.
+
@end
#pragma mark - GPBWrappersRoot_FileDescriptor
@@ -18,8 +39,9 @@ static GPBFileDescriptor *GPBWrappersRoot_FileDescriptor(void) {
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
- GPBDebugCheckRuntimeVersion();
+ GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
+ objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
@@ -44,14 +66,12 @@ typedef struct GPBDoubleValue__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBDoubleValue_FieldNumber_Value,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBDoubleValue__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeDouble,
- .offset = offsetof(GPBDoubleValue__storage_, value),
- .defaultValue.valueDouble = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -59,15 +79,9 @@ typedef struct GPBDoubleValue__storage_ {
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBDoubleValue__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -95,14 +109,12 @@ typedef struct GPBFloatValue__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBFloatValue_FieldNumber_Value,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBFloatValue__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeFloat,
- .offset = offsetof(GPBFloatValue__storage_, value),
- .defaultValue.valueFloat = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -110,15 +122,9 @@ typedef struct GPBFloatValue__storage_ {
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBFloatValue__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -146,14 +152,12 @@ typedef struct GPBInt64Value__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBInt64Value_FieldNumber_Value,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBInt64Value__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt64,
- .offset = offsetof(GPBInt64Value__storage_, value),
- .defaultValue.valueInt64 = 0LL,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -161,15 +165,9 @@ typedef struct GPBInt64Value__storage_ {
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBInt64Value__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -197,14 +195,12 @@ typedef struct GPBUInt64Value__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBUInt64Value_FieldNumber_Value,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBUInt64Value__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeUInt64,
- .offset = offsetof(GPBUInt64Value__storage_, value),
- .defaultValue.valueUInt64 = 0ULL,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -212,15 +208,9 @@ typedef struct GPBUInt64Value__storage_ {
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBUInt64Value__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -248,14 +238,12 @@ typedef struct GPBInt32Value__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBInt32Value_FieldNumber_Value,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBInt32Value__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt32,
- .offset = offsetof(GPBInt32Value__storage_, value),
- .defaultValue.valueInt32 = 0,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -263,15 +251,9 @@ typedef struct GPBInt32Value__storage_ {
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBInt32Value__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -299,14 +281,12 @@ typedef struct GPBUInt32Value__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBUInt32Value_FieldNumber_Value,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBUInt32Value__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeUInt32,
- .offset = offsetof(GPBUInt32Value__storage_, value),
- .defaultValue.valueUInt32 = 0U,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -314,15 +294,9 @@ typedef struct GPBUInt32Value__storage_ {
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBUInt32Value__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -339,7 +313,6 @@ typedef struct GPBUInt32Value__storage_ {
typedef struct GPBBoolValue__storage_ {
uint32_t _has_storage_[1];
- BOOL value;
} GPBBoolValue__storage_;
// This method is threadsafe because it is initially called
@@ -350,14 +323,12 @@ typedef struct GPBBoolValue__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBBoolValue_FieldNumber_Value,
.hasIndex = 0,
+ .offset = 1, // Stored in _has_storage_ to save space.
.flags = GPBFieldOptional,
.dataType = GPBDataTypeBool,
- .offset = offsetof(GPBBoolValue__storage_, value),
- .defaultValue.valueBool = NO,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -365,15 +336,9 @@ typedef struct GPBBoolValue__storage_ {
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBBoolValue__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -401,14 +366,12 @@ typedef struct GPBStringValue__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBStringValue_FieldNumber_Value,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBStringValue__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
- .offset = offsetof(GPBStringValue__storage_, value),
- .defaultValue.valueString = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -416,15 +379,9 @@ typedef struct GPBStringValue__storage_ {
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBStringValue__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -452,14 +409,12 @@ typedef struct GPBBytesValue__storage_ {
static GPBMessageFieldDescription fields[] = {
{
.name = "value",
+ .dataTypeSpecific.className = NULL,
.number = GPBBytesValue_FieldNumber_Value,
.hasIndex = 0,
+ .offset = (uint32_t)offsetof(GPBBytesValue__storage_, value),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeBytes,
- .offset = offsetof(GPBBytesValue__storage_, value),
- .defaultValue.valueData = nil,
- .dataTypeSpecific.className = NULL,
- .fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
@@ -467,15 +422,9 @@ typedef struct GPBBytesValue__storage_ {
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor()
fields:fields
- fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
- oneofs:NULL
- oneofCount:0
- enums:NULL
- enumCount:0
- ranges:NULL
- rangeCount:0
+ fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBBytesValue__storage_)
- wireFormat:NO];
+ flags:GPBDescriptorInitializationFlag_None];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
@@ -485,4 +434,6 @@ typedef struct GPBBytesValue__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)