Merge commit '36bca61764984ff5395653cf8377ec5daa71b709' as 'libs/protobuf'
This commit is contained in:
1
libs/protobuf/objectivec/.clang-format
Normal file
1
libs/protobuf/objectivec/.clang-format
Normal file
@@ -0,0 +1 @@
|
||||
BasedOnStyle: Google
|
||||
23
libs/protobuf/objectivec/.gitignore
vendored
Normal file
23
libs/protobuf/objectivec/.gitignore
vendored
Normal file
@@ -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
|
||||
137
libs/protobuf/objectivec/BUILD.bazel
Normal file
137
libs/protobuf/objectivec/BUILD.bazel
Normal file
@@ -0,0 +1,137 @@
|
||||
load("@rules_cc//cc:defs.bzl", "objc_library")
|
||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
||||
load("//conformance:defs.bzl", "conformance_test")
|
||||
|
||||
objc_library(
|
||||
name = "objectivec",
|
||||
hdrs = [
|
||||
"GPBAny.pbobjc.h",
|
||||
"GPBApi.pbobjc.h",
|
||||
"GPBDuration.pbobjc.h",
|
||||
"GPBEmpty.pbobjc.h",
|
||||
"GPBFieldMask.pbobjc.h",
|
||||
"GPBSourceContext.pbobjc.h",
|
||||
"GPBStruct.pbobjc.h",
|
||||
"GPBTimestamp.pbobjc.h",
|
||||
"GPBType.pbobjc.h",
|
||||
"GPBWrappers.pbobjc.h",
|
||||
"GPBArray.h",
|
||||
"GPBBootstrap.h",
|
||||
"GPBCodedInputStream.h",
|
||||
"GPBCodedOutputStream.h",
|
||||
"GPBDescriptor.h",
|
||||
"GPBDictionary.h",
|
||||
"GPBExtensionInternals.h",
|
||||
"GPBExtensionRegistry.h",
|
||||
"GPBMessage.h",
|
||||
"GPBProtocolBuffers.h",
|
||||
"GPBProtocolBuffers_RuntimeSupport.h",
|
||||
"GPBRootObject.h",
|
||||
"GPBRuntimeTypes.h",
|
||||
"GPBUnknownField.h",
|
||||
"GPBUnknownFieldSet.h",
|
||||
"GPBUtilities.h",
|
||||
"GPBWellKnownTypes.h",
|
||||
"GPBWireFormat.h",
|
||||
"google/protobuf/Any.pbobjc.h",
|
||||
"google/protobuf/Api.pbobjc.h",
|
||||
"google/protobuf/Duration.pbobjc.h",
|
||||
"google/protobuf/Empty.pbobjc.h",
|
||||
"google/protobuf/FieldMask.pbobjc.h",
|
||||
"google/protobuf/SourceContext.pbobjc.h",
|
||||
"google/protobuf/Struct.pbobjc.h",
|
||||
"google/protobuf/Timestamp.pbobjc.h",
|
||||
"google/protobuf/Type.pbobjc.h",
|
||||
"google/protobuf/Wrappers.pbobjc.h",
|
||||
# Package private headers, but exposed because the generated sources
|
||||
# need to use them.
|
||||
"GPBArray_PackagePrivate.h",
|
||||
"GPBCodedInputStream_PackagePrivate.h",
|
||||
"GPBCodedOutputStream_PackagePrivate.h",
|
||||
"GPBDescriptor_PackagePrivate.h",
|
||||
"GPBDictionary_PackagePrivate.h",
|
||||
"GPBMessage_PackagePrivate.h",
|
||||
"GPBRootObject_PackagePrivate.h",
|
||||
"GPBUnknownFieldSet_PackagePrivate.h",
|
||||
"GPBUnknownField_PackagePrivate.h",
|
||||
"GPBUtilities_PackagePrivate.h",
|
||||
],
|
||||
copts = [
|
||||
"-Wno-vla",
|
||||
],
|
||||
includes = [
|
||||
".",
|
||||
],
|
||||
non_arc_srcs = [
|
||||
"GPBAny.pbobjc.m",
|
||||
"GPBApi.pbobjc.m",
|
||||
"GPBArray.m",
|
||||
"GPBCodedInputStream.m",
|
||||
"GPBCodedOutputStream.m",
|
||||
"GPBDescriptor.m",
|
||||
"GPBDictionary.m",
|
||||
"GPBDuration.pbobjc.m",
|
||||
"GPBEmpty.pbobjc.m",
|
||||
"GPBExtensionInternals.m",
|
||||
"GPBExtensionRegistry.m",
|
||||
"GPBFieldMask.pbobjc.m",
|
||||
"GPBMessage.m",
|
||||
"GPBRootObject.m",
|
||||
"GPBSourceContext.pbobjc.m",
|
||||
"GPBStruct.pbobjc.m",
|
||||
"GPBTimestamp.pbobjc.m",
|
||||
"GPBType.pbobjc.m",
|
||||
"GPBUnknownField.m",
|
||||
"GPBUnknownFieldSet.m",
|
||||
"GPBUtilities.m",
|
||||
"GPBWellKnownTypes.m",
|
||||
"GPBWireFormat.m",
|
||||
"GPBWrappers.pbobjc.m",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Tests
|
||||
################################################################################
|
||||
|
||||
conformance_test(
|
||||
name = "conformance_test",
|
||||
failure_list = "//conformance:failure_list_objc.txt",
|
||||
testee = "//conformance:conformance_objc",
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Distribution files
|
||||
################################################################################
|
||||
|
||||
pkg_files(
|
||||
name = "dist_files",
|
||||
srcs = glob([
|
||||
"*.h",
|
||||
"*.m",
|
||||
"**/*.h",
|
||||
"**/*.m",
|
||||
"**/*.mm",
|
||||
"**/*.swift",
|
||||
"DevTools/*.sh",
|
||||
"DevTools/*.py",
|
||||
"ProtocolBuffers_iOS.xcodeproj/**/*",
|
||||
"ProtocolBuffers_OSX.xcodeproj/**/*",
|
||||
"ProtocolBuffers_tvOS.xcodeproj/**/*",
|
||||
"Tests/CocoaPods/**/*",
|
||||
"Tests/*.pddm",
|
||||
"Tests/*.txt",
|
||||
"Tests/*.plist",
|
||||
"Tests/*.proto",
|
||||
]) + [
|
||||
".clang-format",
|
||||
"BUILD.bazel",
|
||||
"README.md",
|
||||
"Tests/golden_message",
|
||||
"Tests/golden_packed_fields_message",
|
||||
"generate_well_known_types.sh",
|
||||
],
|
||||
strip_prefix = strip_prefix.from_root(""),
|
||||
visibility = ["//pkg:__pkg__"],
|
||||
)
|
||||
55
libs/protobuf/objectivec/DevTools/check_version_stamps.sh
Executable file
55
libs/protobuf/objectivec/DevTools/check_version_stamps.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
# This script checks that the runtime version number constant in the compiler
|
||||
# source and in the runtime source is the same.
|
||||
#
|
||||
# A distro can be made of the protobuf sources with only a subset of the
|
||||
# languages, so if the compiler depended on the Objective C runtime, those
|
||||
# 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.
|
||||
|
||||
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
|
||||
readonly ProtoRootDir="${ScriptDir}/../.."
|
||||
|
||||
die() {
|
||||
echo "Error: $1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
readonly GeneratorSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/file.cc"
|
||||
readonly RuntimeSrc="${ProtoRootDir}/objectivec/GPBBootstrap.h"
|
||||
|
||||
check_constant() {
|
||||
local ConstantName="$1"
|
||||
|
||||
# Collect version from generator sources.
|
||||
local GeneratorVersion=$( \
|
||||
cat "${GeneratorSrc}" \
|
||||
| sed -n -e "s:const int32_t ${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
|
||||
}
|
||||
|
||||
# Do the check.
|
||||
check_constant GOOGLE_PROTOBUF_OBJC_VERSION
|
||||
|
||||
# Success
|
||||
136
libs/protobuf/objectivec/DevTools/compile_testing_protos.sh
Executable file
136
libs/protobuf/objectivec/DevTools/compile_testing_protos.sh
Executable file
@@ -0,0 +1,136 @@
|
||||
#!/bin/bash -eu
|
||||
# Invoked by the Xcode projects to build the protos needed for the unittests.
|
||||
|
||||
readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/protos"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Helper for bailing.
|
||||
die() {
|
||||
echo "Error: $1"
|
||||
exit 2
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# What to do.
|
||||
case "${ACTION}" in
|
||||
"")
|
||||
# Build, fall thru
|
||||
;;
|
||||
"clean")
|
||||
rm -rf "${OUTPUT_DIR}"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
die "Unknown action requested: ${ACTION}"
|
||||
;;
|
||||
esac
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# The objc unittest specific proto files.
|
||||
|
||||
OBJC_TEST_PROTO_FILES=(
|
||||
objectivec/Tests/any_test.proto
|
||||
objectivec/Tests/map_proto2_unittest.proto
|
||||
objectivec/Tests/map_unittest.proto
|
||||
objectivec/Tests/unittest_cycle.proto
|
||||
objectivec/Tests/unittest_deprecated_file.proto
|
||||
objectivec/Tests/unittest_deprecated.proto
|
||||
objectivec/Tests/unittest_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_import_public.proto
|
||||
objectivec/Tests/unittest_import.proto
|
||||
objectivec/Tests/unittest_mset.proto
|
||||
objectivec/Tests/unittest_objc_options.proto
|
||||
objectivec/Tests/unittest_objc_startup.proto
|
||||
objectivec/Tests/unittest_objc.proto
|
||||
objectivec/Tests/unittest_preserve_unknown_enum.proto
|
||||
objectivec/Tests/unittest_runtime_proto2.proto
|
||||
objectivec/Tests/unittest_runtime_proto3.proto
|
||||
objectivec/Tests/unittest.proto
|
||||
)
|
||||
|
||||
OBJC_EXTENSIONS=( .pbobjc.h .pbobjc.m )
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Ensure the output dir exists
|
||||
mkdir -p "${OUTPUT_DIR}"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Move to the top of the protobuf directories and ensure there is a protoc
|
||||
# binary to use.
|
||||
cd "${SRCROOT}/.."
|
||||
readonly PROTOC="bazel-bin/protoc"
|
||||
[[ -x "${PROTOC}" ]] || \
|
||||
die "Could not find the protoc binary; make sure you have built it (objectivec/DevTools/full_mac_build.sh -h)."
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
RUN_PROTOC=no
|
||||
|
||||
# Check to if all the output files exist (in case a new one got added).
|
||||
|
||||
for PROTO_FILE in "${OBJC_TEST_PROTO_FILES[@]}"; do
|
||||
DIR=${PROTO_FILE%/*}
|
||||
BASE_NAME=${PROTO_FILE##*/}
|
||||
# Drop the extension
|
||||
BASE_NAME=${BASE_NAME%.*}
|
||||
OBJC_NAME=$(echo "${BASE_NAME}" | awk -F _ '{for(i=1; i<=NF; i++) printf "%s", toupper(substr($i,1,1)) substr($i,2);}')
|
||||
|
||||
for EXT in "${OBJC_EXTENSIONS[@]}"; do
|
||||
if [[ ! -f "${OUTPUT_DIR}/${DIR}/${OBJC_NAME}${EXT}" ]]; then
|
||||
RUN_PROTOC=yes
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# If we haven't decided to run protoc because of a missing file, check to see if
|
||||
# an input has changed.
|
||||
if [[ "${RUN_PROTOC}" != "yes" ]] ; then
|
||||
# Find the newest input file (protos, compiler, and this script).
|
||||
# (these patterns catch some extra stuff, but better to over sample than
|
||||
# under)
|
||||
readonly NewestInput=$(find \
|
||||
objectivec/Tests/*.proto "${PROTOC}" \
|
||||
objectivec/DevTools/compile_testing_protos.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 \
|
||||
"${OUTPUT_DIR}" \
|
||||
-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.
|
||||
if [[ "${NewestInput}" -nt "${OldestOutput}" ]] ; then
|
||||
RUN_PROTOC=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${RUN_PROTOC}" != "yes" ]] ; then
|
||||
# Up to date.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# 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
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Generate the Objective C specific testing protos.
|
||||
|
||||
"${PROTOC}" \
|
||||
--objc_out="${OUTPUT_DIR}" \
|
||||
--objc_opt=expected_prefixes_path=objectivec/Tests/expected_prefixes.txt \
|
||||
--objc_opt=prefixes_must_be_registered=yes \
|
||||
--objc_opt=require_prefixes=yes \
|
||||
--proto_path=. \
|
||||
--proto_path=src \
|
||||
"${OBJC_TEST_PROTO_FILES[@]}"
|
||||
326
libs/protobuf/objectivec/DevTools/full_mac_build.sh
Executable file
326
libs/protobuf/objectivec/DevTools/full_mac_build.sh
Executable file
@@ -0,0 +1,326 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Helper to do build so you don't have to remember all the steps/args.
|
||||
|
||||
|
||||
set -eu
|
||||
|
||||
# Some base locations.
|
||||
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
|
||||
readonly ProtoRootDir="${ScriptDir}/../.."
|
||||
readonly BazelFlags="--announce_rc --macos_minimum_os=10.9 \
|
||||
$(${ScriptDir}/../../kokoro/common/bazel_flags.sh)"
|
||||
|
||||
# Invoke with BAZEL=bazelisk to use that instead.
|
||||
readonly BazelBin="${BAZEL:=bazel}"
|
||||
|
||||
printUsage() {
|
||||
NAME=$(basename "${0}")
|
||||
cat << EOF
|
||||
usage: ${NAME} [OPTIONS]
|
||||
|
||||
This script does the common build steps needed.
|
||||
|
||||
OPTIONS:
|
||||
|
||||
General:
|
||||
|
||||
-h, --help
|
||||
Show this message
|
||||
-c, --clean
|
||||
Issue a clean before the normal build.
|
||||
-r, --regenerate-descriptors
|
||||
Run generate_descriptor_proto.sh to regenerate all the checked in
|
||||
proto sources.
|
||||
--core-only
|
||||
Skip some of the core protobuf build/checks to shorten the build time.
|
||||
--skip-xcode
|
||||
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-xcode-macos
|
||||
Skip the invoke of Xcode to test the runtime on OS X.
|
||||
--skip-xcode-tvos
|
||||
Skip the invoke of Xcode to test the runtime on tvOS.
|
||||
--skip-objc-conformance
|
||||
Skip the Objective C conformance tests (run on OS X).
|
||||
--xcode-quiet
|
||||
Pass -quiet to xcodebuild.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
header() {
|
||||
echo ""
|
||||
echo "========================================================================"
|
||||
echo " ${@}"
|
||||
echo "========================================================================"
|
||||
}
|
||||
|
||||
BAZEL=bazel
|
||||
DO_CLEAN=no
|
||||
REGEN_DESCRIPTORS=no
|
||||
CORE_ONLY=no
|
||||
DO_XCODE_IOS_TESTS=yes
|
||||
DO_XCODE_OSX_TESTS=yes
|
||||
DO_XCODE_TVOS_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 )
|
||||
printUsage
|
||||
exit 0
|
||||
;;
|
||||
-c | --clean )
|
||||
DO_CLEAN=yes
|
||||
;;
|
||||
-r | --regenerate-descriptors )
|
||||
REGEN_DESCRIPTORS=yes
|
||||
;;
|
||||
--core-only )
|
||||
CORE_ONLY=yes
|
||||
;;
|
||||
--skip-xcode )
|
||||
DO_XCODE_IOS_TESTS=no
|
||||
DO_XCODE_OSX_TESTS=no
|
||||
DO_XCODE_TVOS_TESTS=no
|
||||
;;
|
||||
--skip-xcode-ios )
|
||||
DO_XCODE_IOS_TESTS=no
|
||||
;;
|
||||
--skip-xcode-osx | --skip-xcode-macos)
|
||||
DO_XCODE_OSX_TESTS=no
|
||||
;;
|
||||
--skip-xcode-tvos )
|
||||
DO_XCODE_TVOS_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
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unknown argument: ${1}" 1>&2
|
||||
printUsage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Into the proto dir.
|
||||
cd "${ProtoRootDir}"
|
||||
|
||||
if [[ "${DO_CLEAN}" == "yes" ]] ; then
|
||||
header "Cleaning"
|
||||
"${BazelBin}" clean
|
||||
if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
|
||||
XCODEBUILD_CLEAN_BASE_IOS=(
|
||||
xcodebuild
|
||||
-project objectivec/ProtocolBuffers_iOS.xcodeproj
|
||||
-scheme ProtocolBuffers
|
||||
)
|
||||
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=(
|
||||
xcodebuild
|
||||
-project objectivec/ProtocolBuffers_OSX.xcodeproj
|
||||
-scheme ProtocolBuffers
|
||||
)
|
||||
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
|
||||
if [[ "${DO_XCODE_TVOS_TESTS}" == "yes" ]] ; then
|
||||
XCODEBUILD_CLEAN_BASE_OSX=(
|
||||
xcodebuild
|
||||
-project objectivec/ProtocolBuffers_tvOS.xcodeproj
|
||||
-scheme ProtocolBuffers
|
||||
)
|
||||
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_DESCRIPTORS}" == "yes" ]] ; then
|
||||
header "Regenerating the descriptor sources."
|
||||
./generate_descriptor_proto.sh
|
||||
fi
|
||||
|
||||
if [[ "${CORE_ONLY}" == "yes" ]] ; then
|
||||
header "Building core Only"
|
||||
"${BazelBin}" build //:protoc //:protobuf //:protobuf_lite $BazelFlags
|
||||
else
|
||||
header "Building"
|
||||
# Can't issue these together, when fully parallel, something sometimes chokes
|
||||
# at random.
|
||||
"${BazelBin}" test //src/... $BazelFlags
|
||||
# Fire off the conformance tests also.
|
||||
"${BazelBin}" test //objectivec:conformance_test $BazelFlags
|
||||
fi
|
||||
|
||||
# Ensure the WKT sources checked in are current.
|
||||
BAZEL="${BazelBin}" objectivec/generate_well_known_types.sh --check-only $BazelFlags
|
||||
|
||||
header "Checking on the ObjC Runtime Code"
|
||||
# Some of the kokoro machines don't have python3 yet, so fall back to python if need be.
|
||||
if hash python3 >/dev/null 2>&1 ; then
|
||||
LOCAL_PYTHON=python3
|
||||
else
|
||||
LOCAL_PYTHON=python
|
||||
fi
|
||||
"${LOCAL_PYTHON}" objectivec/DevTools/pddm_tests.py
|
||||
if ! "${LOCAL_PYTHON}" objectivec/DevTools/pddm.py --dry-run objectivec/*.[hm] objectivec/Tests/*.[hm] ; then
|
||||
echo ""
|
||||
echo "Update by running:"
|
||||
echo " objectivec/DevTools/pddm.py objectivec/*.[hm] objectivec/Tests/*.[hm]"
|
||||
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.
|
||||
case "${XCODE_VERSION}" in
|
||||
[6-9].* | 1[0-2].* )
|
||||
echo "ERROR: Xcode 13.3.1 or higher is required." 1>&2
|
||||
exit 11
|
||||
;;
|
||||
13.* | 14.*)
|
||||
# Dropped 32bit as Apple doesn't seem support the simulators either.
|
||||
XCODEBUILD_TEST_BASE_IOS+=(
|
||||
-destination "platform=iOS Simulator,name=iPhone 8,OS=latest" # 64bit
|
||||
)
|
||||
;;
|
||||
* )
|
||||
echo ""
|
||||
echo "ATTENTION: Time to update the simulator targets for Xcode ${XCODE_VERSION}"
|
||||
echo ""
|
||||
echo "ERROR: Build aborted!"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
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 Simulator 2> /dev/null || true
|
||||
fi
|
||||
if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
|
||||
XCODEBUILD_TEST_BASE_OSX=(
|
||||
xcodebuild
|
||||
-project objectivec/ProtocolBuffers_OSX.xcodeproj
|
||||
-scheme ProtocolBuffers
|
||||
# Since the ObjC 2.0 Runtime is required, 32bit OS X isn't supported.
|
||||
-destination "platform=OS X,arch=x86_64" # 64bit
|
||||
)
|
||||
if [[ "${XCODE_QUIET}" == "yes" ]] ; then
|
||||
XCODEBUILD_TEST_BASE_OSX+=( -quiet )
|
||||
fi
|
||||
case "${XCODE_VERSION}" in
|
||||
[6-9].* | 1[0-2].* )
|
||||
echo "ERROR: Xcode 13.3.1 or higher is required." 1>&2
|
||||
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_XCODE_TVOS_TESTS}" == "yes" ]] ; then
|
||||
XCODEBUILD_TEST_BASE_TVOS=(
|
||||
xcodebuild
|
||||
-project objectivec/ProtocolBuffers_tvOS.xcodeproj
|
||||
-scheme ProtocolBuffers
|
||||
)
|
||||
case "${XCODE_VERSION}" in
|
||||
[6-9].* | 1[0-2].* )
|
||||
echo "ERROR: Xcode 13.3.1 or higher is required." 1>&2
|
||||
exit 11
|
||||
;;
|
||||
13.* | 14.*)
|
||||
XCODEBUILD_TEST_BASE_TVOS+=(
|
||||
-destination "platform=tvOS Simulator,name=Apple TV 4K (2nd generation),OS=latest"
|
||||
)
|
||||
;;
|
||||
* )
|
||||
echo ""
|
||||
echo "ATTENTION: Time to update the simulator targets for Xcode ${XCODE_VERSION}"
|
||||
echo ""
|
||||
echo "ERROR: Build aborted!"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
if [[ "${XCODE_QUIET}" == "yes" ]] ; then
|
||||
XCODEBUILD_TEST_BASE_TVOS+=( -quiet )
|
||||
fi
|
||||
if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then
|
||||
header "Doing Xcode tvOS build/tests - Debug"
|
||||
"${XCODEBUILD_TEST_BASE_TVOS[@]}" -configuration Debug test
|
||||
fi
|
||||
if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then
|
||||
header "Doing Xcode tvOS build/tests - Release"
|
||||
"${XCODEBUILD_TEST_BASE_TVOS[@]}" -configuration Release test
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${DO_OBJC_CONFORMANCE_TESTS}" == "yes" ]] ; then
|
||||
header "Running ObjC Conformance Tests"
|
||||
"${BazelBin}" test //objectivec:conformance_test $BazelFlags
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "$(basename "${0}"): Success!"
|
||||
692
libs/protobuf/objectivec/DevTools/pddm.py
Executable file
692
libs/protobuf/objectivec/DevTools/pddm.py
Executable file
@@ -0,0 +1,692 @@
|
||||
#! /usr/bin/env python3
|
||||
#
|
||||
# Protocol Buffers - Google's data interchange format
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
# https://developers.google.com/protocol-buffers/
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""PDDM - Poor Developers' Debug-able Macros
|
||||
|
||||
A simple markup that can be added in comments of source so they can then be
|
||||
expanded out into code. Most of this could be done with CPP macros, but then
|
||||
developers can't really step through them in the debugger, this way they are
|
||||
expanded to the same code, but you can debug them.
|
||||
|
||||
Any file can be processed, but the syntax is designed around a C based compiler.
|
||||
Processed lines start with "//%". There are three types of sections you can
|
||||
create: Text (left alone), Macro Definitions, and Macro Expansions. There is
|
||||
no order required between definitions and expansions, all definitions are read
|
||||
before any expansions are processed (thus, if desired, definitions can be put
|
||||
at the end of the file to keep them out of the way of the code).
|
||||
|
||||
Macro Definitions are started with "//%PDDM-DEFINE Name(args)" and all lines
|
||||
afterwards that start with "//%" are included in the definition. Multiple
|
||||
macros can be defined in one block by just using a another "//%PDDM-DEFINE"
|
||||
line to start the next macro. Optionally, a macro can be ended with
|
||||
"//%PDDM-DEFINE-END", this can be useful when you want to make it clear that
|
||||
trailing blank lines are included in the macro. You can also end a definition
|
||||
with an expansion.
|
||||
|
||||
Macro Expansions are started by single lines containing
|
||||
"//%PDDM-EXPAND Name(args)" and then with "//%PDDM-EXPAND-END" or another
|
||||
expansions. All lines in-between are replaced by the result of the expansion.
|
||||
The first line of the expansion is always a blank like just for readability.
|
||||
|
||||
Expansion itself is pretty simple, one macro can invoke another macro, but
|
||||
you cannot nest the invoke of a macro in another macro (i.e. - can't do
|
||||
"foo(bar(a))", but you can define foo(a) and bar(b) where bar invokes foo()
|
||||
within its expansion.
|
||||
|
||||
When macros are expanded, the arg references can also add "$O" suffix to the
|
||||
name (i.e. - "NAME$O") to specify an option to be applied. The options are:
|
||||
|
||||
$S - Replace each character in the value with a space.
|
||||
$l - Lowercase the first letter of the value.
|
||||
$L - Lowercase the whole value.
|
||||
$u - Uppercase the first letter of the value.
|
||||
$U - Uppercase the whole value.
|
||||
|
||||
Within a macro you can use ## to cause things to get joined together after
|
||||
expansion (i.e. - "a##b" within a macro will become "ab").
|
||||
|
||||
Example:
|
||||
|
||||
int foo(MyEnum x) {
|
||||
switch (x) {
|
||||
//%PDDM-EXPAND case(Enum_Left, 1)
|
||||
//%PDDM-EXPAND case(Enum_Center, 2)
|
||||
//%PDDM-EXPAND case(Enum_Right, 3)
|
||||
//%PDDM-EXPAND-END
|
||||
}
|
||||
|
||||
//%PDDM-DEFINE case(_A, _B)
|
||||
//% case _A:
|
||||
//% return _B;
|
||||
|
||||
A macro ends at the start of the next one, or an optional %PDDM-DEFINE-END
|
||||
can be used to avoid adding extra blank lines/returns (or make it clear when
|
||||
it is desired).
|
||||
|
||||
One macro can invoke another by simply using its name NAME(ARGS). You cannot
|
||||
nest an invoke inside another (i.e. - NAME1(NAME2(ARGS)) isn't supported).
|
||||
|
||||
Within a macro you can use ## to cause things to get joined together after
|
||||
processing (i.e. - "a##b" within a macro will become "ab").
|
||||
|
||||
|
||||
"""
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
# Regex for macro definition.
|
||||
_MACRO_RE = re.compile(r'(?P<name>\w+)\((?P<args>.*?)\)')
|
||||
# Regex for macro's argument definition.
|
||||
_MACRO_ARG_NAME_RE = re.compile(r'^\w+$')
|
||||
|
||||
# Line inserted after each EXPAND.
|
||||
_GENERATED_CODE_LINE = (
|
||||
'// This block of code is generated, do not edit it directly.'
|
||||
)
|
||||
|
||||
|
||||
def _MacroRefRe(macro_names):
|
||||
# Takes in a list of macro names and makes a regex that will match invokes
|
||||
# of those macros.
|
||||
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.
|
||||
return re.compile(r'\b(?P<name>(%s))(\$(?P<option>.))?\b' %
|
||||
'|'.join(macro_arg_names))
|
||||
|
||||
|
||||
class PDDMError(Exception):
|
||||
"""Error thrown by pddm."""
|
||||
|
||||
def __init__(self, message="Error"):
|
||||
self.message = message
|
||||
super().__init__(self.message)
|
||||
|
||||
|
||||
class MacroCollection(object):
|
||||
"""Hold a set of macros and can resolve/expand them."""
|
||||
|
||||
def __init__(self, a_file=None):
|
||||
"""Initializes the collection.
|
||||
|
||||
Args:
|
||||
a_file: The file like stream to parse.
|
||||
|
||||
Raises:
|
||||
PDDMError if there are any issues.
|
||||
"""
|
||||
self._macros = dict()
|
||||
if a_file:
|
||||
self.ParseInput(a_file)
|
||||
|
||||
class MacroDefinition(object):
|
||||
"""Holds a macro definition."""
|
||||
|
||||
def __init__(self, name, arg_names):
|
||||
self._name = name
|
||||
self._args = tuple(arg_names)
|
||||
self._body = ''
|
||||
self._needNewLine = False
|
||||
|
||||
def AppendLine(self, line):
|
||||
if self._needNewLine:
|
||||
self._body += '\n'
|
||||
self._body += line
|
||||
self._needNewLine = not line.endswith('\n')
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def args(self):
|
||||
return self._args
|
||||
|
||||
@property
|
||||
def body(self):
|
||||
return self._body
|
||||
|
||||
def ParseInput(self, a_file):
|
||||
"""Consumes input extracting definitions.
|
||||
|
||||
Args:
|
||||
a_file: The file like stream to parse.
|
||||
|
||||
Raises:
|
||||
PDDMError if there are any issues.
|
||||
"""
|
||||
input_lines = a_file.read().splitlines()
|
||||
self.ParseLines(input_lines)
|
||||
|
||||
def ParseLines(self, input_lines):
|
||||
"""Parses list of lines.
|
||||
|
||||
Args:
|
||||
input_lines: A list of strings of input to parse (no newlines on the
|
||||
strings).
|
||||
|
||||
Raises:
|
||||
PDDMError if there are any issues.
|
||||
"""
|
||||
current_macro = None
|
||||
for line in input_lines:
|
||||
if line.startswith('PDDM-'):
|
||||
directive = line.split(' ', 1)[0]
|
||||
if directive == 'PDDM-DEFINE':
|
||||
name, args = self._ParseDefineLine(line)
|
||||
if self._macros.get(name):
|
||||
raise PDDMError('Attempt to redefine macro: "%s"' % line)
|
||||
current_macro = self.MacroDefinition(name, args)
|
||||
self._macros[name] = current_macro
|
||||
continue
|
||||
if directive == 'PDDM-DEFINE-END':
|
||||
if not current_macro:
|
||||
raise PDDMError('Got DEFINE-END directive without an active macro:'
|
||||
' "%s"' % line)
|
||||
current_macro = None
|
||||
continue
|
||||
raise PDDMError('Hit a line with an unknown directive: "%s"' % line)
|
||||
|
||||
if current_macro:
|
||||
current_macro.AppendLine(line)
|
||||
continue
|
||||
|
||||
# Allow blank lines between macro definitions.
|
||||
if line.strip() == '':
|
||||
continue
|
||||
|
||||
raise PDDMError('Hit a line that wasn\'t a directive and no open macro'
|
||||
' definition: "%s"' % line)
|
||||
|
||||
def _ParseDefineLine(self, input_line):
|
||||
assert input_line.startswith('PDDM-DEFINE')
|
||||
line = input_line[12:].strip()
|
||||
match = _MACRO_RE.match(line)
|
||||
# Must match full line
|
||||
if match is None or match.group(0) != line:
|
||||
raise PDDMError('Failed to parse macro definition: "%s"' % input_line)
|
||||
name = match.group('name')
|
||||
args_str = match.group('args').strip()
|
||||
args = []
|
||||
if args_str:
|
||||
for part in args_str.split(','):
|
||||
arg = part.strip()
|
||||
if arg == '':
|
||||
raise PDDMError('Empty arg name in macro definition: "%s"'
|
||||
% input_line)
|
||||
if not _MACRO_ARG_NAME_RE.match(arg):
|
||||
raise PDDMError('Invalid arg name "%s" in macro definition: "%s"'
|
||||
% (arg, input_line))
|
||||
if arg in args:
|
||||
raise PDDMError('Arg name "%s" used more than once in macro'
|
||||
' definition: "%s"' % (arg, input_line))
|
||||
args.append(arg)
|
||||
return (name, tuple(args))
|
||||
|
||||
def Expand(self, macro_ref_str):
|
||||
"""Expands the macro reference.
|
||||
|
||||
Args:
|
||||
macro_ref_str: String of a macro reference (i.e. foo(a, b)).
|
||||
|
||||
Returns:
|
||||
The text from the expansion.
|
||||
|
||||
Raises:
|
||||
PDDMError if there are any issues.
|
||||
"""
|
||||
match = _MACRO_RE.match(macro_ref_str)
|
||||
if match is None or match.group(0) != macro_ref_str:
|
||||
raise PDDMError('Failed to parse macro reference: "%s"' % macro_ref_str)
|
||||
if match.group('name') not in self._macros:
|
||||
raise PDDMError('No macro named "%s".' % match.group('name'))
|
||||
return self._Expand(match, [], macro_ref_str)
|
||||
|
||||
def _FormatStack(self, macro_ref_stack):
|
||||
result = ''
|
||||
for _, macro_ref in reversed(macro_ref_stack):
|
||||
result += '\n...while expanding "%s".' % macro_ref
|
||||
return result
|
||||
|
||||
def _Expand(self, macro_ref_match, macro_stack, macro_ref_str=None):
|
||||
if macro_ref_str is None:
|
||||
macro_ref_str = macro_ref_match.group('macro_ref')
|
||||
name = macro_ref_match.group('name')
|
||||
for prev_name, prev_macro_ref in macro_stack:
|
||||
if name == prev_name:
|
||||
raise PDDMError('Found macro recursion, invoking "%s":%s' %
|
||||
(macro_ref_str, self._FormatStack(macro_stack)))
|
||||
macro = self._macros[name]
|
||||
args_str = macro_ref_match.group('args').strip()
|
||||
args = []
|
||||
if args_str or len(macro.args):
|
||||
args = [x.strip() for x in args_str.split(',')]
|
||||
if len(args) != len(macro.args):
|
||||
raise PDDMError('Expected %d args, got: "%s".%s' %
|
||||
(len(macro.args), macro_ref_str,
|
||||
self._FormatStack(macro_stack)))
|
||||
# Replace args usages.
|
||||
result = self._ReplaceArgValues(macro, args, macro_ref_str, macro_stack)
|
||||
# Expand any macro invokes.
|
||||
new_macro_stack = macro_stack + [(name, macro_ref_str)]
|
||||
while True:
|
||||
eval_result = self._EvalMacrosRefs(result, new_macro_stack)
|
||||
# Consume all ## directives to glue things together.
|
||||
eval_result = eval_result.replace('##', '')
|
||||
if eval_result == result:
|
||||
break
|
||||
result = eval_result
|
||||
return result
|
||||
|
||||
def _ReplaceArgValues(self,
|
||||
macro, arg_values, macro_ref_to_report, macro_stack):
|
||||
if len(arg_values) == 0:
|
||||
# Nothing to do
|
||||
return macro.body
|
||||
assert len(arg_values) == len(macro.args)
|
||||
args = dict(list(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
|
||||
return ' ' * len(val)
|
||||
elif opt == 'l': # Lowercase first character
|
||||
if val:
|
||||
return val[0].lower() + val[1:]
|
||||
else:
|
||||
return val
|
||||
elif opt == 'L': # All Lowercase
|
||||
return val.lower()
|
||||
elif opt == 'u': # Uppercase first character
|
||||
if val:
|
||||
return val[0].upper() + val[1:]
|
||||
else:
|
||||
return val
|
||||
elif opt == 'U': # All Uppercase
|
||||
return val.upper()
|
||||
else:
|
||||
raise PDDMError('Unknown arg option "%s$%s" while expanding "%s".%s'
|
||||
% (match.group('name'), match.group('option'),
|
||||
macro_ref_to_report,
|
||||
self._FormatStack(macro_stack)))
|
||||
return val
|
||||
# Let the regex do the work!
|
||||
macro_arg_ref_re = _MacroArgRefRe(macro.args)
|
||||
return macro_arg_ref_re.sub(_lookupArg, macro.body)
|
||||
|
||||
def _EvalMacrosRefs(self, text, macro_stack):
|
||||
macro_ref_re = _MacroRefRe(list(self._macros.keys()))
|
||||
|
||||
def _resolveMacro(match):
|
||||
return self._Expand(match, macro_stack)
|
||||
return macro_ref_re.sub(_resolveMacro, text)
|
||||
|
||||
|
||||
class SourceFile(object):
|
||||
"""Represents a source file with PDDM directives in it."""
|
||||
|
||||
def __init__(self, a_file, import_resolver=None):
|
||||
"""Initializes the file reading in the file.
|
||||
|
||||
Args:
|
||||
a_file: The file to read in.
|
||||
import_resolver: a function that given a path will return a stream for
|
||||
the contents.
|
||||
|
||||
Raises:
|
||||
PDDMError if there are any issues.
|
||||
"""
|
||||
self._sections = []
|
||||
self._original_content = a_file.read()
|
||||
self._import_resolver = import_resolver
|
||||
self._processed_content = None
|
||||
|
||||
class SectionBase(object):
|
||||
|
||||
def __init__(self, first_line_num):
|
||||
self._lines = []
|
||||
self._first_line_num = first_line_num
|
||||
|
||||
def TryAppend(self, line, line_num):
|
||||
"""Try appending a line.
|
||||
|
||||
Args:
|
||||
line: The line to append.
|
||||
line_num: The number of the line.
|
||||
|
||||
Returns:
|
||||
A tuple of (SUCCESS, CAN_ADD_MORE). If SUCCESS if False, the line
|
||||
wasn't append. If SUCCESS is True, then CAN_ADD_MORE is True/False to
|
||||
indicate if more lines can be added after this one.
|
||||
"""
|
||||
assert False, "subclass should have overridden"
|
||||
return (False, False)
|
||||
|
||||
def HitEOF(self):
|
||||
"""Called when the EOF was reached for for a given section."""
|
||||
pass
|
||||
|
||||
def BindMacroCollection(self, macro_collection):
|
||||
"""Binds the chunk to a macro collection.
|
||||
|
||||
Args:
|
||||
macro_collection: The collection to bind too.
|
||||
"""
|
||||
pass
|
||||
|
||||
def Append(self, line):
|
||||
self._lines.append(line)
|
||||
|
||||
@property
|
||||
def lines(self):
|
||||
return self._lines
|
||||
|
||||
@property
|
||||
def num_lines_captured(self):
|
||||
return len(self._lines)
|
||||
|
||||
@property
|
||||
def first_line_num(self):
|
||||
return self._first_line_num
|
||||
|
||||
@property
|
||||
def first_line(self):
|
||||
if not self._lines:
|
||||
return ''
|
||||
return self._lines[0]
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
return '\n'.join(self.lines) + '\n'
|
||||
|
||||
class TextSection(SectionBase):
|
||||
"""Text section that is echoed out as is."""
|
||||
|
||||
def TryAppend(self, line, line_num):
|
||||
if line.startswith('//%PDDM'):
|
||||
return (False, False)
|
||||
self.Append(line)
|
||||
return (True, True)
|
||||
|
||||
class ExpansionSection(SectionBase):
|
||||
"""Section that is the result of an macro expansion."""
|
||||
|
||||
def __init__(self, first_line_num):
|
||||
SourceFile.SectionBase.__init__(self, first_line_num)
|
||||
self._macro_collection = None
|
||||
|
||||
def TryAppend(self, line, line_num):
|
||||
if line.startswith('//%PDDM'):
|
||||
directive = line.split(' ', 1)[0]
|
||||
if directive == '//%PDDM-EXPAND':
|
||||
self.Append(line)
|
||||
return (True, True)
|
||||
if directive == '//%PDDM-EXPAND-END':
|
||||
assert self.num_lines_captured > 0
|
||||
return (True, False)
|
||||
raise PDDMError('Ran into directive ("%s", line %d) while in "%s".' %
|
||||
(directive, line_num, self.first_line))
|
||||
# Eat other lines.
|
||||
return (True, True)
|
||||
|
||||
def HitEOF(self):
|
||||
raise PDDMError('Hit the end of the file while in "%s".' %
|
||||
self.first_line)
|
||||
|
||||
def BindMacroCollection(self, macro_collection):
|
||||
self._macro_collection = macro_collection
|
||||
|
||||
@property
|
||||
def lines(self):
|
||||
captured_lines = SourceFile.SectionBase.lines.fget(self)
|
||||
directive_len = len('//%PDDM-EXPAND')
|
||||
result = []
|
||||
for line in captured_lines:
|
||||
result.append(line)
|
||||
if self._macro_collection:
|
||||
# Always add a blank line, seems to read better. (If need be, add an
|
||||
# option to the EXPAND to indicate if this should be done.)
|
||||
result.extend([_GENERATED_CODE_LINE, ''])
|
||||
macro = line[directive_len:].strip()
|
||||
try:
|
||||
expand_result = self._macro_collection.Expand(macro)
|
||||
# Since expansions are line oriented, strip trailing whitespace
|
||||
# from the lines.
|
||||
lines = [x.rstrip() for x in expand_result.split('\n')]
|
||||
result.append('\n'.join(lines))
|
||||
except PDDMError as e:
|
||||
raise PDDMError('%s\n...while expanding "%s" from the section'
|
||||
' that started:\n Line %d: %s' %
|
||||
(e.message, macro,
|
||||
self.first_line_num, self.first_line))
|
||||
|
||||
# Add the ending marker.
|
||||
if len(captured_lines) == 1:
|
||||
result.append('//%%PDDM-EXPAND-END %s' %
|
||||
captured_lines[0][directive_len:].strip())
|
||||
else:
|
||||
result.append('//%%PDDM-EXPAND-END (%s expansions)' %
|
||||
len(captured_lines))
|
||||
return result
|
||||
|
||||
class DefinitionSection(SectionBase):
|
||||
"""Section containing macro definitions"""
|
||||
|
||||
def TryAppend(self, line, line_num):
|
||||
if not line.startswith('//%'):
|
||||
return (False, False)
|
||||
if line.startswith('//%PDDM'):
|
||||
directive = line.split(' ', 1)[0]
|
||||
if directive == "//%PDDM-EXPAND":
|
||||
return False, False
|
||||
if directive not in ('//%PDDM-DEFINE', '//%PDDM-DEFINE-END'):
|
||||
raise PDDMError('Ran into directive ("%s", line %d) while in "%s".' %
|
||||
(directive, line_num, self.first_line))
|
||||
self.Append(line)
|
||||
return (True, True)
|
||||
|
||||
def BindMacroCollection(self, macro_collection):
|
||||
if macro_collection:
|
||||
try:
|
||||
# Parse the lines after stripping the prefix.
|
||||
macro_collection.ParseLines([x[3:] for x in self.lines])
|
||||
except PDDMError as e:
|
||||
raise PDDMError('%s\n...while parsing section that started:\n'
|
||||
' Line %d: %s' %
|
||||
(e.message, self.first_line_num, self.first_line))
|
||||
|
||||
class ImportDefinesSection(SectionBase):
|
||||
"""Section containing an import of PDDM-DEFINES from an external file."""
|
||||
|
||||
def __init__(self, first_line_num, import_resolver):
|
||||
SourceFile.SectionBase.__init__(self, first_line_num)
|
||||
self._import_resolver = import_resolver
|
||||
|
||||
def TryAppend(self, line, line_num):
|
||||
if not line.startswith('//%PDDM-IMPORT-DEFINES '):
|
||||
return (False, False)
|
||||
assert self.num_lines_captured == 0
|
||||
self.Append(line)
|
||||
return (True, False)
|
||||
|
||||
def BindMacroCollection(self, macro_colletion):
|
||||
if not macro_colletion:
|
||||
return
|
||||
if self._import_resolver is None:
|
||||
raise PDDMError('Got an IMPORT-DEFINES without a resolver (line %d):'
|
||||
' "%s".' % (self.first_line_num, self.first_line))
|
||||
import_name = self.first_line.split(' ', 1)[1].strip()
|
||||
imported_file = self._import_resolver(import_name)
|
||||
if imported_file is None:
|
||||
raise PDDMError('Resolver failed to find "%s" (line %d):'
|
||||
' "%s".' %
|
||||
(import_name, self.first_line_num, self.first_line))
|
||||
try:
|
||||
imported_src_file = SourceFile(imported_file, self._import_resolver)
|
||||
imported_src_file._ParseFile()
|
||||
for section in imported_src_file._sections:
|
||||
section.BindMacroCollection(macro_colletion)
|
||||
except PDDMError as e:
|
||||
raise PDDMError('%s\n...while importing defines:\n'
|
||||
' Line %d: %s' %
|
||||
(e.message, self.first_line_num, self.first_line))
|
||||
|
||||
def _ParseFile(self):
|
||||
self._sections = []
|
||||
lines = self._original_content.splitlines()
|
||||
cur_section = None
|
||||
for line_num, line in enumerate(lines, 1):
|
||||
if not cur_section:
|
||||
cur_section = self._MakeSection(line, line_num)
|
||||
was_added, accept_more = cur_section.TryAppend(line, line_num)
|
||||
if not was_added:
|
||||
cur_section = self._MakeSection(line, line_num)
|
||||
was_added, accept_more = cur_section.TryAppend(line, line_num)
|
||||
assert was_added
|
||||
if not accept_more:
|
||||
cur_section = None
|
||||
|
||||
if cur_section:
|
||||
cur_section.HitEOF()
|
||||
|
||||
def _MakeSection(self, line, line_num):
|
||||
if not line.startswith('//%PDDM'):
|
||||
section = self.TextSection(line_num)
|
||||
else:
|
||||
directive = line.split(' ', 1)[0]
|
||||
if directive == '//%PDDM-EXPAND':
|
||||
section = self.ExpansionSection(line_num)
|
||||
elif directive == '//%PDDM-DEFINE':
|
||||
section = self.DefinitionSection(line_num)
|
||||
elif directive == '//%PDDM-IMPORT-DEFINES':
|
||||
section = self.ImportDefinesSection(line_num, self._import_resolver)
|
||||
else:
|
||||
raise PDDMError('Unexpected line %d: "%s".' % (line_num, line))
|
||||
self._sections.append(section)
|
||||
return section
|
||||
|
||||
def ProcessContent(self, strip_expansion=False):
|
||||
"""Processes the file contents."""
|
||||
self._ParseFile()
|
||||
if strip_expansion:
|
||||
# Without a collection the expansions become blank, removing them.
|
||||
collection = None
|
||||
else:
|
||||
collection = MacroCollection()
|
||||
for section in self._sections:
|
||||
section.BindMacroCollection(collection)
|
||||
result = ''
|
||||
for section in self._sections:
|
||||
result += section.text
|
||||
self._processed_content = result
|
||||
|
||||
@property
|
||||
def original_content(self):
|
||||
return self._original_content
|
||||
|
||||
@property
|
||||
def processed_content(self):
|
||||
return self._processed_content
|
||||
|
||||
|
||||
def main(args):
|
||||
usage = '%prog [OPTIONS] PATH ...'
|
||||
description = (
|
||||
'Processes PDDM directives in the given paths and write them back out.'
|
||||
)
|
||||
parser = optparse.OptionParser(usage=usage, description=description)
|
||||
parser.add_option('--dry-run',
|
||||
default=False, action='store_true',
|
||||
help='Don\'t write back to the file(s), just report if the'
|
||||
' contents needs an update and exit with a value of 1.')
|
||||
parser.add_option('--verbose',
|
||||
default=False, action='store_true',
|
||||
help='Reports is a file is already current.')
|
||||
parser.add_option('--collapse',
|
||||
default=False, action='store_true',
|
||||
help='Removes all the generated code.')
|
||||
opts, extra_args = parser.parse_args(args)
|
||||
|
||||
if not extra_args:
|
||||
parser.error('Need at least one file to process')
|
||||
|
||||
result = 0
|
||||
for a_path in extra_args:
|
||||
if not os.path.exists(a_path):
|
||||
sys.stderr.write('ERROR: File not found: %s\n' % a_path)
|
||||
return 100
|
||||
|
||||
def _ImportResolver(name):
|
||||
# resolve based on the file being read.
|
||||
a_dir = os.path.dirname(a_path)
|
||||
import_path = os.path.join(a_dir, name)
|
||||
if not os.path.exists(import_path):
|
||||
return None
|
||||
return open(import_path, 'r')
|
||||
|
||||
with open(a_path, 'r') as f:
|
||||
src_file = SourceFile(f, _ImportResolver)
|
||||
|
||||
try:
|
||||
src_file.ProcessContent(strip_expansion=opts.collapse)
|
||||
except PDDMError as e:
|
||||
sys.stderr.write('ERROR: %s\n...While processing "%s"\n' %
|
||||
(e.message, a_path))
|
||||
return 101
|
||||
|
||||
if src_file.processed_content != src_file.original_content:
|
||||
if not opts.dry_run:
|
||||
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)
|
||||
result = 1
|
||||
elif opts.verbose:
|
||||
print('No update for "%s".' % a_path)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
516
libs/protobuf/objectivec/DevTools/pddm_tests.py
Executable file
516
libs/protobuf/objectivec/DevTools/pddm_tests.py
Executable file
@@ -0,0 +1,516 @@
|
||||
#! /usr/bin/env python3
|
||||
#
|
||||
# Protocol Buffers - Google's data interchange format
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
# https://developers.google.com/protocol-buffers/
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""Tests for pddm.py."""
|
||||
|
||||
import io
|
||||
import unittest
|
||||
|
||||
import pddm
|
||||
|
||||
|
||||
class TestParsingMacros(unittest.TestCase):
|
||||
|
||||
def testParseEmpty(self):
|
||||
f = io.StringIO('')
|
||||
result = pddm.MacroCollection(f)
|
||||
self.assertEqual(len(result._macros), 0)
|
||||
|
||||
def testParseOne(self):
|
||||
f = io.StringIO("""PDDM-DEFINE foo( )
|
||||
body""")
|
||||
result = pddm.MacroCollection(f)
|
||||
self.assertEqual(len(result._macros), 1)
|
||||
macro = result._macros.get('foo')
|
||||
self.assertIsNotNone(macro)
|
||||
self.assertEqual(macro.name, 'foo')
|
||||
self.assertEqual(macro.args, tuple())
|
||||
self.assertEqual(macro.body, 'body')
|
||||
|
||||
def testParseGeneral(self):
|
||||
# Tests multiple defines, spaces in all places, etc.
|
||||
f = io.StringIO("""
|
||||
PDDM-DEFINE noArgs( )
|
||||
body1
|
||||
body2
|
||||
|
||||
PDDM-DEFINE-END
|
||||
|
||||
PDDM-DEFINE oneArg(foo)
|
||||
body3
|
||||
PDDM-DEFINE twoArgs( bar_ , baz )
|
||||
body4
|
||||
body5""")
|
||||
result = pddm.MacroCollection(f)
|
||||
self.assertEqual(len(result._macros), 3)
|
||||
macro = result._macros.get('noArgs')
|
||||
self.assertIsNotNone(macro)
|
||||
self.assertEqual(macro.name, 'noArgs')
|
||||
self.assertEqual(macro.args, tuple())
|
||||
self.assertEqual(macro.body, 'body1\nbody2\n')
|
||||
macro = result._macros.get('oneArg')
|
||||
self.assertIsNotNone(macro)
|
||||
self.assertEqual(macro.name, 'oneArg')
|
||||
self.assertEqual(macro.args, ('foo',))
|
||||
self.assertEqual(macro.body, 'body3')
|
||||
macro = result._macros.get('twoArgs')
|
||||
self.assertIsNotNone(macro)
|
||||
self.assertEqual(macro.name, 'twoArgs')
|
||||
self.assertEqual(macro.args, ('bar_', 'baz'))
|
||||
self.assertEqual(macro.body, 'body4\nbody5')
|
||||
# Add into existing collection
|
||||
f = io.StringIO("""
|
||||
PDDM-DEFINE another(a,b,c)
|
||||
body1
|
||||
body2""")
|
||||
result.ParseInput(f)
|
||||
self.assertEqual(len(result._macros), 4)
|
||||
macro = result._macros.get('another')
|
||||
self.assertIsNotNone(macro)
|
||||
self.assertEqual(macro.name, 'another')
|
||||
self.assertEqual(macro.args, ('a', 'b', 'c'))
|
||||
self.assertEqual(macro.body, 'body1\nbody2')
|
||||
|
||||
def testParseDirectiveIssues(self):
|
||||
test_list = [
|
||||
# Unknown directive
|
||||
('PDDM-DEFINE foo()\nbody\nPDDM-DEFINED foo\nbaz',
|
||||
'Hit a line with an unknown directive: '),
|
||||
# End without begin
|
||||
('PDDM-DEFINE foo()\nbody\nPDDM-DEFINE-END\nPDDM-DEFINE-END\n',
|
||||
'Got DEFINE-END directive without an active macro: '),
|
||||
# Line not in macro block
|
||||
('PDDM-DEFINE foo()\nbody\nPDDM-DEFINE-END\nmumble\n',
|
||||
'Hit a line that wasn\'t a directive and no open macro definition: '),
|
||||
# Redefine macro
|
||||
('PDDM-DEFINE foo()\nbody\nPDDM-DEFINE foo(a)\nmumble\n',
|
||||
'Attempt to redefine macro: '),
|
||||
]
|
||||
for idx, (input_str, expected_prefix) in enumerate(test_list, 1):
|
||||
f = io.StringIO(input_str)
|
||||
try:
|
||||
result = pddm.MacroCollection(f)
|
||||
self.fail('Should throw exception, entry %d' % idx)
|
||||
except pddm.PDDMError as e:
|
||||
self.assertTrue(e.message.startswith(expected_prefix),
|
||||
'Entry %d failed: %r' % (idx, e))
|
||||
|
||||
def testParseBeginIssues(self):
|
||||
test_list = [
|
||||
# 1. No name
|
||||
('PDDM-DEFINE\nmumble',
|
||||
'Failed to parse macro definition: '),
|
||||
# 2. No name (with spaces)
|
||||
('PDDM-DEFINE \nmumble',
|
||||
'Failed to parse macro definition: '),
|
||||
# 3. No open paren
|
||||
('PDDM-DEFINE foo\nmumble',
|
||||
'Failed to parse macro definition: '),
|
||||
# 4. No close paren
|
||||
('PDDM-DEFINE foo(\nmumble',
|
||||
'Failed to parse macro definition: '),
|
||||
# 5. No close paren (with args)
|
||||
('PDDM-DEFINE foo(a, b\nmumble',
|
||||
'Failed to parse macro definition: '),
|
||||
# 6. No name before args
|
||||
('PDDM-DEFINE (a, b)\nmumble',
|
||||
'Failed to parse macro definition: '),
|
||||
# 7. No name before args
|
||||
('PDDM-DEFINE foo bar(a, b)\nmumble',
|
||||
'Failed to parse macro definition: '),
|
||||
# 8. Empty arg name
|
||||
('PDDM-DEFINE foo(a, ,b)\nmumble',
|
||||
'Empty arg name in macro definition: '),
|
||||
('PDDM-DEFINE foo(a,,b)\nmumble',
|
||||
'Empty arg name in macro definition: '),
|
||||
# 10. Duplicate name
|
||||
('PDDM-DEFINE foo(a,b,a,c)\nmumble',
|
||||
'Arg name "a" used more than once in macro definition: '),
|
||||
# 11. Invalid arg name
|
||||
('PDDM-DEFINE foo(a b,c)\nmumble',
|
||||
'Invalid arg name "a b" in macro definition: '),
|
||||
('PDDM-DEFINE foo(a.b,c)\nmumble',
|
||||
'Invalid arg name "a.b" in macro definition: '),
|
||||
('PDDM-DEFINE foo(a-b,c)\nmumble',
|
||||
'Invalid arg name "a-b" in macro definition: '),
|
||||
('PDDM-DEFINE foo(a,b,c.)\nmumble',
|
||||
'Invalid arg name "c." in macro definition: '),
|
||||
# 15. Extra stuff after the name
|
||||
('PDDM-DEFINE foo(a,c) foo\nmumble',
|
||||
'Failed to parse macro definition: '),
|
||||
('PDDM-DEFINE foo(a,c) foo)\nmumble',
|
||||
'Failed to parse macro definition: '),
|
||||
]
|
||||
for idx, (input_str, expected_prefix) in enumerate(test_list, 1):
|
||||
f = io.StringIO(input_str)
|
||||
try:
|
||||
result = pddm.MacroCollection(f)
|
||||
self.fail('Should throw exception, entry %d' % idx)
|
||||
except pddm.PDDMError as e:
|
||||
self.assertTrue(e.message.startswith(expected_prefix),
|
||||
'Entry %d failed: %r' % (idx, e))
|
||||
|
||||
|
||||
class TestExpandingMacros(unittest.TestCase):
|
||||
|
||||
def testExpandBasics(self):
|
||||
f = io.StringIO("""
|
||||
PDDM-DEFINE noArgs( )
|
||||
body1
|
||||
body2
|
||||
|
||||
PDDM-DEFINE-END
|
||||
|
||||
PDDM-DEFINE oneArg(a)
|
||||
body3 a
|
||||
|
||||
PDDM-DEFINE-END
|
||||
|
||||
PDDM-DEFINE twoArgs(b,c)
|
||||
body4 b c
|
||||
body5
|
||||
PDDM-DEFINE-END
|
||||
|
||||
""")
|
||||
mc = pddm.MacroCollection(f)
|
||||
test_list = [
|
||||
('noArgs()',
|
||||
'body1\nbody2\n'),
|
||||
('oneArg(wee)',
|
||||
'body3 wee\n'),
|
||||
('twoArgs(having some, fun)',
|
||||
'body4 having some fun\nbody5'),
|
||||
# One arg, pass empty.
|
||||
('oneArg()',
|
||||
'body3 \n'),
|
||||
# Two args, gets empty in each slot.
|
||||
('twoArgs(, empty)',
|
||||
'body4 empty\nbody5'),
|
||||
('twoArgs(empty, )',
|
||||
'body4 empty \nbody5'),
|
||||
('twoArgs(, )',
|
||||
'body4 \nbody5'),
|
||||
]
|
||||
for idx, (input_str, expected) in enumerate(test_list, 1):
|
||||
result = mc.Expand(input_str)
|
||||
self.assertEqual(result, expected,
|
||||
'Entry %d --\n Result: %r\n Expected: %r' %
|
||||
(idx, result, expected))
|
||||
|
||||
def testExpandArgOptions(self):
|
||||
f = io.StringIO("""
|
||||
PDDM-DEFINE bar(a)
|
||||
a-a$S-a$l-a$L-a$u-a$U
|
||||
PDDM-DEFINE-END
|
||||
""")
|
||||
mc = pddm.MacroCollection(f)
|
||||
|
||||
self.assertEqual(mc.Expand('bar(xYz)'), 'xYz- -xYz-xyz-XYz-XYZ')
|
||||
self.assertEqual(mc.Expand('bar(MnoP)'), 'MnoP- -mnoP-mnop-MnoP-MNOP')
|
||||
# Test empty
|
||||
self.assertEqual(mc.Expand('bar()'), '-----')
|
||||
|
||||
def testExpandSimpleMacroErrors(self):
|
||||
f = io.StringIO("""
|
||||
PDDM-DEFINE foo(a, b)
|
||||
<a-z>
|
||||
PDDM-DEFINE baz(a)
|
||||
a - a$z
|
||||
""")
|
||||
mc = pddm.MacroCollection(f)
|
||||
test_list = [
|
||||
# 1. Unknown macro
|
||||
('bar()',
|
||||
'No macro named "bar".'),
|
||||
('bar(a)',
|
||||
'No macro named "bar".'),
|
||||
# 3. Arg mismatch
|
||||
('foo()',
|
||||
'Expected 2 args, got: "foo()".'),
|
||||
('foo(a b)',
|
||||
'Expected 2 args, got: "foo(a b)".'),
|
||||
('foo(a,b,c)',
|
||||
'Expected 2 args, got: "foo(a,b,c)".'),
|
||||
# 6. Unknown option in expansion
|
||||
('baz(mumble)',
|
||||
'Unknown arg option "a$z" while expanding "baz(mumble)".'),
|
||||
]
|
||||
for idx, (input_str, expected_err) in enumerate(test_list, 1):
|
||||
try:
|
||||
result = mc.Expand(input_str)
|
||||
self.fail('Should throw exception, entry %d' % idx)
|
||||
except pddm.PDDMError as e:
|
||||
self.assertEqual(e.message, expected_err,
|
||||
'Entry %d failed: %r' % (idx, e))
|
||||
|
||||
def testExpandReferences(self):
|
||||
f = io.StringIO("""
|
||||
PDDM-DEFINE StartIt()
|
||||
foo(abc, def)
|
||||
foo(ghi, jkl)
|
||||
PDDM-DEFINE foo(a, b)
|
||||
bar(a, int)
|
||||
bar(b, NSString *)
|
||||
PDDM-DEFINE bar(n, t)
|
||||
- (t)n;
|
||||
- (void)set##n$u##:(t)value;
|
||||
|
||||
""")
|
||||
mc = pddm.MacroCollection(f)
|
||||
expected = """- (int)abc;
|
||||
- (void)setAbc:(int)value;
|
||||
|
||||
- (NSString *)def;
|
||||
- (void)setDef:(NSString *)value;
|
||||
|
||||
- (int)ghi;
|
||||
- (void)setGhi:(int)value;
|
||||
|
||||
- (NSString *)jkl;
|
||||
- (void)setJkl:(NSString *)value;
|
||||
"""
|
||||
self.assertEqual(mc.Expand('StartIt()'), expected)
|
||||
|
||||
def testCatchRecursion(self):
|
||||
f = io.StringIO("""
|
||||
PDDM-DEFINE foo(a, b)
|
||||
bar(1, a)
|
||||
bar(2, b)
|
||||
PDDM-DEFINE bar(x, y)
|
||||
foo(x, y)
|
||||
""")
|
||||
mc = pddm.MacroCollection(f)
|
||||
try:
|
||||
result = mc.Expand('foo(A,B)')
|
||||
self.fail('Should throw exception! Test failed to catch recursion.')
|
||||
except pddm.PDDMError as e:
|
||||
self.assertEqual(e.message,
|
||||
'Found macro recursion, invoking "foo(1, A)":\n...while expanding "bar(1, A)".\n...while expanding "foo(A,B)".')
|
||||
|
||||
|
||||
class TestParsingSource(unittest.TestCase):
|
||||
|
||||
def testBasicParse(self):
|
||||
test_list = [
|
||||
# 1. no directives
|
||||
('a\nb\nc',
|
||||
(3,) ),
|
||||
# 2. One define
|
||||
('a\n//%PDDM-DEFINE foo()\n//%body\nc',
|
||||
(1, 2, 1) ),
|
||||
# 3. Two defines
|
||||
('a\n//%PDDM-DEFINE foo()\n//%body\n//%PDDM-DEFINE bar()\n//%body2\nc',
|
||||
(1, 4, 1) ),
|
||||
# 4. Two defines with ends
|
||||
('a\n//%PDDM-DEFINE foo()\n//%body\n//%PDDM-DEFINE-END\n'
|
||||
'//%PDDM-DEFINE bar()\n//%body2\n//%PDDM-DEFINE-END\nc',
|
||||
(1, 6, 1) ),
|
||||
# 5. One expand, one define (that runs to end of file)
|
||||
('a\n//%PDDM-EXPAND foo()\nbody\n//%PDDM-EXPAND-END\n'
|
||||
'//%PDDM-DEFINE bar()\n//%body2\n',
|
||||
(1, 1, 2) ),
|
||||
# 6. One define ended with an expand.
|
||||
('a\nb\n//%PDDM-DEFINE bar()\n//%body2\n'
|
||||
'//%PDDM-EXPAND bar()\nbody2\n//%PDDM-EXPAND-END\n',
|
||||
(2, 2, 1) ),
|
||||
# 7. Two expands (one end), one define.
|
||||
('a\n//%PDDM-EXPAND foo(1)\nbody\n//%PDDM-EXPAND foo(2)\nbody2\n//%PDDM-EXPAND-END\n'
|
||||
'//%PDDM-DEFINE foo()\n//%body2\n',
|
||||
(1, 2, 2) ),
|
||||
]
|
||||
for idx, (input_str, line_counts) in enumerate(test_list, 1):
|
||||
f = io.StringIO(input_str)
|
||||
sf = pddm.SourceFile(f)
|
||||
sf._ParseFile()
|
||||
self.assertEqual(len(sf._sections), len(line_counts),
|
||||
'Entry %d -- %d != %d' %
|
||||
(idx, len(sf._sections), len(line_counts)))
|
||||
for idx2, (sec, expected) in enumerate(zip(sf._sections, line_counts), 1):
|
||||
self.assertEqual(sec.num_lines_captured, expected,
|
||||
'Entry %d, section %d -- %d != %d' %
|
||||
(idx, idx2, sec.num_lines_captured, expected))
|
||||
|
||||
def testErrors(self):
|
||||
test_list = [
|
||||
# 1. Directive within expansion
|
||||
('//%PDDM-EXPAND a()\n//%PDDM-BOGUS',
|
||||
'Ran into directive ("//%PDDM-BOGUS", line 2) while in "//%PDDM-EXPAND a()".'),
|
||||
('//%PDDM-EXPAND a()\n//%PDDM-DEFINE a()\n//%body\n',
|
||||
'Ran into directive ("//%PDDM-DEFINE", line 2) while in "//%PDDM-EXPAND a()".'),
|
||||
# 3. Expansion ran off end of file
|
||||
('//%PDDM-EXPAND a()\na\nb\n',
|
||||
'Hit the end of the file while in "//%PDDM-EXPAND a()".'),
|
||||
# 4. Directive within define
|
||||
('//%PDDM-DEFINE a()\n//%body\n//%PDDM-BOGUS',
|
||||
'Ran into directive ("//%PDDM-BOGUS", line 3) while in "//%PDDM-DEFINE a()".'),
|
||||
('//%PDDM-DEFINE a()\n//%body\n//%PDDM-EXPAND-END a()',
|
||||
'Ran into directive ("//%PDDM-EXPAND-END", line 3) while in "//%PDDM-DEFINE a()".'),
|
||||
# 6. Directives that shouldn't start sections
|
||||
('a\n//%PDDM-DEFINE-END a()\n//a\n',
|
||||
'Unexpected line 2: "//%PDDM-DEFINE-END a()".'),
|
||||
('a\n//%PDDM-EXPAND-END a()\n//a\n',
|
||||
'Unexpected line 2: "//%PDDM-EXPAND-END a()".'),
|
||||
('//%PDDM-BOGUS\n//a\n',
|
||||
'Unexpected line 1: "//%PDDM-BOGUS".'),
|
||||
]
|
||||
for idx, (input_str, expected_err) in enumerate(test_list, 1):
|
||||
f = io.StringIO(input_str)
|
||||
try:
|
||||
pddm.SourceFile(f)._ParseFile()
|
||||
self.fail('Should throw exception, entry %d' % idx)
|
||||
except pddm.PDDMError as e:
|
||||
self.assertEqual(e.message, expected_err,
|
||||
'Entry %d failed: %r' % (idx, e))
|
||||
|
||||
class TestProcessingSource(unittest.TestCase):
|
||||
|
||||
def testBasics(self):
|
||||
self.maxDiff = None
|
||||
input_str = """
|
||||
//%PDDM-IMPORT-DEFINES ImportFile
|
||||
foo
|
||||
//%PDDM-EXPAND mumble(abc)
|
||||
//%PDDM-EXPAND-END
|
||||
bar
|
||||
//%PDDM-EXPAND mumble(def)
|
||||
//%PDDM-EXPAND mumble(ghi)
|
||||
//%PDDM-EXPAND-END
|
||||
baz
|
||||
//%PDDM-DEFINE mumble(a_)
|
||||
//%a_: getName(a_)
|
||||
"""
|
||||
input_str2 = """
|
||||
//%PDDM-DEFINE getName(x_)
|
||||
//%do##x_$u##(int x_);
|
||||
|
||||
"""
|
||||
expected = """
|
||||
//%PDDM-IMPORT-DEFINES ImportFile
|
||||
foo
|
||||
//%PDDM-EXPAND mumble(abc)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
abc: doAbc(int abc);
|
||||
//%PDDM-EXPAND-END mumble(abc)
|
||||
bar
|
||||
//%PDDM-EXPAND mumble(def)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
def: doDef(int def);
|
||||
//%PDDM-EXPAND mumble(ghi)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
ghi: doGhi(int ghi);
|
||||
//%PDDM-EXPAND-END (2 expansions)
|
||||
baz
|
||||
//%PDDM-DEFINE mumble(a_)
|
||||
//%a_: getName(a_)
|
||||
"""
|
||||
expected_stripped = """
|
||||
//%PDDM-IMPORT-DEFINES ImportFile
|
||||
foo
|
||||
//%PDDM-EXPAND mumble(abc)
|
||||
//%PDDM-EXPAND-END mumble(abc)
|
||||
bar
|
||||
//%PDDM-EXPAND mumble(def)
|
||||
//%PDDM-EXPAND mumble(ghi)
|
||||
//%PDDM-EXPAND-END (2 expansions)
|
||||
baz
|
||||
//%PDDM-DEFINE mumble(a_)
|
||||
//%a_: getName(a_)
|
||||
"""
|
||||
def _Resolver(name):
|
||||
self.assertEqual(name, 'ImportFile')
|
||||
return io.StringIO(input_str2)
|
||||
f = io.StringIO(input_str)
|
||||
sf = pddm.SourceFile(f, _Resolver)
|
||||
sf.ProcessContent()
|
||||
self.assertEqual(sf.processed_content, expected)
|
||||
# Feed it through and nothing should change.
|
||||
f2 = io.StringIO(sf.processed_content)
|
||||
sf2 = pddm.SourceFile(f2, _Resolver)
|
||||
sf2.ProcessContent()
|
||||
self.assertEqual(sf2.processed_content, expected)
|
||||
self.assertEqual(sf2.processed_content, sf.processed_content)
|
||||
# Test stripping (with the original input and expanded version).
|
||||
f2 = io.StringIO(input_str)
|
||||
sf2 = pddm.SourceFile(f2)
|
||||
sf2.ProcessContent(strip_expansion=True)
|
||||
self.assertEqual(sf2.processed_content, expected_stripped)
|
||||
f2 = io.StringIO(sf.processed_content)
|
||||
sf2 = pddm.SourceFile(f2, _Resolver)
|
||||
sf2.ProcessContent(strip_expansion=True)
|
||||
self.assertEqual(sf2.processed_content, expected_stripped)
|
||||
|
||||
def testProcessFileWithMacroParseError(self):
|
||||
input_str = """
|
||||
foo
|
||||
//%PDDM-DEFINE mumble(a_)
|
||||
//%body
|
||||
//%PDDM-DEFINE mumble(x_)
|
||||
//%body2
|
||||
|
||||
"""
|
||||
f = io.StringIO(input_str)
|
||||
sf = pddm.SourceFile(f)
|
||||
try:
|
||||
sf.ProcessContent()
|
||||
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'
|
||||
'...while parsing section that started:\n'
|
||||
' Line 3: //%PDDM-DEFINE mumble(a_)')
|
||||
|
||||
def testProcessFileWithExpandError(self):
|
||||
input_str = """
|
||||
foo
|
||||
//%PDDM-DEFINE mumble(a_)
|
||||
//%body
|
||||
//%PDDM-EXPAND foobar(x_)
|
||||
//%PDDM-EXPAND-END
|
||||
|
||||
"""
|
||||
f = io.StringIO(input_str)
|
||||
sf = pddm.SourceFile(f)
|
||||
try:
|
||||
sf.ProcessContent()
|
||||
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'
|
||||
'...while expanding "foobar(x_)" from the section that'
|
||||
' started:\n Line 5: //%PDDM-EXPAND foobar(x_)')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
176
libs/protobuf/objectivec/GPBAny.pbobjc.h
Normal file
176
libs/protobuf/objectivec/GPBAny.pbobjc.h
Normal file
@@ -0,0 +1,176 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/any.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < 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.
|
||||
**/
|
||||
GPB_FINAL @interface GPBAnyRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBAny
|
||||
|
||||
typedef GPB_ENUM(GPBAny_FieldNumber) {
|
||||
GPBAny_FieldNumber_TypeURL = 1,
|
||||
GPBAny_FieldNumber_Value = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* `Any` contains an arbitrary serialized protocol buffer message along with a
|
||||
* URL that describes the type of the serialized message.
|
||||
*
|
||||
* Protobuf library provides support to pack/unpack Any values in the form
|
||||
* of utility functions or additional generated methods of the Any type.
|
||||
*
|
||||
* Example 1: Pack and unpack a message in C++.
|
||||
*
|
||||
* Foo foo = ...;
|
||||
* Any any;
|
||||
* any.PackFrom(foo);
|
||||
* ...
|
||||
* if (any.UnpackTo(&foo)) {
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* Example 2: Pack and unpack a message in Java.
|
||||
*
|
||||
* Foo foo = ...;
|
||||
* Any any = Any.pack(foo);
|
||||
* ...
|
||||
* if (any.is(Foo.class)) {
|
||||
* foo = any.unpack(Foo.class);
|
||||
* }
|
||||
*
|
||||
* Example 3: Pack and unpack a message in Python.
|
||||
*
|
||||
* foo = Foo(...)
|
||||
* any = Any()
|
||||
* any.Pack(foo)
|
||||
* ...
|
||||
* if any.Is(Foo.DESCRIPTOR):
|
||||
* any.Unpack(foo)
|
||||
* ...
|
||||
*
|
||||
* Example 4: Pack and unpack a message in Go
|
||||
*
|
||||
* foo := &pb.Foo{...}
|
||||
* any, err := anypb.New(foo)
|
||||
* if err != nil {
|
||||
* ...
|
||||
* }
|
||||
* ...
|
||||
* foo := &pb.Foo{}
|
||||
* if err := any.UnmarshalTo(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"
|
||||
* }
|
||||
**/
|
||||
GPB_FINAL @interface GPBAny : GPBMessage
|
||||
|
||||
/**
|
||||
* A URL/resource name that uniquely identifies the type of the serialized
|
||||
* protocol buffer message. This string must contain at least
|
||||
* one "/" character. The last segment of the URL's path must represent
|
||||
* the fully qualified name of the type (as in
|
||||
* `path/google.protobuf.Duration`). The name should be in a canonical form
|
||||
* (e.g., leading "." is not accepted).
|
||||
*
|
||||
* In practice, teams usually precompile into the binary all types that they
|
||||
* expect it to use in the context of Any. However, for URLs which use the
|
||||
* scheme `http`, `https`, or no scheme, one can optionally set up a type
|
||||
* server that maps type URLs to message definitions as follows:
|
||||
*
|
||||
* * If no scheme is provided, `https` is assumed.
|
||||
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
||||
* value in binary format, or produce an error.
|
||||
* * Applications are allowed to cache lookup results based on the
|
||||
* URL, or have them precompiled into a binary to avoid any
|
||||
* lookup. Therefore, binary compatibility needs to be preserved
|
||||
* on changes to types. (Use versioned type names to manage
|
||||
* breaking changes.)
|
||||
*
|
||||
* Note: this functionality is not currently available in the official
|
||||
* protobuf release, and it is not used for type URLs beginning with
|
||||
* type.googleapis.com.
|
||||
*
|
||||
* Schemes other than `http`, `https` (or the empty scheme) might be
|
||||
* used with implementation specific semantics.
|
||||
**/
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
|
||||
|
||||
/** Must be a valid serialized protocol buffer of the above specified type. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSData *value;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
103
libs/protobuf/objectivec/GPBAny.pbobjc.m
Normal file
103
libs/protobuf/objectivec/GPBAny.pbobjc.m
Normal file
@@ -0,0 +1,103 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/any.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBAny.pbobjc.h"
|
||||
|
||||
// @@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
|
||||
|
||||
static GPBFileDescriptor *GPBAnyRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - GPBAny
|
||||
|
||||
@implementation GPBAny
|
||||
|
||||
@dynamic typeURL;
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBAny__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSString *typeURL;
|
||||
NSData *value;
|
||||
} GPBAny__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 = "typeURL",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBAny_FieldNumber_TypeURL,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBAny__storage_, typeURL),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBAny_FieldNumber_Value,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBAny__storage_, value),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeBytes,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBAny class]
|
||||
rootClass:[GPBAnyRoot class]
|
||||
file:GPBAnyRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBAny__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
|
||||
static const char *extraTextFormatInfo =
|
||||
"\001\001\004\241!!\000";
|
||||
[localDescriptor setupExtraTextInfo:extraTextFormatInfo];
|
||||
#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
301
libs/protobuf/objectivec/GPBApi.pbobjc.h
Normal file
301
libs/protobuf/objectivec/GPBApi.pbobjc.h
Normal file
@@ -0,0 +1,301 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/api.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
#import "GPBSourceContext.pbobjc.h"
|
||||
#import "GPBType.pbobjc.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < 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;
|
||||
|
||||
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.
|
||||
**/
|
||||
GPB_FINAL @interface GPBApiRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBApi
|
||||
|
||||
typedef GPB_ENUM(GPBApi_FieldNumber) {
|
||||
GPBApi_FieldNumber_Name = 1,
|
||||
GPBApi_FieldNumber_MethodsArray = 2,
|
||||
GPBApi_FieldNumber_OptionsArray = 3,
|
||||
GPBApi_FieldNumber_Version = 4,
|
||||
GPBApi_FieldNumber_SourceContext = 5,
|
||||
GPBApi_FieldNumber_MixinsArray = 6,
|
||||
GPBApi_FieldNumber_Syntax = 7,
|
||||
};
|
||||
|
||||
/**
|
||||
* Api is a light-weight descriptor for an API Interface.
|
||||
*
|
||||
* Interfaces are also described as "protocol buffer services" in some contexts,
|
||||
* such as by the "service" keyword in a .proto file, but they are different
|
||||
* from API Services, which represent a concrete implementation of an interface
|
||||
* as opposed to simply a description of methods and bindings. They are also
|
||||
* sometimes simply referred to as "APIs" in other contexts, such as the name of
|
||||
* this message itself. See https://cloud.google.com/apis/design/glossary for
|
||||
* detailed terminology.
|
||||
**/
|
||||
GPB_FINAL @interface GPBApi : GPBMessage
|
||||
|
||||
/**
|
||||
* The fully qualified name of this interface, including package name
|
||||
* followed by the interface's simple name.
|
||||
**/
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
|
||||
|
||||
/** The methods of this interface, in unspecified order. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMethod*> *methodsArray;
|
||||
/** The number of items in @c methodsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger methodsArray_Count;
|
||||
|
||||
/** Any metadata attached to the interface. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
|
||||
/** The number of items in @c optionsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
|
||||
|
||||
/**
|
||||
* A version string for this interface. If specified, must have the form
|
||||
* `major-version.minor-version`, as in `1.10`. If the minor version is
|
||||
* omitted, it defaults to zero. If the entire version field is empty, the
|
||||
* major version is derived from the package name, as outlined below. If the
|
||||
* field is not empty, the version in the package name will be verified to be
|
||||
* consistent with what is provided here.
|
||||
*
|
||||
* The versioning schema uses [semantic
|
||||
* versioning](http://semver.org) where the major version number
|
||||
* indicates a breaking change and the minor version an additive,
|
||||
* non-breaking change. Both version numbers are signals to users
|
||||
* what to expect from different versions, and should be carefully
|
||||
* chosen based on the product plan.
|
||||
*
|
||||
* The major version is also reflected in the package name of the
|
||||
* interface, which must end in `v<major-version>`, as in
|
||||
* `google.feature.v1`. For major versions 0 and 1, the suffix can
|
||||
* be omitted. Zero major versions must only be used for
|
||||
* experimental, non-GA interfaces.
|
||||
**/
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *version;
|
||||
|
||||
/**
|
||||
* Source context for the protocol buffer service represented by this
|
||||
* message.
|
||||
**/
|
||||
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
|
||||
/** Test to see if @c sourceContext has been set. */
|
||||
@property(nonatomic, readwrite) BOOL hasSourceContext;
|
||||
|
||||
/** Included interfaces. See [Mixin][]. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMixin*> *mixinsArray;
|
||||
/** The number of items in @c mixinsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger mixinsArray_Count;
|
||||
|
||||
/** The source syntax of the service. */
|
||||
@property(nonatomic, readwrite) enum GPBSyntax syntax;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Fetches the raw value of a @c GPBApi's @c syntax property, even
|
||||
* if the value was not defined by the enum at the time the code was generated.
|
||||
**/
|
||||
int32_t GPBApi_Syntax_RawValue(GPBApi *message);
|
||||
/**
|
||||
* Sets the raw value of an @c GPBApi's @c syntax property, allowing
|
||||
* it to be set to a value that was not defined by the enum at the time the code
|
||||
* was generated.
|
||||
**/
|
||||
void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value);
|
||||
|
||||
#pragma mark - GPBMethod
|
||||
|
||||
typedef GPB_ENUM(GPBMethod_FieldNumber) {
|
||||
GPBMethod_FieldNumber_Name = 1,
|
||||
GPBMethod_FieldNumber_RequestTypeURL = 2,
|
||||
GPBMethod_FieldNumber_RequestStreaming = 3,
|
||||
GPBMethod_FieldNumber_ResponseTypeURL = 4,
|
||||
GPBMethod_FieldNumber_ResponseStreaming = 5,
|
||||
GPBMethod_FieldNumber_OptionsArray = 6,
|
||||
GPBMethod_FieldNumber_Syntax = 7,
|
||||
};
|
||||
|
||||
/**
|
||||
* Method represents a method of an API interface.
|
||||
**/
|
||||
GPB_FINAL @interface GPBMethod : GPBMessage
|
||||
|
||||
/** The simple name of this method. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
|
||||
|
||||
/** A URL of the input message type. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *requestTypeURL;
|
||||
|
||||
/** If true, the request is streamed. */
|
||||
@property(nonatomic, readwrite) BOOL requestStreaming;
|
||||
|
||||
/** The URL of the output message type. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *responseTypeURL;
|
||||
|
||||
/** If true, the response is streamed. */
|
||||
@property(nonatomic, readwrite) BOOL responseStreaming;
|
||||
|
||||
/** Any metadata attached to the method. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
|
||||
/** The number of items in @c optionsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
|
||||
|
||||
/** The source syntax of this method. */
|
||||
@property(nonatomic, readwrite) enum GPBSyntax syntax;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Fetches the raw value of a @c GPBMethod's @c syntax property, even
|
||||
* if the value was not defined by the enum at the time the code was generated.
|
||||
**/
|
||||
int32_t GPBMethod_Syntax_RawValue(GPBMethod *message);
|
||||
/**
|
||||
* Sets the raw value of an @c GPBMethod's @c syntax property, allowing
|
||||
* it to be set to a value that was not defined by the enum at the time the code
|
||||
* was generated.
|
||||
**/
|
||||
void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value);
|
||||
|
||||
#pragma mark - GPBMixin
|
||||
|
||||
typedef GPB_ENUM(GPBMixin_FieldNumber) {
|
||||
GPBMixin_FieldNumber_Name = 1,
|
||||
GPBMixin_FieldNumber_Root = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Declares an API Interface to be included in this interface. The including
|
||||
* interface must redeclare all the methods from the included interface, but
|
||||
* documentation and options are inherited as follows:
|
||||
*
|
||||
* - If after comment and whitespace stripping, the documentation
|
||||
* string of the redeclared method is empty, it will be inherited
|
||||
* from the original method.
|
||||
*
|
||||
* - Each annotation belonging to the service config (http,
|
||||
* visibility) which is not set in the redeclared method will be
|
||||
* inherited.
|
||||
*
|
||||
* - If an http annotation is inherited, the path pattern will be
|
||||
* modified as follows. Any version prefix will be replaced by the
|
||||
* version of the including interface plus the [root][] path if
|
||||
* specified.
|
||||
*
|
||||
* Example of a simple mixin:
|
||||
*
|
||||
* package google.acl.v1;
|
||||
* service AccessControl {
|
||||
* // Get the underlying ACL object.
|
||||
* rpc GetAcl(GetAclRequest) returns (Acl) {
|
||||
* option (google.api.http).get = "/v1/{resource=**}:getAcl";
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* package google.storage.v2;
|
||||
* service Storage {
|
||||
* rpc GetAcl(GetAclRequest) returns (Acl);
|
||||
*
|
||||
* // Get a data record.
|
||||
* rpc GetData(GetDataRequest) returns (Data) {
|
||||
* option (google.api.http).get = "/v2/{resource=**}";
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Example of a mixin configuration:
|
||||
*
|
||||
* apis:
|
||||
* - name: google.storage.v2.Storage
|
||||
* mixins:
|
||||
* - name: google.acl.v1.AccessControl
|
||||
*
|
||||
* The mixin construct implies that all methods in `AccessControl` are
|
||||
* also declared with same name and request/response types in
|
||||
* `Storage`. A documentation generator or annotation processor will
|
||||
* see the effective `Storage.GetAcl` method after inheriting
|
||||
* 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";
|
||||
* }
|
||||
* ...
|
||||
* }
|
||||
**/
|
||||
GPB_FINAL @interface GPBMixin : GPBMessage
|
||||
|
||||
/** The fully qualified name of the interface which is included. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
|
||||
|
||||
/**
|
||||
* If non-empty specifies a path under which inherited HTTP paths
|
||||
* are rooted.
|
||||
**/
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *root;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
357
libs/protobuf/objectivec/GPBApi.pbobjc.m
Normal file
357
libs/protobuf/objectivec/GPBApi.pbobjc.m
Normal file
@@ -0,0 +1,357 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/api.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBApi.pbobjc.h"
|
||||
|
||||
// @@protoc_insertion_point(imports)
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
|
||||
|
||||
#pragma mark - Objective C Class declarations
|
||||
// Forward declarations of Objective C classes that we can use as
|
||||
// static values in struct initializers.
|
||||
// We don't use [Foo class] because it is not a static value.
|
||||
GPBObjCClassDeclaration(GPBMethod);
|
||||
GPBObjCClassDeclaration(GPBMixin);
|
||||
GPBObjCClassDeclaration(GPBOption);
|
||||
GPBObjCClassDeclaration(GPBSourceContext);
|
||||
|
||||
#pragma mark - GPBApiRoot
|
||||
|
||||
@implementation GPBApiRoot
|
||||
|
||||
// No extensions in the file and none of the imports (direct or indirect)
|
||||
// defined extensions, so no need to generate +extensionRegistry.
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBApiRoot_FileDescriptor
|
||||
|
||||
static GPBFileDescriptor *GPBApiRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - GPBApi
|
||||
|
||||
@implementation GPBApi
|
||||
|
||||
@dynamic name;
|
||||
@dynamic methodsArray, methodsArray_Count;
|
||||
@dynamic optionsArray, optionsArray_Count;
|
||||
@dynamic version;
|
||||
@dynamic hasSourceContext, sourceContext;
|
||||
@dynamic mixinsArray, mixinsArray_Count;
|
||||
@dynamic syntax;
|
||||
|
||||
typedef struct GPBApi__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
GPBSyntax syntax;
|
||||
NSString *name;
|
||||
NSMutableArray *methodsArray;
|
||||
NSMutableArray *optionsArray;
|
||||
NSString *version;
|
||||
GPBSourceContext *sourceContext;
|
||||
NSMutableArray *mixinsArray;
|
||||
} GPBApi__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",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBApi_FieldNumber_Name,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBApi__storage_, name),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "methodsArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBMethod),
|
||||
.number = GPBApi_FieldNumber_MethodsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBApi__storage_, methodsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "optionsArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBOption),
|
||||
.number = GPBApi_FieldNumber_OptionsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBApi__storage_, optionsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "version",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBApi_FieldNumber_Version,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBApi__storage_, version),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "sourceContext",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBSourceContext),
|
||||
.number = GPBApi_FieldNumber_SourceContext,
|
||||
.hasIndex = 2,
|
||||
.offset = (uint32_t)offsetof(GPBApi__storage_, sourceContext),
|
||||
.flags = GPBFieldOptional,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "mixinsArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBMixin),
|
||||
.number = GPBApi_FieldNumber_MixinsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBApi__storage_, mixinsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "syntax",
|
||||
.dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
|
||||
.number = GPBApi_FieldNumber_Syntax,
|
||||
.hasIndex = 3,
|
||||
.offset = (uint32_t)offsetof(GPBApi__storage_, syntax),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeEnum,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBApi class]
|
||||
rootClass:[GPBApiRoot class]
|
||||
file:GPBApiRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBApi__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int32_t GPBApi_Syntax_RawValue(GPBApi *message) {
|
||||
GPBDescriptor *descriptor = [GPBApi descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBApi_FieldNumber_Syntax];
|
||||
return GPBGetMessageRawEnumField(message, field);
|
||||
}
|
||||
|
||||
void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value) {
|
||||
GPBDescriptor *descriptor = [GPBApi descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBApi_FieldNumber_Syntax];
|
||||
GPBSetMessageRawEnumField(message, field, value);
|
||||
}
|
||||
|
||||
#pragma mark - GPBMethod
|
||||
|
||||
@implementation GPBMethod
|
||||
|
||||
@dynamic name;
|
||||
@dynamic requestTypeURL;
|
||||
@dynamic requestStreaming;
|
||||
@dynamic responseTypeURL;
|
||||
@dynamic responseStreaming;
|
||||
@dynamic optionsArray, optionsArray_Count;
|
||||
@dynamic syntax;
|
||||
|
||||
typedef struct GPBMethod__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
GPBSyntax syntax;
|
||||
NSString *name;
|
||||
NSString *requestTypeURL;
|
||||
NSString *responseTypeURL;
|
||||
NSMutableArray *optionsArray;
|
||||
} GPBMethod__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",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBMethod_FieldNumber_Name,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBMethod__storage_, name),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "requestTypeURL",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBMethod_FieldNumber_RequestTypeURL,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBMethod__storage_, requestTypeURL),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "requestStreaming",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBMethod_FieldNumber_RequestStreaming,
|
||||
.hasIndex = 2,
|
||||
.offset = 3, // Stored in _has_storage_ to save space.
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeBool,
|
||||
},
|
||||
{
|
||||
.name = "responseTypeURL",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBMethod_FieldNumber_ResponseTypeURL,
|
||||
.hasIndex = 4,
|
||||
.offset = (uint32_t)offsetof(GPBMethod__storage_, responseTypeURL),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "responseStreaming",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBMethod_FieldNumber_ResponseStreaming,
|
||||
.hasIndex = 5,
|
||||
.offset = 6, // Stored in _has_storage_ to save space.
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeBool,
|
||||
},
|
||||
{
|
||||
.name = "optionsArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBOption),
|
||||
.number = GPBMethod_FieldNumber_OptionsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBMethod__storage_, optionsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "syntax",
|
||||
.dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
|
||||
.number = GPBMethod_FieldNumber_Syntax,
|
||||
.hasIndex = 7,
|
||||
.offset = (uint32_t)offsetof(GPBMethod__storage_, syntax),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeEnum,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBMethod class]
|
||||
rootClass:[GPBApiRoot class]
|
||||
file:GPBApiRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBMethod__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#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
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int32_t GPBMethod_Syntax_RawValue(GPBMethod *message) {
|
||||
GPBDescriptor *descriptor = [GPBMethod descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBMethod_FieldNumber_Syntax];
|
||||
return GPBGetMessageRawEnumField(message, field);
|
||||
}
|
||||
|
||||
void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value) {
|
||||
GPBDescriptor *descriptor = [GPBMethod descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBMethod_FieldNumber_Syntax];
|
||||
GPBSetMessageRawEnumField(message, field, value);
|
||||
}
|
||||
|
||||
#pragma mark - GPBMixin
|
||||
|
||||
@implementation GPBMixin
|
||||
|
||||
@dynamic name;
|
||||
@dynamic root;
|
||||
|
||||
typedef struct GPBMixin__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSString *name;
|
||||
NSString *root;
|
||||
} GPBMixin__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",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBMixin_FieldNumber_Name,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBMixin__storage_, name),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "root",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBMixin_FieldNumber_Root,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBMixin__storage_, root),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBMixin class]
|
||||
rootClass:[GPBApiRoot class]
|
||||
file:GPBApiRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBMixin__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
1994
libs/protobuf/objectivec/GPBArray.h
Normal file
1994
libs/protobuf/objectivec/GPBArray.h
Normal file
File diff suppressed because it is too large
Load Diff
2563
libs/protobuf/objectivec/GPBArray.m
Normal file
2563
libs/protobuf/objectivec/GPBArray.m
Normal file
File diff suppressed because it is too large
Load Diff
130
libs/protobuf/objectivec/GPBArray_PackagePrivate.h
Normal file
130
libs/protobuf/objectivec/GPBArray_PackagePrivate.h
Normal file
@@ -0,0 +1,130 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBArray.h"
|
||||
|
||||
@class GPBMessage;
|
||||
|
||||
//%PDDM-DEFINE DECLARE_ARRAY_EXTRAS()
|
||||
//%ARRAY_INTERFACE_EXTRAS(Int32, int32_t)
|
||||
//%ARRAY_INTERFACE_EXTRAS(UInt32, uint32_t)
|
||||
//%ARRAY_INTERFACE_EXTRAS(Int64, int64_t)
|
||||
//%ARRAY_INTERFACE_EXTRAS(UInt64, uint64_t)
|
||||
//%ARRAY_INTERFACE_EXTRAS(Float, float)
|
||||
//%ARRAY_INTERFACE_EXTRAS(Double, double)
|
||||
//%ARRAY_INTERFACE_EXTRAS(Bool, BOOL)
|
||||
//%ARRAY_INTERFACE_EXTRAS(Enum, int32_t)
|
||||
|
||||
//%PDDM-DEFINE ARRAY_INTERFACE_EXTRAS(NAME, TYPE)
|
||||
//%#pragma mark - NAME
|
||||
//%
|
||||
//%@interface GPB##NAME##Array () {
|
||||
//% @package
|
||||
//% GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
//%}
|
||||
//%@end
|
||||
//%
|
||||
|
||||
//%PDDM-EXPAND DECLARE_ARRAY_EXTRAS()
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
#pragma mark - Int32
|
||||
|
||||
@interface GPBInt32Array () {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - UInt32
|
||||
|
||||
@interface GPBUInt32Array () {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - Int64
|
||||
|
||||
@interface GPBInt64Array () {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - UInt64
|
||||
|
||||
@interface GPBUInt64Array () {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - Float
|
||||
|
||||
@interface GPBFloatArray () {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - Double
|
||||
|
||||
@interface GPBDoubleArray () {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - Bool
|
||||
|
||||
@interface GPBBoolArray () {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - Enum
|
||||
|
||||
@interface GPBEnumArray () {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
//%PDDM-EXPAND-END DECLARE_ARRAY_EXTRAS()
|
||||
|
||||
#pragma mark - NSArray Subclass
|
||||
|
||||
@interface GPBAutocreatedArray : NSMutableArray {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
147
libs/protobuf/objectivec/GPBBootstrap.h
Normal file
147
libs/protobuf/objectivec/GPBBootstrap.h
Normal file
@@ -0,0 +1,147 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* The Objective C runtime has complete enough info that most protos 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
|
||||
|
||||
// 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 definition of NS_ENUM (really CF_ENUM) changes based on the C++
|
||||
// standard that is in effect. If it isn't C++11 or higher, the definition
|
||||
// doesn't allow us to forward declare. We work around this one case by
|
||||
// providing a local definition. The default case has to use NS_ENUM for the
|
||||
// magic that is Swift bridging of enums.
|
||||
#if (defined(__cplusplus) && __cplusplus && __cplusplus < 201103L)
|
||||
#define GPB_ENUM(X) \
|
||||
enum X : int32_t X; \
|
||||
enum X : int32_t
|
||||
#else
|
||||
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GPB_ENUM_FWD_DECLARE is used for forward declaring enums, for example:
|
||||
*
|
||||
* ```
|
||||
* GPB_ENUM_FWD_DECLARE(Foo_Enum)
|
||||
*
|
||||
* @interface BarClass : NSObject
|
||||
* @property (nonatomic) enum Foo_Enum value;
|
||||
* - (void)bazMethod:(enum Foo_Enum):value;
|
||||
* @end
|
||||
* ```
|
||||
**/
|
||||
#define GPB_ENUM_FWD_DECLARE(X) enum X : int32_t
|
||||
|
||||
/**
|
||||
* Based upon CF_INLINE. Forces inlining in non DEBUG builds.
|
||||
**/
|
||||
#if !defined(DEBUG)
|
||||
#define GPB_INLINE static __inline__ __attribute__((always_inline))
|
||||
#else
|
||||
#define GPB_INLINE static __inline__
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For use in public headers that might need to deal with ARC.
|
||||
**/
|
||||
#ifndef GPB_UNSAFE_UNRETAINED
|
||||
#if __has_feature(objc_arc)
|
||||
#define GPB_UNSAFE_UNRETAINED __unsafe_unretained
|
||||
#else
|
||||
#define GPB_UNSAFE_UNRETAINED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Attribute used for Objective-C proto interface deprecations without messages.
|
||||
**/
|
||||
#ifndef GPB_DEPRECATED
|
||||
#define GPB_DEPRECATED __attribute__((deprecated))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Attribute used for Objective-C proto interface deprecations with messages.
|
||||
**/
|
||||
#ifndef GPB_DEPRECATED_MSG
|
||||
#if __has_extension(attribute_deprecated_with_message)
|
||||
#define GPB_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
|
||||
#else
|
||||
#define GPB_DEPRECATED_MSG(msg) __attribute__((deprecated))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// If property name starts with init we need to annotate it to get past ARC.
|
||||
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
|
||||
//
|
||||
// Meant to be used internally by generated code.
|
||||
#define GPB_METHOD_FAMILY_NONE __attribute__((objc_method_family(none)))
|
||||
|
||||
// Prevent subclassing of generated proto classes.
|
||||
#ifndef GPB_FINAL
|
||||
#define GPB_FINAL __attribute__((objc_subclassing_restricted))
|
||||
#endif // GPB_FINAL
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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 30004
|
||||
|
||||
// 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
|
||||
254
libs/protobuf/objectivec/GPBCodedInputStream.h
Normal file
254
libs/protobuf/objectivec/GPBCodedInputStream.h
Normal file
@@ -0,0 +1,254 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBExtensionRegistry.h"
|
||||
|
||||
@class GPBMessage;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
/**
|
||||
* @c GPBCodedInputStream exception name. Exceptions raised from
|
||||
* @c GPBCodedInputStream contain an underlying error in the userInfo dictionary
|
||||
* under the GPBCodedInputStreamUnderlyingErrorKey key.
|
||||
**/
|
||||
extern NSString *const GPBCodedInputStreamException;
|
||||
|
||||
/** The key under which the underlying NSError from the exception is stored. */
|
||||
extern NSString *const GPBCodedInputStreamUnderlyingErrorKey;
|
||||
|
||||
/** NSError domain used for @c GPBCodedInputStream errors. */
|
||||
extern NSString *const GPBCodedInputStreamErrorDomain;
|
||||
|
||||
/**
|
||||
* Error code for NSError with @c GPBCodedInputStreamErrorDomain.
|
||||
**/
|
||||
typedef NS_ENUM(NSInteger, GPBCodedInputStreamErrorCode) {
|
||||
/** The size does not fit in the remaining bytes to be read. */
|
||||
GPBCodedInputStreamErrorInvalidSize = -100,
|
||||
/** Attempted to read beyond the subsection limit. */
|
||||
GPBCodedInputStreamErrorSubsectionLimitReached = -101,
|
||||
/** The requested subsection limit is invalid. */
|
||||
GPBCodedInputStreamErrorInvalidSubsectionLimit = -102,
|
||||
/** Invalid tag read. */
|
||||
GPBCodedInputStreamErrorInvalidTag = -103,
|
||||
/** Invalid UTF-8 character in a string. */
|
||||
GPBCodedInputStreamErrorInvalidUTF8 = -104,
|
||||
/** Invalid VarInt read. */
|
||||
GPBCodedInputStreamErrorInvalidVarInt = -105,
|
||||
/** The maximum recursion depth of messages was exceeded. */
|
||||
GPBCodedInputStreamErrorRecursionDepthExceeded = -106,
|
||||
};
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
/**
|
||||
* Reads and decodes protocol message fields.
|
||||
*
|
||||
* The common uses of protocol buffers shouldn't need to use this class.
|
||||
* @c GPBMessage's provide a @c +parseFromData:error: and
|
||||
* @c +parseFromData:extensionRegistry:error: method that will decode a
|
||||
* message for you.
|
||||
*
|
||||
* @note Subclassing of @c GPBCodedInputStream is NOT supported.
|
||||
**/
|
||||
@interface GPBCodedInputStream : NSObject
|
||||
|
||||
/**
|
||||
* Creates a new stream wrapping some data.
|
||||
*
|
||||
* @param data The data to wrap inside the stream.
|
||||
*
|
||||
* @return A newly instanced GPBCodedInputStream.
|
||||
**/
|
||||
+ (instancetype)streamWithData:(NSData *)data;
|
||||
|
||||
/**
|
||||
* Initializes a stream wrapping some data.
|
||||
*
|
||||
* @param data The data to wrap inside the stream.
|
||||
*
|
||||
* @return A newly initialized GPBCodedInputStream.
|
||||
**/
|
||||
- (instancetype)initWithData:(NSData *)data;
|
||||
|
||||
/**
|
||||
* Attempts to read a field tag, returning zero if we have reached EOF.
|
||||
* Protocol message parsers use this to read tags, since a protocol message
|
||||
* may legally end wherever a tag occurs, and zero is not a valid tag number.
|
||||
*
|
||||
* @return The field tag, or zero if EOF was reached.
|
||||
**/
|
||||
- (int32_t)readTag;
|
||||
|
||||
/**
|
||||
* @return A double read from the stream.
|
||||
**/
|
||||
- (double)readDouble;
|
||||
/**
|
||||
* @return A float read from the stream.
|
||||
**/
|
||||
- (float)readFloat;
|
||||
/**
|
||||
* @return A uint64 read from the stream.
|
||||
**/
|
||||
- (uint64_t)readUInt64;
|
||||
/**
|
||||
* @return A uint32 read from the stream.
|
||||
**/
|
||||
- (uint32_t)readUInt32;
|
||||
/**
|
||||
* @return An int64 read from the stream.
|
||||
**/
|
||||
- (int64_t)readInt64;
|
||||
/**
|
||||
* @return An int32 read from the stream.
|
||||
**/
|
||||
- (int32_t)readInt32;
|
||||
/**
|
||||
* @return A fixed64 read from the stream.
|
||||
**/
|
||||
- (uint64_t)readFixed64;
|
||||
/**
|
||||
* @return A fixed32 read from the stream.
|
||||
**/
|
||||
- (uint32_t)readFixed32;
|
||||
/**
|
||||
* @return An enum read from the stream.
|
||||
**/
|
||||
- (int32_t)readEnum;
|
||||
/**
|
||||
* @return A sfixed32 read from the stream.
|
||||
**/
|
||||
- (int32_t)readSFixed32;
|
||||
/**
|
||||
* @return A fixed64 read from the stream.
|
||||
**/
|
||||
- (int64_t)readSFixed64;
|
||||
/**
|
||||
* @return A sint32 read from the stream.
|
||||
**/
|
||||
- (int32_t)readSInt32;
|
||||
/**
|
||||
* @return A sint64 read from the stream.
|
||||
**/
|
||||
- (int64_t)readSInt64;
|
||||
/**
|
||||
* @return A boolean read from the stream.
|
||||
**/
|
||||
- (BOOL)readBool;
|
||||
/**
|
||||
* @return A string read from the stream.
|
||||
**/
|
||||
- (NSString *)readString;
|
||||
/**
|
||||
* @return Data read from the stream.
|
||||
**/
|
||||
- (NSData *)readBytes;
|
||||
|
||||
/**
|
||||
* Read an embedded message field value from the stream.
|
||||
*
|
||||
* @param message The message to set fields on as they are read.
|
||||
* @param extensionRegistry An optional extension registry to use to lookup
|
||||
* extensions for message.
|
||||
**/
|
||||
- (void)readMessage:(GPBMessage *)message
|
||||
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry;
|
||||
|
||||
/**
|
||||
* Reads and discards a single field, given its tag value.
|
||||
*
|
||||
* @param tag The tag number of the field to skip.
|
||||
*
|
||||
* @return NO if the tag is an endgroup tag (in which case nothing is skipped),
|
||||
* YES in all other cases.
|
||||
**/
|
||||
- (BOOL)skipField:(int32_t)tag;
|
||||
|
||||
/**
|
||||
* Reads and discards an entire message. This will read either until EOF or
|
||||
* until an endgroup tag, whichever comes first.
|
||||
**/
|
||||
- (void)skipMessage;
|
||||
|
||||
/**
|
||||
* Check to see if the logical end of the stream has been reached.
|
||||
*
|
||||
* @note This can return NO when there is no more data, but the current parsing
|
||||
* expected more data.
|
||||
*
|
||||
* @return YES if the logical end of the stream has been reached, NO otherwise.
|
||||
**/
|
||||
- (BOOL)isAtEnd;
|
||||
|
||||
/**
|
||||
* @return The offset into the stream.
|
||||
**/
|
||||
- (size_t)position;
|
||||
|
||||
/**
|
||||
* Moves the limit to the given byte offset starting at the current location.
|
||||
*
|
||||
* @exception GPBCodedInputStreamException If the requested bytes exceed the
|
||||
* current limit.
|
||||
*
|
||||
* @param byteLimit The number of bytes to move the limit, offset to the current
|
||||
* location.
|
||||
*
|
||||
* @return The limit offset before moving the new limit.
|
||||
*/
|
||||
- (size_t)pushLimit:(size_t)byteLimit;
|
||||
|
||||
/**
|
||||
* Moves the limit back to the offset as it was before calling pushLimit:.
|
||||
*
|
||||
* @param oldLimit The number of bytes to move the current limit. Usually this
|
||||
* is the value returned by the pushLimit: method.
|
||||
*/
|
||||
- (void)popLimit:(size_t)oldLimit;
|
||||
|
||||
/**
|
||||
* Verifies that the last call to -readTag returned the given tag value. This
|
||||
* is used to verify that a nested group ended with the correct end tag.
|
||||
*
|
||||
* @exception NSParseErrorException If the value does not match the last tag.
|
||||
*
|
||||
* @param expected The tag that was expected.
|
||||
**/
|
||||
- (void)checkLastTagWas:(int32_t)expected;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
499
libs/protobuf/objectivec/GPBCodedInputStream.m
Normal file
499
libs/protobuf/objectivec/GPBCodedInputStream.m
Normal file
@@ -0,0 +1,499 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBCodedInputStream_PackagePrivate.h"
|
||||
|
||||
#import "GPBDictionary_PackagePrivate.h"
|
||||
#import "GPBMessage_PackagePrivate.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
#import "GPBWireFormat.h"
|
||||
|
||||
NSString *const GPBCodedInputStreamException = GPBNSStringifySymbol(GPBCodedInputStreamException);
|
||||
|
||||
NSString *const GPBCodedInputStreamUnderlyingErrorKey =
|
||||
GPBNSStringifySymbol(GPBCodedInputStreamUnderlyingErrorKey);
|
||||
|
||||
NSString *const GPBCodedInputStreamErrorDomain =
|
||||
GPBNSStringifySymbol(GPBCodedInputStreamErrorDomain);
|
||||
|
||||
// Matching:
|
||||
// https://github.com/protocolbuffers/protobuf/blob/main/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L62
|
||||
// private static final int DEFAULT_RECURSION_LIMIT = 100;
|
||||
// https://github.com/protocolbuffers/protobuf/blob/main/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) {
|
||||
RaiseException(GPBCodedInputStreamErrorInvalidSize, nil);
|
||||
}
|
||||
if (newSize > state->currentLimit) {
|
||||
// Fast forward to end of currentLimit;
|
||||
state->bufferPos = state->currentLimit;
|
||||
RaiseException(GPBCodedInputStreamErrorSubsectionLimitReached, nil);
|
||||
}
|
||||
}
|
||||
|
||||
static int8_t ReadRawByte(GPBCodedInputStreamState *state) {
|
||||
CheckSize(state, sizeof(int8_t));
|
||||
return ((int8_t *)state->bytes)[state->bufferPos++];
|
||||
}
|
||||
|
||||
static int32_t ReadRawLittleEndian32(GPBCodedInputStreamState *state) {
|
||||
CheckSize(state, sizeof(int32_t));
|
||||
// Not using OSReadLittleInt32 because it has undocumented dependency
|
||||
// on reads being aligned.
|
||||
int32_t value;
|
||||
memcpy(&value, state->bytes + state->bufferPos, sizeof(int32_t));
|
||||
value = OSSwapLittleToHostInt32(value);
|
||||
state->bufferPos += sizeof(int32_t);
|
||||
return value;
|
||||
}
|
||||
|
||||
static int64_t ReadRawLittleEndian64(GPBCodedInputStreamState *state) {
|
||||
CheckSize(state, sizeof(int64_t));
|
||||
// Not using OSReadLittleInt64 because it has undocumented dependency
|
||||
// on reads being aligned.
|
||||
int64_t value;
|
||||
memcpy(&value, state->bytes + state->bufferPos, sizeof(int64_t));
|
||||
value = OSSwapLittleToHostInt64(value);
|
||||
state->bufferPos += sizeof(int64_t);
|
||||
return value;
|
||||
}
|
||||
|
||||
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)((uint64_t)(b & 0x7F) << shift);
|
||||
if ((b & 0x80) == 0) {
|
||||
return result;
|
||||
}
|
||||
shift += 7;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
double GPBCodedInputStreamReadDouble(GPBCodedInputStreamState *state) {
|
||||
int64_t value = ReadRawLittleEndian64(state);
|
||||
return GPBConvertInt64ToDouble(value);
|
||||
}
|
||||
|
||||
float GPBCodedInputStreamReadFloat(GPBCodedInputStreamState *state) {
|
||||
int32_t value = ReadRawLittleEndian32(state);
|
||||
return GPBConvertInt32ToFloat(value);
|
||||
}
|
||||
|
||||
uint64_t GPBCodedInputStreamReadUInt64(GPBCodedInputStreamState *state) {
|
||||
uint64_t value = ReadRawVarint64(state);
|
||||
return value;
|
||||
}
|
||||
|
||||
uint32_t GPBCodedInputStreamReadUInt32(GPBCodedInputStreamState *state) {
|
||||
uint32_t value = ReadRawVarint32(state);
|
||||
return value;
|
||||
}
|
||||
|
||||
int64_t GPBCodedInputStreamReadInt64(GPBCodedInputStreamState *state) {
|
||||
int64_t value = ReadRawVarint64(state);
|
||||
return value;
|
||||
}
|
||||
|
||||
int32_t GPBCodedInputStreamReadInt32(GPBCodedInputStreamState *state) {
|
||||
int32_t value = ReadRawVarint32(state);
|
||||
return value;
|
||||
}
|
||||
|
||||
uint64_t GPBCodedInputStreamReadFixed64(GPBCodedInputStreamState *state) {
|
||||
uint64_t value = ReadRawLittleEndian64(state);
|
||||
return value;
|
||||
}
|
||||
|
||||
uint32_t GPBCodedInputStreamReadFixed32(GPBCodedInputStreamState *state) {
|
||||
uint32_t value = ReadRawLittleEndian32(state);
|
||||
return value;
|
||||
}
|
||||
|
||||
int32_t GPBCodedInputStreamReadEnum(GPBCodedInputStreamState *state) {
|
||||
int32_t value = ReadRawVarint32(state);
|
||||
return value;
|
||||
}
|
||||
|
||||
int32_t GPBCodedInputStreamReadSFixed32(GPBCodedInputStreamState *state) {
|
||||
int32_t value = ReadRawLittleEndian32(state);
|
||||
return value;
|
||||
}
|
||||
|
||||
int64_t GPBCodedInputStreamReadSFixed64(GPBCodedInputStreamState *state) {
|
||||
int64_t value = ReadRawLittleEndian64(state);
|
||||
return value;
|
||||
}
|
||||
|
||||
int32_t GPBCodedInputStreamReadSInt32(GPBCodedInputStreamState *state) {
|
||||
int32_t value = GPBDecodeZigZag32(ReadRawVarint32(state));
|
||||
return value;
|
||||
}
|
||||
|
||||
int64_t GPBCodedInputStreamReadSInt64(GPBCodedInputStreamState *state) {
|
||||
int64_t value = GPBDecodeZigZag64(ReadRawVarint64(state));
|
||||
return value;
|
||||
}
|
||||
|
||||
BOOL GPBCodedInputStreamReadBool(GPBCodedInputStreamState *state) {
|
||||
return ReadRawVarint64(state) != 0;
|
||||
}
|
||||
|
||||
int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
|
||||
if (GPBCodedInputStreamIsAtEnd(state)) {
|
||||
state->lastTag = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
state->lastTag = ReadRawVarint32(state);
|
||||
// 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;
|
||||
}
|
||||
|
||||
NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state) {
|
||||
int32_t size = ReadRawVarint32(state);
|
||||
NSString *result;
|
||||
if (size == 0) {
|
||||
result = @"";
|
||||
} else {
|
||||
CheckSize(state, size);
|
||||
result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos]
|
||||
length:size
|
||||
encoding:NSUTF8StringEncoding];
|
||||
state->bufferPos += size;
|
||||
if (!result) {
|
||||
#ifdef DEBUG
|
||||
// https://developers.google.com/protocol-buffers/docs/proto#scalar
|
||||
NSLog(@"UTF-8 failure, is some field type 'string' when it should be "
|
||||
@"'bytes'?");
|
||||
#endif
|
||||
RaiseException(GPBCodedInputStreamErrorInvalidUTF8, nil);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) {
|
||||
int32_t size = ReadRawVarint32(state);
|
||||
if (size < 0) return nil;
|
||||
CheckSize(state, size);
|
||||
NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos length:size];
|
||||
state->bufferPos += size;
|
||||
return result;
|
||||
}
|
||||
|
||||
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(GPBCodedInputStreamState *state) {
|
||||
int32_t size = ReadRawVarint32(state);
|
||||
if (size < 0) return nil;
|
||||
CheckSize(state, size);
|
||||
// Cast is safe because freeWhenDone is NO.
|
||||
NSData *result = [[NSData alloc] initWithBytesNoCopy:(void *)(state->bytes + state->bufferPos)
|
||||
length:size
|
||||
freeWhenDone:NO];
|
||||
state->bufferPos += size;
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state, size_t byteLimit) {
|
||||
byteLimit += state->bufferPos;
|
||||
size_t oldLimit = state->currentLimit;
|
||||
if (byteLimit > oldLimit) {
|
||||
RaiseException(GPBCodedInputStreamErrorInvalidSubsectionLimit, nil);
|
||||
}
|
||||
state->currentLimit = byteLimit;
|
||||
return oldLimit;
|
||||
}
|
||||
|
||||
void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state, size_t oldLimit) {
|
||||
state->currentLimit = oldLimit;
|
||||
}
|
||||
|
||||
size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state) {
|
||||
return state->currentLimit - state->bufferPos;
|
||||
}
|
||||
|
||||
BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state) {
|
||||
return (state->bufferPos == state->bufferSize) || (state->bufferPos == state->currentLimit);
|
||||
}
|
||||
|
||||
void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t value) {
|
||||
if (state->lastTag != value) {
|
||||
RaiseException(GPBCodedInputStreamErrorInvalidTag, @"Unexpected tag read");
|
||||
}
|
||||
}
|
||||
|
||||
@implementation GPBCodedInputStream
|
||||
|
||||
+ (instancetype)streamWithData:(NSData *)data {
|
||||
return [[[self alloc] initWithData:data] autorelease];
|
||||
}
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data {
|
||||
if ((self = [super init])) {
|
||||
#ifdef DEBUG
|
||||
NSCAssert([self class] == [GPBCodedInputStream class],
|
||||
@"Subclassing of GPBCodedInputStream is not allowed.");
|
||||
#endif
|
||||
buffer_ = [data retain];
|
||||
state_.bytes = (const uint8_t *)[data bytes];
|
||||
state_.bufferSize = [data length];
|
||||
state_.currentLimit = state_.bufferSize;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[buffer_ release];
|
||||
[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_);
|
||||
}
|
||||
|
||||
- (void)checkLastTagWas:(int32_t)value {
|
||||
GPBCodedInputStreamCheckLastTagWas(&state_, value);
|
||||
}
|
||||
|
||||
- (BOOL)skipField:(int32_t)tag {
|
||||
NSAssert(GPBWireFormatIsValidTag(tag), @"Invalid tag");
|
||||
switch (GPBWireFormatGetTagWireType(tag)) {
|
||||
case GPBWireFormatVarint:
|
||||
GPBCodedInputStreamReadInt32(&state_);
|
||||
return YES;
|
||||
case GPBWireFormatFixed64:
|
||||
SkipRawData(&state_, sizeof(int64_t));
|
||||
return YES;
|
||||
case GPBWireFormatLengthDelimited:
|
||||
SkipRawData(&state_, ReadRawVarint32(&state_));
|
||||
return YES;
|
||||
case GPBWireFormatStartGroup:
|
||||
[self skipMessage];
|
||||
GPBCodedInputStreamCheckLastTagWas(
|
||||
&state_,
|
||||
GPBWireFormatMakeTag(GPBWireFormatGetTagFieldNumber(tag), GPBWireFormatEndGroup));
|
||||
return YES;
|
||||
case GPBWireFormatEndGroup:
|
||||
return NO;
|
||||
case GPBWireFormatFixed32:
|
||||
SkipRawData(&state_, sizeof(int32_t));
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)skipMessage {
|
||||
while (YES) {
|
||||
int32_t tag = GPBCodedInputStreamReadTag(&state_);
|
||||
if (tag == 0 || ![self skipField:tag]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (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_);
|
||||
}
|
||||
|
||||
- (float)readFloat {
|
||||
return GPBCodedInputStreamReadFloat(&state_);
|
||||
}
|
||||
|
||||
- (uint64_t)readUInt64 {
|
||||
return GPBCodedInputStreamReadUInt64(&state_);
|
||||
}
|
||||
|
||||
- (int64_t)readInt64 {
|
||||
return GPBCodedInputStreamReadInt64(&state_);
|
||||
}
|
||||
|
||||
- (int32_t)readInt32 {
|
||||
return GPBCodedInputStreamReadInt32(&state_);
|
||||
}
|
||||
|
||||
- (uint64_t)readFixed64 {
|
||||
return GPBCodedInputStreamReadFixed64(&state_);
|
||||
}
|
||||
|
||||
- (uint32_t)readFixed32 {
|
||||
return GPBCodedInputStreamReadFixed32(&state_);
|
||||
}
|
||||
|
||||
- (BOOL)readBool {
|
||||
return GPBCodedInputStreamReadBool(&state_);
|
||||
}
|
||||
|
||||
- (NSString *)readString {
|
||||
return [GPBCodedInputStreamReadRetainedString(&state_) autorelease];
|
||||
}
|
||||
|
||||
- (void)readGroup:(int32_t)fieldNumber
|
||||
message:(GPBMessage *)message
|
||||
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
|
||||
CheckRecursionLimit(&state_);
|
||||
++state_.recursionDepth;
|
||||
[message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
|
||||
GPBCodedInputStreamCheckLastTagWas(&state_,
|
||||
GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
|
||||
--state_.recursionDepth;
|
||||
}
|
||||
|
||||
- (void)readUnknownGroup:(int32_t)fieldNumber message:(GPBUnknownFieldSet *)message {
|
||||
CheckRecursionLimit(&state_);
|
||||
++state_.recursionDepth;
|
||||
[message mergeFromCodedInputStream:self];
|
||||
GPBCodedInputStreamCheckLastTagWas(&state_,
|
||||
GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
|
||||
--state_.recursionDepth;
|
||||
}
|
||||
|
||||
- (void)readMessage:(GPBMessage *)message
|
||||
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
|
||||
CheckRecursionLimit(&state_);
|
||||
int32_t length = ReadRawVarint32(&state_);
|
||||
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
|
||||
++state_.recursionDepth;
|
||||
[message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
|
||||
GPBCodedInputStreamCheckLastTagWas(&state_, 0);
|
||||
--state_.recursionDepth;
|
||||
GPBCodedInputStreamPopLimit(&state_, oldLimit);
|
||||
}
|
||||
|
||||
- (void)readMapEntry:(id)mapDictionary
|
||||
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
|
||||
field:(GPBFieldDescriptor *)field
|
||||
parentMessage:(GPBMessage *)parentMessage {
|
||||
CheckRecursionLimit(&state_);
|
||||
int32_t length = ReadRawVarint32(&state_);
|
||||
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
|
||||
++state_.recursionDepth;
|
||||
GPBDictionaryReadEntry(mapDictionary, self, extensionRegistry, field, parentMessage);
|
||||
GPBCodedInputStreamCheckLastTagWas(&state_, 0);
|
||||
--state_.recursionDepth;
|
||||
GPBCodedInputStreamPopLimit(&state_, oldLimit);
|
||||
}
|
||||
|
||||
- (NSData *)readBytes {
|
||||
return [GPBCodedInputStreamReadRetainedBytes(&state_) autorelease];
|
||||
}
|
||||
|
||||
- (uint32_t)readUInt32 {
|
||||
return GPBCodedInputStreamReadUInt32(&state_);
|
||||
}
|
||||
|
||||
- (int32_t)readEnum {
|
||||
return GPBCodedInputStreamReadEnum(&state_);
|
||||
}
|
||||
|
||||
- (int32_t)readSFixed32 {
|
||||
return GPBCodedInputStreamReadSFixed32(&state_);
|
||||
}
|
||||
|
||||
- (int64_t)readSFixed64 {
|
||||
return GPBCodedInputStreamReadSFixed64(&state_);
|
||||
}
|
||||
|
||||
- (int32_t)readSInt32 {
|
||||
return GPBCodedInputStreamReadSInt32(&state_);
|
||||
}
|
||||
|
||||
- (int64_t)readSInt64 {
|
||||
return GPBCodedInputStreamReadSInt64(&state_);
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
108
libs/protobuf/objectivec/GPBCodedInputStream_PackagePrivate.h
Normal file
108
libs/protobuf/objectivec/GPBCodedInputStream_PackagePrivate.h
Normal file
@@ -0,0 +1,108 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This header is private to the ProtobolBuffers library and must NOT be
|
||||
// included by any sources outside this library. The contents of this file are
|
||||
// subject to change at any time without notice.
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
|
||||
@class GPBUnknownFieldSet;
|
||||
@class GPBFieldDescriptor;
|
||||
|
||||
typedef struct GPBCodedInputStreamState {
|
||||
const uint8_t *bytes;
|
||||
size_t bufferSize;
|
||||
size_t bufferPos;
|
||||
|
||||
// For parsing subsections of an input stream you can put a hard limit on
|
||||
// how much should be read. Normally the limit is the end of the stream,
|
||||
// but you can adjust it to anywhere, and if you hit it you will be at the
|
||||
// end of the stream, until you adjust the limit.
|
||||
size_t currentLimit;
|
||||
int32_t lastTag;
|
||||
NSUInteger recursionDepth;
|
||||
} GPBCodedInputStreamState;
|
||||
|
||||
@interface GPBCodedInputStream () {
|
||||
@package
|
||||
struct GPBCodedInputStreamState state_;
|
||||
NSData *buffer_;
|
||||
}
|
||||
|
||||
// Group support is deprecated, so we hide this interface from users, but
|
||||
// support for older data.
|
||||
- (void)readGroup:(int32_t)fieldNumber
|
||||
message:(GPBMessage *)message
|
||||
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
|
||||
|
||||
// Reads a group field value from the stream and merges it into the given
|
||||
// UnknownFieldSet.
|
||||
- (void)readUnknownGroup:(int32_t)fieldNumber message:(GPBUnknownFieldSet *)message;
|
||||
|
||||
// Reads a map entry.
|
||||
- (void)readMapEntry:(id)mapDictionary
|
||||
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
|
||||
field:(GPBFieldDescriptor *)field
|
||||
parentMessage:(GPBMessage *)parentMessage;
|
||||
@end
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state);
|
||||
|
||||
double GPBCodedInputStreamReadDouble(GPBCodedInputStreamState *state);
|
||||
float GPBCodedInputStreamReadFloat(GPBCodedInputStreamState *state);
|
||||
uint64_t GPBCodedInputStreamReadUInt64(GPBCodedInputStreamState *state);
|
||||
uint32_t GPBCodedInputStreamReadUInt32(GPBCodedInputStreamState *state);
|
||||
int64_t GPBCodedInputStreamReadInt64(GPBCodedInputStreamState *state);
|
||||
int32_t GPBCodedInputStreamReadInt32(GPBCodedInputStreamState *state);
|
||||
uint64_t GPBCodedInputStreamReadFixed64(GPBCodedInputStreamState *state);
|
||||
uint32_t GPBCodedInputStreamReadFixed32(GPBCodedInputStreamState *state);
|
||||
int32_t GPBCodedInputStreamReadEnum(GPBCodedInputStreamState *state);
|
||||
int32_t GPBCodedInputStreamReadSFixed32(GPBCodedInputStreamState *state);
|
||||
int64_t GPBCodedInputStreamReadSFixed64(GPBCodedInputStreamState *state);
|
||||
int32_t GPBCodedInputStreamReadSInt32(GPBCodedInputStreamState *state);
|
||||
int64_t GPBCodedInputStreamReadSInt64(GPBCodedInputStreamState *state);
|
||||
BOOL GPBCodedInputStreamReadBool(GPBCodedInputStreamState *state);
|
||||
NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state)
|
||||
__attribute((ns_returns_retained));
|
||||
NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state)
|
||||
__attribute((ns_returns_retained));
|
||||
NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(GPBCodedInputStreamState *state)
|
||||
__attribute((ns_returns_retained));
|
||||
|
||||
size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state, size_t byteLimit);
|
||||
void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state, size_t oldLimit);
|
||||
size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state);
|
||||
BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state);
|
||||
void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t value);
|
||||
|
||||
CF_EXTERN_C_END
|
||||
763
libs/protobuf/objectivec/GPBCodedOutputStream.h
Normal file
763
libs/protobuf/objectivec/GPBCodedOutputStream.h
Normal file
@@ -0,0 +1,763 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBRuntimeTypes.h"
|
||||
#import "GPBWireFormat.h"
|
||||
|
||||
@class GPBBoolArray;
|
||||
@class GPBDoubleArray;
|
||||
@class GPBEnumArray;
|
||||
@class GPBFloatArray;
|
||||
@class GPBMessage;
|
||||
@class GPBInt32Array;
|
||||
@class GPBInt64Array;
|
||||
@class GPBUInt32Array;
|
||||
@class GPBUInt64Array;
|
||||
@class GPBUnknownFieldSet;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* @c GPBCodedOutputStream exception names.
|
||||
**/
|
||||
extern NSString *const GPBCodedOutputStreamException_OutOfSpace;
|
||||
extern NSString *const GPBCodedOutputStreamException_WriteFailed;
|
||||
|
||||
/**
|
||||
* Writes out protocol message fields.
|
||||
*
|
||||
* The common uses of protocol buffers shouldn't need to use this class.
|
||||
* GPBMessage's provide a -data method that will serialize the message for you.
|
||||
*
|
||||
* @note Any -write* api can raise the GPBCodedOutputStreamException_*
|
||||
* exceptions.
|
||||
*
|
||||
* @note Subclassing of GPBCodedOutputStream is NOT supported.
|
||||
**/
|
||||
@interface GPBCodedOutputStream : NSObject
|
||||
|
||||
/**
|
||||
* Creates a stream to fill in the given data. Data must be sized to fit or
|
||||
* an error will be raised when out of space.
|
||||
*
|
||||
* @param data The data where the stream will be written to.
|
||||
*
|
||||
* @return A newly instanced GPBCodedOutputStream.
|
||||
**/
|
||||
+ (instancetype)streamWithData:(NSMutableData *)data;
|
||||
|
||||
/**
|
||||
* Creates a stream to write into the given NSOutputStream.
|
||||
*
|
||||
* @param output The output stream where the stream will be written to.
|
||||
*
|
||||
* @return A newly instanced GPBCodedOutputStream.
|
||||
**/
|
||||
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output;
|
||||
|
||||
/**
|
||||
* Initializes a stream to fill in the given data. Data must be sized to fit
|
||||
* or an error will be raised when out of space.
|
||||
*
|
||||
* @param data The data where the stream will be written to.
|
||||
*
|
||||
* @return A newly initialized GPBCodedOutputStream.
|
||||
**/
|
||||
- (instancetype)initWithData:(NSMutableData *)data;
|
||||
|
||||
/**
|
||||
* Initializes a stream to write into the given @c NSOutputStream.
|
||||
*
|
||||
* @param output The output stream where the stream will be written to.
|
||||
*
|
||||
* @return A newly initialized GPBCodedOutputStream.
|
||||
**/
|
||||
- (instancetype)initWithOutputStream:(NSOutputStream *)output;
|
||||
|
||||
/**
|
||||
* Flush any buffered data out.
|
||||
**/
|
||||
- (void)flush;
|
||||
|
||||
/**
|
||||
* Write the raw byte out.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeRawByte:(uint8_t)value;
|
||||
|
||||
/**
|
||||
* Write the tag for the given field number and wire format.
|
||||
*
|
||||
* @param fieldNumber The field number.
|
||||
* @param format The wire format the data for the field will be in.
|
||||
**/
|
||||
- (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;
|
||||
|
||||
/**
|
||||
* Write a 32bit value out in little endian format.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeRawLittleEndian32:(int32_t)value;
|
||||
/**
|
||||
* Write a 64bit value out in little endian format.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeRawLittleEndian64:(int64_t)value;
|
||||
|
||||
/**
|
||||
* Write a 32bit value out in varint format.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeRawVarint32:(int32_t)value;
|
||||
/**
|
||||
* Write a 64bit value out in varint format.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeRawVarint64:(int64_t)value;
|
||||
|
||||
/**
|
||||
* Write a size_t out as a 32bit varint value.
|
||||
*
|
||||
* @note This will truncate 64 bit values to 32.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeRawVarintSizeTAs32:(size_t)value;
|
||||
|
||||
/**
|
||||
* Writes the contents of an NSData out.
|
||||
*
|
||||
* @param data The data to write out.
|
||||
**/
|
||||
- (void)writeRawData:(NSData *)data;
|
||||
/**
|
||||
* Writes out the given data.
|
||||
*
|
||||
* @param data The data blob to write out.
|
||||
* @param offset The offset into the blob to start writing out.
|
||||
* @param length The number of bytes from the blob to write out.
|
||||
**/
|
||||
- (void)writeRawPtr:(const void *)data offset:(size_t)offset length:(size_t)length;
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-EXPAND _WRITE_DECLS()
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
/**
|
||||
* Write a double for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeDouble:(int32_t)fieldNumber value:(double)value;
|
||||
/**
|
||||
* Write a packed array of double for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeDoubleArray:(int32_t)fieldNumber
|
||||
values:(GPBDoubleArray *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a double without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeDoubleNoTag:(double)value;
|
||||
|
||||
/**
|
||||
* Write a float for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeFloat:(int32_t)fieldNumber value:(float)value;
|
||||
/**
|
||||
* Write a packed array of float for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeFloatArray:(int32_t)fieldNumber
|
||||
values:(GPBFloatArray *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a float without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeFloatNoTag:(float)value;
|
||||
|
||||
/**
|
||||
* Write a uint64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
|
||||
/**
|
||||
* Write a packed array of uint64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeUInt64Array:(int32_t)fieldNumber
|
||||
values:(GPBUInt64Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a uint64_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeUInt64NoTag:(uint64_t)value;
|
||||
|
||||
/**
|
||||
* Write a int64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
|
||||
/**
|
||||
* Write a packed array of int64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeInt64Array:(int32_t)fieldNumber
|
||||
values:(GPBInt64Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a int64_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeInt64NoTag:(int64_t)value;
|
||||
|
||||
/**
|
||||
* Write a int32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
|
||||
/**
|
||||
* Write a packed array of int32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeInt32Array:(int32_t)fieldNumber
|
||||
values:(GPBInt32Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a int32_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeInt32NoTag:(int32_t)value;
|
||||
|
||||
/**
|
||||
* Write a uint32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
|
||||
/**
|
||||
* Write a packed array of uint32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeUInt32Array:(int32_t)fieldNumber
|
||||
values:(GPBUInt32Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a uint32_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeUInt32NoTag:(uint32_t)value;
|
||||
|
||||
/**
|
||||
* Write a uint64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
|
||||
/**
|
||||
* Write a packed array of uint64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeFixed64Array:(int32_t)fieldNumber
|
||||
values:(GPBUInt64Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a uint64_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeFixed64NoTag:(uint64_t)value;
|
||||
|
||||
/**
|
||||
* Write a uint32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
|
||||
/**
|
||||
* Write a packed array of uint32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeFixed32Array:(int32_t)fieldNumber
|
||||
values:(GPBUInt32Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a uint32_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeFixed32NoTag:(uint32_t)value;
|
||||
|
||||
/**
|
||||
* Write a int32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
|
||||
/**
|
||||
* Write a packed array of int32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeSInt32Array:(int32_t)fieldNumber
|
||||
values:(GPBInt32Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a int32_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeSInt32NoTag:(int32_t)value;
|
||||
|
||||
/**
|
||||
* Write a int64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
|
||||
/**
|
||||
* Write a packed array of int64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeSInt64Array:(int32_t)fieldNumber
|
||||
values:(GPBInt64Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a int64_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeSInt64NoTag:(int64_t)value;
|
||||
|
||||
/**
|
||||
* Write a int64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
|
||||
/**
|
||||
* Write a packed array of int64_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeSFixed64Array:(int32_t)fieldNumber
|
||||
values:(GPBInt64Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a int64_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeSFixed64NoTag:(int64_t)value;
|
||||
|
||||
/**
|
||||
* Write a int32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
|
||||
/**
|
||||
* Write a packed array of int32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeSFixed32Array:(int32_t)fieldNumber
|
||||
values:(GPBInt32Array *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a int32_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeSFixed32NoTag:(int32_t)value;
|
||||
|
||||
/**
|
||||
* Write a BOOL for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
|
||||
/**
|
||||
* Write a packed array of BOOL for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeBoolArray:(int32_t)fieldNumber
|
||||
values:(GPBBoolArray *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a BOOL without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeBoolNoTag:(BOOL)value;
|
||||
|
||||
/**
|
||||
* Write a int32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
|
||||
/**
|
||||
* Write a packed array of int32_t for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
* @param tag The tag assigned to the values.
|
||||
**/
|
||||
- (void)writeEnumArray:(int32_t)fieldNumber
|
||||
values:(GPBEnumArray *)values
|
||||
tag:(uint32_t)tag;
|
||||
/**
|
||||
* Write a int32_t without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeEnumNoTag:(int32_t)value;
|
||||
|
||||
/**
|
||||
* Write a NSString for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
|
||||
/**
|
||||
* Write an array of NSString for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
**/
|
||||
- (void)writeStringArray:(int32_t)fieldNumber
|
||||
values:(NSArray<NSString*> *)values;
|
||||
/**
|
||||
* Write a NSString without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeStringNoTag:(NSString *)value;
|
||||
|
||||
/**
|
||||
* Write a GPBMessage for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
|
||||
/**
|
||||
* Write an array of GPBMessage for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
**/
|
||||
- (void)writeMessageArray:(int32_t)fieldNumber
|
||||
values:(NSArray<GPBMessage*> *)values;
|
||||
/**
|
||||
* Write a GPBMessage without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeMessageNoTag:(GPBMessage *)value;
|
||||
|
||||
/**
|
||||
* Write a NSData for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
|
||||
/**
|
||||
* Write an array of NSData for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
**/
|
||||
- (void)writeBytesArray:(int32_t)fieldNumber
|
||||
values:(NSArray<NSData*> *)values;
|
||||
/**
|
||||
* Write a NSData without any tag.
|
||||
*
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeBytesNoTag:(NSData *)value;
|
||||
|
||||
/**
|
||||
* Write a GPBMessage for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeGroup:(int32_t)fieldNumber
|
||||
value:(GPBMessage *)value;
|
||||
/**
|
||||
* Write an array of GPBMessage for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
**/
|
||||
- (void)writeGroupArray:(int32_t)fieldNumber
|
||||
values:(NSArray<GPBMessage*> *)values;
|
||||
/**
|
||||
* Write a GPBMessage without any tag (but does write the endGroup tag).
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeGroupNoTag:(int32_t)fieldNumber
|
||||
value:(GPBMessage *)value;
|
||||
|
||||
/**
|
||||
* Write a GPBUnknownFieldSet for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeUnknownGroup:(int32_t)fieldNumber
|
||||
value:(GPBUnknownFieldSet *)value;
|
||||
/**
|
||||
* Write an array of GPBUnknownFieldSet for the given field number.
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the values.
|
||||
* @param values The values to write out.
|
||||
**/
|
||||
- (void)writeUnknownGroupArray:(int32_t)fieldNumber
|
||||
values:(NSArray<GPBUnknownFieldSet*> *)values;
|
||||
/**
|
||||
* Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
|
||||
*
|
||||
* @param fieldNumber The field number assigned to the value.
|
||||
* @param value The value to write out.
|
||||
**/
|
||||
- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
|
||||
value:(GPBUnknownFieldSet *)value;
|
||||
|
||||
//%PDDM-EXPAND-END _WRITE_DECLS()
|
||||
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
Write a MessageSet extension field to the stream. For historical reasons,
|
||||
the wire format differs from normal fields.
|
||||
|
||||
@param fieldNumber The extension field number to write out.
|
||||
@param value The message from where to get the extension.
|
||||
*/
|
||||
- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
|
||||
|
||||
/**
|
||||
Write an unparsed MessageSet extension field to the stream. For historical
|
||||
reasons, the wire format differs from normal fields.
|
||||
|
||||
@param fieldNumber The extension field number to write out.
|
||||
@param value The raw message from where to get the extension.
|
||||
*/
|
||||
- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
// Write methods for types that can be in packed arrays.
|
||||
//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
|
||||
//%/**
|
||||
//% * Write a TYPE for the given field number.
|
||||
//% *
|
||||
//% * @param fieldNumber The field number assigned to the value.
|
||||
//% * @param value The value to write out.
|
||||
//% **/
|
||||
//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
|
||||
//%/**
|
||||
//% * Write a packed array of TYPE for the given field number.
|
||||
//% *
|
||||
//% * @param fieldNumber The field number assigned to the values.
|
||||
//% * @param values The values to write out.
|
||||
//% * @param tag The tag assigned to the values.
|
||||
//% **/
|
||||
//%- (void)write##NAME##Array:(int32_t)fieldNumber
|
||||
//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
|
||||
//% NAME$S tag:(uint32_t)tag;
|
||||
//%/**
|
||||
//% * Write a TYPE without any tag.
|
||||
//% *
|
||||
//% * @param value The value to write out.
|
||||
//% **/
|
||||
//%- (void)write##NAME##NoTag:(TYPE)value;
|
||||
//%
|
||||
// Write methods for types that aren't in packed arrays.
|
||||
//%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
|
||||
//%/**
|
||||
//% * Write a TYPE for the given field number.
|
||||
//% *
|
||||
//% * @param fieldNumber The field number assigned to the value.
|
||||
//% * @param value The value to write out.
|
||||
//% **/
|
||||
//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
|
||||
//%/**
|
||||
//% * Write an array of TYPE for the given field number.
|
||||
//% *
|
||||
//% * @param fieldNumber The field number assigned to the values.
|
||||
//% * @param values The values to write out.
|
||||
//% **/
|
||||
//%- (void)write##NAME##Array:(int32_t)fieldNumber
|
||||
//% NAME$S values:(NSArray<##TYPE##*> *)values;
|
||||
//%/**
|
||||
//% * Write a TYPE without any tag.
|
||||
//% *
|
||||
//% * @param value The value to write out.
|
||||
//% **/
|
||||
//%- (void)write##NAME##NoTag:(TYPE *)value;
|
||||
//%
|
||||
// Special write methods for Groups.
|
||||
//%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
|
||||
//%/**
|
||||
//% * Write a TYPE for the given field number.
|
||||
//% *
|
||||
//% * @param fieldNumber The field number assigned to the value.
|
||||
//% * @param value The value to write out.
|
||||
//% **/
|
||||
//%- (void)write##NAME:(int32_t)fieldNumber
|
||||
//% NAME$S value:(TYPE *)value;
|
||||
//%/**
|
||||
//% * Write an array of TYPE for the given field number.
|
||||
//% *
|
||||
//% * @param fieldNumber The field number assigned to the values.
|
||||
//% * @param values The values to write out.
|
||||
//% **/
|
||||
//%- (void)write##NAME##Array:(int32_t)fieldNumber
|
||||
//% NAME$S values:(NSArray<##TYPE##*> *)values;
|
||||
//%/**
|
||||
//% * Write a TYPE without any tag (but does write the endGroup tag).
|
||||
//% *
|
||||
//% * @param fieldNumber The field number assigned to the value.
|
||||
//% * @param value The value to write out.
|
||||
//% **/
|
||||
//%- (void)write##NAME##NoTag:(int32_t)fieldNumber
|
||||
//% NAME$S value:(TYPE *)value;
|
||||
//%
|
||||
|
||||
// One macro to hide it all up above.
|
||||
//%PDDM-DEFINE _WRITE_DECLS()
|
||||
//%_WRITE_PACKABLE_DECLS(Double, Double, double)
|
||||
//%_WRITE_PACKABLE_DECLS(Float, Float, float)
|
||||
//%_WRITE_PACKABLE_DECLS(UInt64, UInt64, uint64_t)
|
||||
//%_WRITE_PACKABLE_DECLS(Int64, Int64, int64_t)
|
||||
//%_WRITE_PACKABLE_DECLS(Int32, Int32, int32_t)
|
||||
//%_WRITE_PACKABLE_DECLS(UInt32, UInt32, uint32_t)
|
||||
//%_WRITE_PACKABLE_DECLS(Fixed64, UInt64, uint64_t)
|
||||
//%_WRITE_PACKABLE_DECLS(Fixed32, UInt32, uint32_t)
|
||||
//%_WRITE_PACKABLE_DECLS(SInt32, Int32, int32_t)
|
||||
//%_WRITE_PACKABLE_DECLS(SInt64, Int64, int64_t)
|
||||
//%_WRITE_PACKABLE_DECLS(SFixed64, Int64, int64_t)
|
||||
//%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t)
|
||||
//%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL)
|
||||
//%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t)
|
||||
//%_WRITE_UNPACKABLE_DECLS(String, NSString)
|
||||
//%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage)
|
||||
//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)
|
||||
//%_WRITE_GROUP_DECLS(Group, GPBMessage)
|
||||
//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet)
|
||||
|
||||
// clang-format on
|
||||
1111
libs/protobuf/objectivec/GPBCodedOutputStream.m
Normal file
1111
libs/protobuf/objectivec/GPBCodedOutputStream.m
Normal file
File diff suppressed because it is too large
Load Diff
104
libs/protobuf/objectivec/GPBCodedOutputStream_PackagePrivate.h
Normal file
104
libs/protobuf/objectivec/GPBCodedOutputStream_PackagePrivate.h
Normal file
@@ -0,0 +1,104 @@
|
||||
// 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
|
||||
318
libs/protobuf/objectivec/GPBDescriptor.h
Normal file
318
libs/protobuf/objectivec/GPBDescriptor.h
Normal file
@@ -0,0 +1,318 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBRuntimeTypes.h"
|
||||
|
||||
@class GPBEnumDescriptor;
|
||||
@class GPBFieldDescriptor;
|
||||
@class GPBFileDescriptor;
|
||||
@class GPBOneofDescriptor;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** Syntax used in the proto file. */
|
||||
typedef NS_ENUM(uint8_t, GPBFileSyntax) {
|
||||
/** Unknown syntax. */
|
||||
GPBFileSyntaxUnknown = 0,
|
||||
/** Proto2 syntax. */
|
||||
GPBFileSyntaxProto2 = 2,
|
||||
/** Proto3 syntax. */
|
||||
GPBFileSyntaxProto3 = 3,
|
||||
};
|
||||
|
||||
/** Type of proto field. */
|
||||
typedef NS_ENUM(uint8_t, GPBFieldType) {
|
||||
/** Optional/required field. Only valid for proto2 fields. */
|
||||
GPBFieldTypeSingle,
|
||||
/** Repeated field. */
|
||||
GPBFieldTypeRepeated,
|
||||
/** Map field. */
|
||||
GPBFieldTypeMap,
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes a proto message.
|
||||
**/
|
||||
@interface GPBDescriptor : NSObject <NSCopying>
|
||||
|
||||
/** Name of the message. */
|
||||
@property(nonatomic, readonly, copy) NSString *name;
|
||||
/** Fields declared in the message. */
|
||||
@property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor *> *fields;
|
||||
/** Oneofs declared in the message. */
|
||||
@property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor *> *oneofs;
|
||||
/** Extension range declared for the message. */
|
||||
@property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges;
|
||||
/** Number of extension ranges declared for the message. */
|
||||
@property(nonatomic, readonly) uint32_t extensionRangesCount;
|
||||
/** Descriptor for the file where the message was defined. */
|
||||
@property(nonatomic, readonly) GPBFileDescriptor *file;
|
||||
|
||||
/** Whether the message is in wire format or not. */
|
||||
@property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat;
|
||||
/** The class of this message. */
|
||||
@property(nonatomic, readonly) Class messageClass;
|
||||
/** Containing message descriptor if this message is nested, or nil otherwise. */
|
||||
@property(readonly, nullable) GPBDescriptor *containingType;
|
||||
/**
|
||||
* Fully qualified name for this message (package.message). Can be nil if the
|
||||
* value is unable to be computed.
|
||||
*/
|
||||
@property(readonly, nullable) NSString *fullName;
|
||||
|
||||
/**
|
||||
* Gets the field for the given number.
|
||||
*
|
||||
* @param fieldNumber The number for the field to get.
|
||||
*
|
||||
* @return The field descriptor for the given number, or nil if not found.
|
||||
**/
|
||||
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
|
||||
|
||||
/**
|
||||
* Gets the field for the given name.
|
||||
*
|
||||
* @param name The name for the field to get.
|
||||
*
|
||||
* @return The field descriptor for the given name, or nil if not found.
|
||||
**/
|
||||
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
|
||||
|
||||
/**
|
||||
* Gets the oneof for the given name.
|
||||
*
|
||||
* @param name The name for the oneof to get.
|
||||
*
|
||||
* @return The oneof descriptor for the given name, or nil if not found.
|
||||
**/
|
||||
- (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Describes a proto file.
|
||||
**/
|
||||
@interface GPBFileDescriptor : NSObject
|
||||
|
||||
/** The package declared in the proto file. */
|
||||
@property(nonatomic, readonly, copy) NSString *package;
|
||||
/** The objc prefix declared in the proto file. */
|
||||
@property(nonatomic, readonly, copy, nullable) NSString *objcPrefix;
|
||||
/** The syntax of the proto file. */
|
||||
@property(nonatomic, readonly) GPBFileSyntax syntax;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Describes a oneof field.
|
||||
**/
|
||||
@interface GPBOneofDescriptor : NSObject
|
||||
/** Name of the oneof field. */
|
||||
@property(nonatomic, readonly) NSString *name;
|
||||
/** Fields declared in the oneof. */
|
||||
@property(nonatomic, readonly) NSArray<GPBFieldDescriptor *> *fields;
|
||||
|
||||
/**
|
||||
* Gets the field for the given number.
|
||||
*
|
||||
* @param fieldNumber The number for the field to get.
|
||||
*
|
||||
* @return The field descriptor for the given number, or nil if not found.
|
||||
**/
|
||||
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
|
||||
|
||||
/**
|
||||
* Gets the field for the given name.
|
||||
*
|
||||
* @param name The name for the field to get.
|
||||
*
|
||||
* @return The field descriptor for the given name, or nil if not found.
|
||||
**/
|
||||
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Describes a proto field.
|
||||
**/
|
||||
@interface GPBFieldDescriptor : NSObject
|
||||
|
||||
/** Name of the field. */
|
||||
@property(nonatomic, readonly, copy) NSString *name;
|
||||
/** Number associated with the field. */
|
||||
@property(nonatomic, readonly) uint32_t number;
|
||||
/** Data type contained in the field. */
|
||||
@property(nonatomic, readonly) GPBDataType dataType;
|
||||
/** Whether it has a default value or not. */
|
||||
@property(nonatomic, readonly) BOOL hasDefaultValue;
|
||||
/** Default value for the field. */
|
||||
@property(nonatomic, readonly) GPBGenericValue defaultValue;
|
||||
/** Whether this field is required. Only valid for proto2 fields. */
|
||||
@property(nonatomic, readonly, getter=isRequired) BOOL required;
|
||||
/** Whether this field is optional. */
|
||||
@property(nonatomic, readonly, getter=isOptional) BOOL optional;
|
||||
/** Type of field (single, repeated, map). */
|
||||
@property(nonatomic, readonly) GPBFieldType fieldType;
|
||||
/** Type of the key if the field is a map. The value's type is -dataType. */
|
||||
@property(nonatomic, readonly) GPBDataType mapKeyDataType;
|
||||
/** Whether the field is packable. */
|
||||
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
|
||||
|
||||
/** The containing oneof if this field is part of one, nil otherwise. */
|
||||
@property(nonatomic, readonly, nullable) GPBOneofDescriptor *containingOneof;
|
||||
|
||||
/** Class of the message if the field is of message type. */
|
||||
@property(nonatomic, readonly, nullable) Class msgClass;
|
||||
|
||||
/** Descriptor for the enum if this field is an enum. */
|
||||
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
|
||||
|
||||
/**
|
||||
* Checks whether the given enum raw value is a valid enum value.
|
||||
*
|
||||
* @param value The raw enum value to check.
|
||||
*
|
||||
* @return YES if value is a valid enum raw value.
|
||||
**/
|
||||
- (BOOL)isValidEnumValue:(int32_t)value;
|
||||
|
||||
/** @return Name for the text format, or nil if not known. */
|
||||
- (nullable NSString *)textFormatName;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Describes a proto enum.
|
||||
**/
|
||||
@interface GPBEnumDescriptor : NSObject
|
||||
|
||||
/** Name of the enum. */
|
||||
@property(nonatomic, readonly, copy) NSString *name;
|
||||
/** Function that validates that raw values are valid enum values. */
|
||||
@property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier;
|
||||
|
||||
/**
|
||||
* Returns the enum value name for the given raw enum.
|
||||
*
|
||||
* Note that there can be more than one name corresponding to a given value
|
||||
* if the allow_alias option is used.
|
||||
*
|
||||
* @param number The raw enum value.
|
||||
*
|
||||
* @return The first name that matches the enum value passed, or nil if not valid.
|
||||
**/
|
||||
- (nullable NSString *)enumNameForValue:(int32_t)number;
|
||||
|
||||
/**
|
||||
* Gets the enum raw value for the given enum name.
|
||||
*
|
||||
* @param outValue A pointer where the value will be set.
|
||||
* @param name The enum name for which to get the raw value.
|
||||
*
|
||||
* @return YES if a value was copied into the pointer, NO otherwise.
|
||||
**/
|
||||
- (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name;
|
||||
|
||||
/**
|
||||
* Returns the text format for the given raw enum value.
|
||||
*
|
||||
* @param number The raw enum value.
|
||||
*
|
||||
* @return The first text format name which matches the enum value, or nil if not valid.
|
||||
**/
|
||||
- (nullable NSString *)textFormatNameForValue:(int32_t)number;
|
||||
|
||||
/**
|
||||
* Gets the enum raw value for the given text format name.
|
||||
*
|
||||
* @param outValue A pointer where the value will be set.
|
||||
* @param textFormatName The text format name for which to get the raw value.
|
||||
*
|
||||
* @return YES if a value was copied into the pointer, NO otherwise.
|
||||
**/
|
||||
- (BOOL)getValue:(nullable int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName;
|
||||
|
||||
/**
|
||||
* Gets the number of defined enum names.
|
||||
*
|
||||
* @return Count of the number of enum names, including any aliases.
|
||||
*/
|
||||
@property(nonatomic, readonly) uint32_t enumNameCount;
|
||||
|
||||
/**
|
||||
* Gets the enum name corresponding to the given index.
|
||||
*
|
||||
* @param index Index into the available names. The defined range is from 0
|
||||
* to self.enumNameCount - 1.
|
||||
*
|
||||
* @returns The enum name at the given index, or nil if the index is out of range.
|
||||
*/
|
||||
- (nullable NSString *)getEnumNameForIndex:(uint32_t)index;
|
||||
|
||||
/**
|
||||
* Gets the enum text format name corresponding to the given index.
|
||||
*
|
||||
* @param index Index into the available names. The defined range is from 0
|
||||
* to self.enumNameCount - 1.
|
||||
*
|
||||
* @returns The text format name at the given index, or nil if the index is out of range.
|
||||
*/
|
||||
- (nullable NSString *)getEnumTextFormatNameForIndex:(uint32_t)index;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Describes a proto extension.
|
||||
**/
|
||||
@interface GPBExtensionDescriptor : NSObject <NSCopying>
|
||||
/** Field number under which the extension is stored. */
|
||||
@property(nonatomic, readonly) uint32_t fieldNumber;
|
||||
/** The containing message class, i.e. the class extended by this extension. */
|
||||
@property(nonatomic, readonly) Class containingMessageClass;
|
||||
/** Data type contained in the extension. */
|
||||
@property(nonatomic, readonly) GPBDataType dataType;
|
||||
/** Whether the extension is repeated. */
|
||||
@property(nonatomic, readonly, getter=isRepeated) BOOL repeated;
|
||||
/** Whether the extension is packable. */
|
||||
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
|
||||
/** The class of the message if the extension is of message type. */
|
||||
@property(nonatomic, readonly) Class msgClass;
|
||||
/** The singleton name for the extension. */
|
||||
@property(nonatomic, readonly) NSString *singletonName;
|
||||
/** The enum descriptor if the extension is of enum type. */
|
||||
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
|
||||
/** The default value for the extension. */
|
||||
@property(nonatomic, readonly, nullable) id defaultValue;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
1106
libs/protobuf/objectivec/GPBDescriptor.m
Normal file
1106
libs/protobuf/objectivec/GPBDescriptor.m
Normal file
File diff suppressed because it is too large
Load Diff
360
libs/protobuf/objectivec/GPBDescriptor_PackagePrivate.h
Normal file
360
libs/protobuf/objectivec/GPBDescriptor_PackagePrivate.h
Normal file
@@ -0,0 +1,360 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This header is private to the ProtobolBuffers library and must NOT be
|
||||
// included by any sources outside this library. The contents of this file are
|
||||
// subject to change at any time without notice.
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBWireFormat.h"
|
||||
|
||||
// Describes attributes of the field.
|
||||
typedef NS_OPTIONS(uint16_t, GPBFieldFlags) {
|
||||
GPBFieldNone = 0,
|
||||
// These map to standard protobuf concepts.
|
||||
GPBFieldRequired = 1 << 0,
|
||||
GPBFieldRepeated = 1 << 1,
|
||||
GPBFieldPacked = 1 << 2,
|
||||
GPBFieldOptional = 1 << 3,
|
||||
GPBFieldHasDefaultValue = 1 << 4,
|
||||
|
||||
// Indicate that the field should "clear" when set to zero value. This is the
|
||||
// proto3 non optional behavior for singular data (ints, data, string, enum)
|
||||
// fields.
|
||||
GPBFieldClearHasIvarOnZero = 1 << 5,
|
||||
// Indicates the field needs custom handling for the TextFormat name, if not
|
||||
// set, the name can be derived from the ObjC name.
|
||||
GPBFieldTextFormatNameCustom = 1 << 6,
|
||||
// Indicates the field has an enum descriptor.
|
||||
GPBFieldHasEnumDescriptor = 1 << 7,
|
||||
|
||||
// These are not standard protobuf concepts, they are specific to the
|
||||
// Objective C runtime.
|
||||
|
||||
// These bits are used to mark the field as a map and what the key
|
||||
// type is.
|
||||
GPBFieldMapKeyMask = 0xF << 8,
|
||||
GPBFieldMapKeyInt32 = 1 << 8,
|
||||
GPBFieldMapKeyInt64 = 2 << 8,
|
||||
GPBFieldMapKeyUInt32 = 3 << 8,
|
||||
GPBFieldMapKeyUInt64 = 4 << 8,
|
||||
GPBFieldMapKeySInt32 = 5 << 8,
|
||||
GPBFieldMapKeySInt64 = 6 << 8,
|
||||
GPBFieldMapKeyFixed32 = 7 << 8,
|
||||
GPBFieldMapKeyFixed64 = 8 << 8,
|
||||
GPBFieldMapKeySFixed32 = 9 << 8,
|
||||
GPBFieldMapKeySFixed64 = 10 << 8,
|
||||
GPBFieldMapKeyBool = 11 << 8,
|
||||
GPBFieldMapKeyString = 12 << 8,
|
||||
};
|
||||
|
||||
// NOTE: The structures defined here have their members ordered to minimize
|
||||
// their size. This directly impacts the size of apps since these exist per
|
||||
// field/extension.
|
||||
|
||||
// Describes a single field in a protobuf as it is represented as an ivar.
|
||||
typedef struct GPBMessageFieldDescription {
|
||||
// Name of ivar.
|
||||
const char *name;
|
||||
union {
|
||||
// className is deprecated and will be removed in favor of clazz.
|
||||
// kept around right now for backwards compatibility.
|
||||
// clazz is used iff GPBDescriptorInitializationFlag_UsesClassRefs is set.
|
||||
char *className; // Name of the class of the message.
|
||||
Class clazz; // Class of the message.
|
||||
// For enums only: If EnumDescriptors are compiled in, it will be that,
|
||||
// otherwise it will be the verifier.
|
||||
GPBEnumDescriptorFunc enumDescFunc;
|
||||
GPBEnumValidationFunc enumVerifier;
|
||||
} dataTypeSpecific;
|
||||
// The field number for the ivar.
|
||||
uint32_t number;
|
||||
// The index (in bits) into _has_storage_.
|
||||
// >= 0: the bit to use for a value being set.
|
||||
// = GPBNoHasBit(INT32_MAX): no storage used.
|
||||
// < 0: in a oneOf, use a full int32 to record the field active.
|
||||
int32_t hasIndex;
|
||||
// Offset of the variable into it's structure struct.
|
||||
uint32_t offset;
|
||||
// Field flags. Use accessor functions below.
|
||||
GPBFieldFlags flags;
|
||||
// Data type of the ivar.
|
||||
GPBDataType dataType;
|
||||
} GPBMessageFieldDescription;
|
||||
|
||||
// Fields in messages defined in a 'proto2' syntax file can provide a default
|
||||
// value. This struct provides the default along with the field info.
|
||||
typedef struct GPBMessageFieldDescriptionWithDefault {
|
||||
// Default value for the ivar.
|
||||
GPBGenericValue defaultValue;
|
||||
|
||||
GPBMessageFieldDescription core;
|
||||
} GPBMessageFieldDescriptionWithDefault;
|
||||
|
||||
// Describes attributes of the extension.
|
||||
typedef NS_OPTIONS(uint8_t, GPBExtensionOptions) {
|
||||
GPBExtensionNone = 0,
|
||||
// These map to standard protobuf concepts.
|
||||
GPBExtensionRepeated = 1 << 0,
|
||||
GPBExtensionPacked = 1 << 1,
|
||||
GPBExtensionSetWireFormat = 1 << 2,
|
||||
};
|
||||
|
||||
// An extension
|
||||
typedef struct GPBExtensionDescription {
|
||||
GPBGenericValue defaultValue;
|
||||
const char *singletonName;
|
||||
// Before 3.12, `extendedClass` was just a `const char *`. Thanks to nested
|
||||
// initialization
|
||||
// (https://en.cppreference.com/w/c/language/struct_initialization#Nested_initialization) old
|
||||
// generated code with `.extendedClass = GPBStringifySymbol(Something)` still works; and the
|
||||
// current generator can use `extendedClass.clazz`, to pass a Class reference.
|
||||
union {
|
||||
const char *name;
|
||||
Class clazz;
|
||||
} extendedClass;
|
||||
// Before 3.12, this was `const char *messageOrGroupClassName`. In the
|
||||
// initial 3.12 release, we moved the `union messageOrGroupClass`, and failed
|
||||
// to realize that would break existing source code for extensions. So to
|
||||
// keep existing source code working, we added an unnamed union (C11) to
|
||||
// provide both the old field name and the new union. This keeps both older
|
||||
// and newer code working.
|
||||
// Background: https://github.com/protocolbuffers/protobuf/issues/7555
|
||||
union {
|
||||
const char *messageOrGroupClassName;
|
||||
union {
|
||||
const char *name;
|
||||
Class clazz;
|
||||
} messageOrGroupClass;
|
||||
};
|
||||
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,
|
||||
|
||||
// This is used as a stopgap as we move from using class names to class
|
||||
// references. The runtime needs to support both until we allow a
|
||||
// breaking change in the runtime.
|
||||
GPBDescriptorInitializationFlag_UsesClassRefs = 1 << 2,
|
||||
|
||||
// This flag is used to indicate that the generated sources already contain
|
||||
// the `GPBFieldClearHasIvarOnZero` flag and it doesn't have to be computed
|
||||
// at startup. This allows older generated code to still work with the
|
||||
// current runtime library.
|
||||
GPBDescriptorInitializationFlag_Proto3OptionalKnown = 1 << 3,
|
||||
};
|
||||
|
||||
@interface GPBDescriptor () {
|
||||
@package
|
||||
NSArray *fields_;
|
||||
NSArray *oneofs_;
|
||||
uint32_t storageSize_;
|
||||
}
|
||||
|
||||
// fieldDescriptions have to be long lived, they are held as raw pointers.
|
||||
+ (instancetype)allocDescriptorForClass:(Class)messageClass
|
||||
rootClass:(Class)rootClass
|
||||
file:(GPBFileDescriptor *)file
|
||||
fields:(void *)fieldDescriptions
|
||||
fieldCount:(uint32_t)fieldCount
|
||||
storageSize:(uint32_t)storageSize
|
||||
flags:(GPBDescriptorInitializationFlags)flags;
|
||||
|
||||
- (instancetype)initWithClass:(Class)messageClass
|
||||
file:(GPBFileDescriptor *)file
|
||||
fields:(NSArray *)fields
|
||||
storageSize:(uint32_t)storage
|
||||
wireFormat:(BOOL)wireFormat;
|
||||
|
||||
// Called right after init to provide extra information to avoid init having
|
||||
// an explosion of args. These pointers are recorded, so they are expected
|
||||
// to live for the lifetime of the app.
|
||||
- (void)setupOneofs:(const char **)oneofNames
|
||||
count:(uint32_t)count
|
||||
firstHasIndex:(int32_t)firstHasIndex;
|
||||
- (void)setupExtraTextInfo:(const char *)extraTextFormatInfo;
|
||||
- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count;
|
||||
- (void)setupContainingMessageClass:(Class)msgClass;
|
||||
- (void)setupMessageClassNameSuffix:(NSString *)suffix;
|
||||
|
||||
// Deprecated. Use setupContainingMessageClass instead.
|
||||
- (void)setupContainingMessageClassName:(const char *)msgClassName;
|
||||
|
||||
@end
|
||||
|
||||
@interface GPBFileDescriptor ()
|
||||
- (instancetype)initWithPackage:(NSString *)package
|
||||
objcPrefix:(NSString *)objcPrefix
|
||||
syntax:(GPBFileSyntax)syntax;
|
||||
- (instancetype)initWithPackage:(NSString *)package syntax:(GPBFileSyntax)syntax;
|
||||
@end
|
||||
|
||||
@interface GPBOneofDescriptor () {
|
||||
@package
|
||||
const char *name_;
|
||||
NSArray *fields_;
|
||||
SEL caseSel_;
|
||||
}
|
||||
// name must be long lived.
|
||||
- (instancetype)initWithName:(const char *)name fields:(NSArray *)fields;
|
||||
@end
|
||||
|
||||
@interface GPBFieldDescriptor () {
|
||||
@package
|
||||
GPBMessageFieldDescription *description_;
|
||||
GPB_UNSAFE_UNRETAINED GPBOneofDescriptor *containingOneof_;
|
||||
|
||||
SEL getSel_;
|
||||
SEL setSel_;
|
||||
SEL hasOrCountSel_; // *Count for map<>/repeated fields, has* otherwise.
|
||||
SEL setHasSel_;
|
||||
}
|
||||
|
||||
// Single initializer
|
||||
// description has to be long lived, it is held as a raw pointer.
|
||||
- (instancetype)initWithFieldDescription:(void *)description
|
||||
includesDefault:(BOOL)includesDefault
|
||||
usesClassRefs:(BOOL)usesClassRefs
|
||||
proto3OptionalKnown:(BOOL)proto3OptionalKnown
|
||||
syntax:(GPBFileSyntax)syntax;
|
||||
|
||||
@end
|
||||
|
||||
@interface GPBEnumDescriptor ()
|
||||
// valueNames, values and extraTextFormatInfo have to be long lived, they are
|
||||
// held as raw pointers.
|
||||
+ (instancetype)allocDescriptorForName:(NSString *)name
|
||||
valueNames:(const char *)valueNames
|
||||
values:(const int32_t *)values
|
||||
count:(uint32_t)valueCount
|
||||
enumVerifier:(GPBEnumValidationFunc)enumVerifier;
|
||||
+ (instancetype)allocDescriptorForName:(NSString *)name
|
||||
valueNames:(const char *)valueNames
|
||||
values:(const int32_t *)values
|
||||
count:(uint32_t)valueCount
|
||||
enumVerifier:(GPBEnumValidationFunc)enumVerifier
|
||||
extraTextFormatInfo:(const char *)extraTextFormatInfo;
|
||||
|
||||
- (instancetype)initWithName:(NSString *)name
|
||||
valueNames:(const char *)valueNames
|
||||
values:(const int32_t *)values
|
||||
count:(uint32_t)valueCount
|
||||
enumVerifier:(GPBEnumValidationFunc)enumVerifier;
|
||||
@end
|
||||
|
||||
@interface GPBExtensionDescriptor () {
|
||||
@package
|
||||
GPBExtensionDescription *description_;
|
||||
}
|
||||
@property(nonatomic, readonly) GPBWireFormat wireType;
|
||||
|
||||
// For repeated extensions, alternateWireType is the wireType with the opposite
|
||||
// value for the packable property. i.e. - if the extension was marked packed
|
||||
// it would be the wire type for unpacked; if the extension was marked unpacked,
|
||||
// it would be the wire type for packed.
|
||||
@property(nonatomic, readonly) GPBWireFormat alternateWireType;
|
||||
|
||||
// description has to be long lived, it is held as a raw pointer.
|
||||
- (instancetype)initWithExtensionDescription:(GPBExtensionDescription *)desc
|
||||
usesClassRefs:(BOOL)usesClassRefs;
|
||||
// Deprecated. Calls above with `usesClassRefs = NO`
|
||||
- (instancetype)initWithExtensionDescription:(GPBExtensionDescription *)desc;
|
||||
|
||||
- (NSComparisonResult)compareByFieldNumber:(GPBExtensionDescriptor *)other;
|
||||
@end
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
// Direct access is use for speed, to avoid even internally declaring things
|
||||
// read/write, etc. The warning is enabled in the project to ensure code calling
|
||||
// protos can turn on -Wdirect-ivar-access without issues.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
|
||||
GPB_INLINE BOOL GPBFieldIsMapOrArray(GPBFieldDescriptor *field) {
|
||||
return (field->description_->flags & (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0;
|
||||
}
|
||||
|
||||
GPB_INLINE GPBDataType GPBGetFieldDataType(GPBFieldDescriptor *field) {
|
||||
return field->description_->dataType;
|
||||
}
|
||||
|
||||
GPB_INLINE int32_t GPBFieldHasIndex(GPBFieldDescriptor *field) {
|
||||
return field->description_->hasIndex;
|
||||
}
|
||||
|
||||
GPB_INLINE uint32_t GPBFieldNumber(GPBFieldDescriptor *field) {
|
||||
return field->description_->number;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
uint32_t GPBFieldTag(GPBFieldDescriptor *self);
|
||||
|
||||
// For repeated fields, alternateWireType is the wireType with the opposite
|
||||
// value for the packable property. i.e. - if the field was marked packed it
|
||||
// would be the wire type for unpacked; if the field was marked unpacked, it
|
||||
// would be the wire type for packed.
|
||||
uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self);
|
||||
|
||||
GPB_INLINE BOOL GPBHasPreservingUnknownEnumSemantics(GPBFileSyntax syntax) {
|
||||
return syntax == GPBFileSyntaxProto3;
|
||||
}
|
||||
|
||||
GPB_INLINE BOOL GPBExtensionIsRepeated(GPBExtensionDescription *description) {
|
||||
return (description->options & GPBExtensionRepeated) != 0;
|
||||
}
|
||||
|
||||
GPB_INLINE BOOL GPBExtensionIsPacked(GPBExtensionDescription *description) {
|
||||
return (description->options & GPBExtensionPacked) != 0;
|
||||
}
|
||||
|
||||
GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) {
|
||||
return (description->options & GPBExtensionSetWireFormat) != 0;
|
||||
}
|
||||
|
||||
// Helper for compile time assets.
|
||||
#ifndef GPBInternalCompileAssert
|
||||
#define GPBInternalCompileAssert(test, msg) _Static_assert((test), #msg)
|
||||
#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
|
||||
5775
libs/protobuf/objectivec/GPBDictionary.h
Normal file
5775
libs/protobuf/objectivec/GPBDictionary.h
Normal file
File diff suppressed because it is too large
Load Diff
11978
libs/protobuf/objectivec/GPBDictionary.m
Normal file
11978
libs/protobuf/objectivec/GPBDictionary.m
Normal file
File diff suppressed because it is too large
Load Diff
488
libs/protobuf/objectivec/GPBDictionary_PackagePrivate.h
Normal file
488
libs/protobuf/objectivec/GPBDictionary_PackagePrivate.h
Normal file
@@ -0,0 +1,488 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBDictionary.h"
|
||||
|
||||
@class GPBCodedInputStream;
|
||||
@class GPBCodedOutputStream;
|
||||
@protocol GPBExtensionRegistry;
|
||||
@class GPBFieldDescriptor;
|
||||
|
||||
@protocol GPBDictionaryInternalsProtocol
|
||||
- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field;
|
||||
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream
|
||||
asField:(GPBFieldDescriptor *)field;
|
||||
- (void)setGPBGenericValue:(GPBGenericValue *)value forGPBGenericValueKey:(GPBGenericValue *)key;
|
||||
- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block;
|
||||
@end
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(KEY_NAME)
|
||||
//%DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(KEY_NAME)
|
||||
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Object, Object)
|
||||
//%PDDM-DEFINE DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(KEY_NAME)
|
||||
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, UInt32, Basic)
|
||||
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Int32, Basic)
|
||||
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, UInt64, Basic)
|
||||
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Int64, Basic)
|
||||
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Bool, Basic)
|
||||
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Float, Basic)
|
||||
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Double, Basic)
|
||||
//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Enum, Enum)
|
||||
|
||||
//%PDDM-DEFINE DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, VALUE_NAME, HELPER)
|
||||
//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
//% @package
|
||||
//% GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
//%}
|
||||
//%EXTRA_DICTIONARY_PRIVATE_INTERFACES_##HELPER()@end
|
||||
//%
|
||||
|
||||
//%PDDM-DEFINE EXTRA_DICTIONARY_PRIVATE_INTERFACES_Basic()
|
||||
// Empty
|
||||
//%PDDM-DEFINE EXTRA_DICTIONARY_PRIVATE_INTERFACES_Object()
|
||||
//%- (BOOL)isInitialized;
|
||||
//%- (instancetype)deepCopyWithZone:(NSZone *)zone
|
||||
//% __attribute__((ns_returns_retained));
|
||||
//%
|
||||
//%PDDM-DEFINE EXTRA_DICTIONARY_PRIVATE_INTERFACES_Enum()
|
||||
//%- (NSData *)serializedDataForUnknownValue:(int32_t)value
|
||||
//% forKey:(GPBGenericValue *)key
|
||||
//% keyDataType:(GPBDataType)keyDataType;
|
||||
//%
|
||||
|
||||
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(UInt32)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
@interface GPBUInt32UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt32Int32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt32UInt64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt32Int64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt32BoolDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt32FloatDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt32DoubleDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt32EnumDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (NSData *)serializedDataForUnknownValue:(int32_t)value
|
||||
forKey:(GPBGenericValue *)key
|
||||
keyDataType:(GPBDataType)keyDataType;
|
||||
@end
|
||||
|
||||
@interface GPBUInt32ObjectDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (BOOL)isInitialized;
|
||||
- (instancetype)deepCopyWithZone:(NSZone *)zone
|
||||
__attribute__((ns_returns_retained));
|
||||
@end
|
||||
|
||||
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Int32)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
@interface GPBInt32UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt32Int32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt32UInt64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt32Int64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt32BoolDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt32FloatDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt32DoubleDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt32EnumDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (NSData *)serializedDataForUnknownValue:(int32_t)value
|
||||
forKey:(GPBGenericValue *)key
|
||||
keyDataType:(GPBDataType)keyDataType;
|
||||
@end
|
||||
|
||||
@interface GPBInt32ObjectDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (BOOL)isInitialized;
|
||||
- (instancetype)deepCopyWithZone:(NSZone *)zone
|
||||
__attribute__((ns_returns_retained));
|
||||
@end
|
||||
|
||||
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(UInt64)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
@interface GPBUInt64UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt64Int32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt64UInt64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt64Int64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt64BoolDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt64FloatDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt64DoubleDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBUInt64EnumDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (NSData *)serializedDataForUnknownValue:(int32_t)value
|
||||
forKey:(GPBGenericValue *)key
|
||||
keyDataType:(GPBDataType)keyDataType;
|
||||
@end
|
||||
|
||||
@interface GPBUInt64ObjectDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (BOOL)isInitialized;
|
||||
- (instancetype)deepCopyWithZone:(NSZone *)zone
|
||||
__attribute__((ns_returns_retained));
|
||||
@end
|
||||
|
||||
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Int64)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
@interface GPBInt64UInt32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt64Int32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt64UInt64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt64Int64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt64BoolDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt64FloatDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt64DoubleDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBInt64EnumDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (NSData *)serializedDataForUnknownValue:(int32_t)value
|
||||
forKey:(GPBGenericValue *)key
|
||||
keyDataType:(GPBDataType)keyDataType;
|
||||
@end
|
||||
|
||||
@interface GPBInt64ObjectDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (BOOL)isInitialized;
|
||||
- (instancetype)deepCopyWithZone:(NSZone *)zone
|
||||
__attribute__((ns_returns_retained));
|
||||
@end
|
||||
|
||||
//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Bool)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
@interface GPBBoolUInt32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBBoolInt32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBBoolUInt64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBBoolInt64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBBoolBoolDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBBoolFloatDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBBoolDoubleDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBBoolEnumDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (NSData *)serializedDataForUnknownValue:(int32_t)value
|
||||
forKey:(GPBGenericValue *)key
|
||||
keyDataType:(GPBDataType)keyDataType;
|
||||
@end
|
||||
|
||||
@interface GPBBoolObjectDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (BOOL)isInitialized;
|
||||
- (instancetype)deepCopyWithZone:(NSZone *)zone
|
||||
__attribute__((ns_returns_retained));
|
||||
@end
|
||||
|
||||
//%PDDM-EXPAND DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(String)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
@interface GPBStringUInt32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBStringInt32Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBStringUInt64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBStringInt64Dictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBStringBoolDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBStringFloatDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBStringDoubleDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GPBStringEnumDictionary () <GPBDictionaryInternalsProtocol> {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
- (NSData *)serializedDataForUnknownValue:(int32_t)value
|
||||
forKey:(GPBGenericValue *)key
|
||||
keyDataType:(GPBDataType)keyDataType;
|
||||
@end
|
||||
|
||||
//%PDDM-EXPAND-END (6 expansions)
|
||||
|
||||
// clang-format on
|
||||
|
||||
#pragma mark - NSDictionary Subclass
|
||||
|
||||
@interface GPBAutocreatedDictionary : NSMutableDictionary {
|
||||
@package
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
// Helper to compute size when an NSDictionary is used for the map instead
|
||||
// of a custom type.
|
||||
size_t GPBDictionaryComputeSizeInternalHelper(NSDictionary *dict, GPBFieldDescriptor *field);
|
||||
|
||||
// Helper to write out when an NSDictionary is used for the map instead
|
||||
// of a custom type.
|
||||
void GPBDictionaryWriteToStreamInternalHelper(GPBCodedOutputStream *outputStream,
|
||||
NSDictionary *dict, GPBFieldDescriptor *field);
|
||||
|
||||
// Helper to check message initialization when an NSDictionary is used for
|
||||
// the map instead of a custom type.
|
||||
BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict, GPBFieldDescriptor *field);
|
||||
|
||||
// Helper to read a map instead.
|
||||
void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream,
|
||||
id<GPBExtensionRegistry> registry, GPBFieldDescriptor *field,
|
||||
GPBMessage *parentMessage);
|
||||
|
||||
CF_EXTERN_C_END
|
||||
136
libs/protobuf/objectivec/GPBDuration.pbobjc.h
Normal file
136
libs/protobuf/objectivec/GPBDuration.pbobjc.h
Normal file
@@ -0,0 +1,136 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/duration.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < 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.
|
||||
**/
|
||||
GPB_FINAL @interface GPBDurationRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBDuration
|
||||
|
||||
typedef GPB_ENUM(GPBDuration_FieldNumber) {
|
||||
GPBDuration_FieldNumber_Seconds = 1,
|
||||
GPBDuration_FieldNumber_Nanos = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* A Duration represents a signed, fixed-length span of time represented
|
||||
* as a count of seconds and fractions of seconds at nanosecond
|
||||
* resolution. It is independent of any calendar and concepts like "day"
|
||||
* or "month". It is related to Timestamp in that the difference between
|
||||
* two Timestamp values is a Duration and it can be added or subtracted
|
||||
* from a Timestamp. Range is approximately +-10,000 years.
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* Example 1: Compute Duration from two Timestamps in pseudo code.
|
||||
*
|
||||
* Timestamp start = ...;
|
||||
* Timestamp end = ...;
|
||||
* Duration duration = ...;
|
||||
*
|
||||
* duration.seconds = end.seconds - start.seconds;
|
||||
* duration.nanos = end.nanos - start.nanos;
|
||||
*
|
||||
* if (duration.seconds < 0 && duration.nanos > 0) {
|
||||
* duration.seconds += 1;
|
||||
* duration.nanos -= 1000000000;
|
||||
* } else if (duration.seconds > 0 && duration.nanos < 0) {
|
||||
* duration.seconds -= 1;
|
||||
* duration.nanos += 1000000000;
|
||||
* }
|
||||
*
|
||||
* Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
||||
*
|
||||
* Timestamp start = ...;
|
||||
* Duration duration = ...;
|
||||
* Timestamp end = ...;
|
||||
*
|
||||
* end.seconds = start.seconds + duration.seconds;
|
||||
* end.nanos = start.nanos + duration.nanos;
|
||||
*
|
||||
* if (end.nanos < 0) {
|
||||
* end.seconds -= 1;
|
||||
* end.nanos += 1000000000;
|
||||
* } else if (end.nanos >= 1000000000) {
|
||||
* end.seconds += 1;
|
||||
* end.nanos -= 1000000000;
|
||||
* }
|
||||
*
|
||||
* Example 3: Compute Duration from datetime.timedelta in Python.
|
||||
*
|
||||
* td = datetime.timedelta(days=3, minutes=10)
|
||||
* duration = Duration()
|
||||
* duration.FromTimedelta(td)
|
||||
*
|
||||
* # JSON Mapping
|
||||
*
|
||||
* In JSON format, the Duration type is encoded as a string rather than an
|
||||
* object, where the string ends in the suffix "s" (indicating seconds) and
|
||||
* is preceded by the number of seconds, with nanoseconds expressed as
|
||||
* fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
||||
* encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
||||
* be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
||||
* microsecond should be expressed in JSON format as "3.000001s".
|
||||
**/
|
||||
GPB_FINAL @interface GPBDuration : GPBMessage
|
||||
|
||||
/**
|
||||
* Signed seconds of the span of time. Must be from -315,576,000,000
|
||||
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
||||
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
||||
**/
|
||||
@property(nonatomic, readwrite) int64_t seconds;
|
||||
|
||||
/**
|
||||
* Signed fractions of a second at nanosecond resolution of the span
|
||||
* of time. Durations less than one second are represented with a 0
|
||||
* `seconds` field and a positive or negative `nanos` field. For durations
|
||||
* of one second or more, a non-zero value for the `nanos` field must be
|
||||
* of the same sign as the `seconds` field. Must be from -999,999,999
|
||||
* to +999,999,999 inclusive.
|
||||
**/
|
||||
@property(nonatomic, readwrite) int32_t nanos;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
98
libs/protobuf/objectivec/GPBDuration.pbobjc.m
Normal file
98
libs/protobuf/objectivec/GPBDuration.pbobjc.m
Normal file
@@ -0,0 +1,98 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/duration.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBDuration.pbobjc.h"
|
||||
|
||||
// @@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
|
||||
|
||||
static GPBFileDescriptor *GPBDurationRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - GPBDuration
|
||||
|
||||
@implementation GPBDuration
|
||||
|
||||
@dynamic seconds;
|
||||
@dynamic nanos;
|
||||
|
||||
typedef struct GPBDuration__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
int32_t nanos;
|
||||
int64_t seconds;
|
||||
} GPBDuration__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 = "seconds",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBDuration_FieldNumber_Seconds,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBDuration__storage_, seconds),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeInt64,
|
||||
},
|
||||
{
|
||||
.name = "nanos",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBDuration_FieldNumber_Nanos,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBDuration__storage_, nanos),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeInt32,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBDuration class]
|
||||
rootClass:[GPBDurationRoot class]
|
||||
file:GPBDurationRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBDuration__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
63
libs/protobuf/objectivec/GPBEmpty.pbobjc.h
Normal file
63
libs/protobuf/objectivec/GPBEmpty.pbobjc.h
Normal file
@@ -0,0 +1,63 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/empty.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < 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.
|
||||
**/
|
||||
GPB_FINAL @interface GPBEmptyRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBEmpty
|
||||
|
||||
/**
|
||||
* A generic empty message that you can re-use to avoid defining duplicated
|
||||
* empty messages in your APIs. A typical example is to use it as the request
|
||||
* or the response type of an API method. For instance:
|
||||
*
|
||||
* service Foo {
|
||||
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
* }
|
||||
**/
|
||||
GPB_FINAL @interface GPBEmpty : GPBMessage
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
74
libs/protobuf/objectivec/GPBEmpty.pbobjc.m
Normal file
74
libs/protobuf/objectivec/GPBEmpty.pbobjc.m
Normal file
@@ -0,0 +1,74 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/empty.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBEmpty.pbobjc.h"
|
||||
|
||||
// @@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
|
||||
|
||||
static GPBFileDescriptor *GPBEmptyRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - GPBEmpty
|
||||
|
||||
@implementation GPBEmpty
|
||||
|
||||
|
||||
typedef struct GPBEmpty__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
} GPBEmpty__storage_;
|
||||
|
||||
// This method is threadsafe because it is initially called
|
||||
// in +initialize for each subclass.
|
||||
+ (GPBDescriptor *)descriptor {
|
||||
static GPBDescriptor *descriptor = nil;
|
||||
if (!descriptor) {
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBEmpty class]
|
||||
rootClass:[GPBEmptyRoot class]
|
||||
file:GPBEmptyRoot_FileDescriptor()
|
||||
fields:NULL
|
||||
fieldCount:0
|
||||
storageSize:sizeof(GPBEmpty__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
47
libs/protobuf/objectivec/GPBExtensionInternals.h
Normal file
47
libs/protobuf/objectivec/GPBExtensionInternals.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
|
||||
@class GPBCodedInputStream;
|
||||
@class GPBCodedOutputStream;
|
||||
@protocol GPBExtensionRegistry;
|
||||
|
||||
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, BOOL isPackedOnStream,
|
||||
GPBCodedInputStream *input,
|
||||
id<GPBExtensionRegistry> extensionRegistry,
|
||||
GPBMessage *message);
|
||||
|
||||
size_t GPBComputeExtensionSerializedSizeIncludingTag(GPBExtensionDescriptor *extension, id value);
|
||||
|
||||
void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension, id value,
|
||||
GPBCodedOutputStream *output);
|
||||
389
libs/protobuf/objectivec/GPBExtensionInternals.m
Normal file
389
libs/protobuf/objectivec/GPBExtensionInternals.m
Normal file
@@ -0,0 +1,389 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBExtensionInternals.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "GPBCodedInputStream_PackagePrivate.h"
|
||||
#import "GPBCodedOutputStream_PackagePrivate.h"
|
||||
#import "GPBDescriptor_PackagePrivate.h"
|
||||
#import "GPBMessage_PackagePrivate.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
|
||||
static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
|
||||
GPBCodedInputStream *input,
|
||||
id<GPBExtensionRegistry> extensionRegistry,
|
||||
GPBMessage *existingValue)
|
||||
__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;
|
||||
case GPBDataTypeFixed32:
|
||||
case GPBDataTypeSFixed32:
|
||||
case GPBDataTypeFloat:
|
||||
return 4;
|
||||
case GPBDataTypeFixed64:
|
||||
case GPBDataTypeSFixed64:
|
||||
case GPBDataTypeDouble:
|
||||
return 8;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
static size_t ComputePBSerializedSizeNoTagOfObject(GPBDataType dataType, id object) {
|
||||
#define FIELD_CASE(TYPE, ACCESSOR) \
|
||||
case GPBDataType##TYPE: \
|
||||
return GPBCompute##TYPE##SizeNoTag([(NSNumber *)object ACCESSOR]);
|
||||
#define FIELD_CASE2(TYPE) \
|
||||
case GPBDataType##TYPE: \
|
||||
return GPBCompute##TYPE##SizeNoTag(object);
|
||||
switch (dataType) {
|
||||
FIELD_CASE(Bool, boolValue)
|
||||
FIELD_CASE(Float, floatValue)
|
||||
FIELD_CASE(Double, doubleValue)
|
||||
FIELD_CASE(Int32, intValue)
|
||||
FIELD_CASE(SFixed32, intValue)
|
||||
FIELD_CASE(SInt32, intValue)
|
||||
FIELD_CASE(Enum, intValue)
|
||||
FIELD_CASE(Int64, longLongValue)
|
||||
FIELD_CASE(SInt64, longLongValue)
|
||||
FIELD_CASE(SFixed64, longLongValue)
|
||||
FIELD_CASE(UInt32, unsignedIntValue)
|
||||
FIELD_CASE(Fixed32, unsignedIntValue)
|
||||
FIELD_CASE(UInt64, unsignedLongLongValue)
|
||||
FIELD_CASE(Fixed64, unsignedLongLongValue)
|
||||
FIELD_CASE2(Bytes)
|
||||
FIELD_CASE2(String)
|
||||
FIELD_CASE2(Message)
|
||||
FIELD_CASE2(Group)
|
||||
}
|
||||
#undef FIELD_CASE
|
||||
#undef FIELD_CASE2
|
||||
}
|
||||
|
||||
static size_t ComputeSerializedSizeIncludingTagOfObject(GPBExtensionDescription *description,
|
||||
id object) {
|
||||
#define FIELD_CASE(TYPE, ACCESSOR) \
|
||||
case GPBDataType##TYPE: \
|
||||
return GPBCompute##TYPE##Size(description->fieldNumber, [(NSNumber *)object ACCESSOR]);
|
||||
#define FIELD_CASE2(TYPE) \
|
||||
case GPBDataType##TYPE: \
|
||||
return GPBCompute##TYPE##Size(description->fieldNumber, object);
|
||||
switch (description->dataType) {
|
||||
FIELD_CASE(Bool, boolValue)
|
||||
FIELD_CASE(Float, floatValue)
|
||||
FIELD_CASE(Double, doubleValue)
|
||||
FIELD_CASE(Int32, intValue)
|
||||
FIELD_CASE(SFixed32, intValue)
|
||||
FIELD_CASE(SInt32, intValue)
|
||||
FIELD_CASE(Enum, intValue)
|
||||
FIELD_CASE(Int64, longLongValue)
|
||||
FIELD_CASE(SInt64, longLongValue)
|
||||
FIELD_CASE(SFixed64, longLongValue)
|
||||
FIELD_CASE(UInt32, unsignedIntValue)
|
||||
FIELD_CASE(Fixed32, unsignedIntValue)
|
||||
FIELD_CASE(UInt64, unsignedLongLongValue)
|
||||
FIELD_CASE(Fixed64, unsignedLongLongValue)
|
||||
FIELD_CASE2(Bytes)
|
||||
FIELD_CASE2(String)
|
||||
FIELD_CASE2(Group)
|
||||
case GPBDataTypeMessage:
|
||||
if (GPBExtensionIsWireFormat(description)) {
|
||||
return GPBComputeMessageSetExtensionSize(description->fieldNumber, object);
|
||||
} else {
|
||||
return GPBComputeMessageSize(description->fieldNumber, object);
|
||||
}
|
||||
}
|
||||
#undef FIELD_CASE
|
||||
#undef FIELD_CASE2
|
||||
}
|
||||
|
||||
static size_t ComputeSerializedSizeIncludingTagOfArray(GPBExtensionDescription *description,
|
||||
NSArray *values) {
|
||||
if (GPBExtensionIsPacked(description)) {
|
||||
size_t size = 0;
|
||||
size_t typeSize = DataTypeSize(description->dataType);
|
||||
if (typeSize != 0) {
|
||||
size = values.count * typeSize;
|
||||
} else {
|
||||
for (id value in values) {
|
||||
size += ComputePBSerializedSizeNoTagOfObject(description->dataType, value);
|
||||
}
|
||||
}
|
||||
return size + GPBComputeTagSize(description->fieldNumber) +
|
||||
GPBComputeRawVarint32SizeForInteger(size);
|
||||
} else {
|
||||
size_t size = 0;
|
||||
for (id value in values) {
|
||||
size += ComputeSerializedSizeIncludingTagOfObject(description, value);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteObjectIncludingTagToCodedOutputStream(id object,
|
||||
GPBExtensionDescription *description,
|
||||
GPBCodedOutputStream *output) {
|
||||
#define FIELD_CASE(TYPE, ACCESSOR) \
|
||||
case GPBDataType##TYPE: \
|
||||
[output write##TYPE:description->fieldNumber value:[(NSNumber *)object ACCESSOR]]; \
|
||||
return;
|
||||
#define FIELD_CASE2(TYPE) \
|
||||
case GPBDataType##TYPE: \
|
||||
[output write##TYPE:description->fieldNumber value:object]; \
|
||||
return;
|
||||
switch (description->dataType) {
|
||||
FIELD_CASE(Bool, boolValue)
|
||||
FIELD_CASE(Float, floatValue)
|
||||
FIELD_CASE(Double, doubleValue)
|
||||
FIELD_CASE(Int32, intValue)
|
||||
FIELD_CASE(SFixed32, intValue)
|
||||
FIELD_CASE(SInt32, intValue)
|
||||
FIELD_CASE(Enum, intValue)
|
||||
FIELD_CASE(Int64, longLongValue)
|
||||
FIELD_CASE(SInt64, longLongValue)
|
||||
FIELD_CASE(SFixed64, longLongValue)
|
||||
FIELD_CASE(UInt32, unsignedIntValue)
|
||||
FIELD_CASE(Fixed32, unsignedIntValue)
|
||||
FIELD_CASE(UInt64, unsignedLongLongValue)
|
||||
FIELD_CASE(Fixed64, unsignedLongLongValue)
|
||||
FIELD_CASE2(Bytes)
|
||||
FIELD_CASE2(String)
|
||||
FIELD_CASE2(Group)
|
||||
case GPBDataTypeMessage:
|
||||
if (GPBExtensionIsWireFormat(description)) {
|
||||
[output writeMessageSetExtension:description->fieldNumber value:object];
|
||||
} else {
|
||||
[output writeMessage:description->fieldNumber value:object];
|
||||
}
|
||||
return;
|
||||
}
|
||||
#undef FIELD_CASE
|
||||
#undef FIELD_CASE2
|
||||
}
|
||||
|
||||
static void WriteObjectNoTagToCodedOutputStream(id object, GPBExtensionDescription *description,
|
||||
GPBCodedOutputStream *output) {
|
||||
#define FIELD_CASE(TYPE, ACCESSOR) \
|
||||
case GPBDataType##TYPE: \
|
||||
[output write##TYPE##NoTag:[(NSNumber *)object ACCESSOR]]; \
|
||||
return;
|
||||
#define FIELD_CASE2(TYPE) \
|
||||
case GPBDataType##TYPE: \
|
||||
[output write##TYPE##NoTag:object]; \
|
||||
return;
|
||||
switch (description->dataType) {
|
||||
FIELD_CASE(Bool, boolValue)
|
||||
FIELD_CASE(Float, floatValue)
|
||||
FIELD_CASE(Double, doubleValue)
|
||||
FIELD_CASE(Int32, intValue)
|
||||
FIELD_CASE(SFixed32, intValue)
|
||||
FIELD_CASE(SInt32, intValue)
|
||||
FIELD_CASE(Enum, intValue)
|
||||
FIELD_CASE(Int64, longLongValue)
|
||||
FIELD_CASE(SInt64, longLongValue)
|
||||
FIELD_CASE(SFixed64, longLongValue)
|
||||
FIELD_CASE(UInt32, unsignedIntValue)
|
||||
FIELD_CASE(Fixed32, unsignedIntValue)
|
||||
FIELD_CASE(UInt64, unsignedLongLongValue)
|
||||
FIELD_CASE(Fixed64, unsignedLongLongValue)
|
||||
FIELD_CASE2(Bytes)
|
||||
FIELD_CASE2(String)
|
||||
FIELD_CASE2(Message)
|
||||
case GPBDataTypeGroup:
|
||||
[output writeGroupNoTag:description->fieldNumber value:object];
|
||||
return;
|
||||
}
|
||||
#undef FIELD_CASE
|
||||
#undef FIELD_CASE2
|
||||
}
|
||||
|
||||
static void WriteArrayIncludingTagsToCodedOutputStream(NSArray *values,
|
||||
GPBExtensionDescription *description,
|
||||
GPBCodedOutputStream *output) {
|
||||
if (GPBExtensionIsPacked(description)) {
|
||||
[output writeTag:description->fieldNumber format:GPBWireFormatLengthDelimited];
|
||||
size_t dataSize = 0;
|
||||
size_t typeSize = DataTypeSize(description->dataType);
|
||||
if (typeSize != 0) {
|
||||
dataSize = values.count * typeSize;
|
||||
} else {
|
||||
for (id value in values) {
|
||||
dataSize += ComputePBSerializedSizeNoTagOfObject(description->dataType, value);
|
||||
}
|
||||
}
|
||||
[output writeRawVarintSizeTAs32:dataSize];
|
||||
for (id value in values) {
|
||||
WriteObjectNoTagToCodedOutputStream(value, description, output);
|
||||
}
|
||||
} else {
|
||||
for (id value in values) {
|
||||
WriteObjectIncludingTagToCodedOutputStream(value, description, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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,
|
||||
id<GPBExtensionRegistry> extensionRegistry,
|
||||
GPBMessage *message) {
|
||||
GPBExtensionDescription *description = extension->description_;
|
||||
GPBCodedInputStreamState *state = &input->state_;
|
||||
if (isPackedOnStream) {
|
||||
NSCAssert(GPBExtensionIsRepeated(description), @"How was it packed if it isn't repeated?");
|
||||
int32_t length = GPBCodedInputStreamReadInt32(state);
|
||||
size_t limit = GPBCodedInputStreamPushLimit(state, length);
|
||||
while (GPBCodedInputStreamBytesUntilLimit(state) > 0) {
|
||||
id value = NewSingleValueFromInputStream(extension, input, extensionRegistry, nil);
|
||||
[message addExtension:extension value:value];
|
||||
[value release];
|
||||
}
|
||||
GPBCodedInputStreamPopLimit(state, limit);
|
||||
} else {
|
||||
id existingValue = nil;
|
||||
BOOL isRepeated = GPBExtensionIsRepeated(description);
|
||||
if (!isRepeated && GPBDataTypeIsMessage(description->dataType)) {
|
||||
existingValue = [message getExistingExtension:extension];
|
||||
}
|
||||
id value = NewSingleValueFromInputStream(extension, input, extensionRegistry, existingValue);
|
||||
if (isRepeated) {
|
||||
[message addExtension:extension value:value];
|
||||
} else {
|
||||
[message setExtension:extension value:value];
|
||||
}
|
||||
[value release];
|
||||
}
|
||||
}
|
||||
|
||||
void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension, id value,
|
||||
GPBCodedOutputStream *output) {
|
||||
GPBExtensionDescription *description = extension->description_;
|
||||
if (GPBExtensionIsRepeated(description)) {
|
||||
WriteArrayIncludingTagsToCodedOutputStream(value, description, output);
|
||||
} else {
|
||||
WriteObjectIncludingTagToCodedOutputStream(value, description, output);
|
||||
}
|
||||
}
|
||||
|
||||
size_t GPBComputeExtensionSerializedSizeIncludingTag(GPBExtensionDescriptor *extension, id value) {
|
||||
GPBExtensionDescription *description = extension->description_;
|
||||
if (GPBExtensionIsRepeated(description)) {
|
||||
return ComputeSerializedSizeIncludingTagOfArray(description, value);
|
||||
} else {
|
||||
return ComputeSerializedSizeIncludingTagOfObject(description, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Note that this returns a retained value intentionally.
|
||||
static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
|
||||
GPBCodedInputStream *input,
|
||||
id<GPBExtensionRegistry> extensionRegistry,
|
||||
GPBMessage *existingValue) {
|
||||
GPBExtensionDescription *description = extension->description_;
|
||||
GPBCodedInputStreamState *state = &input->state_;
|
||||
switch (description->dataType) {
|
||||
case GPBDataTypeBool:
|
||||
return [[NSNumber alloc] initWithBool:GPBCodedInputStreamReadBool(state)];
|
||||
case GPBDataTypeFixed32:
|
||||
return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadFixed32(state)];
|
||||
case GPBDataTypeSFixed32:
|
||||
return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSFixed32(state)];
|
||||
case GPBDataTypeFloat:
|
||||
return [[NSNumber alloc] initWithFloat:GPBCodedInputStreamReadFloat(state)];
|
||||
case GPBDataTypeFixed64:
|
||||
return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadFixed64(state)];
|
||||
case GPBDataTypeSFixed64:
|
||||
return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSFixed64(state)];
|
||||
case GPBDataTypeDouble:
|
||||
return [[NSNumber alloc] initWithDouble:GPBCodedInputStreamReadDouble(state)];
|
||||
case GPBDataTypeInt32:
|
||||
return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadInt32(state)];
|
||||
case GPBDataTypeInt64:
|
||||
return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadInt64(state)];
|
||||
case GPBDataTypeSInt32:
|
||||
return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSInt32(state)];
|
||||
case GPBDataTypeSInt64:
|
||||
return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSInt64(state)];
|
||||
case GPBDataTypeUInt32:
|
||||
return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadUInt32(state)];
|
||||
case GPBDataTypeUInt64:
|
||||
return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadUInt64(state)];
|
||||
case GPBDataTypeBytes:
|
||||
return GPBCodedInputStreamReadRetainedBytes(state);
|
||||
case GPBDataTypeString:
|
||||
return GPBCodedInputStreamReadRetainedString(state);
|
||||
case GPBDataTypeEnum:
|
||||
return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadEnum(state)];
|
||||
case GPBDataTypeGroup:
|
||||
case GPBDataTypeMessage: {
|
||||
GPBMessage *message;
|
||||
if (existingValue) {
|
||||
message = [existingValue retain];
|
||||
} else {
|
||||
GPBDescriptor *descriptor = [extension.msgClass descriptor];
|
||||
message = [[descriptor.messageClass alloc] init];
|
||||
}
|
||||
|
||||
if (description->dataType == GPBDataTypeGroup) {
|
||||
[input readGroup:description->fieldNumber
|
||||
message:message
|
||||
extensionRegistry:extensionRegistry];
|
||||
} else {
|
||||
// description->dataType == GPBDataTypeMessage
|
||||
if (GPBExtensionIsWireFormat(description)) {
|
||||
// For MessageSet fields the message length will have already been
|
||||
// read.
|
||||
[message mergeFromCodedInputStream:input extensionRegistry:extensionRegistry];
|
||||
} else {
|
||||
[input readMessage:message extensionRegistry:extensionRegistry];
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
93
libs/protobuf/objectivec/GPBExtensionRegistry.h
Normal file
93
libs/protobuf/objectivec/GPBExtensionRegistry.h
Normal file
@@ -0,0 +1,93 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class GPBDescriptor;
|
||||
@class GPBExtensionDescriptor;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* A table of known extensions, searchable by name or field number. When
|
||||
* parsing a protocol message that might have extensions, you must provide a
|
||||
* GPBExtensionRegistry in which you have registered any extensions that you
|
||||
* want to be able to parse. Otherwise, those extensions will just be treated
|
||||
* like unknown fields.
|
||||
**/
|
||||
@protocol GPBExtensionRegistry <NSObject>
|
||||
|
||||
/**
|
||||
* Looks for the extension registered for the given field number on a given
|
||||
* GPBDescriptor.
|
||||
*
|
||||
* @param descriptor The descriptor to look for a registered extension on.
|
||||
* @param fieldNumber The field number of the extension to look for.
|
||||
*
|
||||
* @return The registered GPBExtensionDescriptor or nil if none was found.
|
||||
**/
|
||||
- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
|
||||
fieldNumber:(NSInteger)fieldNumber;
|
||||
@end
|
||||
|
||||
/**
|
||||
* A concrete implementation of `GPBExtensionRegistry`.
|
||||
*
|
||||
* The *Root classes provide `+extensionRegistry` for the extensions defined
|
||||
* in a given file *and* all files it imports. You can also create a
|
||||
* 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, GPBExtensionRegistry>
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
129
libs/protobuf/objectivec/GPBExtensionRegistry.m
Normal file
129
libs/protobuf/objectivec/GPBExtensionRegistry.m
Normal file
@@ -0,0 +1,129 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBExtensionRegistry.h"
|
||||
|
||||
#import "GPBBootstrap.h"
|
||||
#import "GPBDescriptor.h"
|
||||
|
||||
@implementation GPBExtensionRegistry {
|
||||
CFMutableDictionaryRef mutableClassMap_;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
if ((self = [super init])) {
|
||||
// The keys are ObjC classes, so straight up ptr comparisons are fine.
|
||||
mutableClassMap_ =
|
||||
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
CFRelease(mutableClassMap_);
|
||||
[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];
|
||||
[result addExtensions:self];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)addExtension:(GPBExtensionDescriptor *)extension {
|
||||
if (extension == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
Class containingMessageClass = extension.containingMessageClass;
|
||||
CFMutableDictionaryRef extensionMap =
|
||||
(CFMutableDictionaryRef)CFDictionaryGetValue(mutableClassMap_, containingMessageClass);
|
||||
if (extensionMap == nil) {
|
||||
// Use a custom dictionary here because the keys are numbers and conversion
|
||||
// back and forth from NSNumber isn't worth the cost.
|
||||
extensionMap =
|
||||
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
|
||||
CFDictionarySetValue(mutableClassMap_, containingMessageClass, extensionMap);
|
||||
CFRelease(extensionMap);
|
||||
}
|
||||
|
||||
ssize_t key = extension.fieldNumber;
|
||||
CFDictionarySetValue(extensionMap, (const void *)key, extension);
|
||||
}
|
||||
|
||||
- (GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
|
||||
fieldNumber:(NSInteger)fieldNumber {
|
||||
Class messageClass = descriptor.messageClass;
|
||||
CFMutableDictionaryRef extensionMap =
|
||||
(CFMutableDictionaryRef)CFDictionaryGetValue(mutableClassMap_, messageClass);
|
||||
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);
|
||||
}
|
||||
|
||||
static void CopySubDictionary(const void *key, const void *value, void *context) {
|
||||
CFMutableDictionaryRef mutableClassMap = (CFMutableDictionaryRef)context;
|
||||
Class containingMessageClass = key;
|
||||
CFMutableDictionaryRef otherExtensionMap = (CFMutableDictionaryRef)value;
|
||||
|
||||
CFMutableDictionaryRef extensionMap =
|
||||
(CFMutableDictionaryRef)CFDictionaryGetValue(mutableClassMap, containingMessageClass);
|
||||
if (extensionMap == nil) {
|
||||
extensionMap = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, otherExtensionMap);
|
||||
CFDictionarySetValue(mutableClassMap, containingMessageClass, extensionMap);
|
||||
CFRelease(extensionMap);
|
||||
} else {
|
||||
CFDictionaryApplyFunction(otherExtensionMap, CopyKeyValue, extensionMap);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addExtensions:(GPBExtensionRegistry *)registry {
|
||||
if (registry == nil) {
|
||||
// In the case where there are no extensions just ignore.
|
||||
return;
|
||||
}
|
||||
CFDictionaryApplyFunction(registry->mutableClassMap_, CopySubDictionary, mutableClassMap_);
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
264
libs/protobuf/objectivec/GPBFieldMask.pbobjc.h
Normal file
264
libs/protobuf/objectivec/GPBFieldMask.pbobjc.h
Normal file
@@ -0,0 +1,264 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/field_mask.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < 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.
|
||||
**/
|
||||
GPB_FINAL @interface GPBFieldMaskRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBFieldMask
|
||||
|
||||
typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
|
||||
GPBFieldMask_FieldNumber_PathsArray = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* `FieldMask` represents a set of symbolic field paths, for example:
|
||||
*
|
||||
* paths: "f.a"
|
||||
* paths: "f.b.d"
|
||||
*
|
||||
* Here `f` represents a field in some root message, `a` and `b`
|
||||
* fields in the message found in `f`, and `d` a field found in the
|
||||
* message in `f.b`.
|
||||
*
|
||||
* Field masks are used to specify a subset of fields that should be
|
||||
* returned by a get operation or modified by an update operation.
|
||||
* Field masks also have a custom JSON encoding (see below).
|
||||
*
|
||||
* # Field Masks in Projections
|
||||
*
|
||||
* When used in the context of a projection, a response message or
|
||||
* sub-message is filtered by the API to only contain those fields as
|
||||
* specified in the mask. For example, if the mask in the previous
|
||||
* example is applied to a response message as follows:
|
||||
*
|
||||
* f {
|
||||
* a : 22
|
||||
* b {
|
||||
* d : 1
|
||||
* x : 2
|
||||
* }
|
||||
* y : 13
|
||||
* }
|
||||
* z: 8
|
||||
*
|
||||
* The result will not contain specific values for fields x,y and z
|
||||
* (their value will be set to the default, and omitted in proto text
|
||||
* output):
|
||||
*
|
||||
*
|
||||
* f {
|
||||
* a : 22
|
||||
* b {
|
||||
* d : 1
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* A repeated field is not allowed except at the last position of a
|
||||
* paths string.
|
||||
*
|
||||
* If a FieldMask object is not present in a get operation, the
|
||||
* operation applies to all fields (as if a FieldMask of all fields
|
||||
* had been specified).
|
||||
*
|
||||
* Note that a field mask does not necessarily apply to the
|
||||
* top-level response message. In case of a REST get operation, the
|
||||
* field mask applies directly to the response, but in case of a REST
|
||||
* list operation, the mask instead applies to each individual message
|
||||
* in the returned resource list. In case of a REST custom method,
|
||||
* other definitions may be used. Where the mask applies will be
|
||||
* clearly documented together with its declaration in the API. In
|
||||
* any case, the effect on the returned resource/resources is required
|
||||
* behavior for APIs.
|
||||
*
|
||||
* # Field Masks in Update Operations
|
||||
*
|
||||
* A field mask in update operations specifies which fields of the
|
||||
* targeted resource are going to be updated. The API is required
|
||||
* to only change the values of the fields as specified in the mask
|
||||
* and leave the others untouched. If a resource is passed in to
|
||||
* describe the updated values, the API ignores the values of all
|
||||
* fields not covered by the mask.
|
||||
*
|
||||
* If a repeated field is specified for an update operation, new values will
|
||||
* be appended to the existing repeated field in the target resource. Note that
|
||||
* a repeated field is only allowed in the last position of a `paths` string.
|
||||
*
|
||||
* If a sub-message is specified in the last position of the field mask for an
|
||||
* update operation, then new value will be merged into the existing sub-message
|
||||
* in the target resource.
|
||||
*
|
||||
* For example, given the target message:
|
||||
*
|
||||
* f {
|
||||
* b {
|
||||
* d: 1
|
||||
* x: 2
|
||||
* }
|
||||
* c: [1]
|
||||
* }
|
||||
*
|
||||
* And an update message:
|
||||
*
|
||||
* f {
|
||||
* b {
|
||||
* d: 10
|
||||
* }
|
||||
* c: [2]
|
||||
* }
|
||||
*
|
||||
* then if the field mask is:
|
||||
*
|
||||
* paths: ["f.b", "f.c"]
|
||||
*
|
||||
* then the result will be:
|
||||
*
|
||||
* f {
|
||||
* b {
|
||||
* d: 10
|
||||
* x: 2
|
||||
* }
|
||||
* c: [1, 2]
|
||||
* }
|
||||
*
|
||||
* An implementation may provide options to override this default behavior for
|
||||
* repeated and message fields.
|
||||
*
|
||||
* In order to reset a field's value to the default, the field must
|
||||
* be in the mask and set to the default value in the provided resource.
|
||||
* Hence, in order to reset all fields of a resource, provide a default
|
||||
* instance of the resource and set all fields in the mask, or do
|
||||
* not provide a mask as described below.
|
||||
*
|
||||
* If a field mask is not present on update, the operation applies to
|
||||
* all fields (as if a field mask of all fields has been specified).
|
||||
* Note that in the presence of schema evolution, this may mean that
|
||||
* fields the client does not know and has therefore not filled into
|
||||
* the request will be reset to their default. If this is unwanted
|
||||
* behavior, a specific service may require a client to always specify
|
||||
* a field mask, producing an error if not.
|
||||
*
|
||||
* As with get operations, the location of the resource which
|
||||
* describes the updated values in the request message depends on the
|
||||
* operation kind. In any case, the effect of the field mask is
|
||||
* required to be honored by the API.
|
||||
*
|
||||
* ## Considerations for HTTP REST
|
||||
*
|
||||
* The HTTP kind of an update operation which uses a field mask must
|
||||
* be set to PATCH instead of PUT in order to satisfy HTTP semantics
|
||||
* (PUT must only be used for full updates).
|
||||
*
|
||||
* # JSON Encoding of Field Masks
|
||||
*
|
||||
* In JSON, a field mask is encoded as a single string where paths are
|
||||
* separated by a comma. Fields name in each path are converted
|
||||
* to/from lower-camel naming conventions.
|
||||
*
|
||||
* As an example, consider the following message declarations:
|
||||
*
|
||||
* message Profile {
|
||||
* User user = 1;
|
||||
* Photo photo = 2;
|
||||
* }
|
||||
* message User {
|
||||
* string display_name = 1;
|
||||
* string address = 2;
|
||||
* }
|
||||
*
|
||||
* In proto a field mask for `Profile` may look as such:
|
||||
*
|
||||
* mask {
|
||||
* paths: "user.display_name"
|
||||
* paths: "photo"
|
||||
* }
|
||||
*
|
||||
* In JSON, the same mask is represented as below:
|
||||
*
|
||||
* {
|
||||
* mask: "user.displayName,photo"
|
||||
* }
|
||||
*
|
||||
* # Field Masks and Oneof Fields
|
||||
*
|
||||
* Field masks treat fields in oneofs just as regular fields. Consider the
|
||||
* following message:
|
||||
*
|
||||
* message SampleMessage {
|
||||
* oneof test_oneof {
|
||||
* string name = 4;
|
||||
* SubMessage sub_message = 9;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* The field mask can be:
|
||||
*
|
||||
* mask {
|
||||
* paths: "name"
|
||||
* }
|
||||
*
|
||||
* Or:
|
||||
*
|
||||
* mask {
|
||||
* paths: "sub_message"
|
||||
* }
|
||||
*
|
||||
* Note that oneof type names ("test_oneof" in this case) cannot be used in
|
||||
* paths.
|
||||
*
|
||||
* ## Field Mask Verification
|
||||
*
|
||||
* The implementation of any API method which has a FieldMask type field in the
|
||||
* request should verify the included field paths, and return an
|
||||
* `INVALID_ARGUMENT` error if any path is unmappable.
|
||||
**/
|
||||
GPB_FINAL @interface GPBFieldMask : GPBMessage
|
||||
|
||||
/** The set of field mask paths. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *pathsArray;
|
||||
/** The number of items in @c pathsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger pathsArray_Count;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
87
libs/protobuf/objectivec/GPBFieldMask.pbobjc.m
Normal file
87
libs/protobuf/objectivec/GPBFieldMask.pbobjc.m
Normal file
@@ -0,0 +1,87 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/field_mask.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBFieldMask.pbobjc.h"
|
||||
|
||||
// @@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
|
||||
|
||||
static GPBFileDescriptor *GPBFieldMaskRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - GPBFieldMask
|
||||
|
||||
@implementation GPBFieldMask
|
||||
|
||||
@dynamic pathsArray, pathsArray_Count;
|
||||
|
||||
typedef struct GPBFieldMask__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSMutableArray *pathsArray;
|
||||
} GPBFieldMask__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 = "pathsArray",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBFieldMask_FieldNumber_PathsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBFieldMask__storage_, pathsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBFieldMask class]
|
||||
rootClass:[GPBFieldMaskRoot class]
|
||||
file:GPBFieldMaskRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBFieldMask__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
467
libs/protobuf/objectivec/GPBMessage.h
Normal file
467
libs/protobuf/objectivec/GPBMessage.h
Normal file
@@ -0,0 +1,467 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBBootstrap.h"
|
||||
#import "GPBExtensionRegistry.h"
|
||||
|
||||
@class GPBDescriptor;
|
||||
@class GPBCodedInputStream;
|
||||
@class GPBCodedOutputStream;
|
||||
@class GPBExtensionDescriptor;
|
||||
@class GPBFieldDescriptor;
|
||||
@class GPBUnknownFieldSet;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
/** NSError domain used for errors. */
|
||||
extern NSString *const GPBMessageErrorDomain;
|
||||
|
||||
/** Error codes for NSErrors originated in GPBMessage. */
|
||||
typedef NS_ENUM(NSInteger, GPBMessageErrorCode) {
|
||||
/** Uncategorized error. */
|
||||
GPBMessageErrorCodeOther = -100,
|
||||
/** Message couldn't be serialized because it is missing required fields. */
|
||||
GPBMessageErrorCodeMissingRequiredField = -101,
|
||||
};
|
||||
|
||||
/**
|
||||
* Key under which the GPBMessage error's reason is stored inside the userInfo
|
||||
* dictionary.
|
||||
**/
|
||||
extern NSString *const GPBErrorReasonKey;
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
/**
|
||||
* Base class that each generated message subclasses from.
|
||||
*
|
||||
* @note @c NSCopying support is a "deep copy", in that all sub objects are
|
||||
* copied. Just like you wouldn't want a UIView/NSView trying to
|
||||
* exist in two places, you don't want a sub message to be a property
|
||||
* property of two other messages.
|
||||
*
|
||||
* @note While the class support NSSecureCoding, if the message has any
|
||||
* extensions, they will end up reloaded in @c unknownFields as there is
|
||||
* no way for the @c NSCoding plumbing to pass through a
|
||||
* @c GPBExtensionRegistry. To support extensions, instead of passing the
|
||||
* calls off to the Message, simple store the result of @c data, and then
|
||||
* when loading, fetch the data and use
|
||||
* @c +parseFromData:extensionRegistry:error: to provide an extension
|
||||
* registry.
|
||||
**/
|
||||
@interface GPBMessage : NSObject <NSSecureCoding, NSCopying>
|
||||
|
||||
// If you add an instance method/property to this class that may conflict with
|
||||
// fields declared in protos, you need to update objective_helpers.cc. The main
|
||||
// cases are methods that take no arguments, or setFoo:/hasFoo: type methods.
|
||||
|
||||
/**
|
||||
* The set of unknown fields for this message.
|
||||
*
|
||||
* Only messages from proto files declared with "proto2" syntax support unknown
|
||||
* fields. For "proto3" syntax, any unknown fields found while parsing are
|
||||
* dropped.
|
||||
**/
|
||||
@property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields;
|
||||
|
||||
/**
|
||||
* Whether the message, along with all submessages, have the required fields
|
||||
* set. This is only applicable for files declared with "proto2" syntax, as
|
||||
* there are no required fields for "proto3" syntax.
|
||||
**/
|
||||
@property(nonatomic, readonly, getter=isInitialized) BOOL initialized;
|
||||
|
||||
/**
|
||||
* @return An autoreleased message with the default values set.
|
||||
**/
|
||||
+ (instancetype)message;
|
||||
|
||||
/**
|
||||
* Creates a new instance by parsing the provided data. This method should be
|
||||
* sent to the generated message class that the data should be interpreted as.
|
||||
* If there is an error the method returns nil and the error is returned in
|
||||
* errorPtr (when provided).
|
||||
*
|
||||
* @note In DEBUG builds, the parsed message is checked to be sure all required
|
||||
* fields were provided, and the parse will fail if some are missing.
|
||||
*
|
||||
* @note The errors returned are likely coming from the domain and codes listed
|
||||
* at the top of this file and GPBCodedInputStream.h.
|
||||
*
|
||||
* @param data The data to parse.
|
||||
* @param errorPtr An optional error pointer to fill in with a failure reason if
|
||||
* the data can not be parsed.
|
||||
*
|
||||
* @return A new instance of the generated class.
|
||||
**/
|
||||
+ (nullable instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr;
|
||||
|
||||
/**
|
||||
* Creates a new instance by parsing the data. This method should be sent to
|
||||
* the generated message class that the data should be interpreted as. If
|
||||
* there is an error the method returns nil and the error is returned in
|
||||
* errorPtr (when provided).
|
||||
*
|
||||
* @note In DEBUG builds, the parsed message is checked to be sure all required
|
||||
* fields were provided, and the parse will fail if some are missing.
|
||||
*
|
||||
* @note The errors returned are likely coming from the domain and codes listed
|
||||
* at the top of this file and GPBCodedInputStream.h.
|
||||
*
|
||||
* @param data The data to parse.
|
||||
* @param extensionRegistry The extension registry to use to look up extensions.
|
||||
* @param errorPtr An optional error pointer to fill in with a failure
|
||||
* reason if the data can not be parsed.
|
||||
*
|
||||
* @return A new instance of the generated class.
|
||||
**/
|
||||
+ (nullable instancetype)parseFromData:(NSData *)data
|
||||
extensionRegistry:(nullable id<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 id<GPBExtensionRegistry>)extensionRegistry
|
||||
error:(NSError **)errorPtr;
|
||||
|
||||
/**
|
||||
* Creates a new instance by parsing the data from the given input stream. This
|
||||
* method should be sent to the generated message class that the data should
|
||||
* be interpreted as. If there is an error the method returns nil and the error
|
||||
* is returned in errorPtr (when provided).
|
||||
*
|
||||
* @note Unlike the parseFrom... methods, this never checks to see if all of
|
||||
* the required fields are set. So this method can be used to reload
|
||||
* messages that may not be complete.
|
||||
*
|
||||
* @note The errors returned are likely coming from the domain and codes listed
|
||||
* at the top of this file and GPBCodedInputStream.h.
|
||||
*
|
||||
* @param input The stream to read data from.
|
||||
* @param extensionRegistry The extension registry to use to look up extensions.
|
||||
* @param errorPtr An optional error pointer to fill in with a failure
|
||||
* reason if the data can not be parsed.
|
||||
*
|
||||
* @return A new instance of the generated class.
|
||||
**/
|
||||
+ (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
|
||||
extensionRegistry:
|
||||
(nullable id<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 id<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 id<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 id<GPBExtensionRegistry>)extensionRegistry;
|
||||
|
||||
/**
|
||||
* Merges the fields from another message (of the same type) into this
|
||||
* message.
|
||||
*
|
||||
* @param other Message to merge into this message.
|
||||
**/
|
||||
- (void)mergeFrom:(GPBMessage *)other;
|
||||
|
||||
/**
|
||||
* Writes out the message to the given coded output stream.
|
||||
*
|
||||
* @param output The coded output stream into which to write the message.
|
||||
*
|
||||
* @note This can raise the GPBCodedOutputStreamException_* exceptions.
|
||||
*
|
||||
**/
|
||||
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output;
|
||||
|
||||
/**
|
||||
* Writes out the message to the given output stream.
|
||||
*
|
||||
* @param output The output stream into which to write the message.
|
||||
*
|
||||
* @note This can raise the GPBCodedOutputStreamException_* exceptions.
|
||||
**/
|
||||
- (void)writeToOutputStream:(NSOutputStream *)output;
|
||||
|
||||
/**
|
||||
* Writes out a varint for the message size followed by the message to
|
||||
* the given output stream.
|
||||
*
|
||||
* @param output The coded output stream into which to write the message.
|
||||
*
|
||||
* @note This can raise the GPBCodedOutputStreamException_* exceptions.
|
||||
**/
|
||||
- (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output;
|
||||
|
||||
/**
|
||||
* Writes out a varint for the message size followed by the message to
|
||||
* the given output stream.
|
||||
*
|
||||
* @param output The output stream into which to write the message.
|
||||
*
|
||||
* @note This can raise the GPBCodedOutputStreamException_* exceptions.
|
||||
**/
|
||||
- (void)writeDelimitedToOutputStream:(NSOutputStream *)output;
|
||||
|
||||
/**
|
||||
* Serializes the message to an NSData.
|
||||
*
|
||||
* If there is an error while generating the data, nil is returned.
|
||||
*
|
||||
* @note This value is not cached, so if you are using it repeatedly, cache
|
||||
* it yourself.
|
||||
*
|
||||
* @note In DEBUG ONLY, the message is also checked for all required field,
|
||||
* if one is missing, nil will be returned.
|
||||
*
|
||||
* @return The binary representation of the message.
|
||||
**/
|
||||
- (nullable NSData *)data;
|
||||
|
||||
/**
|
||||
* Serializes a varint with the message size followed by the message data,
|
||||
* returning that as an NSData.
|
||||
*
|
||||
* @note This value is not cached, so if you are using it repeatedly, it is
|
||||
* recommended to keep a local copy.
|
||||
*
|
||||
* @return The binary representation of the size along with the message.
|
||||
**/
|
||||
- (NSData *)delimitedData;
|
||||
|
||||
/**
|
||||
* Calculates the size of the object if it were serialized.
|
||||
*
|
||||
* This is not a cached value. If you are following a pattern like this:
|
||||
*
|
||||
* ```
|
||||
* size_t size = [aMsg serializedSize];
|
||||
* NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
|
||||
* [foo writeSize:size];
|
||||
* [foo appendData:[aMsg data]];
|
||||
* ```
|
||||
*
|
||||
* you would be better doing:
|
||||
*
|
||||
* ```
|
||||
* NSData *data = [aMsg data];
|
||||
* NSUInteger size = [aMsg length];
|
||||
* NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
|
||||
* [foo writeSize:size];
|
||||
* [foo appendData:data];
|
||||
* ```
|
||||
*
|
||||
* @return The size of the message in it's binary representation.
|
||||
**/
|
||||
- (size_t)serializedSize;
|
||||
|
||||
/**
|
||||
* @return The descriptor for the message class.
|
||||
**/
|
||||
+ (GPBDescriptor *)descriptor;
|
||||
|
||||
/**
|
||||
* Return the descriptor for the message.
|
||||
**/
|
||||
- (GPBDescriptor *)descriptor;
|
||||
|
||||
/**
|
||||
* @return An array with the extension descriptors that are currently set on the
|
||||
* message.
|
||||
**/
|
||||
- (NSArray *)extensionsCurrentlySet;
|
||||
|
||||
/**
|
||||
* Checks whether there is an extension set on the message which matches the
|
||||
* given extension descriptor.
|
||||
*
|
||||
* @param extension Extension descriptor to check if it's set on the message.
|
||||
*
|
||||
* @return Whether the extension is currently set on the message.
|
||||
**/
|
||||
- (BOOL)hasExtension:(GPBExtensionDescriptor *)extension;
|
||||
|
||||
/*
|
||||
* Fetches the given extension's value for this message.
|
||||
*
|
||||
* Extensions use boxed values (NSNumbers) for PODs and NSMutableArrays for
|
||||
* repeated fields. If the extension is a Message one will be auto created for
|
||||
* you and returned similar to fields.
|
||||
*
|
||||
* @param extension The extension descriptor of the extension to fetch.
|
||||
*
|
||||
* @return The extension matching the given descriptor, or nil if none found.
|
||||
**/
|
||||
- (nullable id)getExtension:(GPBExtensionDescriptor *)extension;
|
||||
|
||||
/**
|
||||
* Sets the given extension's value for this message. This only applies for
|
||||
* single field extensions (i.e. - not repeated fields).
|
||||
*
|
||||
* Extensions use boxed values (NSNumbers).
|
||||
*
|
||||
* @param extension The extension descriptor under which to set the value.
|
||||
* @param value The value to be set as the extension.
|
||||
**/
|
||||
- (void)setExtension:(GPBExtensionDescriptor *)extension value:(nullable id)value;
|
||||
|
||||
/**
|
||||
* Adds the given value to the extension for this message. This only applies
|
||||
* to repeated field extensions. If the field is a repeated POD type, the value
|
||||
* should be an NSNumber.
|
||||
*
|
||||
* @param extension The extension descriptor under which to add the value.
|
||||
* @param value The value to be added to the repeated extension.
|
||||
**/
|
||||
- (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given index with the given value for the extension
|
||||
* on this message. This only applies to repeated field extensions. If the field
|
||||
* is a repeated POD type, the value is should be an NSNumber.
|
||||
*
|
||||
* @param extension The extension descriptor under which to replace the value.
|
||||
* @param index The index of the extension to be replaced.
|
||||
* @param value The value to be replaced in the repeated extension.
|
||||
**/
|
||||
- (void)setExtension:(GPBExtensionDescriptor *)extension index:(NSUInteger)index value:(id)value;
|
||||
|
||||
/**
|
||||
* Clears the given extension for this message.
|
||||
*
|
||||
* @param extension The extension descriptor to be cleared from this message.
|
||||
**/
|
||||
- (void)clearExtension:(GPBExtensionDescriptor *)extension;
|
||||
|
||||
/**
|
||||
* Resets all of the fields of this message to their default values.
|
||||
**/
|
||||
- (void)clear;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
3283
libs/protobuf/objectivec/GPBMessage.m
Normal file
3283
libs/protobuf/objectivec/GPBMessage.m
Normal file
File diff suppressed because it is too large
Load Diff
121
libs/protobuf/objectivec/GPBMessage_PackagePrivate.h
Normal file
121
libs/protobuf/objectivec/GPBMessage_PackagePrivate.h
Normal file
@@ -0,0 +1,121 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This header is private to the ProtobolBuffers library and must NOT be
|
||||
// included by any sources outside this library. The contents of this file are
|
||||
// subject to change at any time without notice.
|
||||
|
||||
#import "GPBMessage.h"
|
||||
|
||||
// TODO: Remove this import. Older generated code use the OSAtomic* apis,
|
||||
// so anyone that hasn't regenerated says building by having this. After
|
||||
// enough time has passed, this likely can be removed as folks should have
|
||||
// regenerated.
|
||||
#import <libkern/OSAtomic.h>
|
||||
|
||||
#import "GPBBootstrap.h"
|
||||
|
||||
typedef struct GPBMessage_Storage {
|
||||
uint32_t _has_storage_[0];
|
||||
} GPBMessage_Storage;
|
||||
|
||||
typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
|
||||
|
||||
@interface GPBMessage () {
|
||||
@package
|
||||
// NOTE: Because of the +allocWithZone code using NSAllocateObject(),
|
||||
// this structure should ideally always be kept pointer aligned where the
|
||||
// real storage starts is also pointer aligned. The compiler/runtime already
|
||||
// do this, but it may not be documented.
|
||||
|
||||
// A pointer to the actual fields of the subclasses. The actual structure
|
||||
// pointed to by this pointer will depend on the subclass.
|
||||
// All of the actual structures will start the same as
|
||||
// GPBMessage_Storage with _has_storage__ as the first field.
|
||||
// Kept public because static functions need to access it.
|
||||
GPBMessage_StoragePtr messageStorage_;
|
||||
}
|
||||
|
||||
// Gets an extension value without autocreating the result if not found. (i.e.
|
||||
// returns nil if the extension is not set)
|
||||
- (id)getExistingExtension:(GPBExtensionDescriptor *)extension;
|
||||
|
||||
// Parses a message of this type from the input and merges it with this
|
||||
// message.
|
||||
//
|
||||
// Warning: This does not verify that all required fields are present in
|
||||
// the input message.
|
||||
// Note: The caller should call
|
||||
// -[CodedInputStream checkLastTagWas:] after calling this to
|
||||
// verify that the last tag seen was the appropriate end-group tag,
|
||||
// or zero for EOF.
|
||||
// NOTE: This will throw if there is an error while parsing.
|
||||
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
|
||||
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
|
||||
|
||||
// Parses the next delimited message of this type from the input and merges it
|
||||
// with this message.
|
||||
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
|
||||
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
|
||||
|
||||
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
|
||||
|
||||
@end
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
// Call this before using the readOnlySemaphore_. This ensures it is created only once.
|
||||
void GPBPrepareReadOnlySemaphore(GPBMessage *self);
|
||||
|
||||
// Returns a new instance that was automatically created by |autocreator| for
|
||||
// its field |field|.
|
||||
GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass, GPBMessage *autocreator,
|
||||
GPBFieldDescriptor *field)
|
||||
__attribute__((ns_returns_retained));
|
||||
|
||||
// Returns whether |message| autocreated this message. This is NO if the message
|
||||
// was not autocreated by |message| or if it has been mutated since
|
||||
// autocreation.
|
||||
BOOL GPBWasMessageAutocreatedBy(GPBMessage *message, GPBMessage *parent);
|
||||
|
||||
// Call this when you mutate a message. It will cause the message to become
|
||||
// visible to its autocreator.
|
||||
void GPBBecomeVisibleToAutocreator(GPBMessage *self);
|
||||
|
||||
// Call this when an array/dictionary is mutated so the parent message that
|
||||
// autocreated it can react.
|
||||
void GPBAutocreatedArrayModified(GPBMessage *self, id array);
|
||||
void GPBAutocreatedDictionaryModified(GPBMessage *self, id dictionary);
|
||||
|
||||
// Clear the autocreator, if any. Asserts if the autocreator still has an
|
||||
// autocreated reference to this message.
|
||||
void GPBClearMessageAutocreator(GPBMessage *self);
|
||||
|
||||
CF_EXTERN_C_END
|
||||
59
libs/protobuf/objectivec/GPBProtocolBuffers.h
Normal file
59
libs/protobuf/objectivec/GPBProtocolBuffers.h
Normal file
@@ -0,0 +1,59 @@
|
||||
// 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.
|
||||
|
||||
// clang-format off
|
||||
#import "GPBBootstrap.h"
|
||||
// clang-format on
|
||||
|
||||
#import "GPBArray.h"
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBCodedOutputStream.h"
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBDictionary.h"
|
||||
#import "GPBExtensionRegistry.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
#import "GPBUnknownField.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUtilities.h"
|
||||
#import "GPBWellKnownTypes.h"
|
||||
#import "GPBWireFormat.h"
|
||||
|
||||
// Well-known proto types
|
||||
#import "GPBAny.pbobjc.h"
|
||||
#import "GPBApi.pbobjc.h"
|
||||
#import "GPBDuration.pbobjc.h"
|
||||
#import "GPBEmpty.pbobjc.h"
|
||||
#import "GPBFieldMask.pbobjc.h"
|
||||
#import "GPBSourceContext.pbobjc.h"
|
||||
#import "GPBStruct.pbobjc.h"
|
||||
#import "GPBTimestamp.pbobjc.h"
|
||||
#import "GPBType.pbobjc.h"
|
||||
#import "GPBWrappers.pbobjc.h"
|
||||
65
libs/protobuf/objectivec/GPBProtocolBuffers.m
Normal file
65
libs/protobuf/objectivec/GPBProtocolBuffers.m
Normal file
@@ -0,0 +1,65 @@
|
||||
// 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.
|
||||
|
||||
// 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"
|
||||
#import "GPBDescriptor.m"
|
||||
#import "GPBDictionary.m"
|
||||
#import "GPBExtensionInternals.m"
|
||||
#import "GPBExtensionRegistry.m"
|
||||
#import "GPBMessage.m"
|
||||
#import "GPBRootObject.m"
|
||||
#import "GPBUnknownField.m"
|
||||
#import "GPBUnknownFieldSet.m"
|
||||
#import "GPBUtilities.m"
|
||||
#import "GPBWellKnownTypes.m"
|
||||
#import "GPBWireFormat.m"
|
||||
|
||||
#import "GPBAny.pbobjc.m"
|
||||
#import "GPBApi.pbobjc.m"
|
||||
#import "GPBDuration.pbobjc.m"
|
||||
#import "GPBEmpty.pbobjc.m"
|
||||
#import "GPBFieldMask.pbobjc.m"
|
||||
#import "GPBSourceContext.pbobjc.m"
|
||||
#import "GPBStruct.pbobjc.m"
|
||||
#import "GPBTimestamp.pbobjc.m"
|
||||
#import "GPBType.pbobjc.m"
|
||||
#import "GPBWrappers.pbobjc.m"
|
||||
42
libs/protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h
Normal file
42
libs/protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h
Normal file
@@ -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 header is meant to only be used by the generated source, it should not
|
||||
// be included in code using protocol buffers.
|
||||
|
||||
// clang-format off
|
||||
#import "GPBBootstrap.h"
|
||||
// clang-format on
|
||||
|
||||
#import "GPBDescriptor_PackagePrivate.h"
|
||||
#import "GPBExtensionInternals.h"
|
||||
#import "GPBMessage_PackagePrivate.h"
|
||||
#import "GPBRootObject_PackagePrivate.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
52
libs/protobuf/objectivec/GPBRootObject.h
Normal file
52
libs/protobuf/objectivec/GPBRootObject.h
Normal file
@@ -0,0 +1,52 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class GPBExtensionRegistry;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* Every generated proto file defines a local "Root" class that exposes a
|
||||
* GPBExtensionRegistry for all the extensions defined by that file and
|
||||
* the files it depends on.
|
||||
**/
|
||||
@interface GPBRootObject : NSObject
|
||||
|
||||
/**
|
||||
* @return An extension registry for the given file and all the files it depends
|
||||
* on.
|
||||
**/
|
||||
+ (GPBExtensionRegistry *)extensionRegistry;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
237
libs/protobuf/objectivec/GPBRootObject.m
Normal file
237
libs/protobuf/objectivec/GPBRootObject.m
Normal file
@@ -0,0 +1,237 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBRootObject_PackagePrivate.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
#import <os/lock.h>
|
||||
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBExtensionRegistry.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
|
||||
@interface GPBExtensionDescriptor (GPBRootObject)
|
||||
// Get singletonName as a c string.
|
||||
- (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
|
||||
// Public Domain
|
||||
static uint32_t jenkins_one_at_a_time_hash(const char *key) {
|
||||
uint32_t hash = 0;
|
||||
for (uint32_t i = 0; key[i] != '\0'; ++i) {
|
||||
hash += key[i];
|
||||
hash += (hash << 10);
|
||||
hash ^= (hash >> 6);
|
||||
}
|
||||
hash += (hash << 3);
|
||||
hash ^= (hash >> 11);
|
||||
hash += (hash << 15);
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Key methods for our custom CFDictionary.
|
||||
// Note that the dictionary lasts for the lifetime of our app, so no need
|
||||
// to worry about deallocation. All of the items are added to it at
|
||||
// startup, and so the keys don't need to be retained/released.
|
||||
// Keys are NULL terminated char *.
|
||||
static const void *GPBRootExtensionKeyRetain(__unused CFAllocatorRef allocator, const void *value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static void GPBRootExtensionKeyRelease(__unused CFAllocatorRef allocator,
|
||||
__unused const void *value) {}
|
||||
|
||||
static CFStringRef GPBRootExtensionCopyKeyDescription(const void *value) {
|
||||
const char *key = (const char *)value;
|
||||
return CFStringCreateWithCString(kCFAllocatorDefault, key, kCFStringEncodingUTF8);
|
||||
}
|
||||
|
||||
static Boolean GPBRootExtensionKeyEqual(const void *value1, const void *value2) {
|
||||
const char *key1 = (const char *)value1;
|
||||
const char *key2 = (const char *)value2;
|
||||
return strcmp(key1, key2) == 0;
|
||||
}
|
||||
|
||||
static CFHashCode GPBRootExtensionKeyHash(const void *value) {
|
||||
const char *key = (const char *)value;
|
||||
return jenkins_one_at_a_time_hash(key);
|
||||
}
|
||||
|
||||
// Long ago, this was an OSSpinLock, but then it came to light that there were issues for that on
|
||||
// iOS:
|
||||
// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
|
||||
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html
|
||||
// It was changed to a dispatch_semaphore_t, but that has potential for priority inversion issues.
|
||||
// The minOS versions are now high enough that os_unfair_lock can be used, and should provide
|
||||
// all the support we need. For more information in the concurrency/locking space see:
|
||||
// https://gist.github.com/tclementdev/6af616354912b0347cdf6db159c37057
|
||||
// https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html
|
||||
// https://developer.apple.com/videos/play/wwdc2017/706/
|
||||
static os_unfair_lock gExtensionSingletonDictionaryLock = OS_UNFAIR_LOCK_INIT;
|
||||
static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL;
|
||||
static GPBExtensionRegistry *gDefaultExtensionRegistry = NULL;
|
||||
|
||||
+ (void)initialize {
|
||||
// Ensure the global is started up.
|
||||
if (!gExtensionSingletonDictionary) {
|
||||
CFDictionaryKeyCallBacks keyCallBacks = {
|
||||
// See description above for reason for using custom dictionary.
|
||||
0,
|
||||
GPBRootExtensionKeyRetain,
|
||||
GPBRootExtensionKeyRelease,
|
||||
GPBRootExtensionCopyKeyDescription,
|
||||
GPBRootExtensionKeyEqual,
|
||||
GPBRootExtensionKeyHash,
|
||||
};
|
||||
gExtensionSingletonDictionary = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks);
|
||||
gDefaultExtensionRegistry = [[GPBExtensionRegistry alloc] init];
|
||||
}
|
||||
|
||||
if ([self superclass] == [GPBRootObject class]) {
|
||||
// This is here to start up all the per file "Root" subclasses.
|
||||
// This must be done in initialize to enforce thread safety of start up of
|
||||
// the protocol buffer library.
|
||||
[self extensionRegistry];
|
||||
}
|
||||
}
|
||||
|
||||
+ (GPBExtensionRegistry *)extensionRegistry {
|
||||
// Is overridden in all the subclasses that provide extensions to provide the
|
||||
// per class one.
|
||||
return gDefaultExtensionRegistry;
|
||||
}
|
||||
|
||||
+ (void)globallyRegisterExtension:(GPBExtensionDescriptor *)field {
|
||||
const char *key = [field singletonNameC];
|
||||
os_unfair_lock_lock(&gExtensionSingletonDictionaryLock);
|
||||
CFDictionarySetValue(gExtensionSingletonDictionary, key, field);
|
||||
os_unfair_lock_unlock(&gExtensionSingletonDictionaryLock);
|
||||
}
|
||||
|
||||
static id ExtensionForName(id self, SEL _cmd) {
|
||||
// Really fast way of doing "classname_selName".
|
||||
// This came up as a hotspot (creation of NSString *) when accessing a
|
||||
// lot of extensions.
|
||||
const char *selName = sel_getName(_cmd);
|
||||
if (selName[0] == '_') {
|
||||
return nil; // Apple internal selector.
|
||||
}
|
||||
size_t selNameLen = 0;
|
||||
while (1) {
|
||||
char c = selName[selNameLen];
|
||||
if (c == '\0') { // String end.
|
||||
break;
|
||||
}
|
||||
if (c == ':') {
|
||||
return nil; // Selector took an arg, not one of the runtime methods.
|
||||
}
|
||||
++selNameLen;
|
||||
}
|
||||
|
||||
const char *className = class_getName(self);
|
||||
size_t classNameLen = strlen(className);
|
||||
char key[classNameLen + selNameLen + 2];
|
||||
memcpy(key, className, classNameLen);
|
||||
key[classNameLen] = '_';
|
||||
memcpy(&key[classNameLen + 1], selName, selNameLen);
|
||||
key[classNameLen + 1 + selNameLen] = '\0';
|
||||
|
||||
// NOTE: Even though this method is called from another C function,
|
||||
// gExtensionSingletonDictionaryLock and gExtensionSingletonDictionary
|
||||
// will always be initialized. This is because this call flow is just to
|
||||
// lookup the Extension, meaning the code is calling an Extension class
|
||||
// message on a Message or Root class. This guarantees that the class was
|
||||
// initialized and Message classes ensure their Root was also initialized.
|
||||
NSAssert(gExtensionSingletonDictionary, @"Startup order broken!");
|
||||
|
||||
os_unfair_lock_lock(&gExtensionSingletonDictionaryLock);
|
||||
id extension = (id)CFDictionaryGetValue(gExtensionSingletonDictionary, key);
|
||||
// We can't remove the key from the dictionary here (as an optimization),
|
||||
// two threads could have gone into +resolveClassMethod: for the same method,
|
||||
// and ended up here; there's no way to ensure both return YES without letting
|
||||
// both try to wire in the method.
|
||||
os_unfair_lock_unlock(&gExtensionSingletonDictionaryLock);
|
||||
return extension;
|
||||
}
|
||||
|
||||
BOOL GPBResolveExtensionClassMethod(Class self, SEL sel) {
|
||||
// Another option would be to register the extensions with the class at
|
||||
// globallyRegisterExtension:
|
||||
// Timing the two solutions, this solution turned out to be much faster
|
||||
// and reduced startup time, and runtime memory.
|
||||
// The advantage to globallyRegisterExtension is that it would reduce the
|
||||
// size of the protos somewhat because the singletonNameC wouldn't need
|
||||
// to include the class name. For a class with a lot of extensions it
|
||||
// can add up. You could also significantly reduce the code complexity of this
|
||||
// file.
|
||||
id extension = ExtensionForName(self, sel);
|
||||
if (extension != nil) {
|
||||
const char *encoding = GPBMessageEncodingForSelector(@selector(getClassValue), NO);
|
||||
Class metaClass = objc_getMetaClass(class_getName(self));
|
||||
IMP imp = imp_implementationWithBlock(^(__unused id obj) {
|
||||
return extension;
|
||||
});
|
||||
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;
|
||||
}
|
||||
|
||||
+ (BOOL)resolveClassMethod:(SEL)sel {
|
||||
if (GPBResolveExtensionClassMethod(self, sel)) {
|
||||
return YES;
|
||||
}
|
||||
return [super resolveClassMethod:sel];
|
||||
}
|
||||
|
||||
@end
|
||||
46
libs/protobuf/objectivec/GPBRootObject_PackagePrivate.h
Normal file
46
libs/protobuf/objectivec/GPBRootObject_PackagePrivate.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
@class GPBExtensionDescriptor;
|
||||
|
||||
@interface GPBRootObject ()
|
||||
|
||||
// Globally register.
|
||||
+ (void)globallyRegisterExtension:(GPBExtensionDescriptor *)field;
|
||||
|
||||
@end
|
||||
|
||||
// Returns YES if the selector was resolved and added to the class,
|
||||
// NO otherwise.
|
||||
BOOL GPBResolveExtensionClassMethod(Class self, SEL sel);
|
||||
151
libs/protobuf/objectivec/GPBRuntimeTypes.h
Normal file
151
libs/protobuf/objectivec/GPBRuntimeTypes.h
Normal file
@@ -0,0 +1,151 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBBootstrap.h"
|
||||
|
||||
@class GPBEnumDescriptor;
|
||||
@class GPBMessage;
|
||||
@class GPBInt32Array;
|
||||
|
||||
/**
|
||||
* Verifies that a given value can be represented by an enum type.
|
||||
* */
|
||||
typedef BOOL (*GPBEnumValidationFunc)(int32_t);
|
||||
|
||||
/**
|
||||
* Fetches an EnumDescriptor.
|
||||
* */
|
||||
typedef GPBEnumDescriptor *(*GPBEnumDescriptorFunc)(void);
|
||||
|
||||
/**
|
||||
* Magic value used at runtime to indicate an enum value that wasn't know at
|
||||
* compile time.
|
||||
* */
|
||||
enum {
|
||||
kGPBUnrecognizedEnumeratorValue = (int32_t)0xFBADBEEF,
|
||||
};
|
||||
|
||||
/**
|
||||
* A union for storing all possible Protobuf values. Note that owner is
|
||||
* responsible for memory management of object types.
|
||||
* */
|
||||
typedef union {
|
||||
BOOL valueBool;
|
||||
int32_t valueInt32;
|
||||
int64_t valueInt64;
|
||||
uint32_t valueUInt32;
|
||||
uint64_t valueUInt64;
|
||||
float valueFloat;
|
||||
double valueDouble;
|
||||
GPB_UNSAFE_UNRETAINED NSData *valueData;
|
||||
GPB_UNSAFE_UNRETAINED NSString *valueString;
|
||||
GPB_UNSAFE_UNRETAINED GPBMessage *valueMessage;
|
||||
int32_t valueEnum;
|
||||
} GPBGenericValue;
|
||||
|
||||
/**
|
||||
* Enum listing the possible data types that a field can contain.
|
||||
*
|
||||
* @note Do not change the order of this enum (or add things to it) without
|
||||
* thinking about it very carefully. There are several things that depend
|
||||
* on the order.
|
||||
* */
|
||||
typedef NS_ENUM(uint8_t, GPBDataType) {
|
||||
/** Field contains boolean value(s). */
|
||||
GPBDataTypeBool = 0,
|
||||
/** Field contains unsigned 4 byte value(s). */
|
||||
GPBDataTypeFixed32,
|
||||
/** Field contains signed 4 byte value(s). */
|
||||
GPBDataTypeSFixed32,
|
||||
/** Field contains float value(s). */
|
||||
GPBDataTypeFloat,
|
||||
/** Field contains unsigned 8 byte value(s). */
|
||||
GPBDataTypeFixed64,
|
||||
/** Field contains signed 8 byte value(s). */
|
||||
GPBDataTypeSFixed64,
|
||||
/** Field contains double value(s). */
|
||||
GPBDataTypeDouble,
|
||||
/**
|
||||
* Field contains variable length value(s). Inefficient for encoding negative
|
||||
* numbers – if your field is likely to have negative values, use
|
||||
* GPBDataTypeSInt32 instead.
|
||||
**/
|
||||
GPBDataTypeInt32,
|
||||
/**
|
||||
* Field contains variable length value(s). Inefficient for encoding negative
|
||||
* numbers – if your field is likely to have negative values, use
|
||||
* GPBDataTypeSInt64 instead.
|
||||
**/
|
||||
GPBDataTypeInt64,
|
||||
/** Field contains signed variable length integer value(s). */
|
||||
GPBDataTypeSInt32,
|
||||
/** Field contains signed variable length integer value(s). */
|
||||
GPBDataTypeSInt64,
|
||||
/** Field contains unsigned variable length integer value(s). */
|
||||
GPBDataTypeUInt32,
|
||||
/** Field contains unsigned variable length integer value(s). */
|
||||
GPBDataTypeUInt64,
|
||||
/** Field contains an arbitrary sequence of bytes. */
|
||||
GPBDataTypeBytes,
|
||||
/** Field contains UTF-8 encoded or 7-bit ASCII text. */
|
||||
GPBDataTypeString,
|
||||
/** Field contains message type(s). */
|
||||
GPBDataTypeMessage,
|
||||
/** Field contains message type(s). */
|
||||
GPBDataTypeGroup,
|
||||
/** Field contains enum value(s). */
|
||||
GPBDataTypeEnum,
|
||||
};
|
||||
|
||||
enum {
|
||||
/**
|
||||
* A count of the number of types in GPBDataType. Separated out from the
|
||||
* GPBDataType enum to avoid warnings regarding not handling GPBDataType_Count
|
||||
* in switch statements.
|
||||
**/
|
||||
GPBDataType_Count = GPBDataTypeEnum + 1
|
||||
};
|
||||
|
||||
/** An extension range. */
|
||||
typedef struct GPBExtensionRange {
|
||||
/** Inclusive. */
|
||||
uint32_t start;
|
||||
/** Exclusive. */
|
||||
uint32_t end;
|
||||
} GPBExtensionRange;
|
||||
|
||||
/**
|
||||
A type to represent an Objective C class.
|
||||
This is actually an `objc_class` but the runtime headers will not allow us to
|
||||
reference `objc_class`, so we have defined our own.
|
||||
*/
|
||||
typedef struct GPBObjcClass_t GPBObjcClass_t;
|
||||
68
libs/protobuf/objectivec/GPBSourceContext.pbobjc.h
Normal file
68
libs/protobuf/objectivec/GPBSourceContext.pbobjc.h
Normal file
@@ -0,0 +1,68 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/source_context.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < 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.
|
||||
**/
|
||||
GPB_FINAL @interface GPBSourceContextRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBSourceContext
|
||||
|
||||
typedef GPB_ENUM(GPBSourceContext_FieldNumber) {
|
||||
GPBSourceContext_FieldNumber_FileName = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* `SourceContext` represents information about the source of a
|
||||
* protobuf element, like the file in which it is defined.
|
||||
**/
|
||||
GPB_FINAL @interface GPBSourceContext : GPBMessage
|
||||
|
||||
/**
|
||||
* The path-qualified name of the .proto file that contained the associated
|
||||
* protobuf element. For example: `"google/protobuf/source_context.proto"`.
|
||||
**/
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *fileName;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
87
libs/protobuf/objectivec/GPBSourceContext.pbobjc.m
Normal file
87
libs/protobuf/objectivec/GPBSourceContext.pbobjc.m
Normal file
@@ -0,0 +1,87 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/source_context.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBSourceContext.pbobjc.h"
|
||||
|
||||
// @@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
|
||||
|
||||
static GPBFileDescriptor *GPBSourceContextRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - GPBSourceContext
|
||||
|
||||
@implementation GPBSourceContext
|
||||
|
||||
@dynamic fileName;
|
||||
|
||||
typedef struct GPBSourceContext__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSString *fileName;
|
||||
} GPBSourceContext__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 = "fileName",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBSourceContext_FieldNumber_FileName,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBSourceContext__storage_, fileName),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBSourceContext class]
|
||||
rootClass:[GPBSourceContextRoot class]
|
||||
file:GPBSourceContextRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBSourceContext__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
195
libs/protobuf/objectivec/GPBStruct.pbobjc.h
Normal file
195
libs/protobuf/objectivec/GPBStruct.pbobjc.h
Normal file
@@ -0,0 +1,195 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/struct.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
|
||||
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
|
||||
// @@protoc_insertion_point(imports)
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
@class GPBListValue;
|
||||
@class GPBStruct;
|
||||
@class GPBValue;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#pragma mark - Enum GPBNullValue
|
||||
|
||||
/**
|
||||
* `NullValue` is a singleton enumeration to represent the null value for the
|
||||
* `Value` type union.
|
||||
*
|
||||
* The JSON representation for `NullValue` is JSON `null`.
|
||||
**/
|
||||
typedef GPB_ENUM(GPBNullValue) {
|
||||
/**
|
||||
* Value used if any message's field encounters a value that is not defined
|
||||
* by this enum. The message will also have C functions to get/set the rawValue
|
||||
* of the field.
|
||||
**/
|
||||
GPBNullValue_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
|
||||
/** Null value. */
|
||||
GPBNullValue_NullValue = 0,
|
||||
};
|
||||
|
||||
GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void);
|
||||
|
||||
/**
|
||||
* Checks to see if the given value is defined by the enum or was not known at
|
||||
* the time this source was generated.
|
||||
**/
|
||||
BOOL GPBNullValue_IsValidValue(int32_t value);
|
||||
|
||||
#pragma mark - GPBStructRoot
|
||||
|
||||
/**
|
||||
* Exposes the extension registry for this file.
|
||||
*
|
||||
* The base class provides:
|
||||
* @code
|
||||
* + (GPBExtensionRegistry *)extensionRegistry;
|
||||
* @endcode
|
||||
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
|
||||
* this file and all files that it depends on.
|
||||
**/
|
||||
GPB_FINAL @interface GPBStructRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBStruct
|
||||
|
||||
typedef GPB_ENUM(GPBStruct_FieldNumber) {
|
||||
GPBStruct_FieldNumber_Fields = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* `Struct` represents a structured data value, consisting of fields
|
||||
* which map to dynamically typed values. In some languages, `Struct`
|
||||
* might be supported by a native representation. For example, in
|
||||
* scripting languages like JS a struct is represented as an
|
||||
* object. The details of that representation are described together
|
||||
* with the proto support for the language.
|
||||
*
|
||||
* The JSON representation for `Struct` is JSON object.
|
||||
**/
|
||||
GPB_FINAL @interface GPBStruct : GPBMessage
|
||||
|
||||
/** Unordered map of dynamically typed values. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, GPBValue*> *fields;
|
||||
/** The number of items in @c fields without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger fields_Count;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBValue
|
||||
|
||||
typedef GPB_ENUM(GPBValue_FieldNumber) {
|
||||
GPBValue_FieldNumber_NullValue = 1,
|
||||
GPBValue_FieldNumber_NumberValue = 2,
|
||||
GPBValue_FieldNumber_StringValue = 3,
|
||||
GPBValue_FieldNumber_BoolValue = 4,
|
||||
GPBValue_FieldNumber_StructValue = 5,
|
||||
GPBValue_FieldNumber_ListValue = 6,
|
||||
};
|
||||
|
||||
typedef GPB_ENUM(GPBValue_Kind_OneOfCase) {
|
||||
GPBValue_Kind_OneOfCase_GPBUnsetOneOfCase = 0,
|
||||
GPBValue_Kind_OneOfCase_NullValue = 1,
|
||||
GPBValue_Kind_OneOfCase_NumberValue = 2,
|
||||
GPBValue_Kind_OneOfCase_StringValue = 3,
|
||||
GPBValue_Kind_OneOfCase_BoolValue = 4,
|
||||
GPBValue_Kind_OneOfCase_StructValue = 5,
|
||||
GPBValue_Kind_OneOfCase_ListValue = 6,
|
||||
};
|
||||
|
||||
/**
|
||||
* `Value` represents a dynamically typed value which can be either
|
||||
* null, a number, a string, a boolean, a recursive struct value, or a
|
||||
* list of values. A producer of value is expected to set one of these
|
||||
* variants. Absence of any variant indicates an error.
|
||||
*
|
||||
* The JSON representation for `Value` is JSON value.
|
||||
**/
|
||||
GPB_FINAL @interface GPBValue : GPBMessage
|
||||
|
||||
/** The kind of value. */
|
||||
@property(nonatomic, readonly) GPBValue_Kind_OneOfCase kindOneOfCase;
|
||||
|
||||
/** Represents a null value. */
|
||||
@property(nonatomic, readwrite) GPBNullValue nullValue;
|
||||
|
||||
/** Represents a double value. */
|
||||
@property(nonatomic, readwrite) double numberValue;
|
||||
|
||||
/** Represents a string value. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *stringValue;
|
||||
|
||||
/** Represents a boolean value. */
|
||||
@property(nonatomic, readwrite) BOOL boolValue;
|
||||
|
||||
/** Represents a structured value. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) GPBStruct *structValue;
|
||||
|
||||
/** Represents a repeated `Value`. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) GPBListValue *listValue;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Fetches the raw value of a @c GPBValue's @c nullValue property, even
|
||||
* if the value was not defined by the enum at the time the code was generated.
|
||||
**/
|
||||
int32_t GPBValue_NullValue_RawValue(GPBValue *message);
|
||||
/**
|
||||
* Sets the raw value of an @c GPBValue's @c nullValue property, allowing
|
||||
* it to be set to a value that was not defined by the enum at the time the code
|
||||
* was generated.
|
||||
**/
|
||||
void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value);
|
||||
|
||||
/**
|
||||
* Clears whatever value was set for the oneof 'kind'.
|
||||
**/
|
||||
void GPBValue_ClearKindOneOfCase(GPBValue *message);
|
||||
|
||||
#pragma mark - GPBListValue
|
||||
|
||||
typedef GPB_ENUM(GPBListValue_FieldNumber) {
|
||||
GPBListValue_FieldNumber_ValuesArray = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* `ListValue` is a wrapper around a repeated field of values.
|
||||
*
|
||||
* The JSON representation for `ListValue` is JSON array.
|
||||
**/
|
||||
GPB_FINAL @interface GPBListValue : GPBMessage
|
||||
|
||||
/** Repeated field of dynamically typed values. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBValue*> *valuesArray;
|
||||
/** The number of items in @c valuesArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger valuesArray_Count;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
300
libs/protobuf/objectivec/GPBStruct.pbobjc.m
Normal file
300
libs/protobuf/objectivec/GPBStruct.pbobjc.m
Normal file
@@ -0,0 +1,300 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/struct.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBStruct.pbobjc.h"
|
||||
|
||||
#import <stdatomic.h>
|
||||
|
||||
// @@protoc_insertion_point(imports)
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
|
||||
|
||||
#pragma mark - Objective C Class declarations
|
||||
// Forward declarations of Objective C classes that we can use as
|
||||
// static values in struct initializers.
|
||||
// We don't use [Foo class] because it is not a static value.
|
||||
GPBObjCClassDeclaration(GPBListValue);
|
||||
GPBObjCClassDeclaration(GPBStruct);
|
||||
GPBObjCClassDeclaration(GPBValue);
|
||||
|
||||
#pragma mark - GPBStructRoot
|
||||
|
||||
@implementation GPBStructRoot
|
||||
|
||||
// No extensions in the file and no imports, so no need to generate
|
||||
// +extensionRegistry.
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBStructRoot_FileDescriptor
|
||||
|
||||
static GPBFileDescriptor *GPBStructRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - Enum GPBNullValue
|
||||
|
||||
GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void) {
|
||||
static _Atomic(GPBEnumDescriptor*) descriptor = nil;
|
||||
if (!descriptor) {
|
||||
static const char *valueNames =
|
||||
"NullValue\000";
|
||||
static const int32_t values[] = {
|
||||
GPBNullValue_NullValue,
|
||||
};
|
||||
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;
|
||||
}
|
||||
|
||||
BOOL GPBNullValue_IsValidValue(int32_t value__) {
|
||||
switch (value__) {
|
||||
case GPBNullValue_NullValue:
|
||||
return YES;
|
||||
default:
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - GPBStruct
|
||||
|
||||
@implementation GPBStruct
|
||||
|
||||
@dynamic fields, fields_Count;
|
||||
|
||||
typedef struct GPBStruct__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSMutableDictionary *fields;
|
||||
} GPBStruct__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 = "fields",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBValue),
|
||||
.number = GPBStruct_FieldNumber_Fields,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBStruct__storage_, fields),
|
||||
.flags = GPBFieldMapKeyString,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBStruct class]
|
||||
rootClass:[GPBStructRoot class]
|
||||
file:GPBStructRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBStruct__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBValue
|
||||
|
||||
@implementation GPBValue
|
||||
|
||||
@dynamic kindOneOfCase;
|
||||
@dynamic nullValue;
|
||||
@dynamic numberValue;
|
||||
@dynamic stringValue;
|
||||
@dynamic boolValue;
|
||||
@dynamic structValue;
|
||||
@dynamic listValue;
|
||||
|
||||
typedef struct GPBValue__storage_ {
|
||||
uint32_t _has_storage_[2];
|
||||
GPBNullValue nullValue;
|
||||
NSString *stringValue;
|
||||
GPBStruct *structValue;
|
||||
GPBListValue *listValue;
|
||||
double numberValue;
|
||||
} GPBValue__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 = "nullValue",
|
||||
.dataTypeSpecific.enumDescFunc = GPBNullValue_EnumDescriptor,
|
||||
.number = GPBValue_FieldNumber_NullValue,
|
||||
.hasIndex = -1,
|
||||
.offset = (uint32_t)offsetof(GPBValue__storage_, nullValue),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor),
|
||||
.dataType = GPBDataTypeEnum,
|
||||
},
|
||||
{
|
||||
.name = "numberValue",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBValue_FieldNumber_NumberValue,
|
||||
.hasIndex = -1,
|
||||
.offset = (uint32_t)offsetof(GPBValue__storage_, numberValue),
|
||||
.flags = GPBFieldOptional,
|
||||
.dataType = GPBDataTypeDouble,
|
||||
},
|
||||
{
|
||||
.name = "stringValue",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBValue_FieldNumber_StringValue,
|
||||
.hasIndex = -1,
|
||||
.offset = (uint32_t)offsetof(GPBValue__storage_, stringValue),
|
||||
.flags = GPBFieldOptional,
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "boolValue",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBValue_FieldNumber_BoolValue,
|
||||
.hasIndex = -1,
|
||||
.offset = 0, // Stored in _has_storage_ to save space.
|
||||
.flags = GPBFieldOptional,
|
||||
.dataType = GPBDataTypeBool,
|
||||
},
|
||||
{
|
||||
.name = "structValue",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBStruct),
|
||||
.number = GPBValue_FieldNumber_StructValue,
|
||||
.hasIndex = -1,
|
||||
.offset = (uint32_t)offsetof(GPBValue__storage_, structValue),
|
||||
.flags = GPBFieldOptional,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "listValue",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBListValue),
|
||||
.number = GPBValue_FieldNumber_ListValue,
|
||||
.hasIndex = -1,
|
||||
.offset = (uint32_t)offsetof(GPBValue__storage_, listValue),
|
||||
.flags = GPBFieldOptional,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBValue class]
|
||||
rootClass:[GPBStructRoot class]
|
||||
file:GPBStructRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBValue__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
static const char *oneofs[] = {
|
||||
"kind",
|
||||
};
|
||||
[localDescriptor setupOneofs:oneofs
|
||||
count:(uint32_t)(sizeof(oneofs) / sizeof(char*))
|
||||
firstHasIndex:-1];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int32_t GPBValue_NullValue_RawValue(GPBValue *message) {
|
||||
GPBDescriptor *descriptor = [GPBValue descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBValue_FieldNumber_NullValue];
|
||||
return GPBGetMessageRawEnumField(message, field);
|
||||
}
|
||||
|
||||
void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value) {
|
||||
GPBDescriptor *descriptor = [GPBValue descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBValue_FieldNumber_NullValue];
|
||||
GPBSetMessageRawEnumField(message, field, value);
|
||||
}
|
||||
|
||||
void GPBValue_ClearKindOneOfCase(GPBValue *message) {
|
||||
GPBDescriptor *descriptor = [GPBValue descriptor];
|
||||
GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0];
|
||||
GPBClearOneof(message, oneof);
|
||||
}
|
||||
#pragma mark - GPBListValue
|
||||
|
||||
@implementation GPBListValue
|
||||
|
||||
@dynamic valuesArray, valuesArray_Count;
|
||||
|
||||
typedef struct GPBListValue__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSMutableArray *valuesArray;
|
||||
} GPBListValue__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 = "valuesArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBValue),
|
||||
.number = GPBListValue_FieldNumber_ValuesArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBListValue__storage_, valuesArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBListValue class]
|
||||
rootClass:[GPBStructRoot class]
|
||||
file:GPBStructRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBListValue__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
165
libs/protobuf/objectivec/GPBTimestamp.pbobjc.h
Normal file
165
libs/protobuf/objectivec/GPBTimestamp.pbobjc.h
Normal file
@@ -0,0 +1,165 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/timestamp.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < 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.
|
||||
**/
|
||||
GPB_FINAL @interface GPBTimestampRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBTimestamp
|
||||
|
||||
typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
|
||||
GPBTimestamp_FieldNumber_Seconds = 1,
|
||||
GPBTimestamp_FieldNumber_Nanos = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* A Timestamp represents a point in time independent of any time zone or local
|
||||
* calendar, encoded as a count of seconds and fractions of seconds at
|
||||
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
||||
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
||||
* Gregorian calendar backwards to year one.
|
||||
*
|
||||
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
||||
* second table is needed for interpretation, using a [24-hour linear
|
||||
* smear](https://developers.google.com/time/smear).
|
||||
*
|
||||
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
||||
* restricting to that range, we ensure that we can convert to and from [RFC
|
||||
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* Example 1: Compute Timestamp from POSIX `time()`.
|
||||
*
|
||||
* Timestamp timestamp;
|
||||
* timestamp.set_seconds(time(NULL));
|
||||
* timestamp.set_nanos(0);
|
||||
*
|
||||
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
||||
*
|
||||
* struct timeval tv;
|
||||
* gettimeofday(&tv, NULL);
|
||||
*
|
||||
* Timestamp timestamp;
|
||||
* timestamp.set_seconds(tv.tv_sec);
|
||||
* timestamp.set_nanos(tv.tv_usec * 1000);
|
||||
*
|
||||
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
||||
*
|
||||
* FILETIME ft;
|
||||
* GetSystemTimeAsFileTime(&ft);
|
||||
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
||||
*
|
||||
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
||||
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
||||
* Timestamp timestamp;
|
||||
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
||||
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
||||
*
|
||||
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
||||
*
|
||||
* long millis = System.currentTimeMillis();
|
||||
*
|
||||
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
||||
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
||||
*
|
||||
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
||||
*
|
||||
* Instant now = Instant.now();
|
||||
*
|
||||
* Timestamp timestamp =
|
||||
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
||||
* .setNanos(now.getNano()).build();
|
||||
*
|
||||
* Example 6: Compute Timestamp from current time in Python.
|
||||
*
|
||||
* timestamp = Timestamp()
|
||||
* timestamp.GetCurrentTime()
|
||||
*
|
||||
* # JSON Mapping
|
||||
*
|
||||
* In JSON format, the Timestamp type is encoded as a string in the
|
||||
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
||||
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
||||
* where {year} is always expressed using four digits while {month}, {day},
|
||||
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
||||
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
||||
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
||||
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
||||
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
||||
* able to accept both UTC and other timezones (as indicated by an offset).
|
||||
*
|
||||
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
||||
* 01:30 UTC on January 15, 2017.
|
||||
*
|
||||
* In JavaScript, one can convert a Date object to this format using the
|
||||
* standard
|
||||
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
||||
* method. In Python, a standard `datetime.datetime` object can be converted
|
||||
* to this format using
|
||||
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
||||
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
||||
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
||||
* http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
|
||||
* ) to obtain a formatter capable of generating timestamps in this format.
|
||||
**/
|
||||
GPB_FINAL @interface GPBTimestamp : GPBMessage
|
||||
|
||||
/**
|
||||
* Represents seconds of UTC time since Unix epoch
|
||||
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
||||
* 9999-12-31T23:59:59Z inclusive.
|
||||
**/
|
||||
@property(nonatomic, readwrite) int64_t seconds;
|
||||
|
||||
/**
|
||||
* Non-negative fractions of a second at nanosecond resolution. Negative
|
||||
* second values with fractions must still have non-negative nanos values
|
||||
* that count forward in time. Must be from 0 to 999,999,999
|
||||
* inclusive.
|
||||
**/
|
||||
@property(nonatomic, readwrite) int32_t nanos;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
98
libs/protobuf/objectivec/GPBTimestamp.pbobjc.m
Normal file
98
libs/protobuf/objectivec/GPBTimestamp.pbobjc.m
Normal file
@@ -0,0 +1,98 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/timestamp.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBTimestamp.pbobjc.h"
|
||||
|
||||
// @@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
|
||||
|
||||
static GPBFileDescriptor *GPBTimestampRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - GPBTimestamp
|
||||
|
||||
@implementation GPBTimestamp
|
||||
|
||||
@dynamic seconds;
|
||||
@dynamic nanos;
|
||||
|
||||
typedef struct GPBTimestamp__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
int32_t nanos;
|
||||
int64_t seconds;
|
||||
} GPBTimestamp__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 = "seconds",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBTimestamp_FieldNumber_Seconds,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBTimestamp__storage_, seconds),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeInt64,
|
||||
},
|
||||
{
|
||||
.name = "nanos",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBTimestamp_FieldNumber_Nanos,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBTimestamp__storage_, nanos),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeInt32,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBTimestamp class]
|
||||
rootClass:[GPBTimestampRoot class]
|
||||
file:GPBTimestampRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBTimestamp__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
435
libs/protobuf/objectivec/GPBType.pbobjc.h
Normal file
435
libs/protobuf/objectivec/GPBType.pbobjc.h
Normal file
@@ -0,0 +1,435 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/type.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
#import "GPBAny.pbobjc.h"
|
||||
#import "GPBSourceContext.pbobjc.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < 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 GPBEnumValue;
|
||||
@class GPBField;
|
||||
@class GPBOption;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#pragma mark - Enum GPBSyntax
|
||||
|
||||
/** The syntax in which a protocol buffer element is defined. */
|
||||
typedef GPB_ENUM(GPBSyntax) {
|
||||
/**
|
||||
* Value used if any message's field encounters a value that is not defined
|
||||
* by this enum. The message will also have C functions to get/set the rawValue
|
||||
* of the field.
|
||||
**/
|
||||
GPBSyntax_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
|
||||
/** Syntax `proto2`. */
|
||||
GPBSyntax_SyntaxProto2 = 0,
|
||||
|
||||
/** Syntax `proto3`. */
|
||||
GPBSyntax_SyntaxProto3 = 1,
|
||||
};
|
||||
|
||||
GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void);
|
||||
|
||||
/**
|
||||
* Checks to see if the given value is defined by the enum or was not known at
|
||||
* the time this source was generated.
|
||||
**/
|
||||
BOOL GPBSyntax_IsValidValue(int32_t value);
|
||||
|
||||
#pragma mark - Enum GPBField_Kind
|
||||
|
||||
/** Basic field types. */
|
||||
typedef GPB_ENUM(GPBField_Kind) {
|
||||
/**
|
||||
* Value used if any message's field encounters a value that is not defined
|
||||
* by this enum. The message will also have C functions to get/set the rawValue
|
||||
* of the field.
|
||||
**/
|
||||
GPBField_Kind_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
|
||||
/** Field type unknown. */
|
||||
GPBField_Kind_TypeUnknown = 0,
|
||||
|
||||
/** Field type double. */
|
||||
GPBField_Kind_TypeDouble = 1,
|
||||
|
||||
/** Field type float. */
|
||||
GPBField_Kind_TypeFloat = 2,
|
||||
|
||||
/** Field type int64. */
|
||||
GPBField_Kind_TypeInt64 = 3,
|
||||
|
||||
/** Field type uint64. */
|
||||
GPBField_Kind_TypeUint64 = 4,
|
||||
|
||||
/** Field type int32. */
|
||||
GPBField_Kind_TypeInt32 = 5,
|
||||
|
||||
/** Field type fixed64. */
|
||||
GPBField_Kind_TypeFixed64 = 6,
|
||||
|
||||
/** Field type fixed32. */
|
||||
GPBField_Kind_TypeFixed32 = 7,
|
||||
|
||||
/** Field type bool. */
|
||||
GPBField_Kind_TypeBool = 8,
|
||||
|
||||
/** Field type string. */
|
||||
GPBField_Kind_TypeString = 9,
|
||||
|
||||
/** Field type group. Proto2 syntax only, and deprecated. */
|
||||
GPBField_Kind_TypeGroup = 10,
|
||||
|
||||
/** Field type message. */
|
||||
GPBField_Kind_TypeMessage = 11,
|
||||
|
||||
/** Field type bytes. */
|
||||
GPBField_Kind_TypeBytes = 12,
|
||||
|
||||
/** Field type uint32. */
|
||||
GPBField_Kind_TypeUint32 = 13,
|
||||
|
||||
/** Field type enum. */
|
||||
GPBField_Kind_TypeEnum = 14,
|
||||
|
||||
/** Field type sfixed32. */
|
||||
GPBField_Kind_TypeSfixed32 = 15,
|
||||
|
||||
/** Field type sfixed64. */
|
||||
GPBField_Kind_TypeSfixed64 = 16,
|
||||
|
||||
/** Field type sint32. */
|
||||
GPBField_Kind_TypeSint32 = 17,
|
||||
|
||||
/** Field type sint64. */
|
||||
GPBField_Kind_TypeSint64 = 18,
|
||||
};
|
||||
|
||||
GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void);
|
||||
|
||||
/**
|
||||
* Checks to see if the given value is defined by the enum or was not known at
|
||||
* the time this source was generated.
|
||||
**/
|
||||
BOOL GPBField_Kind_IsValidValue(int32_t value);
|
||||
|
||||
#pragma mark - Enum GPBField_Cardinality
|
||||
|
||||
/** Whether a field is optional, required, or repeated. */
|
||||
typedef GPB_ENUM(GPBField_Cardinality) {
|
||||
/**
|
||||
* Value used if any message's field encounters a value that is not defined
|
||||
* by this enum. The message will also have C functions to get/set the rawValue
|
||||
* of the field.
|
||||
**/
|
||||
GPBField_Cardinality_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
|
||||
/** For fields with unknown cardinality. */
|
||||
GPBField_Cardinality_CardinalityUnknown = 0,
|
||||
|
||||
/** For optional fields. */
|
||||
GPBField_Cardinality_CardinalityOptional = 1,
|
||||
|
||||
/** For required fields. Proto2 syntax only. */
|
||||
GPBField_Cardinality_CardinalityRequired = 2,
|
||||
|
||||
/** For repeated fields. */
|
||||
GPBField_Cardinality_CardinalityRepeated = 3,
|
||||
};
|
||||
|
||||
GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void);
|
||||
|
||||
/**
|
||||
* Checks to see if the given value is defined by the enum or was not known at
|
||||
* the time this source was generated.
|
||||
**/
|
||||
BOOL GPBField_Cardinality_IsValidValue(int32_t value);
|
||||
|
||||
#pragma mark - GPBTypeRoot
|
||||
|
||||
/**
|
||||
* Exposes the extension registry for this file.
|
||||
*
|
||||
* The base class provides:
|
||||
* @code
|
||||
* + (GPBExtensionRegistry *)extensionRegistry;
|
||||
* @endcode
|
||||
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
|
||||
* this file and all files that it depends on.
|
||||
**/
|
||||
GPB_FINAL @interface GPBTypeRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBType
|
||||
|
||||
typedef GPB_ENUM(GPBType_FieldNumber) {
|
||||
GPBType_FieldNumber_Name = 1,
|
||||
GPBType_FieldNumber_FieldsArray = 2,
|
||||
GPBType_FieldNumber_OneofsArray = 3,
|
||||
GPBType_FieldNumber_OptionsArray = 4,
|
||||
GPBType_FieldNumber_SourceContext = 5,
|
||||
GPBType_FieldNumber_Syntax = 6,
|
||||
};
|
||||
|
||||
/**
|
||||
* A protocol buffer message type.
|
||||
**/
|
||||
GPB_FINAL @interface GPBType : GPBMessage
|
||||
|
||||
/** The fully qualified message name. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
|
||||
|
||||
/** The list of fields. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBField*> *fieldsArray;
|
||||
/** The number of items in @c fieldsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger fieldsArray_Count;
|
||||
|
||||
/** The list of types appearing in `oneof` definitions in this type. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *oneofsArray;
|
||||
/** The number of items in @c oneofsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger oneofsArray_Count;
|
||||
|
||||
/** The protocol buffer options. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
|
||||
/** The number of items in @c optionsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
|
||||
|
||||
/** The source context. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
|
||||
/** Test to see if @c sourceContext has been set. */
|
||||
@property(nonatomic, readwrite) BOOL hasSourceContext;
|
||||
|
||||
/** The source syntax. */
|
||||
@property(nonatomic, readwrite) GPBSyntax syntax;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Fetches the raw value of a @c GPBType's @c syntax property, even
|
||||
* if the value was not defined by the enum at the time the code was generated.
|
||||
**/
|
||||
int32_t GPBType_Syntax_RawValue(GPBType *message);
|
||||
/**
|
||||
* Sets the raw value of an @c GPBType's @c syntax property, allowing
|
||||
* it to be set to a value that was not defined by the enum at the time the code
|
||||
* was generated.
|
||||
**/
|
||||
void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value);
|
||||
|
||||
#pragma mark - GPBField
|
||||
|
||||
typedef GPB_ENUM(GPBField_FieldNumber) {
|
||||
GPBField_FieldNumber_Kind = 1,
|
||||
GPBField_FieldNumber_Cardinality = 2,
|
||||
GPBField_FieldNumber_Number = 3,
|
||||
GPBField_FieldNumber_Name = 4,
|
||||
GPBField_FieldNumber_TypeURL = 6,
|
||||
GPBField_FieldNumber_OneofIndex = 7,
|
||||
GPBField_FieldNumber_Packed = 8,
|
||||
GPBField_FieldNumber_OptionsArray = 9,
|
||||
GPBField_FieldNumber_JsonName = 10,
|
||||
GPBField_FieldNumber_DefaultValue = 11,
|
||||
};
|
||||
|
||||
/**
|
||||
* A single field of a message type.
|
||||
**/
|
||||
GPB_FINAL @interface GPBField : GPBMessage
|
||||
|
||||
/** The field type. */
|
||||
@property(nonatomic, readwrite) GPBField_Kind kind;
|
||||
|
||||
/** The field cardinality. */
|
||||
@property(nonatomic, readwrite) GPBField_Cardinality cardinality;
|
||||
|
||||
/** The field number. */
|
||||
@property(nonatomic, readwrite) int32_t number;
|
||||
|
||||
/** The field name. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
|
||||
|
||||
/**
|
||||
* The field type URL, without the scheme, for message or enumeration
|
||||
* types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
|
||||
**/
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
|
||||
|
||||
/**
|
||||
* The index of the field type in `Type.oneofs`, for message or enumeration
|
||||
* types. The first type has index 1; zero means the type is not in the list.
|
||||
**/
|
||||
@property(nonatomic, readwrite) int32_t oneofIndex;
|
||||
|
||||
/** Whether to use alternative packed wire representation. */
|
||||
@property(nonatomic, readwrite) BOOL packed;
|
||||
|
||||
/** The protocol buffer options. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
|
||||
/** The number of items in @c optionsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
|
||||
|
||||
/** The field JSON name. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName;
|
||||
|
||||
/** The string value of the default value of this field. Proto2 syntax only. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Fetches the raw value of a @c GPBField's @c kind property, even
|
||||
* if the value was not defined by the enum at the time the code was generated.
|
||||
**/
|
||||
int32_t GPBField_Kind_RawValue(GPBField *message);
|
||||
/**
|
||||
* Sets the raw value of an @c GPBField's @c kind property, allowing
|
||||
* it to be set to a value that was not defined by the enum at the time the code
|
||||
* was generated.
|
||||
**/
|
||||
void SetGPBField_Kind_RawValue(GPBField *message, int32_t value);
|
||||
|
||||
/**
|
||||
* Fetches the raw value of a @c GPBField's @c cardinality property, even
|
||||
* if the value was not defined by the enum at the time the code was generated.
|
||||
**/
|
||||
int32_t GPBField_Cardinality_RawValue(GPBField *message);
|
||||
/**
|
||||
* Sets the raw value of an @c GPBField's @c cardinality property, allowing
|
||||
* it to be set to a value that was not defined by the enum at the time the code
|
||||
* was generated.
|
||||
**/
|
||||
void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value);
|
||||
|
||||
#pragma mark - GPBEnum
|
||||
|
||||
typedef GPB_ENUM(GPBEnum_FieldNumber) {
|
||||
GPBEnum_FieldNumber_Name = 1,
|
||||
GPBEnum_FieldNumber_EnumvalueArray = 2,
|
||||
GPBEnum_FieldNumber_OptionsArray = 3,
|
||||
GPBEnum_FieldNumber_SourceContext = 4,
|
||||
GPBEnum_FieldNumber_Syntax = 5,
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum type definition.
|
||||
**/
|
||||
GPB_FINAL @interface GPBEnum : GPBMessage
|
||||
|
||||
/** Enum type name. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
|
||||
|
||||
/** Enum value definitions. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBEnumValue*> *enumvalueArray;
|
||||
/** The number of items in @c enumvalueArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger enumvalueArray_Count;
|
||||
|
||||
/** Protocol buffer options. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
|
||||
/** The number of items in @c optionsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
|
||||
|
||||
/** The source context. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
|
||||
/** Test to see if @c sourceContext has been set. */
|
||||
@property(nonatomic, readwrite) BOOL hasSourceContext;
|
||||
|
||||
/** The source syntax. */
|
||||
@property(nonatomic, readwrite) GPBSyntax syntax;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Fetches the raw value of a @c GPBEnum's @c syntax property, even
|
||||
* if the value was not defined by the enum at the time the code was generated.
|
||||
**/
|
||||
int32_t GPBEnum_Syntax_RawValue(GPBEnum *message);
|
||||
/**
|
||||
* Sets the raw value of an @c GPBEnum's @c syntax property, allowing
|
||||
* it to be set to a value that was not defined by the enum at the time the code
|
||||
* was generated.
|
||||
**/
|
||||
void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value);
|
||||
|
||||
#pragma mark - GPBEnumValue
|
||||
|
||||
typedef GPB_ENUM(GPBEnumValue_FieldNumber) {
|
||||
GPBEnumValue_FieldNumber_Name = 1,
|
||||
GPBEnumValue_FieldNumber_Number = 2,
|
||||
GPBEnumValue_FieldNumber_OptionsArray = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum value definition.
|
||||
**/
|
||||
GPB_FINAL @interface GPBEnumValue : GPBMessage
|
||||
|
||||
/** Enum value name. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
|
||||
|
||||
/** Enum value number. */
|
||||
@property(nonatomic, readwrite) int32_t number;
|
||||
|
||||
/** Protocol buffer options. */
|
||||
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
|
||||
/** The number of items in @c optionsArray without causing the container to be created. */
|
||||
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBOption
|
||||
|
||||
typedef GPB_ENUM(GPBOption_FieldNumber) {
|
||||
GPBOption_FieldNumber_Name = 1,
|
||||
GPBOption_FieldNumber_Value = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* A protocol buffer option, which can be attached to a message, field,
|
||||
* enumeration, etc.
|
||||
**/
|
||||
GPB_FINAL @interface GPBOption : GPBMessage
|
||||
|
||||
/**
|
||||
* The option's name. For protobuf built-in options (options defined in
|
||||
* descriptor.proto), this is the short name. For example, `"map_entry"`.
|
||||
* For custom options, it should be the fully-qualified name. For example,
|
||||
* `"google.api.http"`.
|
||||
**/
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
|
||||
|
||||
/**
|
||||
* The option's value packed in an Any message. If the value is a primitive,
|
||||
* the corresponding wrapper type defined in google/protobuf/wrappers.proto
|
||||
* should be used. If the value is an enum, it should be stored as an int32
|
||||
* value using the google.protobuf.Int32Value type.
|
||||
**/
|
||||
@property(nonatomic, readwrite, strong, null_resettable) GPBAny *value;
|
||||
/** Test to see if @c value has been set. */
|
||||
@property(nonatomic, readwrite) BOOL hasValue;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
712
libs/protobuf/objectivec/GPBType.pbobjc.m
Normal file
712
libs/protobuf/objectivec/GPBType.pbobjc.m
Normal file
@@ -0,0 +1,712 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/type.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBType.pbobjc.h"
|
||||
|
||||
#import <stdatomic.h>
|
||||
|
||||
// @@protoc_insertion_point(imports)
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
|
||||
|
||||
#pragma mark - Objective C Class declarations
|
||||
// Forward declarations of Objective C classes that we can use as
|
||||
// static values in struct initializers.
|
||||
// We don't use [Foo class] because it is not a static value.
|
||||
GPBObjCClassDeclaration(GPBAny);
|
||||
GPBObjCClassDeclaration(GPBEnumValue);
|
||||
GPBObjCClassDeclaration(GPBField);
|
||||
GPBObjCClassDeclaration(GPBOption);
|
||||
GPBObjCClassDeclaration(GPBSourceContext);
|
||||
|
||||
#pragma mark - GPBTypeRoot
|
||||
|
||||
@implementation GPBTypeRoot
|
||||
|
||||
// No extensions in the file and none of the imports (direct or indirect)
|
||||
// defined extensions, so no need to generate +extensionRegistry.
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBTypeRoot_FileDescriptor
|
||||
|
||||
static GPBFileDescriptor *GPBTypeRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - Enum GPBSyntax
|
||||
|
||||
GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void) {
|
||||
static _Atomic(GPBEnumDescriptor*) descriptor = nil;
|
||||
if (!descriptor) {
|
||||
static const char *valueNames =
|
||||
"SyntaxProto2\000SyntaxProto3\000";
|
||||
static const int32_t values[] = {
|
||||
GPBSyntax_SyntaxProto2,
|
||||
GPBSyntax_SyntaxProto3,
|
||||
};
|
||||
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;
|
||||
}
|
||||
|
||||
BOOL GPBSyntax_IsValidValue(int32_t value__) {
|
||||
switch (value__) {
|
||||
case GPBSyntax_SyntaxProto2:
|
||||
case GPBSyntax_SyntaxProto3:
|
||||
return YES;
|
||||
default:
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - GPBType
|
||||
|
||||
@implementation GPBType
|
||||
|
||||
@dynamic name;
|
||||
@dynamic fieldsArray, fieldsArray_Count;
|
||||
@dynamic oneofsArray, oneofsArray_Count;
|
||||
@dynamic optionsArray, optionsArray_Count;
|
||||
@dynamic hasSourceContext, sourceContext;
|
||||
@dynamic syntax;
|
||||
|
||||
typedef struct GPBType__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
GPBSyntax syntax;
|
||||
NSString *name;
|
||||
NSMutableArray *fieldsArray;
|
||||
NSMutableArray *oneofsArray;
|
||||
NSMutableArray *optionsArray;
|
||||
GPBSourceContext *sourceContext;
|
||||
} GPBType__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",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBType_FieldNumber_Name,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBType__storage_, name),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "fieldsArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBField),
|
||||
.number = GPBType_FieldNumber_FieldsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBType__storage_, fieldsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "oneofsArray",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBType_FieldNumber_OneofsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBType__storage_, oneofsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "optionsArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBOption),
|
||||
.number = GPBType_FieldNumber_OptionsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBType__storage_, optionsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "sourceContext",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBSourceContext),
|
||||
.number = GPBType_FieldNumber_SourceContext,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBType__storage_, sourceContext),
|
||||
.flags = GPBFieldOptional,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "syntax",
|
||||
.dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
|
||||
.number = GPBType_FieldNumber_Syntax,
|
||||
.hasIndex = 2,
|
||||
.offset = (uint32_t)offsetof(GPBType__storage_, syntax),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeEnum,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBType class]
|
||||
rootClass:[GPBTypeRoot class]
|
||||
file:GPBTypeRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBType__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int32_t GPBType_Syntax_RawValue(GPBType *message) {
|
||||
GPBDescriptor *descriptor = [GPBType descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBType_FieldNumber_Syntax];
|
||||
return GPBGetMessageRawEnumField(message, field);
|
||||
}
|
||||
|
||||
void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value) {
|
||||
GPBDescriptor *descriptor = [GPBType descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBType_FieldNumber_Syntax];
|
||||
GPBSetMessageRawEnumField(message, field, value);
|
||||
}
|
||||
|
||||
#pragma mark - GPBField
|
||||
|
||||
@implementation GPBField
|
||||
|
||||
@dynamic kind;
|
||||
@dynamic cardinality;
|
||||
@dynamic number;
|
||||
@dynamic name;
|
||||
@dynamic typeURL;
|
||||
@dynamic oneofIndex;
|
||||
@dynamic packed;
|
||||
@dynamic optionsArray, optionsArray_Count;
|
||||
@dynamic jsonName;
|
||||
@dynamic defaultValue;
|
||||
|
||||
typedef struct GPBField__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
GPBField_Kind kind;
|
||||
GPBField_Cardinality cardinality;
|
||||
int32_t number;
|
||||
int32_t oneofIndex;
|
||||
NSString *name;
|
||||
NSString *typeURL;
|
||||
NSMutableArray *optionsArray;
|
||||
NSString *jsonName;
|
||||
NSString *defaultValue;
|
||||
} GPBField__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 = "kind",
|
||||
.dataTypeSpecific.enumDescFunc = GPBField_Kind_EnumDescriptor,
|
||||
.number = GPBField_FieldNumber_Kind,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBField__storage_, kind),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeEnum,
|
||||
},
|
||||
{
|
||||
.name = "cardinality",
|
||||
.dataTypeSpecific.enumDescFunc = GPBField_Cardinality_EnumDescriptor,
|
||||
.number = GPBField_FieldNumber_Cardinality,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBField__storage_, cardinality),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeEnum,
|
||||
},
|
||||
{
|
||||
.name = "number",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBField_FieldNumber_Number,
|
||||
.hasIndex = 2,
|
||||
.offset = (uint32_t)offsetof(GPBField__storage_, number),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeInt32,
|
||||
},
|
||||
{
|
||||
.name = "name",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBField_FieldNumber_Name,
|
||||
.hasIndex = 3,
|
||||
.offset = (uint32_t)offsetof(GPBField__storage_, name),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "typeURL",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBField_FieldNumber_TypeURL,
|
||||
.hasIndex = 4,
|
||||
.offset = (uint32_t)offsetof(GPBField__storage_, typeURL),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "oneofIndex",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBField_FieldNumber_OneofIndex,
|
||||
.hasIndex = 5,
|
||||
.offset = (uint32_t)offsetof(GPBField__storage_, oneofIndex),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeInt32,
|
||||
},
|
||||
{
|
||||
.name = "packed",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBField_FieldNumber_Packed,
|
||||
.hasIndex = 6,
|
||||
.offset = 7, // Stored in _has_storage_ to save space.
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeBool,
|
||||
},
|
||||
{
|
||||
.name = "optionsArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBOption),
|
||||
.number = GPBField_FieldNumber_OptionsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBField__storage_, optionsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "jsonName",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBField_FieldNumber_JsonName,
|
||||
.hasIndex = 8,
|
||||
.offset = (uint32_t)offsetof(GPBField__storage_, jsonName),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "defaultValue",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBField_FieldNumber_DefaultValue,
|
||||
.hasIndex = 9,
|
||||
.offset = (uint32_t)offsetof(GPBField__storage_, defaultValue),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBField class]
|
||||
rootClass:[GPBTypeRoot class]
|
||||
file:GPBTypeRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBField__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
|
||||
static const char *extraTextFormatInfo =
|
||||
"\001\006\004\241!!\000";
|
||||
[localDescriptor setupExtraTextInfo:extraTextFormatInfo];
|
||||
#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int32_t GPBField_Kind_RawValue(GPBField *message) {
|
||||
GPBDescriptor *descriptor = [GPBField descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBField_FieldNumber_Kind];
|
||||
return GPBGetMessageRawEnumField(message, field);
|
||||
}
|
||||
|
||||
void SetGPBField_Kind_RawValue(GPBField *message, int32_t value) {
|
||||
GPBDescriptor *descriptor = [GPBField descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBField_FieldNumber_Kind];
|
||||
GPBSetMessageRawEnumField(message, field, value);
|
||||
}
|
||||
|
||||
int32_t GPBField_Cardinality_RawValue(GPBField *message) {
|
||||
GPBDescriptor *descriptor = [GPBField descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBField_FieldNumber_Cardinality];
|
||||
return GPBGetMessageRawEnumField(message, field);
|
||||
}
|
||||
|
||||
void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value) {
|
||||
GPBDescriptor *descriptor = [GPBField descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBField_FieldNumber_Cardinality];
|
||||
GPBSetMessageRawEnumField(message, field, value);
|
||||
}
|
||||
|
||||
#pragma mark - Enum GPBField_Kind
|
||||
|
||||
GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void) {
|
||||
static _Atomic(GPBEnumDescriptor*) descriptor = nil;
|
||||
if (!descriptor) {
|
||||
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,
|
||||
};
|
||||
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;
|
||||
}
|
||||
|
||||
BOOL GPBField_Kind_IsValidValue(int32_t value__) {
|
||||
switch (value__) {
|
||||
case GPBField_Kind_TypeUnknown:
|
||||
case GPBField_Kind_TypeDouble:
|
||||
case GPBField_Kind_TypeFloat:
|
||||
case GPBField_Kind_TypeInt64:
|
||||
case GPBField_Kind_TypeUint64:
|
||||
case GPBField_Kind_TypeInt32:
|
||||
case GPBField_Kind_TypeFixed64:
|
||||
case GPBField_Kind_TypeFixed32:
|
||||
case GPBField_Kind_TypeBool:
|
||||
case GPBField_Kind_TypeString:
|
||||
case GPBField_Kind_TypeGroup:
|
||||
case GPBField_Kind_TypeMessage:
|
||||
case GPBField_Kind_TypeBytes:
|
||||
case GPBField_Kind_TypeUint32:
|
||||
case GPBField_Kind_TypeEnum:
|
||||
case GPBField_Kind_TypeSfixed32:
|
||||
case GPBField_Kind_TypeSfixed64:
|
||||
case GPBField_Kind_TypeSint32:
|
||||
case GPBField_Kind_TypeSint64:
|
||||
return YES;
|
||||
default:
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Enum GPBField_Cardinality
|
||||
|
||||
GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void) {
|
||||
static _Atomic(GPBEnumDescriptor*) descriptor = nil;
|
||||
if (!descriptor) {
|
||||
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,
|
||||
};
|
||||
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;
|
||||
}
|
||||
|
||||
BOOL GPBField_Cardinality_IsValidValue(int32_t value__) {
|
||||
switch (value__) {
|
||||
case GPBField_Cardinality_CardinalityUnknown:
|
||||
case GPBField_Cardinality_CardinalityOptional:
|
||||
case GPBField_Cardinality_CardinalityRequired:
|
||||
case GPBField_Cardinality_CardinalityRepeated:
|
||||
return YES;
|
||||
default:
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - GPBEnum
|
||||
|
||||
@implementation GPBEnum
|
||||
|
||||
@dynamic name;
|
||||
@dynamic enumvalueArray, enumvalueArray_Count;
|
||||
@dynamic optionsArray, optionsArray_Count;
|
||||
@dynamic hasSourceContext, sourceContext;
|
||||
@dynamic syntax;
|
||||
|
||||
typedef struct GPBEnum__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
GPBSyntax syntax;
|
||||
NSString *name;
|
||||
NSMutableArray *enumvalueArray;
|
||||
NSMutableArray *optionsArray;
|
||||
GPBSourceContext *sourceContext;
|
||||
} GPBEnum__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",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBEnum_FieldNumber_Name,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBEnum__storage_, name),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "enumvalueArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBEnumValue),
|
||||
.number = GPBEnum_FieldNumber_EnumvalueArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBEnum__storage_, enumvalueArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "optionsArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBOption),
|
||||
.number = GPBEnum_FieldNumber_OptionsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBEnum__storage_, optionsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "sourceContext",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBSourceContext),
|
||||
.number = GPBEnum_FieldNumber_SourceContext,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBEnum__storage_, sourceContext),
|
||||
.flags = GPBFieldOptional,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
{
|
||||
.name = "syntax",
|
||||
.dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
|
||||
.number = GPBEnum_FieldNumber_Syntax,
|
||||
.hasIndex = 2,
|
||||
.offset = (uint32_t)offsetof(GPBEnum__storage_, syntax),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeEnum,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBEnum class]
|
||||
rootClass:[GPBTypeRoot class]
|
||||
file:GPBTypeRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBEnum__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int32_t GPBEnum_Syntax_RawValue(GPBEnum *message) {
|
||||
GPBDescriptor *descriptor = [GPBEnum descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBEnum_FieldNumber_Syntax];
|
||||
return GPBGetMessageRawEnumField(message, field);
|
||||
}
|
||||
|
||||
void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value) {
|
||||
GPBDescriptor *descriptor = [GPBEnum descriptor];
|
||||
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBEnum_FieldNumber_Syntax];
|
||||
GPBSetMessageRawEnumField(message, field, value);
|
||||
}
|
||||
|
||||
#pragma mark - GPBEnumValue
|
||||
|
||||
@implementation GPBEnumValue
|
||||
|
||||
@dynamic name;
|
||||
@dynamic number;
|
||||
@dynamic optionsArray, optionsArray_Count;
|
||||
|
||||
typedef struct GPBEnumValue__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
int32_t number;
|
||||
NSString *name;
|
||||
NSMutableArray *optionsArray;
|
||||
} GPBEnumValue__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",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBEnumValue_FieldNumber_Name,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBEnumValue__storage_, name),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "number",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBEnumValue_FieldNumber_Number,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBEnumValue__storage_, number),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeInt32,
|
||||
},
|
||||
{
|
||||
.name = "optionsArray",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBOption),
|
||||
.number = GPBEnumValue_FieldNumber_OptionsArray,
|
||||
.hasIndex = GPBNoHasBit,
|
||||
.offset = (uint32_t)offsetof(GPBEnumValue__storage_, optionsArray),
|
||||
.flags = GPBFieldRepeated,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBEnumValue class]
|
||||
rootClass:[GPBTypeRoot class]
|
||||
file:GPBTypeRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBEnumValue__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBOption
|
||||
|
||||
@implementation GPBOption
|
||||
|
||||
@dynamic name;
|
||||
@dynamic hasValue, value;
|
||||
|
||||
typedef struct GPBOption__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSString *name;
|
||||
GPBAny *value;
|
||||
} GPBOption__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",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBOption_FieldNumber_Name,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBOption__storage_, name),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
{
|
||||
.name = "value",
|
||||
.dataTypeSpecific.clazz = GPBObjCClass(GPBAny),
|
||||
.number = GPBOption_FieldNumber_Value,
|
||||
.hasIndex = 1,
|
||||
.offset = (uint32_t)offsetof(GPBOption__storage_, value),
|
||||
.flags = GPBFieldOptional,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBOption class]
|
||||
rootClass:[GPBTypeRoot class]
|
||||
file:GPBTypeRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBOption__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
99
libs/protobuf/objectivec/GPBUnknownField.h
Normal file
99
libs/protobuf/objectivec/GPBUnknownField.h
Normal file
@@ -0,0 +1,99 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class GPBCodedOutputStream;
|
||||
@class GPBUInt32Array;
|
||||
@class GPBUInt64Array;
|
||||
@class GPBUnknownFieldSet;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
* Store an unknown field. These are used in conjunction with
|
||||
* GPBUnknownFieldSet.
|
||||
**/
|
||||
@interface GPBUnknownField : NSObject <NSCopying>
|
||||
|
||||
/** Initialize a field with the given number. */
|
||||
- (instancetype)initWithNumber:(int32_t)number;
|
||||
|
||||
/** The field number the data is stored under. */
|
||||
@property(nonatomic, readonly, assign) int32_t number;
|
||||
|
||||
/** An array of varint values for this field. */
|
||||
@property(nonatomic, readonly, strong) GPBUInt64Array *varintList;
|
||||
|
||||
/** An array of fixed32 values for this field. */
|
||||
@property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List;
|
||||
|
||||
/** An array of fixed64 values for this field. */
|
||||
@property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List;
|
||||
|
||||
/** An array of data values for this field. */
|
||||
@property(nonatomic, readonly, strong) NSArray<NSData *> *lengthDelimitedList;
|
||||
|
||||
/** An array of groups of values for this field. */
|
||||
@property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet *> *groupList;
|
||||
|
||||
/**
|
||||
* Add a value to the varintList.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addVarint:(uint64_t)value;
|
||||
/**
|
||||
* Add a value to the fixed32List.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addFixed32:(uint32_t)value;
|
||||
/**
|
||||
* Add a value to the fixed64List.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addFixed64:(uint64_t)value;
|
||||
/**
|
||||
* Add a value to the lengthDelimitedList.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addLengthDelimited:(NSData *)value;
|
||||
/**
|
||||
* Add a value to the groupList.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addGroup:(GPBUnknownFieldSet *)value;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
318
libs/protobuf/objectivec/GPBUnknownField.m
Normal file
318
libs/protobuf/objectivec/GPBUnknownField.m
Normal file
@@ -0,0 +1,318 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
|
||||
#import "GPBArray.h"
|
||||
#import "GPBCodedOutputStream_PackagePrivate.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
|
||||
@implementation GPBUnknownField {
|
||||
@protected
|
||||
int32_t number_;
|
||||
GPBUInt64Array *mutableVarintList_;
|
||||
GPBUInt32Array *mutableFixed32List_;
|
||||
GPBUInt64Array *mutableFixed64List_;
|
||||
NSMutableArray<NSData *> *mutableLengthDelimitedList_;
|
||||
NSMutableArray<GPBUnknownFieldSet *> *mutableGroupList_;
|
||||
}
|
||||
|
||||
@synthesize number = number_;
|
||||
@synthesize varintList = mutableVarintList_;
|
||||
@synthesize fixed32List = mutableFixed32List_;
|
||||
@synthesize fixed64List = mutableFixed64List_;
|
||||
@synthesize lengthDelimitedList = mutableLengthDelimitedList_;
|
||||
@synthesize groupList = mutableGroupList_;
|
||||
|
||||
- (instancetype)initWithNumber:(int32_t)number {
|
||||
if ((self = [super init])) {
|
||||
number_ = number;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[mutableVarintList_ release];
|
||||
[mutableFixed32List_ release];
|
||||
[mutableFixed64List_ release];
|
||||
[mutableLengthDelimitedList_ release];
|
||||
[mutableGroupList_ release];
|
||||
|
||||
[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_ mutableCopyWithZone:zone];
|
||||
result->mutableVarintList_ = [mutableVarintList_ copyWithZone:zone];
|
||||
if (mutableGroupList_.count) {
|
||||
result->mutableGroupList_ =
|
||||
[[NSMutableArray allocWithZone:zone] initWithCapacity:mutableGroupList_.count];
|
||||
for (GPBUnknownFieldSet *group in mutableGroupList_) {
|
||||
GPBUnknownFieldSet *copied = [group copyWithZone:zone];
|
||||
[result->mutableGroupList_ addObject:copied];
|
||||
[copied release];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)object {
|
||||
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_];
|
||||
if (!equalVarint) return NO;
|
||||
BOOL equalFixed32 = (mutableFixed32List_.count == 0 && field->mutableFixed32List_.count == 0) ||
|
||||
[mutableFixed32List_ isEqual:field->mutableFixed32List_];
|
||||
if (!equalFixed32) return NO;
|
||||
BOOL equalFixed64 = (mutableFixed64List_.count == 0 && field->mutableFixed64List_.count == 0) ||
|
||||
[mutableFixed64List_ isEqual:field->mutableFixed64List_];
|
||||
if (!equalFixed64) return NO;
|
||||
BOOL equalLDList =
|
||||
(mutableLengthDelimitedList_.count == 0 && field->mutableLengthDelimitedList_.count == 0) ||
|
||||
[mutableLengthDelimitedList_ isEqual:field->mutableLengthDelimitedList_];
|
||||
if (!equalLDList) return NO;
|
||||
BOOL equalGroupList = (mutableGroupList_.count == 0 && field->mutableGroupList_.count == 0) ||
|
||||
[mutableGroupList_ isEqual:field->mutableGroupList_];
|
||||
if (!equalGroupList) return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
// Just mix the hashes of the possible sub arrays.
|
||||
const int prime = 31;
|
||||
NSUInteger result = prime + [mutableVarintList_ hash];
|
||||
result = prime * result + [mutableFixed32List_ hash];
|
||||
result = prime * result + [mutableFixed64List_ hash];
|
||||
result = prime * result + [mutableLengthDelimitedList_ hash];
|
||||
result = prime * result + [mutableGroupList_ hash];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)writeToOutput:(GPBCodedOutputStream *)output {
|
||||
NSUInteger count = mutableVarintList_.count;
|
||||
if (count > 0) {
|
||||
[output writeUInt64Array:number_ values:mutableVarintList_ tag:0];
|
||||
}
|
||||
count = mutableFixed32List_.count;
|
||||
if (count > 0) {
|
||||
[output writeFixed32Array:number_ values:mutableFixed32List_ tag:0];
|
||||
}
|
||||
count = mutableFixed64List_.count;
|
||||
if (count > 0) {
|
||||
[output writeFixed64Array:number_ values:mutableFixed64List_ tag:0];
|
||||
}
|
||||
count = mutableLengthDelimitedList_.count;
|
||||
if (count > 0) {
|
||||
[output writeBytesArray:number_ values:mutableLengthDelimitedList_];
|
||||
}
|
||||
count = mutableGroupList_.count;
|
||||
if (count > 0) {
|
||||
[output writeUnknownGroupArray:number_ values:mutableGroupList_];
|
||||
}
|
||||
}
|
||||
|
||||
- (size_t)serializedSize {
|
||||
__block size_t result = 0;
|
||||
int32_t number = number_;
|
||||
[mutableVarintList_
|
||||
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
result += GPBComputeUInt64Size(number, value);
|
||||
}];
|
||||
|
||||
[mutableFixed32List_
|
||||
enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
result += GPBComputeFixed32Size(number, value);
|
||||
}];
|
||||
|
||||
[mutableFixed64List_
|
||||
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
result += GPBComputeFixed64Size(number, value);
|
||||
}];
|
||||
|
||||
for (NSData *data in mutableLengthDelimitedList_) {
|
||||
result += GPBComputeBytesSize(number, data);
|
||||
}
|
||||
|
||||
for (GPBUnknownFieldSet *set in mutableGroupList_) {
|
||||
result += GPBComputeUnknownGroupSize(number, set);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)writeAsMessageSetExtensionToOutput:(GPBCodedOutputStream *)output {
|
||||
for (NSData *data in mutableLengthDelimitedList_) {
|
||||
[output writeRawMessageSetExtension:number_ value:data];
|
||||
}
|
||||
}
|
||||
|
||||
- (size_t)serializedSizeAsMessageSetExtension {
|
||||
size_t result = 0;
|
||||
for (NSData *data in mutableLengthDelimitedList_) {
|
||||
result += GPBComputeRawMessageSetExtensionSize(number_, data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
NSMutableString *description =
|
||||
[NSMutableString stringWithFormat:@"<%@ %p>: Field: %d {\n", [self class], self, number_];
|
||||
[mutableVarintList_
|
||||
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[description appendFormat:@"\t%llu\n", value];
|
||||
}];
|
||||
|
||||
[mutableFixed32List_
|
||||
enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[description appendFormat:@"\t%u\n", value];
|
||||
}];
|
||||
|
||||
[mutableFixed64List_
|
||||
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[description appendFormat:@"\t%llu\n", value];
|
||||
}];
|
||||
|
||||
for (NSData *data in mutableLengthDelimitedList_) {
|
||||
[description appendFormat:@"\t%@\n", data];
|
||||
}
|
||||
|
||||
for (GPBUnknownFieldSet *set in mutableGroupList_) {
|
||||
[description appendFormat:@"\t%@\n", set];
|
||||
}
|
||||
[description appendString:@"}"];
|
||||
return description;
|
||||
}
|
||||
|
||||
- (void)mergeFromField:(GPBUnknownField *)other {
|
||||
GPBUInt64Array *otherVarintList = other.varintList;
|
||||
if (otherVarintList.count > 0) {
|
||||
if (mutableVarintList_ == nil) {
|
||||
mutableVarintList_ = [otherVarintList copy];
|
||||
} else {
|
||||
[mutableVarintList_ addValuesFromArray:otherVarintList];
|
||||
}
|
||||
}
|
||||
|
||||
GPBUInt32Array *otherFixed32List = other.fixed32List;
|
||||
if (otherFixed32List.count > 0) {
|
||||
if (mutableFixed32List_ == nil) {
|
||||
mutableFixed32List_ = [otherFixed32List copy];
|
||||
} else {
|
||||
[mutableFixed32List_ addValuesFromArray:otherFixed32List];
|
||||
}
|
||||
}
|
||||
|
||||
GPBUInt64Array *otherFixed64List = other.fixed64List;
|
||||
if (otherFixed64List.count > 0) {
|
||||
if (mutableFixed64List_ == nil) {
|
||||
mutableFixed64List_ = [otherFixed64List copy];
|
||||
} else {
|
||||
[mutableFixed64List_ addValuesFromArray:otherFixed64List];
|
||||
}
|
||||
}
|
||||
|
||||
NSArray *otherLengthDelimitedList = other.lengthDelimitedList;
|
||||
if (otherLengthDelimitedList.count > 0) {
|
||||
if (mutableLengthDelimitedList_ == nil) {
|
||||
mutableLengthDelimitedList_ = [otherLengthDelimitedList mutableCopy];
|
||||
} else {
|
||||
[mutableLengthDelimitedList_ addObjectsFromArray:otherLengthDelimitedList];
|
||||
}
|
||||
}
|
||||
|
||||
NSArray *otherGroupList = other.groupList;
|
||||
if (otherGroupList.count > 0) {
|
||||
if (mutableGroupList_ == nil) {
|
||||
mutableGroupList_ = [[NSMutableArray alloc] initWithCapacity:otherGroupList.count];
|
||||
}
|
||||
// Make our own mutable copies.
|
||||
for (GPBUnknownFieldSet *group in otherGroupList) {
|
||||
GPBUnknownFieldSet *copied = [group copy];
|
||||
[mutableGroupList_ addObject:copied];
|
||||
[copied release];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addVarint:(uint64_t)value {
|
||||
if (mutableVarintList_ == nil) {
|
||||
mutableVarintList_ = [[GPBUInt64Array alloc] initWithValues:&value count:1];
|
||||
} else {
|
||||
[mutableVarintList_ addValue:value];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addFixed32:(uint32_t)value {
|
||||
if (mutableFixed32List_ == nil) {
|
||||
mutableFixed32List_ = [[GPBUInt32Array alloc] initWithValues:&value count:1];
|
||||
} else {
|
||||
[mutableFixed32List_ addValue:value];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addFixed64:(uint64_t)value {
|
||||
if (mutableFixed64List_ == nil) {
|
||||
mutableFixed64List_ = [[GPBUInt64Array alloc] initWithValues:&value count:1];
|
||||
} else {
|
||||
[mutableFixed64List_ addValue:value];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addLengthDelimited:(NSData *)value {
|
||||
if (mutableLengthDelimitedList_ == nil) {
|
||||
mutableLengthDelimitedList_ = [[NSMutableArray alloc] initWithObjects:&value count:1];
|
||||
} else {
|
||||
[mutableLengthDelimitedList_ addObject:value];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addGroup:(GPBUnknownFieldSet *)value {
|
||||
if (mutableGroupList_ == nil) {
|
||||
mutableGroupList_ = [[NSMutableArray alloc] initWithObjects:&value count:1];
|
||||
} else {
|
||||
[mutableGroupList_ addObject:value];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
82
libs/protobuf/objectivec/GPBUnknownFieldSet.h
Normal file
82
libs/protobuf/objectivec/GPBUnknownFieldSet.h
Normal file
@@ -0,0 +1,82 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class GPBUnknownField;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* A collection of unknown fields. Fields parsed from the binary representation
|
||||
* of a message that are unknown end up in an instance of this set. This only
|
||||
* applies for files declared with the "proto2" syntax. Files declared with the
|
||||
* "proto3" syntax discard the unknown values.
|
||||
**/
|
||||
@interface GPBUnknownFieldSet : NSObject <NSCopying>
|
||||
|
||||
/**
|
||||
* Tests to see if the given field number has a value.
|
||||
*
|
||||
* @param number The field number to check.
|
||||
*
|
||||
* @return YES if there is an unknown field for the given field number.
|
||||
**/
|
||||
- (BOOL)hasField:(int32_t)number;
|
||||
|
||||
/**
|
||||
* Fetches the GPBUnknownField for the given field number.
|
||||
*
|
||||
* @param number The field number to look up.
|
||||
*
|
||||
* @return The GPBUnknownField or nil if none found.
|
||||
**/
|
||||
- (nullable GPBUnknownField *)getField:(int32_t)number;
|
||||
|
||||
/**
|
||||
* @return The number of fields in this set.
|
||||
**/
|
||||
- (NSUInteger)countOfFields;
|
||||
|
||||
/**
|
||||
* Adds the given field to the set.
|
||||
*
|
||||
* @param field The field to add to the set.
|
||||
**/
|
||||
- (void)addField:(GPBUnknownField *)field;
|
||||
|
||||
/**
|
||||
* @return An array of the GPBUnknownFields sorted by the field numbers.
|
||||
**/
|
||||
- (NSArray<GPBUnknownField *> *)sortedFields;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
374
libs/protobuf/objectivec/GPBUnknownFieldSet.m
Normal file
374
libs/protobuf/objectivec/GPBUnknownFieldSet.m
Normal file
@@ -0,0 +1,374 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
|
||||
#import "GPBCodedInputStream_PackagePrivate.h"
|
||||
#import "GPBCodedOutputStream.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "GPBUtilities.h"
|
||||
#import "GPBWireFormat.h"
|
||||
|
||||
#pragma mark Helpers
|
||||
|
||||
static void checkNumber(int32_t number) {
|
||||
if (number == 0) {
|
||||
[NSException raise:NSInvalidArgumentException format:@"Zero is not a valid field number."];
|
||||
}
|
||||
}
|
||||
|
||||
@implementation GPBUnknownFieldSet {
|
||||
@package
|
||||
CFMutableDictionaryRef fields_;
|
||||
}
|
||||
|
||||
static void CopyWorker(__unused const void *key, const void *value, void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
GPBUnknownFieldSet *result = context;
|
||||
|
||||
GPBUnknownField *copied = [field copy];
|
||||
[result addField:copied];
|
||||
[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_) {
|
||||
CFDictionaryApplyFunction(fields_, CopyWorker, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if (fields_) {
|
||||
CFRelease(fields_);
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)object {
|
||||
BOOL equal = NO;
|
||||
if ([object isKindOfClass:[GPBUnknownFieldSet class]]) {
|
||||
GPBUnknownFieldSet *set = (GPBUnknownFieldSet *)object;
|
||||
if ((fields_ == NULL) && (set->fields_ == NULL)) {
|
||||
equal = YES;
|
||||
} else if ((fields_ != NULL) && (set->fields_ != NULL)) {
|
||||
equal = CFEqual(fields_, set->fields_);
|
||||
}
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
// Return the hash of the fields dictionary (or just some value).
|
||||
if (fields_) {
|
||||
return CFHash(fields_);
|
||||
}
|
||||
return (NSUInteger)[GPBUnknownFieldSet class];
|
||||
}
|
||||
|
||||
#pragma mark - Public Methods
|
||||
|
||||
- (BOOL)hasField:(int32_t)number {
|
||||
ssize_t key = number;
|
||||
return fields_ ? (CFDictionaryGetValue(fields_, (void *)key) != nil) : NO;
|
||||
}
|
||||
|
||||
- (GPBUnknownField *)getField:(int32_t)number {
|
||||
ssize_t key = number;
|
||||
GPBUnknownField *result = fields_ ? CFDictionaryGetValue(fields_, (void *)key) : nil;
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSUInteger)countOfFields {
|
||||
return fields_ ? CFDictionaryGetCount(fields_) : 0;
|
||||
}
|
||||
|
||||
- (NSArray *)sortedFields {
|
||||
if (!fields_) return [NSArray array];
|
||||
size_t count = CFDictionaryGetCount(fields_);
|
||||
ssize_t keys[count];
|
||||
GPBUnknownField *values[count];
|
||||
CFDictionaryGetKeysAndValues(fields_, (const void **)keys, (const void **)values);
|
||||
struct GPBFieldPair {
|
||||
ssize_t key;
|
||||
GPBUnknownField *value;
|
||||
} pairs[count];
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
pairs[i].key = keys[i];
|
||||
pairs[i].value = values[i];
|
||||
};
|
||||
qsort_b(pairs, count, sizeof(struct GPBFieldPair), ^(const void *first, const void *second) {
|
||||
const struct GPBFieldPair *a = first;
|
||||
const struct GPBFieldPair *b = second;
|
||||
return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1);
|
||||
});
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
values[i] = pairs[i].value;
|
||||
};
|
||||
return [NSArray arrayWithObjects:values count:count];
|
||||
}
|
||||
|
||||
#pragma mark - Internal Methods
|
||||
|
||||
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output {
|
||||
if (!fields_) return;
|
||||
size_t count = CFDictionaryGetCount(fields_);
|
||||
ssize_t keys[count];
|
||||
GPBUnknownField *values[count];
|
||||
CFDictionaryGetKeysAndValues(fields_, (const void **)keys, (const void **)values);
|
||||
if (count > 1) {
|
||||
struct GPBFieldPair {
|
||||
ssize_t key;
|
||||
GPBUnknownField *value;
|
||||
} pairs[count];
|
||||
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
pairs[i].key = keys[i];
|
||||
pairs[i].value = values[i];
|
||||
};
|
||||
qsort_b(pairs, count, sizeof(struct GPBFieldPair), ^(const void *first, const void *second) {
|
||||
const struct GPBFieldPair *a = first;
|
||||
const struct GPBFieldPair *b = second;
|
||||
return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1);
|
||||
});
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
GPBUnknownField *value = pairs[i].value;
|
||||
[value writeToOutput:output];
|
||||
}
|
||||
} else {
|
||||
[values[0] writeToOutput:output];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
NSMutableString *description =
|
||||
[NSMutableString stringWithFormat:@"<%@ %p>: TextFormat: {\n", [self class], self];
|
||||
NSString *textFormat = GPBTextFormatForUnknownFieldSet(self, @" ");
|
||||
[description appendString:textFormat];
|
||||
[description appendString:@"}"];
|
||||
return description;
|
||||
}
|
||||
|
||||
static void GPBUnknownFieldSetSerializedSize(__unused const void *key, const void *value,
|
||||
void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
size_t *result = context;
|
||||
*result += [field serializedSize];
|
||||
}
|
||||
|
||||
- (size_t)serializedSize {
|
||||
size_t result = 0;
|
||||
if (fields_) {
|
||||
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetSerializedSize, &result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void GPBUnknownFieldSetWriteAsMessageSetTo(__unused const void *key, const void *value,
|
||||
void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
GPBCodedOutputStream *output = context;
|
||||
[field writeAsMessageSetExtensionToOutput:output];
|
||||
}
|
||||
|
||||
- (void)writeAsMessageSetTo:(GPBCodedOutputStream *)output {
|
||||
if (fields_) {
|
||||
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetWriteAsMessageSetTo, output);
|
||||
}
|
||||
}
|
||||
|
||||
static void GPBUnknownFieldSetSerializedSizeAsMessageSet(__unused const void *key,
|
||||
const void *value, void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
size_t *result = context;
|
||||
*result += [field serializedSizeAsMessageSetExtension];
|
||||
}
|
||||
|
||||
- (size_t)serializedSizeAsMessageSet {
|
||||
size_t result = 0;
|
||||
if (fields_) {
|
||||
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetSerializedSizeAsMessageSet, &result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSData *)data {
|
||||
NSMutableData *data = [NSMutableData dataWithLength:self.serializedSize];
|
||||
GPBCodedOutputStream *output = [[GPBCodedOutputStream alloc] initWithData:data];
|
||||
[self writeToCodedOutputStream:output];
|
||||
[output release];
|
||||
return data;
|
||||
}
|
||||
|
||||
+ (BOOL)isFieldTag:(int32_t)tag {
|
||||
return GPBWireFormatGetTagWireType(tag) != GPBWireFormatEndGroup;
|
||||
}
|
||||
|
||||
- (void)addField:(GPBUnknownField *)field {
|
||||
int32_t number = [field number];
|
||||
checkNumber(number);
|
||||
if (!fields_) {
|
||||
// Use a custom dictionary here because the keys are numbers and conversion
|
||||
// back and forth from NSNumber isn't worth the cost.
|
||||
fields_ =
|
||||
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
|
||||
}
|
||||
ssize_t key = number;
|
||||
CFDictionarySetValue(fields_, (const void *)key, field);
|
||||
}
|
||||
|
||||
- (GPBUnknownField *)mutableFieldForNumber:(int32_t)number create:(BOOL)create {
|
||||
ssize_t key = number;
|
||||
GPBUnknownField *existing = fields_ ? CFDictionaryGetValue(fields_, (const void *)key) : nil;
|
||||
if (!existing && create) {
|
||||
existing = [[GPBUnknownField alloc] initWithNumber:number];
|
||||
// This retains existing.
|
||||
[self addField:existing];
|
||||
[existing release];
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
static void GPBUnknownFieldSetMergeUnknownFields(__unused const void *key, const void *value,
|
||||
void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
GPBUnknownFieldSet *self = context;
|
||||
|
||||
int32_t number = [field number];
|
||||
checkNumber(number);
|
||||
GPBUnknownField *oldField = [self mutableFieldForNumber:number create:NO];
|
||||
if (oldField) {
|
||||
[oldField mergeFromField:field];
|
||||
} else {
|
||||
// Merge only comes from GPBMessage's mergeFrom:, so it means we are on
|
||||
// mutable message and are an mutable instance, so make sure we need
|
||||
// mutable fields.
|
||||
GPBUnknownField *fieldCopy = [field copy];
|
||||
[self addField:fieldCopy];
|
||||
[fieldCopy release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mergeUnknownFields:(GPBUnknownFieldSet *)other {
|
||||
if (other && other->fields_) {
|
||||
CFDictionaryApplyFunction(other->fields_, GPBUnknownFieldSetMergeUnknownFields, self);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mergeFromData:(NSData *)data {
|
||||
GPBCodedInputStream *input = [[GPBCodedInputStream alloc] initWithData:data];
|
||||
[self mergeFromCodedInputStream:input];
|
||||
[input checkLastTagWas:0];
|
||||
[input release];
|
||||
}
|
||||
|
||||
- (void)mergeVarintField:(int32_t)number value:(int32_t)value {
|
||||
checkNumber(number);
|
||||
[[self mutableFieldForNumber:number create:YES] addVarint:value];
|
||||
}
|
||||
|
||||
- (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)) {
|
||||
case GPBWireFormatVarint: {
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addVarint:GPBCodedInputStreamReadInt64(state)];
|
||||
return YES;
|
||||
}
|
||||
case GPBWireFormatFixed64: {
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addFixed64:GPBCodedInputStreamReadFixed64(state)];
|
||||
return YES;
|
||||
}
|
||||
case GPBWireFormatLengthDelimited: {
|
||||
NSData *data = GPBCodedInputStreamReadRetainedBytes(state);
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addLengthDelimited:data];
|
||||
[data release];
|
||||
return YES;
|
||||
}
|
||||
case GPBWireFormatStartGroup: {
|
||||
GPBUnknownFieldSet *unknownFieldSet = [[GPBUnknownFieldSet alloc] init];
|
||||
[input readUnknownGroup:number message:unknownFieldSet];
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addGroup:unknownFieldSet];
|
||||
[unknownFieldSet release];
|
||||
return YES;
|
||||
}
|
||||
case GPBWireFormatEndGroup:
|
||||
return NO;
|
||||
case GPBWireFormatFixed32: {
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addFixed32:GPBCodedInputStreamReadFixed32(state)];
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mergeMessageSetMessage:(int32_t)number data:(NSData *)messageData {
|
||||
[[self mutableFieldForNumber:number create:YES] addLengthDelimited:messageData];
|
||||
}
|
||||
|
||||
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data {
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:fieldNum create:YES];
|
||||
[field addLengthDelimited:data];
|
||||
}
|
||||
|
||||
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input {
|
||||
while (YES) {
|
||||
int32_t tag = GPBCodedInputStreamReadTag(&input->state_);
|
||||
if (tag == 0 || ![self mergeFieldFrom:tag input:input]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)getTags:(int32_t *)tags {
|
||||
if (!fields_) return;
|
||||
size_t count = CFDictionaryGetCount(fields_);
|
||||
ssize_t keys[count];
|
||||
CFDictionaryGetKeysAndValues(fields_, (const void **)keys, NULL);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
tags[i] = (int32_t)keys[i];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
61
libs/protobuf/objectivec/GPBUnknownFieldSet_PackagePrivate.h
Normal file
61
libs/protobuf/objectivec/GPBUnknownFieldSet_PackagePrivate.h
Normal file
@@ -0,0 +1,61 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
|
||||
@class GPBCodedOutputStream;
|
||||
@class GPBCodedInputStream;
|
||||
|
||||
@interface GPBUnknownFieldSet ()
|
||||
|
||||
+ (BOOL)isFieldTag:(int32_t)tag;
|
||||
|
||||
- (NSData *)data;
|
||||
|
||||
- (size_t)serializedSize;
|
||||
- (size_t)serializedSizeAsMessageSet;
|
||||
|
||||
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output;
|
||||
- (void)writeAsMessageSetTo:(GPBCodedOutputStream *)output;
|
||||
|
||||
- (void)mergeUnknownFields:(GPBUnknownFieldSet *)other;
|
||||
|
||||
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input;
|
||||
- (void)mergeFromData:(NSData *)data;
|
||||
|
||||
- (void)mergeVarintField:(int32_t)number value:(int32_t)value;
|
||||
- (BOOL)mergeFieldFrom:(int32_t)tag input:(GPBCodedInputStream *)input;
|
||||
- (void)mergeMessageSetMessage:(int32_t)number data:(NSData *)messageData;
|
||||
|
||||
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
|
||||
|
||||
@end
|
||||
47
libs/protobuf/objectivec/GPBUnknownField_PackagePrivate.h
Normal file
47
libs/protobuf/objectivec/GPBUnknownField_PackagePrivate.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBUnknownField.h"
|
||||
|
||||
@class GPBCodedOutputStream;
|
||||
|
||||
@interface GPBUnknownField ()
|
||||
|
||||
- (void)writeToOutput:(GPBCodedOutputStream *)output;
|
||||
- (size_t)serializedSize;
|
||||
|
||||
- (void)writeAsMessageSetExtensionToOutput:(GPBCodedOutputStream *)output;
|
||||
- (size_t)serializedSizeAsMessageSetExtension;
|
||||
|
||||
- (void)mergeFromField:(GPBUnknownField *)other;
|
||||
|
||||
@end
|
||||
557
libs/protobuf/objectivec/GPBUtilities.h
Normal file
557
libs/protobuf/objectivec/GPBUtilities.h
Normal file
@@ -0,0 +1,557 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBArray.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRuntimeTypes.h"
|
||||
|
||||
@class GPBOneofDescriptor;
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* Generates a string that should be a valid "TextFormat" for the C++ version
|
||||
* of Protocol Buffers.
|
||||
*
|
||||
* @param message The message to generate from.
|
||||
* @param lineIndent A string to use as the prefix for all lines generated. Can
|
||||
* be nil if no extra indent is needed.
|
||||
*
|
||||
* @return An NSString with the TextFormat of the message.
|
||||
**/
|
||||
NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *__nullable lineIndent);
|
||||
|
||||
/**
|
||||
* Generates a string that should be a valid "TextFormat" for the C++ version
|
||||
* of Protocol Buffers.
|
||||
*
|
||||
* @param unknownSet The unknown field set to generate from.
|
||||
* @param lineIndent A string to use as the prefix for all lines generated. Can
|
||||
* be nil if no extra indent is needed.
|
||||
*
|
||||
* @return An NSString with the TextFormat of the unknown field set.
|
||||
**/
|
||||
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *__nullable unknownSet,
|
||||
NSString *__nullable lineIndent);
|
||||
|
||||
/**
|
||||
* Checks if the given field number is set on a message.
|
||||
*
|
||||
* @param self The message to check.
|
||||
* @param fieldNumber The field number to check.
|
||||
*
|
||||
* @return YES if the field number is set on the given message.
|
||||
**/
|
||||
BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber);
|
||||
|
||||
/**
|
||||
* Checks if the given field is set on a message.
|
||||
*
|
||||
* @param self The message to check.
|
||||
* @param field The field to check.
|
||||
*
|
||||
* @return YES if the field is set on the given message.
|
||||
**/
|
||||
BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Clears the given field for the given message.
|
||||
*
|
||||
* @param self The message for which to clear the field.
|
||||
* @param field The field to clear.
|
||||
**/
|
||||
void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Clears the given oneof field for the given message.
|
||||
*
|
||||
* @param self The message for which to clear the field.
|
||||
* @param oneof The oneof to clear.
|
||||
**/
|
||||
void GPBClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof);
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-EXPAND GPB_ACCESSORS()
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
|
||||
//
|
||||
// Get/Set a given field from/to a message.
|
||||
//
|
||||
|
||||
// Single Fields
|
||||
|
||||
/**
|
||||
* Gets the value of a bytes field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
NSData *GPBGetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of a bytes field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field, NSData *value);
|
||||
|
||||
/**
|
||||
* Gets the value of a string field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
NSString *GPBGetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of a string field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field, NSString *value);
|
||||
|
||||
/**
|
||||
* Gets the value of a message field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
GPBMessage *GPBGetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of a message field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
|
||||
|
||||
/**
|
||||
* Gets the value of a group field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
GPBMessage *GPBGetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of a group field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
|
||||
|
||||
/**
|
||||
* Gets the value of a bool field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of a bool field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field, BOOL value);
|
||||
|
||||
/**
|
||||
* Gets the value of an int32 field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
int32_t GPBGetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of an int32 field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
|
||||
|
||||
/**
|
||||
* Gets the value of an uint32 field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
uint32_t GPBGetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of an uint32 field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field, uint32_t value);
|
||||
|
||||
/**
|
||||
* Gets the value of an int64 field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
int64_t GPBGetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of an int64 field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field, int64_t value);
|
||||
|
||||
/**
|
||||
* Gets the value of an uint64 field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
uint64_t GPBGetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of an uint64 field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field, uint64_t value);
|
||||
|
||||
/**
|
||||
* Gets the value of a float field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
float GPBGetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of a float field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field, float value);
|
||||
|
||||
/**
|
||||
* Gets the value of a double field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
**/
|
||||
double GPBGetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of a double field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The to set in the field.
|
||||
**/
|
||||
void GPBSetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field, double value);
|
||||
|
||||
/**
|
||||
* Gets the given enum field of a message. For proto3, if the value isn't a
|
||||
* member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned.
|
||||
* GPBGetMessageRawEnumField will bypass the check and return whatever value
|
||||
* was set.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
*
|
||||
* @return The enum value for the given field.
|
||||
**/
|
||||
int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Set the given enum field of a message. You can only set values that are
|
||||
* members of the enum.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The enum value to set in the field.
|
||||
**/
|
||||
void GPBSetMessageEnumField(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
int32_t value);
|
||||
|
||||
/**
|
||||
* Get the given enum field of a message. No check is done to ensure the value
|
||||
* was defined in the enum.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The field to get.
|
||||
*
|
||||
* @return The raw enum value for the given field.
|
||||
**/
|
||||
int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Set the given enum field of a message. You can set the value to anything,
|
||||
* even a value that is not a member of the enum.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param value The raw enum value to set in the field.
|
||||
**/
|
||||
void GPBSetMessageRawEnumField(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
int32_t value);
|
||||
|
||||
// Repeated Fields
|
||||
|
||||
/**
|
||||
* Gets the value of a repeated field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The repeated field to get.
|
||||
*
|
||||
* @return A GPB*Array or an NSMutableArray based on the field's type.
|
||||
**/
|
||||
id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of a repeated field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param array A GPB*Array or NSMutableArray based on the field's type.
|
||||
**/
|
||||
void GPBSetMessageRepeatedField(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
id array);
|
||||
|
||||
// Map Fields
|
||||
|
||||
/**
|
||||
* Gets the value of a map<> field.
|
||||
*
|
||||
* @param self The message from which to get the field.
|
||||
* @param field The repeated field to get.
|
||||
*
|
||||
* @return A GPB*Dictionary or NSMutableDictionary based on the field's type.
|
||||
**/
|
||||
id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
/**
|
||||
* Sets the value of a map<> field.
|
||||
*
|
||||
* @param self The message into which to set the field.
|
||||
* @param field The field to set.
|
||||
* @param dictionary A GPB*Dictionary or NSMutableDictionary based on the
|
||||
* field's type.
|
||||
**/
|
||||
void GPBSetMessageMapField(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
id dictionary);
|
||||
|
||||
//%PDDM-EXPAND-END GPB_ACCESSORS()
|
||||
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE GPB_ACCESSORS()
|
||||
//%
|
||||
//%//
|
||||
//%// Get/Set a given field from/to a message.
|
||||
//%//
|
||||
//%
|
||||
//%// Single Fields
|
||||
//%
|
||||
//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, , *)
|
||||
//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, , *)
|
||||
//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, , *)
|
||||
//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, , *)
|
||||
//%GPB_ACCESSOR_SINGLE(Bool, BOOL, )
|
||||
//%GPB_ACCESSOR_SINGLE(Int32, int32_t, n)
|
||||
//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t, n)
|
||||
//%GPB_ACCESSOR_SINGLE(Int64, int64_t, n)
|
||||
//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t, n)
|
||||
//%GPB_ACCESSOR_SINGLE(Float, float, )
|
||||
//%GPB_ACCESSOR_SINGLE(Double, double, )
|
||||
//%/**
|
||||
//% * Gets the given enum field of a message. For proto3, if the value isn't a
|
||||
//% * member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned.
|
||||
//% * GPBGetMessageRawEnumField will bypass the check and return whatever value
|
||||
//% * was set.
|
||||
//% *
|
||||
//% * @param self The message from which to get the field.
|
||||
//% * @param field The field to get.
|
||||
//% *
|
||||
//% * @return The enum value for the given field.
|
||||
//% **/
|
||||
//%int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
//%
|
||||
//%/**
|
||||
//% * Set the given enum field of a message. You can only set values that are
|
||||
//% * members of the enum.
|
||||
//% *
|
||||
//% * @param self The message into which to set the field.
|
||||
//% * @param field The field to set.
|
||||
//% * @param value The enum value to set in the field.
|
||||
//% **/
|
||||
//%void GPBSetMessageEnumField(GPBMessage *self,
|
||||
//% GPBFieldDescriptor *field,
|
||||
//% int32_t value);
|
||||
//%
|
||||
//%/**
|
||||
//% * Get the given enum field of a message. No check is done to ensure the value
|
||||
//% * was defined in the enum.
|
||||
//% *
|
||||
//% * @param self The message from which to get the field.
|
||||
//% * @param field The field to get.
|
||||
//% *
|
||||
//% * @return The raw enum value for the given field.
|
||||
//% **/
|
||||
//%int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
//%
|
||||
//%/**
|
||||
//% * Set the given enum field of a message. You can set the value to anything,
|
||||
//% * even a value that is not a member of the enum.
|
||||
//% *
|
||||
//% * @param self The message into which to set the field.
|
||||
//% * @param field The field to set.
|
||||
//% * @param value The raw enum value to set in the field.
|
||||
//% **/
|
||||
//%void GPBSetMessageRawEnumField(GPBMessage *self,
|
||||
//% GPBFieldDescriptor *field,
|
||||
//% int32_t value);
|
||||
//%
|
||||
//%// Repeated Fields
|
||||
//%
|
||||
//%/**
|
||||
//% * Gets the value of a repeated field.
|
||||
//% *
|
||||
//% * @param self The message from which to get the field.
|
||||
//% * @param field The repeated field to get.
|
||||
//% *
|
||||
//% * @return A GPB*Array or an NSMutableArray based on the field's type.
|
||||
//% **/
|
||||
//%id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
//%
|
||||
//%/**
|
||||
//% * Sets the value of a repeated field.
|
||||
//% *
|
||||
//% * @param self The message into which to set the field.
|
||||
//% * @param field The field to set.
|
||||
//% * @param array A GPB*Array or NSMutableArray based on the field's type.
|
||||
//% **/
|
||||
//%void GPBSetMessageRepeatedField(GPBMessage *self,
|
||||
//% GPBFieldDescriptor *field,
|
||||
//% id array);
|
||||
//%
|
||||
//%// Map Fields
|
||||
//%
|
||||
//%/**
|
||||
//% * Gets the value of a map<> field.
|
||||
//% *
|
||||
//% * @param self The message from which to get the field.
|
||||
//% * @param field The repeated field to get.
|
||||
//% *
|
||||
//% * @return A GPB*Dictionary or NSMutableDictionary based on the field's type.
|
||||
//% **/
|
||||
//%id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
//%
|
||||
//%/**
|
||||
//% * Sets the value of a map<> field.
|
||||
//% *
|
||||
//% * @param self The message into which to set the field.
|
||||
//% * @param field The field to set.
|
||||
//% * @param dictionary A GPB*Dictionary or NSMutableDictionary based on the
|
||||
//% * field's type.
|
||||
//% **/
|
||||
//%void GPBSetMessageMapField(GPBMessage *self,
|
||||
//% GPBFieldDescriptor *field,
|
||||
//% id dictionary);
|
||||
//%
|
||||
|
||||
//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE, AN)
|
||||
//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, )
|
||||
//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, TisP)
|
||||
//%/**
|
||||
//% * Gets the value of a##AN NAME$L field.
|
||||
//% *
|
||||
//% * @param self The message from which to get the field.
|
||||
//% * @param field The field to get.
|
||||
//% **/
|
||||
//%TYPE TisP##GPBGetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
//%
|
||||
//%/**
|
||||
//% * Sets the value of a##AN NAME$L field.
|
||||
//% *
|
||||
//% * @param self The message into which to set the field.
|
||||
//% * @param field The field to set.
|
||||
//% * @param value The to set in the field.
|
||||
//% **/
|
||||
//%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value);
|
||||
//%
|
||||
|
||||
// clang-format on
|
||||
2215
libs/protobuf/objectivec/GPBUtilities.m
Normal file
2215
libs/protobuf/objectivec/GPBUtilities.m
Normal file
File diff suppressed because it is too large
Load Diff
334
libs/protobuf/objectivec/GPBUtilities_PackagePrivate.h
Normal file
334
libs/protobuf/objectivec/GPBUtilities_PackagePrivate.h
Normal file
@@ -0,0 +1,334 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBUtilities.h"
|
||||
|
||||
#import "GPBDescriptor_PackagePrivate.h"
|
||||
|
||||
// Macros for stringifying library symbols. These are used in the generated
|
||||
// GPB descriptor classes wherever a library symbol name is represented as a
|
||||
// string.
|
||||
#define GPBStringify(S) #S
|
||||
#define GPBStringifySymbol(S) GPBStringify(S)
|
||||
|
||||
#define GPBNSStringify(S) @ #S
|
||||
#define GPBNSStringifySymbol(S) GPBNSStringify(S)
|
||||
|
||||
// Macros for generating a Class from a class name. These are used in
|
||||
// the generated GPB descriptor classes wherever an Objective C class
|
||||
// reference is needed for a generated class.
|
||||
#define GPBObjCClassSymbol(name) OBJC_CLASS_$_##name
|
||||
#define GPBObjCClass(name) ((__bridge Class) & (GPBObjCClassSymbol(name)))
|
||||
#define GPBObjCClassDeclaration(name) extern const GPBObjcClass_t GPBObjCClassSymbol(name)
|
||||
|
||||
// Constant to internally mark when there is no has bit.
|
||||
#define GPBNoHasBit INT32_MAX
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
// These two are used to inject a runtime check for version mismatch into the
|
||||
// generated sources to make sure they are linked with a supporting runtime.
|
||||
void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion);
|
||||
GPB_INLINE void GPB_DEBUG_CHECK_RUNTIME_VERSIONS() {
|
||||
// NOTE: By being inline here, this captures the value from the library's
|
||||
// headers at the time the generated code was compiled.
|
||||
#if defined(DEBUG) && DEBUG
|
||||
GPBCheckRuntimeVersionSupport(GOOGLE_PROTOBUF_OBJC_VERSION);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Legacy version of the checks, remove when GOOGLE_PROTOBUF_OBJC_GEN_VERSION
|
||||
// goes away (see more info in GPBBootstrap.h).
|
||||
void GPBCheckRuntimeVersionInternal(int32_t version);
|
||||
GPB_INLINE void GPBDebugCheckRuntimeVersion() {
|
||||
#if defined(DEBUG) && DEBUG
|
||||
GPBCheckRuntimeVersionInternal(GOOGLE_PROTOBUF_OBJC_GEN_VERSION);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Conversion functions for de/serializing floating point types.
|
||||
|
||||
GPB_INLINE int64_t GPBConvertDoubleToInt64(double v) {
|
||||
GPBInternalCompileAssert(sizeof(double) == sizeof(int64_t), double_not_64_bits);
|
||||
int64_t result;
|
||||
memcpy(&result, &v, sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
GPB_INLINE int32_t GPBConvertFloatToInt32(float v) {
|
||||
GPBInternalCompileAssert(sizeof(float) == sizeof(int32_t), float_not_32_bits);
|
||||
int32_t result;
|
||||
memcpy(&result, &v, sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
GPB_INLINE double GPBConvertInt64ToDouble(int64_t v) {
|
||||
GPBInternalCompileAssert(sizeof(double) == sizeof(int64_t), double_not_64_bits);
|
||||
double result;
|
||||
memcpy(&result, &v, sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
GPB_INLINE float GPBConvertInt32ToFloat(int32_t v) {
|
||||
GPBInternalCompileAssert(sizeof(float) == sizeof(int32_t), float_not_32_bits);
|
||||
float result;
|
||||
memcpy(&result, &v, sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
GPB_INLINE int32_t GPBLogicalRightShift32(int32_t value, int32_t spaces) {
|
||||
return (int32_t)((uint32_t)(value) >> spaces);
|
||||
}
|
||||
|
||||
GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) {
|
||||
return (int64_t)((uint64_t)(value) >> spaces);
|
||||
}
|
||||
|
||||
// Decode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers
|
||||
// into values that can be efficiently encoded with varint. (Otherwise,
|
||||
// negative values must be sign-extended to 64 bits to be varint encoded,
|
||||
// thus always taking 10 bytes on the wire.)
|
||||
GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) {
|
||||
return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n)&1));
|
||||
}
|
||||
|
||||
// Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
|
||||
// into values that can be efficiently encoded with varint. (Otherwise,
|
||||
// negative values must be sign-extended to 64 bits to be varint encoded,
|
||||
// thus always taking 10 bytes on the wire.)
|
||||
GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) {
|
||||
return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n)&1));
|
||||
}
|
||||
|
||||
// Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers
|
||||
// into values that can be efficiently encoded with varint. (Otherwise,
|
||||
// negative values must be sign-extended to 64 bits to be varint encoded,
|
||||
// thus always taking 10 bytes on the wire.)
|
||||
GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) {
|
||||
// Note: the right-shift must be arithmetic
|
||||
return ((uint32_t)n << 1) ^ (uint32_t)(n >> 31);
|
||||
}
|
||||
|
||||
// Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
|
||||
// into values that can be efficiently encoded with varint. (Otherwise,
|
||||
// negative values must be sign-extended to 64 bits to be varint encoded,
|
||||
// thus always taking 10 bytes on the wire.)
|
||||
GPB_INLINE uint64_t GPBEncodeZigZag64(int64_t n) {
|
||||
// Note: the right-shift must be arithmetic
|
||||
return ((uint64_t)n << 1) ^ (uint64_t)(n >> 63);
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
|
||||
GPB_INLINE BOOL GPBDataTypeIsObject(GPBDataType type) {
|
||||
switch (type) {
|
||||
case GPBDataTypeBytes:
|
||||
case GPBDataTypeString:
|
||||
case GPBDataTypeMessage:
|
||||
case GPBDataTypeGroup:
|
||||
return YES;
|
||||
default:
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
GPB_INLINE BOOL GPBDataTypeIsMessage(GPBDataType type) {
|
||||
switch (type) {
|
||||
case GPBDataTypeMessage:
|
||||
case GPBDataTypeGroup:
|
||||
return YES;
|
||||
default:
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
GPB_INLINE BOOL GPBFieldDataTypeIsMessage(GPBFieldDescriptor *field) {
|
||||
return GPBDataTypeIsMessage(field->description_->dataType);
|
||||
}
|
||||
|
||||
GPB_INLINE BOOL GPBFieldDataTypeIsObject(GPBFieldDescriptor *field) {
|
||||
return GPBDataTypeIsObject(field->description_->dataType);
|
||||
}
|
||||
|
||||
GPB_INLINE BOOL GPBExtensionIsMessage(GPBExtensionDescriptor *ext) {
|
||||
return GPBDataTypeIsMessage(ext->description_->dataType);
|
||||
}
|
||||
|
||||
// The field is an array/map or it has an object value.
|
||||
GPB_INLINE BOOL GPBFieldStoresObject(GPBFieldDescriptor *field) {
|
||||
GPBMessageFieldDescription *desc = field->description_;
|
||||
if ((desc->flags & (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0) {
|
||||
return YES;
|
||||
}
|
||||
return GPBDataTypeIsObject(desc->dataType);
|
||||
}
|
||||
|
||||
BOOL GPBGetHasIvar(GPBMessage *self, int32_t index, uint32_t fieldNumber);
|
||||
void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, BOOL value);
|
||||
uint32_t GPBGetHasOneof(GPBMessage *self, int32_t index);
|
||||
|
||||
GPB_INLINE BOOL GPBGetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field) {
|
||||
GPBMessageFieldDescription *fieldDesc = field->description_;
|
||||
return GPBGetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number);
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE)
|
||||
//%void GPBSet##NAME##IvarWithFieldPrivate(GPBMessage *self,
|
||||
//% NAME$S GPBFieldDescriptor *field,
|
||||
//% NAME$S TYPE value);
|
||||
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Bool, BOOL)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
void GPBSetBoolIvarWithFieldPrivate(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
BOOL value);
|
||||
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Int32, int32_t)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
void GPBSetInt32IvarWithFieldPrivate(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
int32_t value);
|
||||
//%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt32, uint32_t)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
void GPBSetUInt32IvarWithFieldPrivate(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
uint32_t value);
|
||||
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Int64, int64_t)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
void GPBSetInt64IvarWithFieldPrivate(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
int64_t value);
|
||||
//%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt64, uint64_t)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
void GPBSetUInt64IvarWithFieldPrivate(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
uint64_t value);
|
||||
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Float, float)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
void GPBSetFloatIvarWithFieldPrivate(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
float value);
|
||||
//%PDDM-EXPAND GPB_IVAR_SET_DECL(Double, double)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
void GPBSetDoubleIvarWithFieldPrivate(GPBMessage *self,
|
||||
GPBFieldDescriptor *field,
|
||||
double value);
|
||||
//%PDDM-EXPAND-END (7 expansions)
|
||||
|
||||
// clang-format on
|
||||
|
||||
void GPBSetEnumIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
|
||||
|
||||
id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
void GPBSetObjectIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field, id value);
|
||||
void GPBSetRetainedObjectIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field,
|
||||
id __attribute__((ns_consumed)) value);
|
||||
|
||||
// GPBGetObjectIvarWithField will automatically create the field (message) if
|
||||
// it doesn't exist. GPBGetObjectIvarWithFieldNoAutocreate will return nil.
|
||||
id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
// Clears and releases the autocreated message ivar, if it's autocreated. If
|
||||
// it's not set as autocreated, this method does nothing.
|
||||
void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self, GPBFieldDescriptor *field);
|
||||
|
||||
// Returns an Objective C encoding for |selector|. |instanceSel| should be
|
||||
// YES if it's an instance selector (as opposed to a class selector).
|
||||
// |selector| must be a selector from MessageSignatureProtocol.
|
||||
const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel);
|
||||
|
||||
// Helper for text format name encoding.
|
||||
// decodeData is the data describing the special decodes.
|
||||
// key and inputString are the input that needs decoding.
|
||||
NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, NSString *inputString);
|
||||
|
||||
// Shims from the older generated code into the runtime.
|
||||
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, GPBFieldDescriptor *field, int32_t value,
|
||||
GPBFileSyntax syntax);
|
||||
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, int32_t oneofHasIndex,
|
||||
uint32_t fieldNumberNotToClear);
|
||||
|
||||
// A series of selectors that are used solely to get @encoding values
|
||||
// for them by the dynamic protobuf runtime code. See
|
||||
// GPBMessageEncodingForSelector for details. GPBRootObject conforms to
|
||||
// the protocol so that it is encoded in the Objective C runtime.
|
||||
@protocol GPBMessageSignatureProtocol
|
||||
@optional
|
||||
|
||||
#define GPB_MESSAGE_SIGNATURE_ENTRY(TYPE, NAME) \
|
||||
-(TYPE)get##NAME; \
|
||||
-(void)set##NAME : (TYPE)value; \
|
||||
-(TYPE)get##NAME##AtIndex : (NSUInteger)index;
|
||||
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(BOOL, Bool)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(uint32_t, Fixed32)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, SFixed32)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(float, Float)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(uint64_t, Fixed64)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, SFixed64)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(double, Double)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Int32)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, Int64)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, SInt32)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, SInt64)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(uint32_t, UInt32)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(uint64_t, UInt64)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(NSData *, Bytes)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(NSString *, String)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(GPBMessage *, Message)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(GPBMessage *, Group)
|
||||
GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Enum)
|
||||
|
||||
#undef GPB_MESSAGE_SIGNATURE_ENTRY
|
||||
|
||||
- (id)getArray;
|
||||
- (NSUInteger)getArrayCount;
|
||||
- (void)setArray:(NSArray *)array;
|
||||
+ (id)getClassValue;
|
||||
@end
|
||||
|
||||
BOOL GPBClassHasSel(Class aClass, SEL sel);
|
||||
|
||||
CF_EXTERN_C_END
|
||||
229
libs/protobuf/objectivec/GPBWellKnownTypes.h
Normal file
229
libs/protobuf/objectivec/GPBWellKnownTypes.h
Normal file
@@ -0,0 +1,229 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBAny.pbobjc.h"
|
||||
#import "GPBDuration.pbobjc.h"
|
||||
#import "GPBTimestamp.pbobjc.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#pragma mark - Errors
|
||||
|
||||
/** NSError domain used for errors. */
|
||||
extern NSString *const GPBWellKnownTypesErrorDomain;
|
||||
|
||||
/** Error code for NSError with GPBWellKnownTypesErrorDomain. */
|
||||
typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
|
||||
/** The type_url could not be computed for the requested GPBMessage class. */
|
||||
GPBWellKnownTypesErrorCodeFailedToComputeTypeURL = -100,
|
||||
/** type_url in a Any 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
|
||||
|
||||
#pragma mark - GPBDuration
|
||||
|
||||
/**
|
||||
* Category for GPBDuration to work with standard Foundation time type.
|
||||
**/
|
||||
@interface GPBDuration (GBPWellKnownTypes)
|
||||
|
||||
/**
|
||||
* The NSTimeInterval representation of this GPBDuration.
|
||||
*
|
||||
* @note: Not all second/nanos combinations can be represented in a
|
||||
* NSTimeInterval, so getting this could be a lossy transform.
|
||||
**/
|
||||
@property(nonatomic, readwrite) NSTimeInterval timeInterval;
|
||||
|
||||
/**
|
||||
* Initializes a GPBDuration with the given NSTimeInterval.
|
||||
*
|
||||
* @param timeInterval Time interval to configure the GPBDuration with.
|
||||
*
|
||||
* @return A newly initialized GPBDuration.
|
||||
**/
|
||||
- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval;
|
||||
|
||||
// These next two methods are deprecated because GBPDuration has no need of a
|
||||
// "base" time. The older methods were about symmetry with GBPTimestamp, but
|
||||
// the unix epoch usage is too confusing.
|
||||
|
||||
/** Deprecated, use timeInterval instead. */
|
||||
@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970
|
||||
__attribute__((deprecated("Use timeInterval")));
|
||||
/** Deprecated, use initWithTimeInterval: instead. */
|
||||
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970
|
||||
__attribute__((deprecated("Use initWithTimeInterval:")));
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBAny
|
||||
|
||||
/**
|
||||
* Category for GPBAny to help work with the message within the object.
|
||||
**/
|
||||
@interface GPBAny (GBPWellKnownTypes)
|
||||
|
||||
/**
|
||||
* Convenience method to create a GPBAny containing the serialized message.
|
||||
* This uses type.googleapis.com/ as the type_url's prefix.
|
||||
*
|
||||
* @param message The message to be packed into the GPBAny.
|
||||
* @param errorPtr Pointer to an error that will be populated if something goes
|
||||
* wrong.
|
||||
*
|
||||
* @return A newly configured GPBAny with the given message, or nil on failure.
|
||||
*/
|
||||
+ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message error:(NSError **)errorPtr;
|
||||
|
||||
/**
|
||||
* Convenience method to create a GPBAny containing the serialized message.
|
||||
*
|
||||
* @param message The message to be packed into the GPBAny.
|
||||
* @param typeURLPrefix The URL prefix to apply for type_url.
|
||||
* @param errorPtr Pointer to an error that will be populated if something
|
||||
* goes wrong.
|
||||
*
|
||||
* @return A newly configured GPBAny with the given message, or nil on failure.
|
||||
*/
|
||||
+ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message
|
||||
typeURLPrefix:(nonnull NSString *)typeURLPrefix
|
||||
error:(NSError **)errorPtr;
|
||||
|
||||
/**
|
||||
* Initializes a GPBAny to contain the serialized message. This uses
|
||||
* type.googleapis.com/ as the type_url's prefix.
|
||||
*
|
||||
* @param message The message to be packed into the GPBAny.
|
||||
* @param errorPtr Pointer to an error that will be populated if something goes
|
||||
* wrong.
|
||||
*
|
||||
* @return A newly configured GPBAny with the given message, or nil on failure.
|
||||
*/
|
||||
- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message error:(NSError **)errorPtr;
|
||||
|
||||
/**
|
||||
* Initializes a GPBAny to contain the serialized message.
|
||||
*
|
||||
* @param message The message to be packed into the GPBAny.
|
||||
* @param typeURLPrefix The URL prefix to apply for type_url.
|
||||
* @param errorPtr Pointer to an error that will be populated if something
|
||||
* goes wrong.
|
||||
*
|
||||
* @return A newly configured GPBAny with the given message, or nil on failure.
|
||||
*/
|
||||
- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message
|
||||
typeURLPrefix:(nonnull NSString *)typeURLPrefix
|
||||
error:(NSError **)errorPtr;
|
||||
|
||||
/**
|
||||
* Packs the serialized message into this GPBAny. This uses
|
||||
* type.googleapis.com/ as the type_url's prefix.
|
||||
*
|
||||
* @param message The message to be packed into the GPBAny.
|
||||
* @param errorPtr Pointer to an error that will be populated if something goes
|
||||
* wrong.
|
||||
*
|
||||
* @return Whether the packing was successful or not.
|
||||
*/
|
||||
- (BOOL)packWithMessage:(nonnull GPBMessage *)message error:(NSError **)errorPtr;
|
||||
|
||||
/**
|
||||
* Packs the serialized message into this GPBAny.
|
||||
*
|
||||
* @param message The message to be packed into the GPBAny.
|
||||
* @param typeURLPrefix The URL prefix to apply for type_url.
|
||||
* @param errorPtr Pointer to an error that will be populated if something
|
||||
* goes wrong.
|
||||
*
|
||||
* @return Whether the packing was successful or not.
|
||||
*/
|
||||
- (BOOL)packWithMessage:(nonnull GPBMessage *)message
|
||||
typeURLPrefix:(nonnull NSString *)typeURLPrefix
|
||||
error:(NSError **)errorPtr;
|
||||
|
||||
/**
|
||||
* Unpacks the serialized message as if it was an instance of the given class.
|
||||
*
|
||||
* @note When checking type_url, the base URL is not checked, only the fully
|
||||
* qualified name.
|
||||
*
|
||||
* @param messageClass The class to use to deserialize the contained message.
|
||||
* @param errorPtr Pointer to an error that will be populated if something
|
||||
* goes wrong.
|
||||
*
|
||||
* @return An instance of the given class populated with the contained data, or
|
||||
* nil on failure.
|
||||
*/
|
||||
- (nullable GPBMessage *)unpackMessageClass:(Class)messageClass error:(NSError **)errorPtr;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
247
libs/protobuf/objectivec/GPBWellKnownTypes.m
Normal file
247
libs/protobuf/objectivec/GPBWellKnownTypes.m
Normal file
@@ -0,0 +1,247 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Importing sources here to force the linker to include our category methods in
|
||||
// the static library. If these were compiled separately, the category methods
|
||||
// below would be stripped by the linker.
|
||||
|
||||
#import "GPBWellKnownTypes.h"
|
||||
|
||||
#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 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 {
|
||||
return [self initWithTimeIntervalSince1970:date.timeIntervalSince1970];
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
|
||||
if ((self = [super init])) {
|
||||
int64_t seconds;
|
||||
int32_t nanos = SecondsAndNanosFromTimeInterval(timeIntervalSince1970, &seconds, YES);
|
||||
self.seconds = seconds;
|
||||
self.nanos = nanos;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSDate *)date {
|
||||
return [NSDate dateWithTimeIntervalSince1970:self.timeIntervalSince1970];
|
||||
}
|
||||
|
||||
- (void)setDate:(NSDate *)date {
|
||||
self.timeIntervalSince1970 = date.timeIntervalSince1970;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)timeIntervalSince1970 {
|
||||
return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos);
|
||||
}
|
||||
|
||||
- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
|
||||
int64_t seconds;
|
||||
int32_t nanos = SecondsAndNanosFromTimeInterval(timeIntervalSince1970, &seconds, YES);
|
||||
self.seconds = seconds;
|
||||
self.nanos = nanos;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBDuration
|
||||
|
||||
@implementation GPBDuration (GBPWellKnownTypes)
|
||||
|
||||
- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval {
|
||||
if ((self = [super init])) {
|
||||
int64_t seconds;
|
||||
int32_t nanos = SecondsAndNanosFromTimeInterval(timeInterval, &seconds, NO);
|
||||
self.seconds = seconds;
|
||||
self.nanos = nanos;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
|
||||
return [self initWithTimeInterval:timeIntervalSince1970];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)timeInterval {
|
||||
return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos);
|
||||
}
|
||||
|
||||
- (void)setTimeInterval:(NSTimeInterval)timeInterval {
|
||||
int64_t seconds;
|
||||
int32_t nanos = 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
|
||||
73
libs/protobuf/objectivec/GPBWireFormat.h
Normal file
73
libs/protobuf/objectivec/GPBWireFormat.h
Normal file
@@ -0,0 +1,73 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBRuntimeTypes.h"
|
||||
|
||||
CF_EXTERN_C_BEGIN
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef enum {
|
||||
GPBWireFormatVarint = 0,
|
||||
GPBWireFormatFixed64 = 1,
|
||||
GPBWireFormatLengthDelimited = 2,
|
||||
GPBWireFormatStartGroup = 3,
|
||||
GPBWireFormatEndGroup = 4,
|
||||
GPBWireFormatFixed32 = 5,
|
||||
} GPBWireFormat;
|
||||
|
||||
enum {
|
||||
GPBWireFormatMessageSetItem = 1,
|
||||
GPBWireFormatMessageSetTypeId = 2,
|
||||
GPBWireFormatMessageSetMessage = 3
|
||||
};
|
||||
|
||||
uint32_t GPBWireFormatMakeTag(uint32_t fieldNumber, GPBWireFormat wireType)
|
||||
__attribute__((const));
|
||||
GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) __attribute__((const));
|
||||
uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) __attribute__((const));
|
||||
BOOL GPBWireFormatIsValidTag(uint32_t tag) __attribute__((const));
|
||||
|
||||
GPBWireFormat GPBWireFormatForType(GPBDataType dataType, BOOL isPacked)
|
||||
__attribute__((const));
|
||||
|
||||
#define GPBWireFormatMessageSetItemTag \
|
||||
(GPBWireFormatMakeTag(GPBWireFormatMessageSetItem, GPBWireFormatStartGroup))
|
||||
#define GPBWireFormatMessageSetItemEndTag \
|
||||
(GPBWireFormatMakeTag(GPBWireFormatMessageSetItem, GPBWireFormatEndGroup))
|
||||
#define GPBWireFormatMessageSetTypeIdTag \
|
||||
(GPBWireFormatMakeTag(GPBWireFormatMessageSetTypeId, GPBWireFormatVarint))
|
||||
#define GPBWireFormatMessageSetMessageTag \
|
||||
(GPBWireFormatMakeTag(GPBWireFormatMessageSetMessage, \
|
||||
GPBWireFormatLengthDelimited))
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
85
libs/protobuf/objectivec/GPBWireFormat.m
Normal file
85
libs/protobuf/objectivec/GPBWireFormat.m
Normal file
@@ -0,0 +1,85 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBWireFormat.h"
|
||||
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
|
||||
enum {
|
||||
GPBWireFormatTagTypeBits = 3,
|
||||
GPBWireFormatTagTypeMask = 7 /* = (1 << GPBWireFormatTagTypeBits) - 1 */,
|
||||
};
|
||||
|
||||
uint32_t GPBWireFormatMakeTag(uint32_t fieldNumber, GPBWireFormat wireType) {
|
||||
return (fieldNumber << GPBWireFormatTagTypeBits) | wireType;
|
||||
}
|
||||
|
||||
GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) {
|
||||
return (GPBWireFormat)(tag & GPBWireFormatTagTypeMask);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static const GPBWireFormat format[GPBDataType_Count] = {
|
||||
GPBWireFormatVarint, // GPBDataTypeBool
|
||||
GPBWireFormatFixed32, // GPBDataTypeFixed32
|
||||
GPBWireFormatFixed32, // GPBDataTypeSFixed32
|
||||
GPBWireFormatFixed32, // GPBDataTypeFloat
|
||||
GPBWireFormatFixed64, // GPBDataTypeFixed64
|
||||
GPBWireFormatFixed64, // GPBDataTypeSFixed64
|
||||
GPBWireFormatFixed64, // GPBDataTypeDouble
|
||||
GPBWireFormatVarint, // GPBDataTypeInt32
|
||||
GPBWireFormatVarint, // GPBDataTypeInt64
|
||||
GPBWireFormatVarint, // GPBDataTypeSInt32
|
||||
GPBWireFormatVarint, // GPBDataTypeSInt64
|
||||
GPBWireFormatVarint, // GPBDataTypeUInt32
|
||||
GPBWireFormatVarint, // GPBDataTypeUInt64
|
||||
GPBWireFormatLengthDelimited, // GPBDataTypeBytes
|
||||
GPBWireFormatLengthDelimited, // GPBDataTypeString
|
||||
GPBWireFormatLengthDelimited, // GPBDataTypeMessage
|
||||
GPBWireFormatStartGroup, // GPBDataTypeGroup
|
||||
GPBWireFormatVarint // GPBDataTypeEnum
|
||||
};
|
||||
return format[type];
|
||||
}
|
||||
210
libs/protobuf/objectivec/GPBWrappers.pbobjc.h
Normal file
210
libs/protobuf/objectivec/GPBWrappers.pbobjc.h
Normal file
@@ -0,0 +1,210 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/wrappers.proto
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
|
||||
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
|
||||
#endif
|
||||
#if 30004 < 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.
|
||||
**/
|
||||
GPB_FINAL @interface GPBWrappersRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
#pragma mark - GPBDoubleValue
|
||||
|
||||
typedef GPB_ENUM(GPBDoubleValue_FieldNumber) {
|
||||
GPBDoubleValue_FieldNumber_Value = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper message for `double`.
|
||||
*
|
||||
* The JSON representation for `DoubleValue` is JSON number.
|
||||
**/
|
||||
GPB_FINAL @interface GPBDoubleValue : GPBMessage
|
||||
|
||||
/** The double value. */
|
||||
@property(nonatomic, readwrite) double value;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBFloatValue
|
||||
|
||||
typedef GPB_ENUM(GPBFloatValue_FieldNumber) {
|
||||
GPBFloatValue_FieldNumber_Value = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper message for `float`.
|
||||
*
|
||||
* The JSON representation for `FloatValue` is JSON number.
|
||||
**/
|
||||
GPB_FINAL @interface GPBFloatValue : GPBMessage
|
||||
|
||||
/** The float value. */
|
||||
@property(nonatomic, readwrite) float value;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBInt64Value
|
||||
|
||||
typedef GPB_ENUM(GPBInt64Value_FieldNumber) {
|
||||
GPBInt64Value_FieldNumber_Value = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper message for `int64`.
|
||||
*
|
||||
* The JSON representation for `Int64Value` is JSON string.
|
||||
**/
|
||||
GPB_FINAL @interface GPBInt64Value : GPBMessage
|
||||
|
||||
/** The int64 value. */
|
||||
@property(nonatomic, readwrite) int64_t value;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBUInt64Value
|
||||
|
||||
typedef GPB_ENUM(GPBUInt64Value_FieldNumber) {
|
||||
GPBUInt64Value_FieldNumber_Value = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper message for `uint64`.
|
||||
*
|
||||
* The JSON representation for `UInt64Value` is JSON string.
|
||||
**/
|
||||
GPB_FINAL @interface GPBUInt64Value : GPBMessage
|
||||
|
||||
/** The uint64 value. */
|
||||
@property(nonatomic, readwrite) uint64_t value;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBInt32Value
|
||||
|
||||
typedef GPB_ENUM(GPBInt32Value_FieldNumber) {
|
||||
GPBInt32Value_FieldNumber_Value = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper message for `int32`.
|
||||
*
|
||||
* The JSON representation for `Int32Value` is JSON number.
|
||||
**/
|
||||
GPB_FINAL @interface GPBInt32Value : GPBMessage
|
||||
|
||||
/** The int32 value. */
|
||||
@property(nonatomic, readwrite) int32_t value;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBUInt32Value
|
||||
|
||||
typedef GPB_ENUM(GPBUInt32Value_FieldNumber) {
|
||||
GPBUInt32Value_FieldNumber_Value = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper message for `uint32`.
|
||||
*
|
||||
* The JSON representation for `UInt32Value` is JSON number.
|
||||
**/
|
||||
GPB_FINAL @interface GPBUInt32Value : GPBMessage
|
||||
|
||||
/** The uint32 value. */
|
||||
@property(nonatomic, readwrite) uint32_t value;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBBoolValue
|
||||
|
||||
typedef GPB_ENUM(GPBBoolValue_FieldNumber) {
|
||||
GPBBoolValue_FieldNumber_Value = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper message for `bool`.
|
||||
*
|
||||
* The JSON representation for `BoolValue` is JSON `true` and `false`.
|
||||
**/
|
||||
GPB_FINAL @interface GPBBoolValue : GPBMessage
|
||||
|
||||
/** The bool value. */
|
||||
@property(nonatomic, readwrite) BOOL value;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBStringValue
|
||||
|
||||
typedef GPB_ENUM(GPBStringValue_FieldNumber) {
|
||||
GPBStringValue_FieldNumber_Value = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper message for `string`.
|
||||
*
|
||||
* The JSON representation for `StringValue` is JSON string.
|
||||
**/
|
||||
GPB_FINAL @interface GPBStringValue : GPBMessage
|
||||
|
||||
/** The string value. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *value;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBBytesValue
|
||||
|
||||
typedef GPB_ENUM(GPBBytesValue_FieldNumber) {
|
||||
GPBBytesValue_FieldNumber_Value = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper message for `bytes`.
|
||||
*
|
||||
* The JSON representation for `BytesValue` is JSON string.
|
||||
**/
|
||||
GPB_FINAL @interface GPBBytesValue : GPBMessage
|
||||
|
||||
/** The bytes value. */
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSData *value;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clange-format on
|
||||
446
libs/protobuf/objectivec/GPBWrappers.pbobjc.m
Normal file
446
libs/protobuf/objectivec/GPBWrappers.pbobjc.m
Normal file
@@ -0,0 +1,446 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// clang-format off
|
||||
// source: google/protobuf/wrappers.proto
|
||||
|
||||
#import "GPBProtocolBuffers_RuntimeSupport.h"
|
||||
#import "GPBWrappers.pbobjc.h"
|
||||
|
||||
// @@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
|
||||
|
||||
static GPBFileDescriptor *GPBWrappersRoot_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) {
|
||||
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
|
||||
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
|
||||
objcPrefix:@"GPB"
|
||||
syntax:GPBFileSyntaxProto3];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
#pragma mark - GPBDoubleValue
|
||||
|
||||
@implementation GPBDoubleValue
|
||||
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBDoubleValue__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
double value;
|
||||
} GPBDoubleValue__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 = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBDoubleValue_FieldNumber_Value,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBDoubleValue__storage_, value),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeDouble,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBDoubleValue class]
|
||||
rootClass:[GPBWrappersRoot class]
|
||||
file:GPBWrappersRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBDoubleValue__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBFloatValue
|
||||
|
||||
@implementation GPBFloatValue
|
||||
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBFloatValue__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
float value;
|
||||
} GPBFloatValue__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 = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBFloatValue_FieldNumber_Value,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBFloatValue__storage_, value),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeFloat,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBFloatValue class]
|
||||
rootClass:[GPBWrappersRoot class]
|
||||
file:GPBWrappersRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBFloatValue__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBInt64Value
|
||||
|
||||
@implementation GPBInt64Value
|
||||
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBInt64Value__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
int64_t value;
|
||||
} GPBInt64Value__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 = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBInt64Value_FieldNumber_Value,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBInt64Value__storage_, value),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeInt64,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBInt64Value class]
|
||||
rootClass:[GPBWrappersRoot class]
|
||||
file:GPBWrappersRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBInt64Value__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBUInt64Value
|
||||
|
||||
@implementation GPBUInt64Value
|
||||
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBUInt64Value__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
uint64_t value;
|
||||
} GPBUInt64Value__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 = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBUInt64Value_FieldNumber_Value,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBUInt64Value__storage_, value),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeUInt64,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBUInt64Value class]
|
||||
rootClass:[GPBWrappersRoot class]
|
||||
file:GPBWrappersRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBUInt64Value__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBInt32Value
|
||||
|
||||
@implementation GPBInt32Value
|
||||
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBInt32Value__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
int32_t value;
|
||||
} GPBInt32Value__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 = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBInt32Value_FieldNumber_Value,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBInt32Value__storage_, value),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeInt32,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBInt32Value class]
|
||||
rootClass:[GPBWrappersRoot class]
|
||||
file:GPBWrappersRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBInt32Value__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBUInt32Value
|
||||
|
||||
@implementation GPBUInt32Value
|
||||
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBUInt32Value__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
uint32_t value;
|
||||
} GPBUInt32Value__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 = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBUInt32Value_FieldNumber_Value,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBUInt32Value__storage_, value),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeUInt32,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBUInt32Value class]
|
||||
rootClass:[GPBWrappersRoot class]
|
||||
file:GPBWrappersRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBUInt32Value__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBBoolValue
|
||||
|
||||
@implementation GPBBoolValue
|
||||
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBBoolValue__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
} GPBBoolValue__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 = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBBoolValue_FieldNumber_Value,
|
||||
.hasIndex = 0,
|
||||
.offset = 1, // Stored in _has_storage_ to save space.
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeBool,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBBoolValue class]
|
||||
rootClass:[GPBWrappersRoot class]
|
||||
file:GPBWrappersRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBBoolValue__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBStringValue
|
||||
|
||||
@implementation GPBStringValue
|
||||
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBStringValue__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSString *value;
|
||||
} GPBStringValue__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 = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBStringValue_FieldNumber_Value,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBStringValue__storage_, value),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeString,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBStringValue class]
|
||||
rootClass:[GPBWrappersRoot class]
|
||||
file:GPBWrappersRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBStringValue__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBBytesValue
|
||||
|
||||
@implementation GPBBytesValue
|
||||
|
||||
@dynamic value;
|
||||
|
||||
typedef struct GPBBytesValue__storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSData *value;
|
||||
} GPBBytesValue__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 = "value",
|
||||
.dataTypeSpecific.clazz = Nil,
|
||||
.number = GPBBytesValue_FieldNumber_Value,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(GPBBytesValue__storage_, value),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero),
|
||||
.dataType = GPBDataTypeBytes,
|
||||
},
|
||||
};
|
||||
GPBDescriptor *localDescriptor =
|
||||
[GPBDescriptor allocDescriptorForClass:[GPBBytesValue class]
|
||||
rootClass:[GPBWrappersRoot class]
|
||||
file:GPBWrappersRoot_FileDescriptor()
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(GPBBytesValue__storage_)
|
||||
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(descriptor == nil, @"Startup recursed!");
|
||||
#endif // DEBUG
|
||||
descriptor = localDescriptor;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
// clang-format on
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:ProtocolBuffers_OSX.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -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>
|
||||
@@ -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>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,344 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0930"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "CodedInputStreamTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "CodedOutputStreamTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "ConcurrencyTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "DescriptorTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBAutocreatedArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBAutocreatedDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolBoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolDoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolFloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolUInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolUInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBridgeTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBDoubleArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBEnumArrayCustomTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBEnumArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBExtensionRegistryTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBFloatArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBObjectiveCPlusPlusTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringBoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringDoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringEnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringEnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringFloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringUInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringUInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBTestCase">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageMergeTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageRuntimeTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageSerializationTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UnknownFieldSetTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UtilitiesTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "WellKnownTypesTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "WireFormatTests">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Release">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0930"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "NO">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F4487C381A9F8E0200531423"
|
||||
BuildableName = "libTestSingleSourceBuild.a"
|
||||
BlueprintName = "TestSingleSourceBuild"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
codeCoverageEnabled = "YES"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "PerfTests">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.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">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_OSX.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:ProtocolBuffers_iOS.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -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>
|
||||
@@ -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>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,344 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0930"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "CodedInputStreamTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "CodedOutputStreamTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "ConcurrencyTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "DescriptorTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBAutocreatedArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBAutocreatedDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolBoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolDoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolFloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolUInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolUInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBridgeTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBDoubleArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBEnumArrayCustomTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBEnumArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBExtensionRegistryTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBFloatArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBObjectiveCPlusPlusTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringBoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringDoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringEnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringEnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringFloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringUInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringUInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBTestCase">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageMergeTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageRuntimeTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageSerializationTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UnknownFieldSetTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UtilitiesTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "WellKnownTypesTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "WireFormatTests">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8B9A5EA41831993600A9D33B"
|
||||
BuildableName = "iOSTestHarness.app"
|
||||
BlueprintName = "iOSTestHarness"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Release">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0930"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "NO">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F4487C551A9F8F8100531423"
|
||||
BuildableName = "libTestSingleSourceBuild.a"
|
||||
BlueprintName = "TestSingleSourceBuild"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
codeCoverageEnabled = "YES"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "PerfTests">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8B9A5EA41831993600A9D33B"
|
||||
BuildableName = "iOSTestHarness.app"
|
||||
BlueprintName = "iOSTestHarness"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.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">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_iOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -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>
|
||||
@@ -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>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,370 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0930"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "CodedInputStreamTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "CodedOutputStreamTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "ConcurrencyTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "DescriptorTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBAutocreatedArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBAutocreatedDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolBoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolDoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolFloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolUInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBoolUInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBBridgeTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBDoubleArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBEnumArrayCustomTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBEnumArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBExtensionRegistryTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBFloatArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt32UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBInt64UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBObjectiveCPlusPlusTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringBoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringDoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringEnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringEnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringFloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringUInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBStringUInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBTestCase">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt32UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64ArrayTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64BoolDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64DoubleDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64EnumDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64EnumDictionaryUnknownEnumTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64FloatDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64Int32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64Int64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64ObjectDictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64UInt32DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GPBUInt64UInt64DictionaryTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageMergeTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageRuntimeTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageSerializationTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "MessageTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "PerfTests/testHas">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UnknownFieldSetTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UtilitiesTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "WellKnownTypesTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "WireFormatTests">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Release">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0930"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "NO">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F4487C551A9F8F8100531423"
|
||||
BuildableName = "libTestSingleSourceBuild.a"
|
||||
BlueprintName = "TestSingleSourceBuild"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
codeCoverageEnabled = "YES"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BBEA4A5147C727100C4ADB7"
|
||||
BuildableName = "UnitTests.xctest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "PerfTests">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.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">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7461B52D0F94FAF800A0C422"
|
||||
BuildableName = "libProtocolBuffers.a"
|
||||
BlueprintName = "ProtocolBuffers"
|
||||
ReferencedContainer = "container:ProtocolBuffers_tvOS.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
259
libs/protobuf/objectivec/README.md
Normal file
259
libs/protobuf/objectivec/README.md
Normal file
@@ -0,0 +1,259 @@
|
||||
Protocol Buffers - Google's data interchange format
|
||||
===================================================
|
||||
|
||||
Copyright 2008 Google Inc.
|
||||
|
||||
This directory contains the Objective C Protocol Buffers runtime library.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
The Objective C implementation requires:
|
||||
|
||||
- Objective C 2.0 Runtime (32bit & 64bit iOS, 64bit OS X).
|
||||
- Xcode 13.3.1 (or later).
|
||||
- The library code does *not* use ARC (for performance reasons), but it all can
|
||||
be called from ARC code.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
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
|
||||
|
||||
This will generate the `protoc` binary.
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
There are two ways to include the Runtime sources in your project:
|
||||
|
||||
Add `objectivec/*.h`, `objectivec/google/protobuf/*.pbobjc.h`, and
|
||||
`objectivec/GPBProtocolBuffers.m` to your project.
|
||||
|
||||
*or*
|
||||
|
||||
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.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
The objects generated for messages should work like any other Objective C
|
||||
object. They are mutable objects, but if you don't change them, they are safe
|
||||
to share between threads (similar to passing an NSMutableDictionary between
|
||||
threads/queues; as long as no one mutates it, things are fine).
|
||||
|
||||
There are a few behaviors worth calling out:
|
||||
|
||||
A property that is type NSString\* will never return nil. If the value is
|
||||
unset, it will return an empty string (@""). This is inpart to align things
|
||||
with the Protocol Buffers spec which says the default for strings is an empty
|
||||
string, but also so you can always safely pass them to isEqual:/compare:, etc.
|
||||
and have deterministic results.
|
||||
|
||||
A property that is type NSData\* also won't return nil, it will return an empty
|
||||
data ([NSData data]). The reasoning is the same as for NSString not returning
|
||||
nil.
|
||||
|
||||
A property that is another GPBMessage class also will not return nil. If the
|
||||
field wasn't already set, you will get a instance of the correct class. This
|
||||
instance will be a temporary instance unless you mutate it, at which point it
|
||||
will be attached to its parent object. We call this pattern *autocreators*.
|
||||
Similar to NSString and NSData properties it makes things a little safer when
|
||||
using them with isEqual:/etc.; but more importantly, this allows you to write
|
||||
code that uses Objective C's property dot notation to walk into nested objects
|
||||
and access and/or assign things without having to check that they are not nil
|
||||
and create them each step along the way. You can write this:
|
||||
|
||||
```
|
||||
- (void)updateRecord:(MyMessage *)msg {
|
||||
...
|
||||
// Note: You don't have to check subMessage and otherMessage for nil and
|
||||
// alloc/init/assign them back along the way.
|
||||
msg.subMessage.otherMessage.lastName = @"Smith";
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
If you want to check if a GPBMessage property is present, there is always as
|
||||
`has\[NAME\]` property to go with the main property to check if it is set.
|
||||
|
||||
A property that is of an Array or Dictionary type also provides *autocreator*
|
||||
behavior and will never return nil. This provides all the same benefits you
|
||||
see for the message properties. Again, you can write:
|
||||
|
||||
```
|
||||
- (void)updateRecord:(MyMessage *)msg {
|
||||
...
|
||||
// Note: Just like above, you don't have to check subMessage and otherMessage
|
||||
// for nil and alloc/init/assign them back along the way. You also don't have
|
||||
// to create the siblingsArray, you can safely just append to it.
|
||||
[msg.subMessage.otherMessage.siblingsArray addObject:@"Pat"];
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
If you are inspecting a message you got from some other place (server, disk,
|
||||
etc), you may want to check if the Array or Dictionary has entries without
|
||||
causing it to be created for you. For this, there is always a `\[NAME\]_Count`
|
||||
property also provided that can return zero or the real count, but won't trigger
|
||||
the creation.
|
||||
|
||||
For primitive type fields (ints, floats, bools, enum) in messages defined in a
|
||||
`.proto` file that use *proto2* syntax there are conceptual differences between
|
||||
having an *explicit* and *default* value. You can always get the value of the
|
||||
property. In the case that it hasn't been set you will get the default. In
|
||||
cases where you need to know whether it was set explicitly or you are just
|
||||
getting the default, you can use the `has\[NAME\]` property. If the value has
|
||||
been set, and you want to clear it, you can set the `has\[NAME\]` to `NO`.
|
||||
*proto3* syntax messages do away with this concept, thus the default values are
|
||||
never included when the message is encoded.
|
||||
|
||||
The Objective C classes/enums can be used from Swift code.
|
||||
|
||||
Objective C Generator Proto File Options
|
||||
----------------------------------------
|
||||
|
||||
**objc_class_prefix=\<prefix\>** (no default)
|
||||
|
||||
This options allow you to provide a custom prefix for all the symbols generated
|
||||
from a proto file (classes (from message), enums, the Root for extension
|
||||
support).
|
||||
|
||||
If not set, the generation options `package_to_prefix_mappings_path` and
|
||||
`use_package_as_prefix` (documented below) controls what is used instead. Since
|
||||
Objective C uses a global namespace for all of its classes, there can be collisions.
|
||||
`use_package_as_prefix=yes` should avoid collisions since proto package are used to
|
||||
scope/name things in other languages, but this option can be used to get shorter
|
||||
names instead. Convention is to base the explicit prefix on the proto package.
|
||||
|
||||
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 in case it has a
|
||||
lot of proto files included in it; and having multiple lines makes things
|
||||
easier to read.
|
||||
|
||||
* `runtime_import_prefix`: The `value` used for this key to be used as a
|
||||
prefix on `#import`s of runtime provided headers in the generated files.
|
||||
When integrating ObjC protos into a build system, this can be used to avoid
|
||||
having to add the runtime directory to the header search path since the
|
||||
generate `#import` will be more complete.
|
||||
|
||||
* `package_to_prefix_mappings_path`: The `value` used for this key is a
|
||||
path to a file containing a list of proto packages and prefixes.
|
||||
The generator will use this to locate which ObjC class prefix to use when
|
||||
generating sources _unless_ the `objc_class_prefix` file option is set.
|
||||
This option can be useful if multiple apps consume a common set of
|
||||
proto files but wish to use a different prefix for the generated sources
|
||||
between them. This option takes precedent over the `use_package_as_prefix`
|
||||
option.
|
||||
|
||||
The format of the file is:
|
||||
* An entry is a line of "package=prefix".
|
||||
* Comments start with `#`.
|
||||
* A comment can go on a line after a expected package/prefix pair.
|
||||
(i.e. - "package=prefix # comment")
|
||||
* For files that do NOT have a proto package (not recommended), an
|
||||
entry can be made as "no_package:PATH=prefix", where PATH is the
|
||||
path for the .proto file.
|
||||
|
||||
* `use_package_as_prefix`, `package_as_prefix_forced_prefix` and
|
||||
`proto_package_prefix_exceptions_path`: The `value` for
|
||||
`use_package_as_prefix` can be `yes` or `no`, and indicates if a prefix
|
||||
should be derived from the proto package for all the symbols for files that
|
||||
don't have the `objc_class_prefix` file option (mentioned above). This helps
|
||||
ensure the symbols are more unique and means there is less chance of ObjC
|
||||
class name collisions.
|
||||
|
||||
To help in migrating code to using this support,
|
||||
`proto_package_prefix_exceptions_path` can be used to provide the path
|
||||
to a file that contains proto package names (one per line, comments allowed
|
||||
if prefixed with `#`). These package won't get the derived prefix, allowing
|
||||
migrations to the behavior one proto package at a time across a code base.
|
||||
|
||||
`package_as_prefix_forced_prefix` can be used to provide a value that will
|
||||
be used before all prefixes derived from the packages to help group all of
|
||||
these types with a common prefix. Thus it only makes sense to use it when
|
||||
`use_package_as_prefix` is also enabled. For example, setting this to
|
||||
"XYZ\_" and generating a file with the package "something" defining
|
||||
"MyMessage", would have Objective-C class be `XYZ_Something_MyMessage`.
|
||||
|
||||
`use_package_as_prefix` currently defaults to `no` (existing behavior), but
|
||||
that could change in the future as it helps avoid collisions when more
|
||||
protos get added to the build. Note that this would be a breaking change.
|
||||
|
||||
* `headers_use_forward_declarations`: The `value` for this can be `yes` or
|
||||
`no`, and indicates if the generated headers use forward declarations for
|
||||
Message and Enum types from other .proto files or if the files should be
|
||||
imported into the generated header instead.
|
||||
|
||||
By using forward declarations, less code is likely to recompile when the
|
||||
files do change, but Swift generally doesn't like forward declarations and
|
||||
will fail to include properties when the concrete definition of the type is
|
||||
known at import time. If your proto usages span modules, this can be a
|
||||
problem.
|
||||
|
||||
`headers_use_forward_declarations` currently defaults to `yes` (existing
|
||||
behavior), but in a future release, that default may change to provide
|
||||
better Swift support by default.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Please make updates to the tests along with changes. If just changing the
|
||||
runtime, the Xcode projects can be used to build and run tests. If your change
|
||||
also requires changes to the generated code,
|
||||
`objectivec/DevTools/full_mac_build.sh` can be used to easily rebuild and test
|
||||
changes. Passing `-h` to the script will show the addition options that could
|
||||
be useful.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
The complete documentation for Protocol Buffers is available via the
|
||||
web at:
|
||||
|
||||
https://developers.google.com/protocol-buffers/
|
||||
49
libs/protobuf/objectivec/Tests/GPBARCUnittestProtos.m
Normal file
49
libs/protobuf/objectivec/Tests/GPBARCUnittestProtos.m
Normal file
@@ -0,0 +1,49 @@
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
// 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.
|
||||
|
||||
// Makes sure all the generated headers compile with ARC on.
|
||||
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestCycle.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestDeprecated.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestDeprecatedFile.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestImport.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestImportPublic.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestMset.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjcOptions.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjcStartup.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestPreserveUnknownEnum.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto3.pbobjc.h"
|
||||
3678
libs/protobuf/objectivec/Tests/GPBArrayTests.m
Normal file
3678
libs/protobuf/objectivec/Tests/GPBArrayTests.m
Normal file
File diff suppressed because it is too large
Load Diff
442
libs/protobuf/objectivec/Tests/GPBCodedInputStreamTests.m
Normal file
442
libs/protobuf/objectivec/Tests/GPBCodedInputStreamTests.m
Normal file
@@ -0,0 +1,442 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBCodedOutputStream.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
|
||||
@interface CodedInputStreamTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation CodedInputStreamTests
|
||||
|
||||
- (NSData*)bytes_with_sentinel:(int32_t)unused, ... {
|
||||
va_list list;
|
||||
va_start(list, unused);
|
||||
|
||||
NSMutableData* values = [NSMutableData dataWithCapacity:0];
|
||||
int32_t i;
|
||||
|
||||
while ((i = va_arg(list, int32_t)) != 256) {
|
||||
NSAssert(i >= 0 && i < 256, @"");
|
||||
uint8_t u = (uint8_t)i;
|
||||
[values appendBytes:&u length:1];
|
||||
}
|
||||
|
||||
va_end(list);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
#define bytes(...) [self bytes_with_sentinel:0, __VA_ARGS__, 256]
|
||||
|
||||
- (void)testDecodeZigZag {
|
||||
[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((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(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((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 {
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertThrows([input readInt32]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertThrows([input readInt64]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testBytes {
|
||||
NSData* data = bytes(0xa2, 0x74);
|
||||
XCTAssertEqual(data.length, (NSUInteger)2);
|
||||
XCTAssertEqual(((uint8_t*)data.bytes)[0], (uint8_t)0xa2);
|
||||
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) | (0x04 << 21) | (0x0bLL << 28)];
|
||||
|
||||
// 64-bit
|
||||
// 7256456126
|
||||
[self assertReadVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x1bLL << 28)];
|
||||
// 41256202580718336
|
||||
[self assertReadVarint:bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49)
|
||||
value:(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | (0x43LL << 28) |
|
||||
(0x49LL << 35) | (0x24LL << 42) | (0x49LL << 49)];
|
||||
// 11964378330978735131
|
||||
[self assertReadVarint:bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01)
|
||||
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | (0x3bLL << 28) |
|
||||
(0x56LL << 35) | (0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
|
||||
(0x01ULL << 63)];
|
||||
|
||||
// Failures
|
||||
[self assertReadVarintFailure:bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x00)];
|
||||
[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];
|
||||
[self assertReadLittleEndian32:bytes(0xf0, 0xde, 0xbc, 0x9a) value:0x9abcdef0];
|
||||
|
||||
[self assertReadLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12)
|
||||
value:0x123456789abcdef0LL];
|
||||
[self assertReadLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a)
|
||||
value:0x9abcdef012345678LL];
|
||||
}
|
||||
|
||||
- (void)testReadWholeMessage {
|
||||
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
|
||||
NSData* rawBytes = message.data;
|
||||
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
|
||||
|
||||
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes extensionRegistry:nil error:NULL];
|
||||
[self assertAllFieldsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testSkipWholeMessage {
|
||||
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes = message.data;
|
||||
|
||||
// Create two parallel inputs. Parse one as unknown fields while using
|
||||
// skipField() to skip each field on the other. Expect the same tags.
|
||||
GPBCodedInputStream* input1 = [GPBCodedInputStream streamWithData:rawBytes];
|
||||
GPBCodedInputStream* input2 = [GPBCodedInputStream streamWithData:rawBytes];
|
||||
GPBUnknownFieldSet* unknownFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
|
||||
while (YES) {
|
||||
int32_t tag = [input1 readTag];
|
||||
XCTAssertEqual(tag, [input2 readTag]);
|
||||
if (tag == 0) {
|
||||
break;
|
||||
}
|
||||
[unknownFields mergeFieldFrom:tag input:input1];
|
||||
[input2 skipField:tag];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testReadHugeBlob {
|
||||
// Allocate and initialize a 1MB blob.
|
||||
NSMutableData* blob = [NSMutableData dataWithLength:1 << 20];
|
||||
for (NSUInteger i = 0; i < blob.length; i++) {
|
||||
((uint8_t*)blob.mutableBytes)[i] = (uint8_t)i;
|
||||
}
|
||||
|
||||
// Make a message containing it.
|
||||
TestAllTypes* message = [TestAllTypes message];
|
||||
[self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
|
||||
[message setOptionalBytes:blob];
|
||||
|
||||
// Serialize and parse it. Make sure to parse from an InputStream, not
|
||||
// directly from a ByteString, so that CodedInputStream uses buffered
|
||||
// reading.
|
||||
NSData* messageData = message.data;
|
||||
XCTAssertNotNil(messageData);
|
||||
GPBCodedInputStream* stream = [GPBCodedInputStream streamWithData:messageData];
|
||||
TestAllTypes* message2 = [TestAllTypes parseFromCodedInputStream:stream
|
||||
extensionRegistry:nil
|
||||
error:NULL];
|
||||
|
||||
XCTAssertEqualObjects(message.optionalBytes, message2.optionalBytes);
|
||||
|
||||
// Make sure all the other fields were parsed correctly.
|
||||
TestAllTypes* message3 = [[message2 copy] autorelease];
|
||||
TestAllTypes* types = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* data = [types optionalBytes];
|
||||
[message3 setOptionalBytes:data];
|
||||
|
||||
[self assertAllFieldsSet:message3 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testReadMaliciouslyLargeBlob {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
|
||||
int32_t tag = GPBWireFormatMakeTag(1, GPBWireFormatLengthDelimited);
|
||||
[output writeRawVarint32:tag];
|
||||
[output writeRawVarint32:0x7FFFFFFF];
|
||||
uint8_t bytes[32] = {0};
|
||||
[output writeRawData:[NSData dataWithBytes:bytes length:32]];
|
||||
[output flush];
|
||||
|
||||
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
GPBCodedInputStream* input =
|
||||
[GPBCodedInputStream streamWithData:[NSMutableData dataWithData:data]];
|
||||
XCTAssertEqual(tag, [input readTag]);
|
||||
|
||||
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
|
||||
// again, it will help validate that class' handing of bad utf8.
|
||||
- (void)testReadMalformedString {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
|
||||
int32_t tag =
|
||||
GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString, GPBWireFormatLengthDelimited);
|
||||
[output writeRawVarint32:tag];
|
||||
[output writeRawVarint32:5];
|
||||
// Create an invalid utf-8 byte array.
|
||||
uint8_t bytes[] = {0xc2, 0xf2, 0x0, 0x0, 0x0};
|
||||
[output writeRawData:[NSData dataWithBytes:bytes length:sizeof(bytes)]];
|
||||
[output flush];
|
||||
|
||||
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
NSError* error = nil;
|
||||
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
|
||||
extensionRegistry:nil
|
||||
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 in case a custom string class is ever
|
||||
// used again.)
|
||||
const char* strs[] = {
|
||||
"\xEF\xBB\xBF String with BOM",
|
||||
"String with \xEF\xBB\xBF in middle",
|
||||
"String with end bom \xEF\xBB\xBF",
|
||||
"\xEF\xBB\xBF\xe2\x99\xa1", // BOM White Heart
|
||||
"\xEF\xBB\xBF\xEF\xBB\xBF String with Two BOM",
|
||||
};
|
||||
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
|
||||
399
libs/protobuf/objectivec/Tests/GPBCodedOutputStreamTests.m
Normal file
399
libs/protobuf/objectivec/Tests/GPBCodedOutputStreamTests.m
Normal file
@@ -0,0 +1,399 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBCodedOutputStream_PackagePrivate.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
#import "objectivec/Tests/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
|
||||
|
||||
@implementation CodedOutputStreamTests
|
||||
|
||||
- (NSData*)bytes_with_sentinel:(int32_t)unused, ... {
|
||||
va_list list;
|
||||
va_start(list, unused);
|
||||
|
||||
NSMutableData* values = [NSMutableData dataWithCapacity:0];
|
||||
int32_t i;
|
||||
|
||||
while ((i = va_arg(list, int32_t)) != 256) {
|
||||
NSAssert(i >= 0 && i < 256, @"");
|
||||
uint8_t u = (uint8_t)i;
|
||||
[values appendBytes:&u length:1];
|
||||
}
|
||||
|
||||
va_end(list);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
#define bytes(...) [self bytes_with_sentinel:0, __VA_ARGS__, 256]
|
||||
|
||||
- (void)assertWriteLittleEndian32:(NSData*)data value:(int32_t)value {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawLittleEndian32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
|
||||
rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput bufferSize:blockSize];
|
||||
[output writeRawLittleEndian32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)assertWriteLittleEndian64:(NSData*)data value:(int64_t)value {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawLittleEndian64:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
|
||||
rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput bufferSize:blockSize];
|
||||
[output writeRawLittleEndian64:value];
|
||||
[output flush];
|
||||
|
||||
actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)assertWriteVarint:(NSData*)data value:(int64_t)value {
|
||||
// Only do 32-bit write if the value fits in 32 bits.
|
||||
if (GPBLogicalRightShift64(value, 32) == 0) {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawVarint32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Also try computing size.
|
||||
XCTAssertEqual(GPBComputeRawVarint32Size((int32_t)value), (size_t)data.length);
|
||||
}
|
||||
|
||||
{
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawVarint64:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Also try computing size.
|
||||
XCTAssertEqual(GPBComputeRawVarint64Size(value), (size_t)data.length);
|
||||
}
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
|
||||
// Only do 32-bit write if the value fits in 32 bits.
|
||||
if (GPBLogicalRightShift64(value, 32) == 0) {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
|
||||
[output writeRawVarint32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
|
||||
{
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
|
||||
[output writeRawVarint64:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint2 {
|
||||
[self assertWriteVarint:bytes(0x01) value:1];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint3 {
|
||||
[self assertWriteVarint:bytes(0x7f) value:127];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint4 {
|
||||
// 14882
|
||||
[self assertWriteVarint:bytes(0xa2, 0x74) value:(0x22 << 0) | (0x74 << 7)];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint5 {
|
||||
// The sign/nosign distinction is done here because normally varints are
|
||||
// around 64bit values, but for some cases a 32bit value is forced with
|
||||
// with the sign bit (tags, uint32, etc.)
|
||||
|
||||
// 1887747006 (no sign bit)
|
||||
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x07)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x07LL << 28)];
|
||||
// 2961488830 (sign bit)
|
||||
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x0bLL << 28)];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint6 {
|
||||
// 64-bit
|
||||
// 7256456126
|
||||
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x1bLL << 28)];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint7 {
|
||||
// 41256202580718336
|
||||
[self assertWriteVarint:bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49)
|
||||
value:(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | (0x43LL << 28) |
|
||||
(0x49LL << 35) | (0x24LL << 42) | (0x49LL << 49)];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint8 {
|
||||
// 11964378330978735131
|
||||
[self assertWriteVarint:bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01)
|
||||
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | (0x3bLL << 28) |
|
||||
(0x56LL << 35) | (0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
|
||||
(0x01ULL << 63)];
|
||||
}
|
||||
|
||||
- (void)testWriteLittleEndian {
|
||||
[self assertWriteLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12) value:0x12345678];
|
||||
[self assertWriteLittleEndian32:bytes(0xf0, 0xde, 0xbc, 0x9a) value:0x9abcdef0];
|
||||
|
||||
[self assertWriteLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12)
|
||||
value:0x123456789abcdef0LL];
|
||||
[self assertWriteLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a)
|
||||
value:0x9abcdef012345678LL];
|
||||
}
|
||||
|
||||
- (void)testEncodeZigZag {
|
||||
XCTAssertEqual(0U, GPBEncodeZigZag32(0));
|
||||
XCTAssertEqual(1U, GPBEncodeZigZag32(-1));
|
||||
XCTAssertEqual(2U, GPBEncodeZigZag32(1));
|
||||
XCTAssertEqual(3U, GPBEncodeZigZag32(-2));
|
||||
XCTAssertEqual(0x7FFFFFFEU, GPBEncodeZigZag32(0x3FFFFFFF));
|
||||
XCTAssertEqual(0x7FFFFFFFU, GPBEncodeZigZag32(0xC0000000));
|
||||
XCTAssertEqual(0xFFFFFFFEU, GPBEncodeZigZag32(0x7FFFFFFF));
|
||||
XCTAssertEqual(0xFFFFFFFFU, GPBEncodeZigZag32(0x80000000));
|
||||
|
||||
XCTAssertEqual(0ULL, GPBEncodeZigZag64(0));
|
||||
XCTAssertEqual(1ULL, GPBEncodeZigZag64(-1));
|
||||
XCTAssertEqual(2ULL, GPBEncodeZigZag64(1));
|
||||
XCTAssertEqual(3ULL, GPBEncodeZigZag64(-2));
|
||||
XCTAssertEqual(0x000000007FFFFFFEULL, GPBEncodeZigZag64(0x000000003FFFFFFFLL));
|
||||
XCTAssertEqual(0x000000007FFFFFFFULL, GPBEncodeZigZag64(0xFFFFFFFFC0000000LL));
|
||||
XCTAssertEqual(0x00000000FFFFFFFEULL, GPBEncodeZigZag64(0x000000007FFFFFFFLL));
|
||||
XCTAssertEqual(0x00000000FFFFFFFFULL, GPBEncodeZigZag64(0xFFFFFFFF80000000LL));
|
||||
XCTAssertEqual(0xFFFFFFFFFFFFFFFEULL, GPBEncodeZigZag64(0x7FFFFFFFFFFFFFFFLL));
|
||||
XCTAssertEqual(0xFFFFFFFFFFFFFFFFULL, GPBEncodeZigZag64(0x8000000000000000LL));
|
||||
|
||||
// Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1)
|
||||
// were chosen semi-randomly via keyboard bashing.
|
||||
XCTAssertEqual(0U, GPBEncodeZigZag32(GPBDecodeZigZag32(0)));
|
||||
XCTAssertEqual(1U, GPBEncodeZigZag32(GPBDecodeZigZag32(1)));
|
||||
XCTAssertEqual(-1U, GPBEncodeZigZag32(GPBDecodeZigZag32(-1)));
|
||||
XCTAssertEqual(14927U, GPBEncodeZigZag32(GPBDecodeZigZag32(14927)));
|
||||
XCTAssertEqual(-3612U, GPBEncodeZigZag32(GPBDecodeZigZag32(-3612)));
|
||||
|
||||
XCTAssertEqual(0ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(0)));
|
||||
XCTAssertEqual(1ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(1)));
|
||||
XCTAssertEqual(-1ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-1)));
|
||||
XCTAssertEqual(14927ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(14927)));
|
||||
XCTAssertEqual(-3612ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-3612)));
|
||||
|
||||
XCTAssertEqual(856912304801416ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(856912304801416LL)));
|
||||
XCTAssertEqual(-75123905439571256ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-75123905439571256LL)));
|
||||
}
|
||||
|
||||
- (void)testWriteWholeMessage {
|
||||
// Not kGPBDefaultRepeatCount because we are comparing to a golden master file
|
||||
// that was generated with 2.
|
||||
TestAllTypes* message = [self allSetRepeatedCount:2];
|
||||
|
||||
NSData* rawBytes = message.data;
|
||||
NSData* goldenData = [self getDataFileNamed:@"golden_message" dataToWrite:rawBytes];
|
||||
XCTAssertEqualObjects(rawBytes, goldenData);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize < 256; blockSize *= 2) {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
[message writeToCodedOutputStream:output];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(rawBytes, actual);
|
||||
}
|
||||
|
||||
// Not kGPBDefaultRepeatCount because we are comparing to a golden master file
|
||||
// that was generated with 2.
|
||||
TestAllExtensions* extensions = [self allExtensionsSetRepeatedCount:2];
|
||||
rawBytes = extensions.data;
|
||||
goldenData = [self getDataFileNamed:@"golden_packed_fields_message" dataToWrite:rawBytes];
|
||||
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 behind 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
|
||||
38
libs/protobuf/objectivec/Tests/GPBCompileTest01.m
Normal file
38
libs/protobuf/objectivec/Tests/GPBCompileTest01.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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;
|
||||
38
libs/protobuf/objectivec/Tests/GPBCompileTest02.m
Normal file
38
libs/protobuf/objectivec/Tests/GPBCompileTest02.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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;
|
||||
38
libs/protobuf/objectivec/Tests/GPBCompileTest03.m
Normal file
38
libs/protobuf/objectivec/Tests/GPBCompileTest03.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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;
|
||||
38
libs/protobuf/objectivec/Tests/GPBCompileTest04.m
Normal file
38
libs/protobuf/objectivec/Tests/GPBCompileTest04.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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;
|
||||
38
libs/protobuf/objectivec/Tests/GPBCompileTest05.m
Normal file
38
libs/protobuf/objectivec/Tests/GPBCompileTest05.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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;
|
||||
38
libs/protobuf/objectivec/Tests/GPBCompileTest06.m
Normal file
38
libs/protobuf/objectivec/Tests/GPBCompileTest06.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user