@ -0,0 +1,33 @@ |
|||||||
|
# Only test one combination: "Visual Studio 12 + Win64 + Debug + DLL". We can |
||||||
|
# test more combinations but AppVeyor just takes too long to finish (each |
||||||
|
# combination takes ~15mins). |
||||||
|
platform: |
||||||
|
- Win64 |
||||||
|
|
||||||
|
configuration: |
||||||
|
- Debug |
||||||
|
|
||||||
|
environment: |
||||||
|
matrix: |
||||||
|
- BUILD_DLL: ON |
||||||
|
|
||||||
|
install: |
||||||
|
- ps: Start-FileDownload https://googletest.googlecode.com/files/gtest-1.7.0.zip |
||||||
|
- 7z x gtest-1.7.0.zip |
||||||
|
- rename gtest-1.7.0 gtest |
||||||
|
|
||||||
|
before_build: |
||||||
|
- if %platform%==Win32 set generator=Visual Studio 12 |
||||||
|
- if %platform%==Win64 set generator=Visual Studio 12 Win64 |
||||||
|
- if %platform%==Win32 set vcplatform=Win32 |
||||||
|
- if %platform%==Win64 set vcplatform=x64 |
||||||
|
|
||||||
|
build_script: |
||||||
|
- mkdir build |
||||||
|
- cd build |
||||||
|
- cmake -G "%generator%" -DBUILD_SHARED_LIBS=%BUILD_DLL% ../cmake |
||||||
|
- msbuild protobuf.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" |
||||||
|
- cd %configuration% |
||||||
|
- tests.exe |
||||||
|
|
||||||
|
|
@ -1,4 +0,0 @@ |
|||||||
#define GOOGLE_PROTOBUF_CMAKE_BUILD |
|
||||||
|
|
||||||
#define HAVE_PTHREAD ${HAVE_PTHREAD} |
|
||||||
#define HAVE_ZLIB ${HAVE_ZLIB} |
|
@ -0,0 +1,105 @@ |
|||||||
|
mkdir include |
||||||
|
mkdir include\google |
||||||
|
mkdir include\google\protobuf |
||||||
|
mkdir include\google\protobuf\compiler |
||||||
|
mkdir include\google\protobuf\compiler\cpp |
||||||
|
mkdir include\google\protobuf\compiler\csharp |
||||||
|
mkdir include\google\protobuf\compiler\java |
||||||
|
mkdir include\google\protobuf\compiler\javanano |
||||||
|
mkdir include\google\protobuf\compiler\objectivec |
||||||
|
mkdir include\google\protobuf\compiler\python |
||||||
|
mkdir include\google\protobuf\compiler\ruby |
||||||
|
mkdir include\google\protobuf\io |
||||||
|
mkdir include\google\protobuf\stubs |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.h include\google\protobuf\any.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.pb.h include\google\protobuf\any.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.pb.h include\google\protobuf\api.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena.h include\google\protobuf\arena.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenastring.h include\google\protobuf\arenastring.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h include\google\protobuf\compiler\csharp\csharp_generator.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h include\google\protobuf\compiler\java\java_names.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\javanano\javanano_generator.h include\google\protobuf\compiler\javanano\javanano_generator.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h include\google\protobuf\compiler\objectivec\objectivec_generator.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h include\google\protobuf\compiler\objectivec\objectivec_helpers.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\ruby\ruby_generator.h include\google\protobuf\compiler\ruby\ruby_generator.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.pb.h include\google\protobuf\duration.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.pb.h include\google\protobuf\empty.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set.h include\google\protobuf\extension_set.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.pb.h include\google\protobuf\field_mask.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflection.h include\google\protobuf\generated_enum_reflection.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h include\google\protobuf\generated_enum_util.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h include\google\protobuf\io\printer.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map.h include\google\protobuf\map.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry.h include\google\protobuf\map_entry.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry_lite.h include\google\protobuf\map_entry_lite.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field.h include\google\protobuf\map_field.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_inl.h include\google\protobuf\map_field_inl.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_lite.h include\google\protobuf\map_field_lite.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_type_handler.h include\google\protobuf\map_type_handler.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message.h include\google\protobuf\message.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message_lite.h include\google\protobuf\message_lite.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata.h include\google\protobuf\metadata.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection.h include\google\protobuf\reflection.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field_reflection.h include\google\protobuf\repeated_field_reflection.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\service.h include\google\protobuf\service.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h include\google\protobuf\source_context.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.pb.h include\google\protobuf\struct.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomic_sequence_num.h include\google\protobuf\stubs\atomic_sequence_num.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops.h include\google\protobuf\stubs\atomicops.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_aix.h include\google\protobuf\stubs\atomicops_internals_aix.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm64_gcc.h include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_gcc.h include\google\protobuf\stubs\atomicops_internals_arm_gcc.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_qnx.h include\google\protobuf\stubs\atomicops_internals_arm_qnx.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_atomicword_compat.h include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_gcc.h include\google\protobuf\stubs\atomicops_internals_generic_gcc.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_macosx.h include\google\protobuf\stubs\atomicops_internals_macosx.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h include\google\protobuf\stubs\atomicops_internals_mips_gcc.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_pnacl.h include\google\protobuf\stubs\atomicops_internals_pnacl.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_solaris.h include\google\protobuf\stubs\atomicops_internals_solaris.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_tsan.h include\google\protobuf\stubs\atomicops_internals_tsan.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_gcc.h include\google\protobuf\stubs\atomicops_internals_x86_gcc.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_msvc.h include\google\protobuf\stubs\atomicops_internals_x86_msvc.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h include\google\protobuf\stubs\casts.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastmem.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h include\google\protobuf\stubs\hash.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\shared_ptr.h include\google\protobuf\stubs\shared_ptr.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stl_util.h include\google\protobuf\stubs\stl_util.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\text_format.h include\google\protobuf\text_format.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.pb.h include\google\protobuf\timestamp.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.pb.h include\google\protobuf\type.pb.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h |
||||||
|
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.pb.h include\google\protobuf\wrappers.pb.h |
||||||
|
copy ${PROTOBUF_BINARY_WIN32_PATH}\google\protobuf\stubs\pbconfig.h include\google\protobuf\stubs\pbconfig.h |
@ -1,119 +0,0 @@ |
|||||||
include(CheckCXXSourceCompiles) |
|
||||||
|
|
||||||
function(find_hash_map) |
|
||||||
set(HAVE_HASH_MAP 1 PARENT_SCOPE) |
|
||||||
set(HAVE_HASH_SET 1 PARENT_SCOPE) |
|
||||||
# Search for hash_map in the following order: |
|
||||||
# 1. <unordered_map> ::std::unordered_map |
|
||||||
# 2. <tr1/unordered_map> ::std::tr1::unordered_map |
|
||||||
# 3. <hash_map> ::hash_map |
|
||||||
# 4. <hash_map> ::stdext::hash_map |
|
||||||
# 5. <ext/hash_map> ::std::hash_map |
|
||||||
# 6. <ext/hash_map> ::__gnu_cxx::hash_map |
|
||||||
check_cxx_source_compiles(" |
|
||||||
#include <unordered_map> |
|
||||||
int main() { ::std::unordered_map<int, int> v; return v[0]; } |
|
||||||
" HAS_STD_UNORDERED_MAP) |
|
||||||
if (HAS_STD_UNORDERED_MAP) |
|
||||||
set(HASH_NAMESPACE ::std PARENT_SCOPE) |
|
||||||
set(HASH_MAP_H <unordered_map> PARENT_SCOPE) |
|
||||||
set(HASH_MAP_CLASS unordered_map PARENT_SCOPE) |
|
||||||
set(HASH_SET_H <unordered_set> PARENT_SCOPE) |
|
||||||
set(HASH_SET_CLASS unordered_set PARENT_SCOPE) |
|
||||||
return() |
|
||||||
endif (HAS_STD_UNORDERED_MAP) |
|
||||||
|
|
||||||
check_cxx_source_compiles(" |
|
||||||
#include <tr1/unordered_map> |
|
||||||
int main() { ::std::tr1::unordered_map<int, int> v; return v[0]; } |
|
||||||
" HAS_STD_TR1_UNORDERED_MAP) |
|
||||||
if (HAS_STD_TR1_UNORDERED_MAP) |
|
||||||
set(HASH_NAMESPACE ::std::tr1 PARENT_SCOPE) |
|
||||||
set(HASH_MAP_H <tr1/unordered_map> PARENT_SCOPE) |
|
||||||
set(HASH_MAP_CLASS unordered_map PARENT_SCOPE) |
|
||||||
set(HASH_SET_H <tr1/unordered_set> PARENT_SCOPE) |
|
||||||
set(HASH_SET_CLASS unordered_set PARENT_SCOPE) |
|
||||||
return() |
|
||||||
endif (HAS_STD_TR1_UNORDERED_MAP) |
|
||||||
|
|
||||||
check_cxx_source_compiles(" |
|
||||||
#include <hash_map> |
|
||||||
int main() { ::hash_map<int, int> v; return v[0]; } |
|
||||||
" HAS_HASH_MAP) |
|
||||||
if (HAS_HASH_MAP) |
|
||||||
set(HASH_NAMESPACE :: PARENT_SCOPE) |
|
||||||
set(HASH_MAP_H <hash_map> PARENT_SCOPE) |
|
||||||
set(HASH_MAP_CLASS hash_map PARENT_SCOPE) |
|
||||||
set(HASH_SET_H <hash_set> PARENT_SCOPE) |
|
||||||
set(HASH_SET_CLASS hash_set PARENT_SCOPE) |
|
||||||
return() |
|
||||||
endif (HAS_HASH_MAP) |
|
||||||
|
|
||||||
check_cxx_source_compiles(" |
|
||||||
#include <hash_map> |
|
||||||
int main() { ::stdext::hash_map<int, int> v; return v[0]; } |
|
||||||
" HAS_STDEXT_HASH_MAP) |
|
||||||
if (HAS_STDEXT_HASH_MAP) |
|
||||||
set(HASH_NAMESPACE ::stdext PARENT_SCOPE) |
|
||||||
set(HASH_MAP_H <hash_map> PARENT_SCOPE) |
|
||||||
set(HASH_MAP_CLASS hash_map PARENT_SCOPE) |
|
||||||
set(HASH_SET_H <hash_set> PARENT_SCOPE) |
|
||||||
set(HASH_SET_CLASS hash_set PARENT_SCOPE) |
|
||||||
return() |
|
||||||
endif (HAS_STDEXT_HASH_MAP) |
|
||||||
|
|
||||||
check_cxx_source_compiles(" |
|
||||||
#include <ext/hash_map> |
|
||||||
int main() { ::std::hash_map<int, int> v; return v[0]; } |
|
||||||
" HAS_STD_HASH_MAP) |
|
||||||
if (HAS_STD_HASH_MAP) |
|
||||||
set(HASH_NAMESPACE ::std PARENT_SCOPE) |
|
||||||
set(HASH_MAP_H <ext/hash_map> PARENT_SCOPE) |
|
||||||
set(HASH_MAP_CLASS hash_map PARENT_SCOPE) |
|
||||||
set(HASH_SET_H <ext/hash_set> PARENT_SCOPE) |
|
||||||
set(HASH_SET_CLASS hash_set PARENT_SCOPE) |
|
||||||
return() |
|
||||||
endif (HAS_STD_HASH_MAP) |
|
||||||
|
|
||||||
check_cxx_source_compiles(" |
|
||||||
#include <ext/hash_map> |
|
||||||
int main() { ::__gnu_cxx::hash_map<int, int> v; return v[0]; } |
|
||||||
" HAS_GNU_CXX_HASH_MAP) |
|
||||||
if (HAS_GNU_CXX_HASH_MAP) |
|
||||||
set(HASH_NAMESPACE ::gnu_cxx PARENT_SCOPE) |
|
||||||
set(HASH_MAP_H <ext/hash_map> PARENT_SCOPE) |
|
||||||
set(HASH_MAP_CLASS hash_map PARENT_SCOPE) |
|
||||||
set(HASH_SET_H <ext/hash_set> PARENT_SCOPE) |
|
||||||
set(HASH_SET_CLASS hash_set PARENT_SCOPE) |
|
||||||
return() |
|
||||||
endif (HAS_GNU_CXX_HASH_MAP) |
|
||||||
|
|
||||||
set(HAVE_HASH_MAP 0 PARENT_SCOPE) |
|
||||||
set(HAVE_HASH_SET 0 PARENT_SCOPE) |
|
||||||
endfunction() |
|
||||||
|
|
||||||
function(find_hash_compare) |
|
||||||
if (MSVC) |
|
||||||
check_cxx_source_compiles(" |
|
||||||
#include ${HASH_MAP_H} |
|
||||||
int main() { ::std::hash_compare<int> cp; return cp(0); } |
|
||||||
" HAS_STD_HASH_COMPARE) |
|
||||||
if (HAS_STD_HASH_COMPARE) |
|
||||||
set(HASH_COMPARE ::std::hash_compare PARENT_SCOPE) |
|
||||||
return() |
|
||||||
endif (HAS_STD_HASH_COMPARE) |
|
||||||
|
|
||||||
check_cxx_source_compiles(" |
|
||||||
#include ${HASH_MAP_H} |
|
||||||
int main() { ::stdext::hash_compare<int> cp; return cp(0); } |
|
||||||
" HAS_STDEXT_HASH_COMPARE) |
|
||||||
if (HAS_STDEXT_HASH_COMPARE) |
|
||||||
set(HASH_COMPARE ::stdext::hash_compare PARENT_SCOPE) |
|
||||||
return() |
|
||||||
endif (HAS_STDEXT_HASH_COMPARE) |
|
||||||
endif (MSVC) |
|
||||||
set(HASH_COMPARE PARENT_SCOPE) |
|
||||||
endfunction() |
|
||||||
|
|
||||||
find_hash_map() |
|
||||||
find_hash_compare() |
|
@ -1,9 +0,0 @@ |
|||||||
#define GOOGLE_PROTOBUF_HAVE_HASH_MAP ${HAVE_HASH_MAP} |
|
||||||
#define GOOGLE_PROTOBUF_HAVE_HASH_SET ${HAVE_HASH_MAP} |
|
||||||
|
|
||||||
#define GOOGLE_PROTOBUF_HASH_NAMESPACE ${HASH_NAMESPACE} |
|
||||||
#define GOOGLE_PROTOBUF_HASH_MAP_H ${HASH_MAP_H} |
|
||||||
#define GOOGLE_PROTOBUF_HASH_MAP_CLASS ${HASH_MAP_CLASS} |
|
||||||
#define GOOGLE_PROTOBUF_HASH_SET_H ${HASH_SET_H} |
|
||||||
#define GOOGLE_PROTOBUF_HASH_SET_CLASS ${HASH_SET_CLASS} |
|
||||||
#define GOOGLE_PROTOBUF_HASH_COMPARE ${HASH_COMPARE} |
|
@ -1,7 +0,0 @@ |
|||||||
HASH_MAP_CLASS |
|
||||||
HASH_MAP_H |
|
||||||
HASH_NAMESPACE |
|
||||||
HASH_SET_CLASS |
|
||||||
HASH_SET_H |
|
||||||
HAVE_HASH_MAP |
|
||||||
HAVE_HASH_SET |
|
@ -0,0 +1,21 @@ |
|||||||
|
# This is the list of conformance tests that are known to fail for the C++ |
||||||
|
# implementation right now. These should be fixed. |
||||||
|
# |
||||||
|
# By listing them here we can keep tabs on which ones are failing and be sure |
||||||
|
# that we don't introduce regressions in other tests. |
||||||
|
# |
||||||
|
# TODO(haberman): insert links to corresponding bugs tracking the issue. |
||||||
|
# Should we use GitHub issues or the Google-internal bug tracker? |
||||||
|
|
||||||
|
PrematureEofBeforeKnownRepeatedValue.MESSAGE |
||||||
|
PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE |
||||||
|
PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE |
||||||
|
PrematureEofInPackedField.BOOL |
||||||
|
PrematureEofInPackedField.ENUM |
||||||
|
PrematureEofInPackedField.INT32 |
||||||
|
PrematureEofInPackedField.INT64 |
||||||
|
PrematureEofInPackedField.SINT32 |
||||||
|
PrematureEofInPackedField.SINT64 |
||||||
|
PrematureEofInPackedField.UINT32 |
||||||
|
PrematureEofInPackedField.UINT64 |
||||||
|
PrematureEofInsideKnownRepeatedValue.MESSAGE |
@ -0,0 +1,113 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
# Invoked by the Xcode projects to build the protos needed for the unittests. |
||||||
|
|
||||||
|
set -eu |
||||||
|
|
||||||
|
readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/protos" |
||||||
|
|
||||||
|
# Helper for bailing. |
||||||
|
die() { |
||||||
|
echo "Error: $1" |
||||||
|
exit 2 |
||||||
|
} |
||||||
|
|
||||||
|
# What to do. |
||||||
|
case "${ACTION}" in |
||||||
|
"") |
||||||
|
# Build, fall thru |
||||||
|
;; |
||||||
|
"clean") |
||||||
|
rm -rf "${OUTPUT_DIR}" |
||||||
|
exit 0 |
||||||
|
;; |
||||||
|
*) |
||||||
|
die "Unknown action requested: ${ACTION}" |
||||||
|
;; |
||||||
|
esac |
||||||
|
|
||||||
|
# Move to the top of the protobuf directories. |
||||||
|
cd "${SRCROOT}/.." |
||||||
|
|
||||||
|
[[ -x src/protoc ]] || \ |
||||||
|
die "Could not find the protoc binary; make sure you have built it (objectivec/DevTools/full_mac_build.sh -h)." |
||||||
|
|
||||||
|
RUN_PROTOC=no |
||||||
|
if [[ ! -d "${OUTPUT_DIR}" ]] ; then |
||||||
|
RUN_PROTOC=yes |
||||||
|
else |
||||||
|
# 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 \ |
||||||
|
src/google/protobuf/*.proto \ |
||||||
|
objectivec/Tests/*.proto \ |
||||||
|
src/.libs src/*.la src/protoc \ |
||||||
|
objectivec/DevTools/compile_testing_protos.sh \ |
||||||
|
-type f -print0 \ |
||||||
|
| xargs -0 stat -f "%m %N" \ |
||||||
|
| sort -n | tail -n1 | cut -f2- -d" ") |
||||||
|
# Find the oldest output file. |
||||||
|
readonly OldestOutput=$(find \ |
||||||
|
"${OUTPUT_DIR}" \ |
||||||
|
-type f -print0 \ |
||||||
|
| xargs -0 stat -f "%m %N" \ |
||||||
|
| sort -n -r | tail -n1 | cut -f2- -d" ") |
||||||
|
# If the newest input is newer than the oldest output, regenerate. |
||||||
|
if [[ "${NewestInput}" -nt "${OldestOutput}" ]] ; then |
||||||
|
RUN_PROTOC=yes |
||||||
|
fi |
||||||
|
fi |
||||||
|
|
||||||
|
if [[ "${RUN_PROTOC}" != "yes" ]] ; then |
||||||
|
# Up to date. |
||||||
|
exit 0 |
||||||
|
fi |
||||||
|
|
||||||
|
# Ensure the output dir exists |
||||||
|
mkdir -p "${OUTPUT_DIR}/google/protobuf" |
||||||
|
|
||||||
|
CORE_PROTO_FILES=( \ |
||||||
|
src/google/protobuf/unittest_custom_options.proto \ |
||||||
|
src/google/protobuf/unittest_enormous_descriptor.proto \ |
||||||
|
src/google/protobuf/unittest_embed_optimize_for.proto \ |
||||||
|
src/google/protobuf/unittest_empty.proto \ |
||||||
|
src/google/protobuf/unittest_import.proto \ |
||||||
|
src/google/protobuf/unittest_import_lite.proto \ |
||||||
|
src/google/protobuf/unittest_lite.proto \ |
||||||
|
src/google/protobuf/unittest_mset.proto \ |
||||||
|
src/google/protobuf/unittest_no_generic_services.proto \ |
||||||
|
src/google/protobuf/unittest_optimize_for.proto \ |
||||||
|
src/google/protobuf/unittest.proto \ |
||||||
|
src/google/protobuf/unittest_import_public.proto \ |
||||||
|
src/google/protobuf/unittest_import_public_lite.proto \ |
||||||
|
src/google/protobuf/unittest_drop_unknown_fields.proto \ |
||||||
|
src/google/protobuf/unittest_preserve_unknown_enum.proto \ |
||||||
|
src/google/protobuf/map_lite_unittest.proto \ |
||||||
|
src/google/protobuf/map_proto2_unittest.proto \ |
||||||
|
src/google/protobuf/map_unittest.proto \ |
||||||
|
) |
||||||
|
|
||||||
|
compile_proto() { |
||||||
|
src/protoc \ |
||||||
|
--objc_out="${OUTPUT_DIR}/google/protobuf" \ |
||||||
|
--proto_path=src/google/protobuf/ \ |
||||||
|
--proto_path=src \ |
||||||
|
$* |
||||||
|
} |
||||||
|
|
||||||
|
for a_proto in "${CORE_PROTO_FILES[@]}" ; do |
||||||
|
compile_proto "${a_proto}" |
||||||
|
done |
||||||
|
|
||||||
|
OBJC_PROTO_FILES=( \ |
||||||
|
objectivec/Tests/unittest_cycle.proto \ |
||||||
|
objectivec/Tests/unittest_runtime_proto2.proto \ |
||||||
|
objectivec/Tests/unittest_runtime_proto3.proto \ |
||||||
|
objectivec/Tests/unittest_objc.proto \ |
||||||
|
objectivec/Tests/unittest_objc_startup.proto \ |
||||||
|
) |
||||||
|
|
||||||
|
for a_proto in "${OBJC_PROTO_FILES[@]}" ; do |
||||||
|
compile_proto --proto_path="objectivec/Tests" "${a_proto}" |
||||||
|
done |
@ -1,525 +0,0 @@ |
|||||||
// 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 "GPBExtensionField_PackagePrivate.h" |
|
||||||
|
|
||||||
#import <objc/runtime.h> |
|
||||||
|
|
||||||
#import "GPBCodedInputStream_PackagePrivate.h" |
|
||||||
#import "GPBCodedOutputStream.h" |
|
||||||
#import "GPBDescriptor_PackagePrivate.h" |
|
||||||
#import "GPBMessage_PackagePrivate.h" |
|
||||||
#import "GPBUtilities_PackagePrivate.h" |
|
||||||
|
|
||||||
GPB_INLINE size_t TypeSize(GPBType type) { |
|
||||||
switch (type) { |
|
||||||
case GPBTypeBool: |
|
||||||
return 1; |
|
||||||
case GPBTypeFixed32: |
|
||||||
case GPBTypeSFixed32: |
|
||||||
case GPBTypeFloat: |
|
||||||
return 4; |
|
||||||
case GPBTypeFixed64: |
|
||||||
case GPBTypeSFixed64: |
|
||||||
case GPBTypeDouble: |
|
||||||
return 8; |
|
||||||
default: |
|
||||||
return 0; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
GPB_INLINE BOOL ExtensionIsRepeated(GPBExtensionDescription *description) { |
|
||||||
return (description->options & GPBExtensionRepeated) != 0; |
|
||||||
} |
|
||||||
|
|
||||||
GPB_INLINE BOOL ExtensionIsPacked(GPBExtensionDescription *description) { |
|
||||||
return (description->options & GPBExtensionPacked) != 0; |
|
||||||
} |
|
||||||
|
|
||||||
GPB_INLINE BOOL ExtensionIsWireFormat(GPBExtensionDescription *description) { |
|
||||||
return (description->options & GPBExtensionSetWireFormat) != 0; |
|
||||||
} |
|
||||||
|
|
||||||
static size_t ComputePBSerializedSizeNoTagOfObject(GPBType type, id object) { |
|
||||||
#define FIELD_CASE(TYPE, ACCESSOR) \ |
|
||||||
case GPBType##TYPE: \ |
|
||||||
return GPBCompute##TYPE##SizeNoTag([(NSNumber *)object ACCESSOR]); |
|
||||||
#define FIELD_CASE2(TYPE) \ |
|
||||||
case GPBType##TYPE: \ |
|
||||||
return GPBCompute##TYPE##SizeNoTag(object); |
|
||||||
switch (type) { |
|
||||||
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(Data) |
|
||||||
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 GPBType##TYPE: \ |
|
||||||
return GPBCompute##TYPE##Size(description->fieldNumber, \ |
|
||||||
[(NSNumber *)object ACCESSOR]); |
|
||||||
#define FIELD_CASE2(TYPE) \ |
|
||||||
case GPBType##TYPE: \ |
|
||||||
return GPBCompute##TYPE##Size(description->fieldNumber, object); |
|
||||||
switch (description->type) { |
|
||||||
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(Data) |
|
||||||
FIELD_CASE2(String) |
|
||||||
FIELD_CASE2(Group) |
|
||||||
case GPBTypeMessage: |
|
||||||
if (ExtensionIsWireFormat(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 (ExtensionIsPacked(description)) { |
|
||||||
size_t size = 0; |
|
||||||
size_t typeSize = TypeSize(description->type); |
|
||||||
if (typeSize != 0) { |
|
||||||
size = values.count * typeSize; |
|
||||||
} else { |
|
||||||
for (id value in values) { |
|
||||||
size += ComputePBSerializedSizeNoTagOfObject(description->type, 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 GPBType##TYPE: \ |
|
||||||
[output write##TYPE:description->fieldNumber \ |
|
||||||
value:[(NSNumber *)object ACCESSOR]]; \ |
|
||||||
return; |
|
||||||
#define FIELD_CASE2(TYPE) \ |
|
||||||
case GPBType##TYPE: \ |
|
||||||
[output write##TYPE:description->fieldNumber value:object]; \ |
|
||||||
return; |
|
||||||
switch (description->type) { |
|
||||||
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(Data) |
|
||||||
FIELD_CASE2(String) |
|
||||||
FIELD_CASE2(Group) |
|
||||||
case GPBTypeMessage: |
|
||||||
if (ExtensionIsWireFormat(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 GPBType##TYPE: \ |
|
||||||
[output write##TYPE##NoTag:[(NSNumber *)object ACCESSOR]]; \ |
|
||||||
return; |
|
||||||
#define FIELD_CASE2(TYPE) \ |
|
||||||
case GPBType##TYPE: \ |
|
||||||
[output write##TYPE##NoTag:object]; \ |
|
||||||
return; |
|
||||||
switch (description->type) { |
|
||||||
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(Data) |
|
||||||
FIELD_CASE2(String) |
|
||||||
FIELD_CASE2(Message) |
|
||||||
case GPBTypeGroup: |
|
||||||
[output writeGroupNoTag:description->fieldNumber value:object]; |
|
||||||
return; |
|
||||||
} |
|
||||||
#undef FIELD_CASE |
|
||||||
#undef FIELD_CASE2 |
|
||||||
} |
|
||||||
|
|
||||||
static void WriteArrayIncludingTagsToCodedOutputStream( |
|
||||||
NSArray *values, GPBExtensionDescription *description, |
|
||||||
GPBCodedOutputStream *output) { |
|
||||||
if (ExtensionIsPacked(description)) { |
|
||||||
[output writeTag:description->fieldNumber |
|
||||||
format:GPBWireFormatLengthDelimited]; |
|
||||||
size_t dataSize = 0; |
|
||||||
size_t typeSize = TypeSize(description->type); |
|
||||||
if (typeSize != 0) { |
|
||||||
dataSize = values.count * typeSize; |
|
||||||
} else { |
|
||||||
for (id value in values) { |
|
||||||
dataSize += |
|
||||||
ComputePBSerializedSizeNoTagOfObject(description->type, value); |
|
||||||
} |
|
||||||
} |
|
||||||
[output writeRawVarintSizeTAs32:dataSize]; |
|
||||||
for (id value in values) { |
|
||||||
WriteObjectNoTagToCodedOutputStream(value, description, output); |
|
||||||
} |
|
||||||
} else { |
|
||||||
for (id value in values) { |
|
||||||
WriteObjectIncludingTagToCodedOutputStream(value, description, output); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@implementation GPBExtensionField { |
|
||||||
GPBExtensionDescription *description_; |
|
||||||
GPBExtensionDescriptor *descriptor_; |
|
||||||
GPBValue defaultValue_; |
|
||||||
} |
|
||||||
|
|
||||||
@synthesize containingType = containingType_; |
|
||||||
@synthesize descriptor = descriptor_; |
|
||||||
|
|
||||||
- (instancetype)init { |
|
||||||
// Throw an exception if people attempt to not use the designated initializer. |
|
||||||
self = [super init]; |
|
||||||
if (self != nil) { |
|
||||||
[self doesNotRecognizeSelector:_cmd]; |
|
||||||
self = nil; |
|
||||||
} |
|
||||||
return self; |
|
||||||
} |
|
||||||
|
|
||||||
- (instancetype)initWithDescription:(GPBExtensionDescription *)description { |
|
||||||
if ((self = [super init])) { |
|
||||||
description_ = description; |
|
||||||
if (description->extendedClass) { |
|
||||||
Class containingClass = objc_lookUpClass(description->extendedClass); |
|
||||||
NSAssert1(containingClass, @"Class %s not defined", |
|
||||||
description->extendedClass); |
|
||||||
containingType_ = [containingClass descriptor]; |
|
||||||
} |
|
||||||
#if DEBUG |
|
||||||
const char *className = description->messageOrGroupClassName; |
|
||||||
if (className) { |
|
||||||
NSAssert1(objc_lookUpClass(className) != Nil, @"Class %s not defined", |
|
||||||
className); |
|
||||||
} |
|
||||||
#endif |
|
||||||
descriptor_ = [[GPBExtensionDescriptor alloc] |
|
||||||
initWithExtensionDescription:description]; |
|
||||||
GPBType type = description_->type; |
|
||||||
if (type == GPBTypeData) { |
|
||||||
// Data stored as a length prefixed c-string in descriptor records. |
|
||||||
const uint8_t *bytes = |
|
||||||
(const uint8_t *)description->defaultValue.valueData; |
|
||||||
if (bytes) { |
|
||||||
uint32_t length = *((uint32_t *)bytes); |
|
||||||
// The length is stored in network byte order. |
|
||||||
length = ntohl(length); |
|
||||||
bytes += sizeof(length); |
|
||||||
defaultValue_.valueData = |
|
||||||
[[NSData alloc] initWithBytes:bytes length:length]; |
|
||||||
} |
|
||||||
} else if (type == GPBTypeMessage || type == GPBTypeGroup) { |
|
||||||
// The default is looked up in -defaultValue instead since extensions |
|
||||||
// aren't |
|
||||||
// common, we avoid the hit startup hit and it avoid initialization order |
|
||||||
// issues. |
|
||||||
} else { |
|
||||||
defaultValue_ = description->defaultValue; |
|
||||||
} |
|
||||||
} |
|
||||||
return self; |
|
||||||
} |
|
||||||
|
|
||||||
- (void)dealloc { |
|
||||||
if ((description_->type == GPBTypeData) && |
|
||||||
!ExtensionIsRepeated(description_)) { |
|
||||||
[defaultValue_.valueData release]; |
|
||||||
} |
|
||||||
[descriptor_ release]; |
|
||||||
[super dealloc]; |
|
||||||
} |
|
||||||
|
|
||||||
- (NSString *)description { |
|
||||||
return [NSString stringWithFormat:@"<%@ %p> FieldNumber:%d ContainingType:%@", |
|
||||||
[self class], self, self.fieldNumber, |
|
||||||
self.containingType]; |
|
||||||
} |
|
||||||
|
|
||||||
- (id)copyWithZone:(NSZone *)__unused zone { |
|
||||||
return [self retain]; |
|
||||||
} |
|
||||||
|
|
||||||
#pragma mark Properties |
|
||||||
|
|
||||||
- (int32_t)fieldNumber { |
|
||||||
return description_->fieldNumber; |
|
||||||
} |
|
||||||
|
|
||||||
- (GPBWireFormat)wireType { |
|
||||||
return GPBWireFormatForType(description_->type, |
|
||||||
ExtensionIsPacked(description_)); |
|
||||||
} |
|
||||||
|
|
||||||
- (BOOL)isRepeated { |
|
||||||
return ExtensionIsRepeated(description_); |
|
||||||
} |
|
||||||
|
|
||||||
- (id)defaultValue { |
|
||||||
if (ExtensionIsRepeated(description_)) { |
|
||||||
return nil; |
|
||||||
} |
|
||||||
|
|
||||||
switch (description_->type) { |
|
||||||
case GPBTypeBool: |
|
||||||
return @(defaultValue_.valueBool); |
|
||||||
case GPBTypeFloat: |
|
||||||
return @(defaultValue_.valueFloat); |
|
||||||
case GPBTypeDouble: |
|
||||||
return @(defaultValue_.valueDouble); |
|
||||||
case GPBTypeInt32: |
|
||||||
case GPBTypeSInt32: |
|
||||||
case GPBTypeEnum: |
|
||||||
case GPBTypeSFixed32: |
|
||||||
return @(defaultValue_.valueInt32); |
|
||||||
case GPBTypeInt64: |
|
||||||
case GPBTypeSInt64: |
|
||||||
case GPBTypeSFixed64: |
|
||||||
return @(defaultValue_.valueInt64); |
|
||||||
case GPBTypeUInt32: |
|
||||||
case GPBTypeFixed32: |
|
||||||
return @(defaultValue_.valueUInt32); |
|
||||||
case GPBTypeUInt64: |
|
||||||
case GPBTypeFixed64: |
|
||||||
return @(defaultValue_.valueUInt64); |
|
||||||
case GPBTypeData: |
|
||||||
// Like message fields, the default is zero length data. |
|
||||||
return (defaultValue_.valueData ? defaultValue_.valueData |
|
||||||
: GPBEmptyNSData()); |
|
||||||
case GPBTypeString: |
|
||||||
// Like message fields, the default is zero length string. |
|
||||||
return (defaultValue_.valueString ? defaultValue_.valueString : @""); |
|
||||||
case GPBTypeGroup: |
|
||||||
case GPBTypeMessage: |
|
||||||
NSAssert(0, @"Shouldn't get here"); |
|
||||||
return nil; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#pragma mark Internals |
|
||||||
|
|
||||||
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input |
|
||||||
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry |
|
||||||
message:(GPBMessage *)message { |
|
||||||
GPBCodedInputStreamState *state = &input->state_; |
|
||||||
if (ExtensionIsPacked(description_)) { |
|
||||||
int32_t length = GPBCodedInputStreamReadInt32(state); |
|
||||||
size_t limit = GPBCodedInputStreamPushLimit(state, length); |
|
||||||
while (GPBCodedInputStreamBytesUntilLimit(state) > 0) { |
|
||||||
id value = [self newSingleValueFromCodedInputStream:input |
|
||||||
extensionRegistry:extensionRegistry |
|
||||||
existingValue:nil]; |
|
||||||
[message addExtension:self value:value]; |
|
||||||
[value release]; |
|
||||||
} |
|
||||||
GPBCodedInputStreamPopLimit(state, limit); |
|
||||||
} else { |
|
||||||
id existingValue = nil; |
|
||||||
BOOL isRepeated = ExtensionIsRepeated(description_); |
|
||||||
if (!isRepeated && GPBTypeIsMessage(description_->type)) { |
|
||||||
existingValue = [message getExistingExtension:self]; |
|
||||||
} |
|
||||||
id value = [self newSingleValueFromCodedInputStream:input |
|
||||||
extensionRegistry:extensionRegistry |
|
||||||
existingValue:existingValue]; |
|
||||||
if (isRepeated) { |
|
||||||
[message addExtension:self value:value]; |
|
||||||
} else { |
|
||||||
[message setExtension:self value:value]; |
|
||||||
} |
|
||||||
[value release]; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
- (void)writeValue:(id)value |
|
||||||
includingTagToCodedOutputStream:(GPBCodedOutputStream *)output { |
|
||||||
if (ExtensionIsRepeated(description_)) { |
|
||||||
WriteArrayIncludingTagsToCodedOutputStream(value, description_, output); |
|
||||||
} else { |
|
||||||
WriteObjectIncludingTagToCodedOutputStream(value, description_, output); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
- (size_t)computeSerializedSizeIncludingTag:(id)value { |
|
||||||
if (ExtensionIsRepeated(description_)) { |
|
||||||
return ComputeSerializedSizeIncludingTagOfArray(description_, value); |
|
||||||
} else { |
|
||||||
return ComputeSerializedSizeIncludingTagOfObject(description_, value); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// Note that this returns a retained value intentionally. |
|
||||||
- (id)newSingleValueFromCodedInputStream:(GPBCodedInputStream *)input |
|
||||||
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry |
|
||||||
existingValue:(GPBMessage *)existingValue { |
|
||||||
GPBCodedInputStreamState *state = &input->state_; |
|
||||||
switch (description_->type) { |
|
||||||
case GPBTypeBool: return [[NSNumber alloc] initWithBool:GPBCodedInputStreamReadBool(state)]; |
|
||||||
case GPBTypeFixed32: return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadFixed32(state)]; |
|
||||||
case GPBTypeSFixed32: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSFixed32(state)]; |
|
||||||
case GPBTypeFloat: return [[NSNumber alloc] initWithFloat:GPBCodedInputStreamReadFloat(state)]; |
|
||||||
case GPBTypeFixed64: return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadFixed64(state)]; |
|
||||||
case GPBTypeSFixed64: return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSFixed64(state)]; |
|
||||||
case GPBTypeDouble: return [[NSNumber alloc] initWithDouble:GPBCodedInputStreamReadDouble(state)]; |
|
||||||
case GPBTypeInt32: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadInt32(state)]; |
|
||||||
case GPBTypeInt64: return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadInt64(state)]; |
|
||||||
case GPBTypeSInt32: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSInt32(state)]; |
|
||||||
case GPBTypeSInt64: return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSInt64(state)]; |
|
||||||
case GPBTypeUInt32: return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadUInt32(state)]; |
|
||||||
case GPBTypeUInt64: return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadUInt64(state)]; |
|
||||||
case GPBTypeData: return GPBCodedInputStreamReadRetainedData(state); |
|
||||||
case GPBTypeString: return GPBCodedInputStreamReadRetainedString(state); |
|
||||||
case GPBTypeEnum: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadEnum(state)]; |
|
||||||
case GPBTypeGroup: |
|
||||||
case GPBTypeMessage: { |
|
||||||
GPBMessage *message; |
|
||||||
if (existingValue) { |
|
||||||
message = [existingValue retain]; |
|
||||||
} else { |
|
||||||
GPBDescriptor *decriptor = [descriptor_.msgClass descriptor]; |
|
||||||
message = [[decriptor.messageClass alloc] init]; |
|
||||||
} |
|
||||||
|
|
||||||
if (description_->type == GPBTypeGroup) { |
|
||||||
[input readGroup:description_->fieldNumber |
|
||||||
message:message |
|
||||||
extensionRegistry:extensionRegistry]; |
|
||||||
} else { |
|
||||||
// description_->type == GPBTypeMessage |
|
||||||
if (ExtensionIsWireFormat(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; |
|
||||||
} |
|
||||||
|
|
||||||
- (NSComparisonResult)compareByFieldNumber:(GPBExtensionField *)other { |
|
||||||
int32_t selfNumber = description_->fieldNumber; |
|
||||||
int32_t otherNumber = other->description_->fieldNumber; |
|
||||||
if (selfNumber < otherNumber) { |
|
||||||
return NSOrderedAscending; |
|
||||||
} else if (selfNumber == otherNumber) { |
|
||||||
return NSOrderedSame; |
|
||||||
} else { |
|
||||||
return NSOrderedDescending; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@end |
|
@ -1,51 +0,0 @@ |
|||||||
// 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 "GPBExtensionField.h" |
|
||||||
|
|
||||||
struct GPBExtensionDescription; |
|
||||||
|
|
||||||
@interface GPBExtensionField () |
|
||||||
|
|
||||||
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input |
|
||||||
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry |
|
||||||
message:(GPBMessage *)message; |
|
||||||
|
|
||||||
- (instancetype)initWithDescription:(struct GPBExtensionDescription *)description; |
|
||||||
|
|
||||||
- (size_t)computeSerializedSizeIncludingTag:(id)value; |
|
||||||
- (void)writeValue:(id)value |
|
||||||
includingTagToCodedOutputStream:(GPBCodedOutputStream *)output; |
|
||||||
|
|
||||||
- (NSComparisonResult)compareByFieldNumber:(GPBExtensionField *)other; |
|
||||||
|
|
||||||
@end |
|
@ -0,0 +1,380 @@ |
|||||||
|
// 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.h" |
||||||
|
#import "GPBDescriptor_PackagePrivate.h" |
||||||
|
#import "GPBMessage_PackagePrivate.h" |
||||||
|
#import "GPBUtilities_PackagePrivate.h" |
||||||
|
|
||||||
|
static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension, |
||||||
|
GPBCodedInputStream *input, |
||||||
|
GPBExtensionRegistry *extensionRegistry, |
||||||
|
GPBMessage *existingValue) |
||||||
|
__attribute__((ns_returns_retained)); |
||||||
|
|
||||||
|
GPB_INLINE size_t DataTypeSize(GPBDataType dataType) { |
||||||
|
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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
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); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, |
||||||
|
BOOL isPackedOnStream, |
||||||
|
GPBCodedInputStream *input, |
||||||
|
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, |
||||||
|
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 *decriptor = [extension.msgClass descriptor]; |
||||||
|
message = [[decriptor.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; |
||||||
|
} |
@ -1,35 +0,0 @@ |
|||||||
// Protocol Buffers - Google's data interchange format |
|
||||||
// Copyright 2014 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. |
|
||||||
|
|
||||||
|
|
||||||
// Test the filter system for the ObjC Protocol Buffer Compiler to test |
|
||||||
// multiple filter support. |
|
||||||
|
|
||||||
Other |
|
@ -1,98 +0,0 @@ |
|||||||
// Protocol Buffers - Google's data interchange format |
|
||||||
// Copyright 2013 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 our filter system for ObjC. |
|
||||||
// The proto being filtered is unittest_filter.proto. |
|
||||||
// The filter file is Filter.txt. |
|
||||||
|
|
||||||
#import "GPBTestUtilities.h" |
|
||||||
|
|
||||||
#import "google/protobuf/UnittestFilter.pbobjc.h" |
|
||||||
|
|
||||||
// If we get an error about this already being defined, it is most likely |
|
||||||
// because of an error in protoc which is supposed to be filtering |
|
||||||
// the Remove message. |
|
||||||
enum { Other_FieldNumber_B = 0 }; |
|
||||||
|
|
||||||
@interface FilteredMessageTests : GPBTestCase |
|
||||||
@end |
|
||||||
|
|
||||||
@implementation FilteredMessageTests |
|
||||||
|
|
||||||
- (void)testEnumFiltering { |
|
||||||
// If compile fails here it is because protoc did not generate KeepEnum. |
|
||||||
XCTAssertTrue(KeepEnum_IsValidValue(KeepEnum_KeepValue)); |
|
||||||
XCTAssertNotNil(KeepEnum_EnumDescriptor()); |
|
||||||
|
|
||||||
// If compile fails here it is because protoc did not generate |
|
||||||
// KeepEnumInsideEnum and is probably due to nested enum handling being |
|
||||||
// broken. |
|
||||||
XCTAssertTrue(RemoveEnumMessage_KeepEnumInside_IsValidValue( |
|
||||||
RemoveEnumMessage_KeepEnumInside_KeepValue)); |
|
||||||
XCTAssertNotNil(RemoveEnumMessage_KeepEnumInside_EnumDescriptor()); |
|
||||||
} |
|
||||||
|
|
||||||
- (void)testMessageFiltering { |
|
||||||
// Messages that should be generated. |
|
||||||
XCTAssertNil([UnittestFilterRoot extensionRegistry]); |
|
||||||
XCTAssertNotNil([[[Keep alloc] init] autorelease]); |
|
||||||
XCTAssertNotNil([[[Other alloc] init] autorelease]); |
|
||||||
XCTAssertNotNil([[[RemoveJustKidding alloc] init] autorelease]); |
|
||||||
XCTAssertNotNil( |
|
||||||
[[[RemoveEnumMessage_KeepNestedInside alloc] init] autorelease]); |
|
||||||
|
|
||||||
// Messages that should not be generated |
|
||||||
XCTAssertNil(NSClassFromString(@"Remove")); |
|
||||||
XCTAssertNil(NSClassFromString(@"RemoveEnumMessage")); |
|
||||||
XCTAssertNil(NSClassFromString(@"RemoveEnumMessage_RemoveNestedInside")); |
|
||||||
|
|
||||||
// These should all fail compile if protoc is bad. |
|
||||||
XCTAssertTrue([Other instancesRespondToSelector:@selector(hasA)]); |
|
||||||
XCTAssertTrue([Other instancesRespondToSelector:@selector(setHasA:)]); |
|
||||||
XCTAssertTrue([Other instancesRespondToSelector:@selector(a)]); |
|
||||||
XCTAssertTrue([Other instancesRespondToSelector:@selector(setA:)]); |
|
||||||
|
|
||||||
// These the compiler should not generate. |
|
||||||
XCTAssertFalse( |
|
||||||
[Other instancesRespondToSelector:NSSelectorFromString(@"hasB")]); |
|
||||||
XCTAssertFalse( |
|
||||||
[Other instancesRespondToSelector:NSSelectorFromString(@"setHasB:")]); |
|
||||||
XCTAssertFalse([Other instancesRespondToSelector:NSSelectorFromString(@"b")]); |
|
||||||
XCTAssertFalse( |
|
||||||
[Other instancesRespondToSelector:NSSelectorFromString(@"setB:")]); |
|
||||||
|
|
||||||
// This should fail if protoc filters it. |
|
||||||
XCTAssertEqual(Other_FieldNumber_A, 1); |
|
||||||
|
|
||||||
// Make sure the definition at the top of the file is providing the value. |
|
||||||
XCTAssertEqual(Other_FieldNumber_B, 0); |
|
||||||
} |
|
||||||
|
|
||||||
@end |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
@ -1,71 +0,0 @@ |
|||||||
// Protocol Buffers - Google's data interchange format |
|
||||||
// Copyright 2013 Google Inc. All rights reserved. |
|
||||||
// |
|
||||||
// Redistribution and use in source and binary forms, with or without |
|
||||||
// modification, are permitted provided that the following conditions are |
|
||||||
// met: |
|
||||||
// |
|
||||||
// * Redistributions of source code must retain the above copyright |
|
||||||
// notice, this list of conditions and the following disclaimer. |
|
||||||
// * Redistributions in binary form must reproduce the above |
|
||||||
// copyright notice, this list of conditions and the following disclaimer |
|
||||||
// in the documentation and/or other materials provided with the |
|
||||||
// distribution. |
|
||||||
// * Neither the name of Google Inc. nor the names of its |
|
||||||
// contributors may be used to endorse or promote products derived from |
|
||||||
// this software without specific prior written permission. |
|
||||||
// |
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
syntax = "proto2"; |
|
||||||
|
|
||||||
package protobuf_unittest; |
|
||||||
|
|
||||||
|
|
||||||
message Keep { |
|
||||||
} |
|
||||||
|
|
||||||
message Remove { |
|
||||||
} |
|
||||||
|
|
||||||
message RemoveJustKidding { |
|
||||||
} |
|
||||||
|
|
||||||
message Other { |
|
||||||
optional Keep a = 1; |
|
||||||
optional Remove b = 2; |
|
||||||
} |
|
||||||
|
|
||||||
enum RemoveEnum { |
|
||||||
RemoveValue = 1; |
|
||||||
} |
|
||||||
|
|
||||||
enum KeepEnum { |
|
||||||
KeepValue = 1; |
|
||||||
} |
|
||||||
|
|
||||||
message RemoveEnumMessage { |
|
||||||
enum KeepEnumInside { |
|
||||||
KeepValue = 1; |
|
||||||
} |
|
||||||
|
|
||||||
enum RemoveEnumInside { |
|
||||||
RemoveValue = 1; |
|
||||||
} |
|
||||||
|
|
||||||
message KeepNestedInside { |
|
||||||
} |
|
||||||
|
|
||||||
message RemoveNestedInside { |
|
||||||
} |
|
||||||
} |
|
@ -1,37 +0,0 @@ |
|||||||
// Protocol Buffers - Google's data interchange format |
|
||||||
// Copyright 2015 Google Inc. All rights reserved. |
|
||||||
// |
|
||||||
// Redistribution and use in source and binary forms, with or without |
|
||||||
// modification, are permitted provided that the following conditions are |
|
||||||
// met: |
|
||||||
// |
|
||||||
// * Redistributions of source code must retain the above copyright |
|
||||||
// notice, this list of conditions and the following disclaimer. |
|
||||||
// * Redistributions in binary form must reproduce the above |
|
||||||
// copyright notice, this list of conditions and the following disclaimer |
|
||||||
// in the documentation and/or other materials provided with the |
|
||||||
// distribution. |
|
||||||
// * Neither the name of Google Inc. nor the names of its |
|
||||||
// contributors may be used to endorse or promote products derived from |
|
||||||
// this software without specific prior written permission. |
|
||||||
// |
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
syntax = "proto2"; |
|
||||||
|
|
||||||
option objc_class_prefix = "ABC"; |
|
||||||
|
|
||||||
package protobuf_unittest; |
|
||||||
|
|
||||||
// TODO(thomasvl): Add tests for the special cases in name mangling. |
|
||||||
|
|