PROTOBUF_SYNC_PIPER
pull/9652/head
Adam Cozzette 3 years ago
commit a336ba0346
  1. 348
      CMakeLists.txt
  2. BIN
      csharp/src/Google.Protobuf.Test/testprotos.pb
  3. 2
      csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
  4. 4
      java/core/src/main/java/com/google/protobuf/AbstractMessage.java
  5. 3
      java/core/src/main/java/com/google/protobuf/TextFormat.java
  6. 89
      java/core/src/main/java/com/google/protobuf/Utf8.java
  7. 12
      java/core/src/test/java/com/google/protobuf/DecodeUtf8Test.java
  8. 1
      kokoro/linux/dockerfile/test/ruby/Dockerfile
  9. 18
      kokoro/linux/ruby31/build.sh
  10. 11
      kokoro/linux/ruby31/continuous.cfg
  11. 11
      kokoro/linux/ruby31/presubmit.cfg
  12. 2
      kokoro/macos/prepare_build_macos_rc
  13. 12
      kokoro/macos/ruby31/build.sh
  14. 5
      kokoro/macos/ruby31/continuous.cfg
  15. 5
      kokoro/macos/ruby31/presubmit.cfg
  16. 40
      kokoro/release/ruby/macos/ruby/ruby_build_environment.sh
  17. 2
      objectivec/GPBEmpty.pbobjc.h
  18. 45
      php/ext/google/protobuf/php_protobuf.h
  19. 1
      php/src/Google/Protobuf/GPBEmpty.php
  20. 39
      python/google/protobuf/internal/decoder.py
  21. 119
      python/google/protobuf/internal/unknown_fields_test.py
  22. 43
      python/google/protobuf/text_format.py
  23. 125
      python/google/protobuf/unknown_fields.py
  24. 7
      python/setup.py
  25. 4
      ruby/Rakefile
  26. 1
      ruby/compatibility_tests/v3.0.0/tests/repeated_field_test.rb
  27. 8
      ruby/ext/google/protobuf_c/convert.c
  28. 38
      ruby/ext/google/protobuf_c/message.c
  29. 4
      ruby/ext/google/protobuf_c/protobuf.c
  30. 699
      ruby/ext/google/protobuf_c/ruby-upb.c
  31. 1100
      ruby/ext/google/protobuf_c/ruby-upb.h
  32. 3
      ruby/google-protobuf.gemspec
  33. 1
      ruby/tests/repeated_field_test.rb
  34. 4
      src/README.md
  35. 1
      src/google/protobuf/arena_test_util.cc
  36. 2
      src/google/protobuf/arena_test_util.h
  37. 6
      src/google/protobuf/arena_unittest.cc
  38. 18
      src/google/protobuf/compiler/cpp/cpp_unittest.inc
  39. 11
      src/google/protobuf/compiler/java/java_doc_comment_unittest.cc
  40. 20
      src/google/protobuf/compiler/java/java_helpers.cc
  41. 25
      src/google/protobuf/compiler/java/java_plugin_unittest.cc
  42. 1
      src/google/protobuf/compiler/plugin.cc
  43. 5
      src/google/protobuf/compiler/python/python_plugin_unittest.cc
  44. 1
      src/google/protobuf/empty.proto
  45. 3
      src/google/protobuf/extension_set_heavy.cc
  46. 14
      src/google/protobuf/extension_set_unittest.cc
  47. 22
      src/google/protobuf/generated_message_reflection_unittest.cc
  48. 10
      src/google/protobuf/lite_unittest.cc
  49. 4
      src/google/protobuf/map_field_test.cc
  50. 1
      src/google/protobuf/map_lite_test_util.cc
  51. 14
      src/google/protobuf/map_test.inc
  52. 2
      src/google/protobuf/map_test_util.inc
  53. 20
      src/google/protobuf/repeated_ptr_field.h
  54. 5
      tests.sh
  55. 43
      toolchain/BUILD
  56. 22
      toolchain/cc_toolchain_config.bzl
  57. 7
      update_file_lists.sh

@ -0,0 +1,348 @@
# Minimum CMake required
cmake_minimum_required(VERSION 3.5)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Configuring...")
endif()
# CMake policies
cmake_policy(SET CMP0022 NEW)
# On MacOS use @rpath/ for target's install name prefix path
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif ()
# Clear VERSION variables when no VERSION is given to project()
if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()
# MSVC runtime library flags are selected by an abstraction.
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
# Project
project(protobuf C CXX)
if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE)
if(CMAKE_PROJECT_NAME STREQUAL "protobuf")
get_filename_component(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} DIRECTORY)
endif()
get_filename_component(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
get_filename_component(PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
get_filename_component(protobuf_SOURCE_DIR ${protobuf_SOURCE_DIR} DIRECTORY)
endif()
# Add c++11 flags
if (CYGWIN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
else()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
# The Intel compiler isn't able to deal with noinline member functions of
# template classes defined in headers. As such it spams the output with
# warning #2196: routine is both "inline" and "noinline"
# This silences that warning.
if (CMAKE_CXX_COMPILER_ID MATCHES Intel)
string(APPEND CMAKE_CXX_FLAGS " -diag-disable=2196")
endif()
# Options
option(protobuf_INSTALL "Install protobuf binaries and files" ON)
if(WITH_PROTOC)
set(protobuf_PROTOC_EXE ${WITH_PROTOC} CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE)
endif()
option(protobuf_BUILD_TESTS "Build tests" ON)
option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF)
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
option(protobuf_BUILD_PROTOC_BINARIES "Build libprotoc and protoc compiler" ON)
option(protobuf_BUILD_LIBPROTOC "Build libprotoc" OFF)
option(protobuf_DISABLE_RTTI "Remove runtime type information in the binaries" OFF)
if (BUILD_SHARED_LIBS)
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
else (BUILD_SHARED_LIBS)
set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF)
endif (BUILD_SHARED_LIBS)
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})
include(CMakeDependentOption)
cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON
"NOT protobuf_BUILD_SHARED_LIBS" OFF)
set(protobuf_WITH_ZLIB_DEFAULT ON)
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
set(protobuf_DEBUG_POSTFIX "d"
CACHE STRING "Default debug postfix")
mark_as_advanced(protobuf_DEBUG_POSTFIX)
# User options
include(${protobuf_SOURCE_DIR}/cmake/protobuf-options.cmake)
# Overrides for option dependencies
if (protobuf_BUILD_PROTOC_BINARIES OR protobuf_BUILD_TESTS)
set(protobuf_BUILD_LIBPROTOC ON)
endif ()
# Path to main configure script
set(protobuf_CONFIGURE_SCRIPT "${protobuf_SOURCE_DIR}/configure.ac")
# Parse configure script
set(protobuf_AC_INIT_REGEX
"^AC_INIT\\(\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\]\\)$")
file(STRINGS "${protobuf_CONFIGURE_SCRIPT}" protobuf_AC_INIT_LINE
LIMIT_COUNT 1 REGEX "^AC_INIT")
# Description
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\1"
protobuf_DESCRIPTION "${protobuf_AC_INIT_LINE}")
# Version
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2"
protobuf_VERSION_STRING "${protobuf_AC_INIT_LINE}")
# Contact
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3"
protobuf_CONTACT "${protobuf_AC_INIT_LINE}")
# Parse version tweaks
set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+)([-]rc[-]|\\.)?([0-9]*)$")
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1"
protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}")
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2"
protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}")
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3"
protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}")
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\5"
protobuf_VERSION_PRERELEASE "${protobuf_VERSION_STRING}")
message(STATUS "${protobuf_VERSION_PRERELEASE}")
# Package version
set(protobuf_VERSION
"${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}")
if(protobuf_VERSION_PRERELEASE)
set(protobuf_VERSION "${protobuf_VERSION}.${protobuf_VERSION_PRERELEASE}")
else()
set(protobuf_VERSION "${protobuf_VERSION}.0")
endif()
message(STATUS "${protobuf_VERSION}")
if(protobuf_VERBOSE)
message(STATUS "Configuration script parsing status [")
message(STATUS " Description : ${protobuf_DESCRIPTION}")
message(STATUS " Version : ${protobuf_VERSION} (${protobuf_VERSION_STRING})")
message(STATUS " Contact : ${protobuf_CONTACT}")
message(STATUS "]")
endif()
add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD)
if (protobuf_DISABLE_RTTI)
add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map
"{
global:
main;
local:
*;
};")
# CheckLinkerFlag module available in CMake >=3.18.
if(${CMAKE_VERSION} VERSION_GREATER 3.18 OR ${CMAKE_VERSION} VERSION_EQUAL 3.18)
include(CheckLinkerFlag)
check_linker_flag(CXX -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map protobuf_HAVE_LD_VERSION_SCRIPT)
else()
include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
check_cxx_source_compiles("
int main() {
return 0;
}
" protobuf_HAVE_LD_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endif()
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
find_package(Threads REQUIRED)
set(_protobuf_FIND_ZLIB)
if (protobuf_WITH_ZLIB)
find_package(ZLIB)
if (ZLIB_FOUND)
set(HAVE_ZLIB 1)
# FindZLIB module define ZLIB_INCLUDE_DIRS variable
# Set ZLIB_INCLUDE_DIRECTORIES for compatible
set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS})
# Using imported target if exists
if (TARGET ZLIB::ZLIB)
set(ZLIB_LIBRARIES ZLIB::ZLIB)
set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()")
endif (TARGET ZLIB::ZLIB)
else (ZLIB_FOUND)
set(HAVE_ZLIB 0)
# Explicitly set these to empty (override NOT_FOUND) so cmake doesn't
# complain when we use them later.
set(ZLIB_INCLUDE_DIRECTORIES)
set(ZLIB_LIBRARIES)
endif (ZLIB_FOUND)
endif (protobuf_WITH_ZLIB)
if (HAVE_ZLIB)
add_definitions(-DHAVE_ZLIB)
endif (HAVE_ZLIB)
# We need to link with libatomic on systems that do not have builtin atomics, or
# don't have builtin support for 8 byte atomics
set(protobuf_LINK_LIBATOMIC false)
if (NOT MSVC)
include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++11)
check_cxx_source_compiles("
#include <atomic>
int main() {
return std::atomic<int64_t>{};
}
" protobuf_HAVE_BUILTIN_ATOMICS)
if (NOT protobuf_HAVE_BUILTIN_ATOMICS)
set(protobuf_LINK_LIBATOMIC true)
endif (NOT protobuf_HAVE_BUILTIN_ATOMICS)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endif (NOT MSVC)
if (protobuf_BUILD_SHARED_LIBS)
set(protobuf_SHARED_OR_STATIC "SHARED")
else (protobuf_BUILD_SHARED_LIBS)
set(protobuf_SHARED_OR_STATIC "STATIC")
# The CMAKE_<LANG>_FLAGS(_<BUILD_TYPE>)? is meant to be user controlled.
# Prior to CMake 3.15, the MSVC runtime library was pushed into the same flags
# making programmatic control difficult. Prefer the functionality in newer
# CMake versions when available.
if(${CMAKE_VERSION} VERSION_GREATER 3.15 OR ${CMAKE_VERSION} VERSION_EQUAL 3.15)
if (protobuf_MSVC_STATIC_RUNTIME)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>DLL)
endif()
else()
# In case we are building static libraries, link also the runtime library statically
# so that MSVCR*.DLL is not required at runtime.
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
# This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
if (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
endif (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
endif()
endif (protobuf_BUILD_SHARED_LIBS)
if (MSVC)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Build with multiple processes
add_definitions(/MP)
endif()
# Set source file and execution character sets to UTF-8
add_definitions(/utf-8)
# MSVC warning suppressions
add_definitions(
/wd4065 # switch statement contains 'default' but no 'case' labels
/wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
/wd4251 # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
/wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
/wd4305 # 'identifier' : truncation from 'type1' to 'type2'
/wd4307 # 'operator' : integral constant overflow
/wd4309 # 'conversion' : truncation of constant value
/wd4334 # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
/wd4355 # 'this' : used in base member initializer list
/wd4506 # no definition for inline function 'function'
/wd4800 # 'type' : forcing value to bool 'true' or 'false' (performance warning)
/wd4996 # The compiler encountered a deprecated declaration.
)
# Allow big object
add_definitions(/bigobj)
string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
string(REPLACE "." "," protobuf_RC_FILEVERSION "${protobuf_VERSION}")
configure_file(${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in extract_includes.bat)
# Suppress linker warnings about files with no symbols defined.
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Configure Resource Compiler
enable_language(RC)
# use English language (0x409) in resource compiler
set(rc_flags "/l0x409")
# fix rc.exe invocations because of usage of add_definitions()
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${rc_flags} <DEFINES> /fo<OBJECT> <SOURCE>")
endif()
configure_file(${protobuf_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
endif (MSVC)
include_directories(
${ZLIB_INCLUDE_DIRECTORIES}
${protobuf_BINARY_DIR}
${protobuf_SOURCE_DIR}/src)
if (MSVC)
# Add the "lib" prefix for generated .lib outputs.
set(LIB_PREFIX lib)
else (MSVC)
# When building with "make", "lib" prefix will be added automatically by
# the build tool.
set(LIB_PREFIX)
endif (MSVC)
if (protobuf_UNICODE)
add_definitions(-DUNICODE -D_UNICODE)
endif (protobuf_UNICODE)
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf-lite.cmake)
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf.cmake)
if (protobuf_BUILD_LIBPROTOC)
include(${protobuf_SOURCE_DIR}/cmake/libprotoc.cmake)
endif (protobuf_BUILD_LIBPROTOC)
if (protobuf_BUILD_PROTOC_BINARIES)
include(${protobuf_SOURCE_DIR}/cmake/protoc.cmake)
if (NOT DEFINED protobuf_PROTOC_EXE)
set(protobuf_PROTOC_EXE protoc)
endif (NOT DEFINED protobuf_PROTOC_EXE)
endif (protobuf_BUILD_PROTOC_BINARIES)
# Ensure we have a protoc executable if we need one
if (protobuf_BUILD_TESTS OR protobuf_BUILD_CONFORMANCE OR protobuf_BUILD_EXAMPLES)
if (NOT DEFINED protobuf_PROTOC_EXE)
find_program(protobuf_PROTOC_EXE protoc)
if (NOT protobuf_PROTOC_EXE)
message(FATAL "Build requires 'protoc' but binary not found and not building protoc.")
endif ()
endif ()
if(protobuf_VERBOSE)
message(STATUS "Using protoc : ${protobuf_PROTOC_EXE}")
endif(protobuf_VERBOSE)
endif ()
if (protobuf_BUILD_TESTS)
enable_testing()
include(${protobuf_SOURCE_DIR}/cmake/tests.cmake)
endif (protobuf_BUILD_TESTS)
if (protobuf_BUILD_CONFORMANCE)
include(${protobuf_SOURCE_DIR}/cmake/conformance.cmake)
endif (protobuf_BUILD_CONFORMANCE)
if (protobuf_INSTALL)
include(${protobuf_SOURCE_DIR}/cmake/install.cmake)
endif (protobuf_INSTALL)
if (protobuf_BUILD_EXAMPLES)
include(${protobuf_SOURCE_DIR}/cmake/examples.cmake)
endif (protobuf_BUILD_EXAMPLES)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Configuring done")
endif(protobuf_VERBOSE)

@ -47,8 +47,6 @@ namespace Google.Protobuf.WellKnownTypes {
/// service Foo { /// service Foo {
/// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); /// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
/// } /// }
///
/// The JSON representation for `Empty` is empty JSON object `{}`.
/// </summary> /// </summary>
public sealed partial class Empty : pb::IMessage<Empty> public sealed partial class Empty : pb::IMessage<Empty>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE

@ -94,13 +94,13 @@ public abstract class AbstractMessage
return MessageReflection.delimitWithCommas(findInitializationErrors()); return MessageReflection.delimitWithCommas(findInitializationErrors());
} }
/** TODO(jieluo): Clear it when all subclasses have implemented this method. */ // TODO(jieluo): Clear it when all subclasses have implemented this method.
@Override @Override
public boolean hasOneof(OneofDescriptor oneof) { public boolean hasOneof(OneofDescriptor oneof) {
throw new UnsupportedOperationException("hasOneof() is not implemented."); throw new UnsupportedOperationException("hasOneof() is not implemented.");
} }
/** TODO(jieluo): Clear it when all subclasses have implemented this method. */ // TODO(jieluo): Clear it when all subclasses have implemented this method.
@Override @Override
public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) { public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) {
throw new UnsupportedOperationException("getOneofFieldDescriptor() is not implemented."); throw new UnsupportedOperationException("getOneofFieldDescriptor() is not implemented.");

@ -43,6 +43,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -1552,7 +1553,6 @@ public final class TextFormat {
* control the parser behavior. * control the parser behavior.
*/ */
public static class Parser { public static class Parser {
private int debugStringSilentMarker;
/** /**
* A valid silent marker appears between a field name and its value. If there is a ":" in * A valid silent marker appears between a field name and its value. If there is a ":" in
@ -1803,7 +1803,6 @@ public final class TextFormat {
while (!tokenizer.atEnd()) { while (!tokenizer.atEnd()) {
mergeField(tokenizer, extensionRegistry, target, unknownFields); mergeField(tokenizer, extensionRegistry, target, unknownFields);
} }
checkUnknownFields(unknownFields); checkUnknownFields(unknownFields);
} }

@ -42,6 +42,7 @@ import static java.lang.Character.isSurrogatePair;
import static java.lang.Character.toCodePoint; import static java.lang.Character.toCodePoint;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays;
/** /**
* A set of low-level, high-performance static utility methods related to the UTF-8 character * A set of low-level, high-performance static utility methods related to the UTF-8 character
@ -1366,88 +1367,26 @@ final class Utf8 {
@Override @Override
String decodeUtf8(byte[] bytes, int index, int size) throws InvalidProtocolBufferException { String decodeUtf8(byte[] bytes, int index, int size) throws InvalidProtocolBufferException {
if ((index | size | bytes.length - index - size) < 0) { String s = new String(bytes, index, size, Internal.UTF_8);
throw new ArrayIndexOutOfBoundsException(
String.format("buffer length=%d, index=%d, size=%d", bytes.length, index, size));
}
int offset = index + unsafeEstimateConsecutiveAscii(bytes, index, size);
final int limit = index + size;
// get an "exact" consecutive ASCII
while (offset < limit) {
byte b = UnsafeUtil.getByte(bytes, offset);
if (b < 0) {
break;
}
offset++;
}
if (offset == limit) { // "\uFFFD" is UTF-8 default replacement string, which illegal byte sequences get replaced
// The entire byte sequence is ASCII. Don't bother copying to a char[], JVMs using // with.
// compact strings will just turn it back into the same byte[]. if (!s.contains("\uFFFD")) {
return new String(bytes, index, size, Internal.US_ASCII); return s;
} }
// It's not all ASCII, at this point. This may over-allocate, but we will truncate in the // Since s contains "\uFFFD" there are 2 options:
// end. // 1) The byte array slice is invalid UTF-8.
char[] resultArr = new char[size]; // 2) The byte array slice is valid UTF-8 and contains encodings for "\uFFFD".
int resultPos = 0; // To rule out (1), we encode s and compare it to the byte array slice.
// If the byte array slice was invalid UTF-8, then we would get a different sequence of bytes.
// Copy over the initial run of ASCII. if (Arrays.equals(
for (int i = index; i < offset; i++) { s.getBytes(Internal.UTF_8), Arrays.copyOfRange(bytes, index, index + size))) {
DecodeUtil.handleOneByte(UnsafeUtil.getByte(bytes, i), resultArr, resultPos++); return s;
} }
while (offset < limit) {
byte byte1 = UnsafeUtil.getByte(bytes, offset++);
if (DecodeUtil.isOneByte(byte1)) {
DecodeUtil.handleOneByte(byte1, resultArr, resultPos++);
// It's common for there to be multiple ASCII characters in a run mixed in, so add an
// extra optimized loop to take care of these runs.
while (offset < limit) {
byte b = UnsafeUtil.getByte(bytes, offset);
if (!DecodeUtil.isOneByte(b)) {
break;
}
offset++;
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
}
} else if (DecodeUtil.isTwoBytes(byte1)) {
if (offset >= limit) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleTwoBytes(
byte1, /* byte2 */ UnsafeUtil.getByte(bytes, offset++), resultArr, resultPos++);
} else if (DecodeUtil.isThreeBytes(byte1)) {
if (offset >= limit - 1) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleThreeBytes(
byte1,
/* byte2 */ UnsafeUtil.getByte(bytes, offset++),
/* byte3 */ UnsafeUtil.getByte(bytes, offset++),
resultArr,
resultPos++);
} else {
if (offset >= limit - 2) {
throw InvalidProtocolBufferException.invalidUtf8(); throw InvalidProtocolBufferException.invalidUtf8();
} }
DecodeUtil.handleFourBytes(
byte1,
/* byte2 */ UnsafeUtil.getByte(bytes, offset++),
/* byte3 */ UnsafeUtil.getByte(bytes, offset++),
/* byte4 */ UnsafeUtil.getByte(bytes, offset++),
resultArr,
resultPos++);
// 4-byte case requires two chars.
resultPos++;
}
}
return new String(resultArr, 0, resultPos);
}
@Override @Override
String decodeUtf8Direct(ByteBuffer buffer, int index, int size) String decodeUtf8Direct(ByteBuffer buffer, int index, int size)

@ -253,13 +253,13 @@ public class DecodeUtf8Test extends TestCase {
try { try {
UNSAFE_PROCESSOR.decodeUtf8(bytes, index, size); UNSAFE_PROCESSOR.decodeUtf8(bytes, index, size);
fail(); fail();
} catch (ArrayIndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
// Expected. // Expected.
} }
try { try {
SAFE_PROCESSOR.decodeUtf8(bytes, index, size); SAFE_PROCESSOR.decodeUtf8(bytes, index, size);
fail(); fail();
} catch (ArrayIndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
// Expected. // Expected.
} }
@ -269,13 +269,13 @@ public class DecodeUtf8Test extends TestCase {
try { try {
UNSAFE_PROCESSOR.decodeUtf8(direct, index, size); UNSAFE_PROCESSOR.decodeUtf8(direct, index, size);
fail(); fail();
} catch (ArrayIndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
// Expected. // Expected.
} }
try { try {
SAFE_PROCESSOR.decodeUtf8(direct, index, size); SAFE_PROCESSOR.decodeUtf8(direct, index, size);
fail(); fail();
} catch (ArrayIndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
// Expected. // Expected.
} }
@ -285,13 +285,13 @@ public class DecodeUtf8Test extends TestCase {
try { try {
UNSAFE_PROCESSOR.decodeUtf8(heap, index, size); UNSAFE_PROCESSOR.decodeUtf8(heap, index, size);
fail(); fail();
} catch (ArrayIndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
// Expected. // Expected.
} }
try { try {
SAFE_PROCESSOR.decodeUtf8(heap, index, size); SAFE_PROCESSOR.decodeUtf8(heap, index, size);
fail(); fail();
} catch (ArrayIndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
// Expected. // Expected.
} }
} }

@ -35,6 +35,7 @@ RUN /bin/bash -l -c "rvm install 2.5.1"
RUN /bin/bash -l -c "rvm install 2.6.0" RUN /bin/bash -l -c "rvm install 2.6.0"
RUN /bin/bash -l -c "rvm install 2.7.0" RUN /bin/bash -l -c "rvm install 2.7.0"
RUN /bin/bash -l -c "rvm install 3.0.0" RUN /bin/bash -l -c "rvm install 3.0.0"
RUN /bin/bash -l -c "rvm install 3.1.0"
RUN /bin/bash -l -c "rvm install jruby-9.2.20.1" RUN /bin/bash -l -c "rvm install jruby-9.2.20.1"
RUN /bin/bash -l -c "rvm install jruby-9.3.3.0" RUN /bin/bash -l -c "rvm install jruby-9.3.3.0"

@ -0,0 +1,18 @@
#!/bin/bash
#
# This is the top-level script we give to Kokoro as the entry point for
# running the "pull request" project:
#
# This script selects a specific Dockerfile (for building a Docker image) and
# a script to run inside that image. Then we delegate to the general
# build_and_run_docker.sh script.
# Change to repo root
cd $(dirname $0)/../../..
export DOCKERHUB_ORGANIZATION=protobuftesting
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/ruby
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh
export OUTPUT_DIR=testoutput
export TEST_SET="ruby31"
./kokoro/linux/build_and_run_docker.sh

@ -0,0 +1,11 @@
# Config file for running tests in Kokoro
# Location of the build script in repository
build_file: "protobuf/kokoro/linux/ruby31/build.sh"
timeout_mins: 120
action {
define_artifacts {
regex: "**/sponge_log.xml"
}
}

@ -0,0 +1,11 @@
# Config file for running tests in Kokoro
# Location of the build script in repository
build_file: "protobuf/kokoro/linux/ruby31/build.sh"
timeout_mins: 120
action {
define_artifacts {
regex: "**/sponge_log.xml"
}
}

@ -36,5 +36,5 @@ if [[ "${KOKORO_INSTALL_RVM:-}" == "yes" ]] ; then
# Old OpenSSL versions cannot handle the SSL certificate used by # Old OpenSSL versions cannot handle the SSL certificate used by
# https://get.rvm.io, so as a workaround we download RVM directly from # https://get.rvm.io, so as a workaround we download RVM directly from
# GitHub. See this issue for details: https://github.com/rvm/rvm/issues/5133 # GitHub. See this issue for details: https://github.com/rvm/rvm/issues/5133
curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s stable --ruby curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s master --ruby
fi fi

@ -0,0 +1,12 @@
#!/bin/bash
#
# Build file to set up and run tests
# Change to repo root
cd $(dirname $0)/../../..
# Prepare worker environment to run tests
KOKORO_INSTALL_RVM=yes
source kokoro/macos/prepare_build_macos_rc
./tests.sh ruby31

@ -0,0 +1,5 @@
# Config file for running tests in Kokoro
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/ruby31/build.sh"
timeout_mins: 1440

@ -0,0 +1,5 @@
# Config file for running tests in Kokoro
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/ruby31/build.sh"
timeout_mins: 1440

@ -3,12 +3,25 @@
set -ex set -ex
set +ex # rvm script is very verbose and exits with errorcode set +ex # rvm script is very verbose and exits with errorcode
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
# Old OpenSSL versions cannot handle the SSL certificate used by
# https://get.rvm.io, so as a workaround we download RVM directly from
# GitHub. See this issue for details: https://github.com/rvm/rvm/issues/5133
curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s master --ruby
source $HOME/.rvm/scripts/rvm source $HOME/.rvm/scripts/rvm
set -e # rvm commands are very verbose set -e # rvm commands are very verbose
time rvm install 2.5.0 time rvm install 2.5.0
rvm use 2.5.0 rvm use 2.5.0
gem install rake-compiler --no-document gem install rake-compiler --no-document
gem install bundler --no-document gem install bundler --no-document
time rvm install 3.1.0
rvm use 3.1.0
gem install rake-compiler --no-document
gem install bundler --no-document
time rvm install 2.7.0 time rvm install 2.7.0
rvm use 2.7.0 --default rvm use 2.7.0 --default
gem install rake-compiler --no-document gem install rake-compiler --no-document
@ -20,6 +33,8 @@ set -ex
rm -rf ~/.rake-compiler rm -rf ~/.rake-compiler
CROSS_RUBY=$(mktemp tmpfile.XXXXXXXX) CROSS_RUBY=$(mktemp tmpfile.XXXXXXXX)
CROSS_RUBY31=$(mktemp tmpfile.XXXXXXXX)
curl https://raw.githubusercontent.com/rake-compiler/rake-compiler/72184e51779b6a3b9b8580b036a052fdc3181ced/tasks/bin/cross-ruby.rake > "$CROSS_RUBY" curl https://raw.githubusercontent.com/rake-compiler/rake-compiler/72184e51779b6a3b9b8580b036a052fdc3181ced/tasks/bin/cross-ruby.rake > "$CROSS_RUBY"
@ -52,8 +67,33 @@ patch "$CROSS_RUBY" << EOF
end end
EOF EOF
cp $CROSS_RUBY $CROSS_RUBY31
patch "$CROSS_RUBY31" << EOF
--- cross-ruby.rake 2022-03-04 11:49:52.000000000 +0000
+++ patched 2022-03-04 11:58:22.000000000 +0000
@@ -114,6 +114,7 @@
'--enable-static',
'--disable-shared',
'--disable-install-doc',
+ '--with-coroutine=ucontext',
'--without-gmp',
'--with-ext=',
'LDFLAGS=-pipe',
EOF
MAKE="make -j8" MAKE="make -j8"
set +x # rvm commands are very verbose
rvm use 3.1.0
set -x
ruby --version | grep 'ruby 3.1.0'
for v in 3.1.0 ; do
ccache -c
rake -f "$CROSS_RUBY31" cross-ruby VERSION="$v" HOST=x86_64-darwin MAKE="$MAKE"
rake -f "$CROSS_RUBY31" cross-ruby VERSION="$v" HOST=aarch64-darwin MAKE="$MAKE"
done
set +x # rvm commands are very verbose set +x # rvm commands are very verbose
rvm use 2.7.0 rvm use 2.7.0
set -x set -x

@ -46,8 +46,6 @@ GPB_FINAL @interface GPBEmptyRoot : GPBRootObject
* service Foo { * service Foo {
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
* } * }
*
* The JSON representation for `Empty` is empty JSON object `{}`.
**/ **/
GPB_FINAL @interface GPBEmpty : GPBMessage GPB_FINAL @interface GPBEmpty : GPBMessage

@ -0,0 +1,45 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2022 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// ! THIS FILE ONLY APPROACHING IN-TREE PHP EXTENSION BUILD !
// ! DOES NOT USE NORMALLY. !
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// 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.
#ifndef PHP_PROTOBUF_H
# define PHP_PROTOBUF_H
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
extern zend_module_entry protobuf_module_entry;
# define phpext_protobuf_ptr &protobuf_module_entry
#endif /* PHP_PROTOBUF_H */

@ -15,7 +15,6 @@ use Google\Protobuf\Internal\GPBUtil;
* service Foo { * service Foo {
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
* } * }
* The JSON representation for `Empty` is empty JSON object `{}`.
* *
* Generated from protobuf message <code>google.protobuf.Empty</code> * Generated from protobuf message <code>google.protobuf.Empty</code>
*/ */

@ -831,6 +831,45 @@ def MessageSetItemDecoder(descriptor):
return DecodeItem return DecodeItem
def UnknownMessageSetItemDecoder():
"""Returns a decoder for a Unknown MessageSet item."""
type_id_tag_bytes = encoder.TagBytes(2, wire_format.WIRETYPE_VARINT)
message_tag_bytes = encoder.TagBytes(3, wire_format.WIRETYPE_LENGTH_DELIMITED)
item_end_tag_bytes = encoder.TagBytes(1, wire_format.WIRETYPE_END_GROUP)
def DecodeUnknownItem(buffer):
pos = 0
end = len(buffer)
message_start = -1
message_end = -1
while 1:
(tag_bytes, pos) = ReadTag(buffer, pos)
if tag_bytes == type_id_tag_bytes:
(type_id, pos) = _DecodeVarint(buffer, pos)
elif tag_bytes == message_tag_bytes:
(size, message_start) = _DecodeVarint(buffer, pos)
pos = message_end = message_start + size
elif tag_bytes == item_end_tag_bytes:
break
else:
pos = SkipField(buffer, pos, end, tag_bytes)
if pos == -1:
raise _DecodeError('Missing group end tag.')
if pos > end:
raise _DecodeError('Truncated message.')
if type_id == -1:
raise _DecodeError('MessageSet item missing type_id.')
if message_start == -1:
raise _DecodeError('MessageSet item missing message.')
return (type_id, buffer[message_start:message_end].tobytes())
return DecodeUnknownItem
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def MapDecoder(field_descriptor, new_default, is_message_map): def MapDecoder(field_descriptor, new_default, is_message_map):

@ -49,7 +49,7 @@ from google.protobuf.internal import testing_refleaks
from google.protobuf.internal import type_checkers from google.protobuf.internal import type_checkers
from google.protobuf.internal import wire_format from google.protobuf.internal import wire_format
from google.protobuf import descriptor from google.protobuf import descriptor
from google.protobuf import unknown_fields
try: try:
import tracemalloc # pylint: disable=g-import-not-at-top import tracemalloc # pylint: disable=g-import-not-at-top
except ImportError: except ImportError:
@ -106,14 +106,14 @@ class UnknownFieldsTest(unittest.TestCase):
proto = message_set_extensions_pb2.TestMessageSet() proto = message_set_extensions_pb2.TestMessageSet()
proto.MergeFromString(serialized) proto.MergeFromString(serialized)
unknown_fields = proto.UnknownFields() unknown_field_set = unknown_fields.UnknownFieldSet(proto)
self.assertEqual(len(unknown_fields), 1) self.assertEqual(len(unknown_field_set), 1)
# Unknown field should have wire format data which can be parsed back to # Unknown field should have wire format data which can be parsed back to
# original message. # original message.
self.assertEqual(unknown_fields[0].field_number, item.type_id) self.assertEqual(unknown_field_set[0].field_number, item.type_id)
self.assertEqual(unknown_fields[0].wire_type, self.assertEqual(unknown_field_set[0].wire_type,
wire_format.WIRETYPE_LENGTH_DELIMITED) wire_format.WIRETYPE_LENGTH_DELIMITED)
d = unknown_fields[0].data d = unknown_field_set[0].data
message_new = message_set_extensions_pb2.TestMessageSetExtension1() message_new = message_set_extensions_pb2.TestMessageSetExtension1()
message_new.ParseFromString(d) message_new.ParseFromString(d)
self.assertEqual(message1, message_new) self.assertEqual(message1, message_new)
@ -196,11 +196,11 @@ class UnknownFieldsAccessorsTest(unittest.TestCase):
decoder(memoryview(value), 0, len(value), self.all_fields, result_dict) decoder(memoryview(value), 0, len(value), self.all_fields, result_dict)
self.assertEqual(expected_value, result_dict[field_descriptor]) self.assertEqual(expected_value, result_dict[field_descriptor])
def CheckUnknownField(self, name, unknown_fields, expected_value): def CheckUnknownField(self, name, unknown_field_set, expected_value):
field_descriptor = self.descriptor.fields_by_name[name] field_descriptor = self.descriptor.fields_by_name[name]
expected_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[ expected_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[
field_descriptor.type] field_descriptor.type]
for unknown_field in unknown_fields: for unknown_field in unknown_field_set:
if unknown_field.field_number == field_descriptor.number: if unknown_field.field_number == field_descriptor.number:
self.assertEqual(expected_type, unknown_field.wire_type) self.assertEqual(expected_type, unknown_field.wire_type)
if expected_type == 3: if expected_type == 3:
@ -218,57 +218,57 @@ class UnknownFieldsAccessorsTest(unittest.TestCase):
self.assertEqual(expected_value, unknown_field.data) self.assertEqual(expected_value, unknown_field.data)
def testCheckUnknownFieldValue(self): def testCheckUnknownFieldValue(self):
unknown_fields = self.empty_message.UnknownFields() unknown_field_set = unknown_fields.UnknownFieldSet(self.empty_message)
# Test enum. # Test enum.
self.CheckUnknownField('optional_nested_enum', self.CheckUnknownField('optional_nested_enum',
unknown_fields, unknown_field_set,
self.all_fields.optional_nested_enum) self.all_fields.optional_nested_enum)
self.InternalCheckUnknownField('optional_nested_enum', self.InternalCheckUnknownField('optional_nested_enum',
self.all_fields.optional_nested_enum) self.all_fields.optional_nested_enum)
# Test repeated enum. # Test repeated enum.
self.CheckUnknownField('repeated_nested_enum', self.CheckUnknownField('repeated_nested_enum',
unknown_fields, unknown_field_set,
self.all_fields.repeated_nested_enum) self.all_fields.repeated_nested_enum)
self.InternalCheckUnknownField('repeated_nested_enum', self.InternalCheckUnknownField('repeated_nested_enum',
self.all_fields.repeated_nested_enum) self.all_fields.repeated_nested_enum)
# Test varint. # Test varint.
self.CheckUnknownField('optional_int32', self.CheckUnknownField('optional_int32',
unknown_fields, unknown_field_set,
self.all_fields.optional_int32) self.all_fields.optional_int32)
self.InternalCheckUnknownField('optional_int32', self.InternalCheckUnknownField('optional_int32',
self.all_fields.optional_int32) self.all_fields.optional_int32)
# Test fixed32. # Test fixed32.
self.CheckUnknownField('optional_fixed32', self.CheckUnknownField('optional_fixed32',
unknown_fields, unknown_field_set,
self.all_fields.optional_fixed32) self.all_fields.optional_fixed32)
self.InternalCheckUnknownField('optional_fixed32', self.InternalCheckUnknownField('optional_fixed32',
self.all_fields.optional_fixed32) self.all_fields.optional_fixed32)
# Test fixed64. # Test fixed64.
self.CheckUnknownField('optional_fixed64', self.CheckUnknownField('optional_fixed64',
unknown_fields, unknown_field_set,
self.all_fields.optional_fixed64) self.all_fields.optional_fixed64)
self.InternalCheckUnknownField('optional_fixed64', self.InternalCheckUnknownField('optional_fixed64',
self.all_fields.optional_fixed64) self.all_fields.optional_fixed64)
# Test length delimited. # Test length delimited.
self.CheckUnknownField('optional_string', self.CheckUnknownField('optional_string',
unknown_fields, unknown_field_set,
self.all_fields.optional_string.encode('utf-8')) self.all_fields.optional_string.encode('utf-8'))
self.InternalCheckUnknownField('optional_string', self.InternalCheckUnknownField('optional_string',
self.all_fields.optional_string) self.all_fields.optional_string)
# Test group. # Test group.
self.CheckUnknownField('optionalgroup', self.CheckUnknownField('optionalgroup',
unknown_fields, unknown_field_set,
(17, 0, 117)) (17, 0, 117))
self.InternalCheckUnknownField('optionalgroup', self.InternalCheckUnknownField('optionalgroup',
self.all_fields.optionalgroup) self.all_fields.optionalgroup)
self.assertEqual(97, len(unknown_fields)) self.assertEqual(97, len(unknown_field_set))
def testCopyFrom(self): def testCopyFrom(self):
message = unittest_pb2.TestEmptyMessage() message = unittest_pb2.TestEmptyMessage()
@ -286,18 +286,18 @@ class UnknownFieldsAccessorsTest(unittest.TestCase):
message.optional_int64 = 3 message.optional_int64 = 3
message.optional_uint32 = 4 message.optional_uint32 = 4
destination = unittest_pb2.TestEmptyMessage() destination = unittest_pb2.TestEmptyMessage()
unknown_fields = destination.UnknownFields() unknown_field_set = unknown_fields.UnknownFieldSet(destination)
self.assertEqual(0, len(unknown_fields)) self.assertEqual(0, len(unknown_field_set))
destination.ParseFromString(message.SerializeToString()) destination.ParseFromString(message.SerializeToString())
# ParseFromString clears the message thus unknown fields is invalid. # TODO(jieluo): add this back after implement new cpp unknown fields
with self.assertRaises(ValueError) as context: # b/217277954
len(unknown_fields) if api_implementation.Type() == 'cpp':
self.assertIn('UnknownFields does not exist.', return
str(context.exception)) self.assertEqual(0, len(unknown_field_set))
unknown_fields = destination.UnknownFields() unknown_field_set = unknown_fields.UnknownFieldSet(destination)
self.assertEqual(2, len(unknown_fields)) self.assertEqual(2, len(unknown_field_set))
destination.MergeFrom(source) destination.MergeFrom(source)
self.assertEqual(4, len(unknown_fields)) self.assertEqual(2, len(unknown_field_set))
# Check that the fields where correctly merged, even stored in the unknown # Check that the fields where correctly merged, even stored in the unknown
# fields set. # fields set.
message.ParseFromString(destination.SerializeToString()) message.ParseFromString(destination.SerializeToString())
@ -306,14 +306,15 @@ class UnknownFieldsAccessorsTest(unittest.TestCase):
self.assertEqual(message.optional_int64, 3) self.assertEqual(message.optional_int64, 3)
def testClear(self): def testClear(self):
unknown_fields = self.empty_message.UnknownFields() unknown_field_set = unknown_fields.UnknownFieldSet(self.empty_message)
self.empty_message.Clear() self.empty_message.Clear()
# All cleared, even unknown fields. # All cleared, even unknown fields.
self.assertEqual(self.empty_message.SerializeToString(), b'') self.assertEqual(self.empty_message.SerializeToString(), b'')
with self.assertRaises(ValueError) as context: # TODO(jieluo): add this back after implement new cpp unknown fields
len(unknown_fields) # b/217277954
self.assertIn('UnknownFields does not exist.', if api_implementation.Type() == 'cpp':
str(context.exception)) return
self.assertEqual(len(unknown_field_set), 97)
@unittest.skipIf((sys.version_info.major, sys.version_info.minor) < (3, 4), @unittest.skipIf((sys.version_info.major, sys.version_info.minor) < (3, 4),
'tracemalloc requires python 3.4+') 'tracemalloc requires python 3.4+')
@ -323,7 +324,7 @@ class UnknownFieldsAccessorsTest(unittest.TestCase):
def leaking_function(): def leaking_function():
for _ in range(nb_leaks): for _ in range(nb_leaks):
self.empty_message.UnknownFields() unknown_fields.UnknownFieldSet(self.empty_message)
tracemalloc.start() tracemalloc.start()
snapshot1 = tracemalloc.take_snapshot() snapshot1 = tracemalloc.take_snapshot()
@ -340,49 +341,47 @@ class UnknownFieldsAccessorsTest(unittest.TestCase):
message.optionalgroup.a = 123 message.optionalgroup.a = 123
destination = unittest_pb2.TestEmptyMessage() destination = unittest_pb2.TestEmptyMessage()
destination.ParseFromString(message.SerializeToString()) destination.ParseFromString(message.SerializeToString())
sub_unknown_fields = destination.UnknownFields()[0].data sub_unknown_fields = unknown_fields.UnknownFieldSet(destination)[0].data
self.assertEqual(1, len(sub_unknown_fields)) self.assertEqual(1, len(sub_unknown_fields))
self.assertEqual(sub_unknown_fields[0].data, 123) self.assertEqual(sub_unknown_fields[0].data, 123)
destination.Clear() destination.Clear()
with self.assertRaises(ValueError) as context: # TODO(jieluo): add this back after implement new cpp unknown fields
len(sub_unknown_fields) # b/217277954
self.assertIn('UnknownFields does not exist.', if api_implementation.Type() == 'cpp':
str(context.exception)) return
with self.assertRaises(ValueError) as context: self.assertEqual(1, len(sub_unknown_fields))
# pylint: disable=pointless-statement self.assertEqual(sub_unknown_fields[0].data, 123)
sub_unknown_fields[0]
self.assertIn('UnknownFields does not exist.',
str(context.exception))
message.Clear() message.Clear()
message.optional_uint32 = 456 message.optional_uint32 = 456
nested_message = unittest_pb2.NestedTestAllTypes() nested_message = unittest_pb2.NestedTestAllTypes()
nested_message.payload.optional_nested_message.ParseFromString( nested_message.payload.optional_nested_message.ParseFromString(
message.SerializeToString()) message.SerializeToString())
unknown_fields = ( unknown_field_set = unknown_fields.UnknownFieldSet(
nested_message.payload.optional_nested_message.UnknownFields()) nested_message.payload.optional_nested_message)
self.assertEqual(unknown_fields[0].data, 456) self.assertEqual(unknown_field_set[0].data, 456)
nested_message.ClearField('payload') nested_message.ClearField('payload')
self.assertEqual(unknown_fields[0].data, 456) self.assertEqual(unknown_field_set[0].data, 456)
unknown_fields = ( unknown_field_set = unknown_fields.UnknownFieldSet(
nested_message.payload.optional_nested_message.UnknownFields()) nested_message.payload.optional_nested_message)
self.assertEqual(0, len(unknown_fields)) self.assertEqual(0, len(unknown_field_set))
def testUnknownField(self): def testUnknownField(self):
message = unittest_pb2.TestAllTypes() message = unittest_pb2.TestAllTypes()
message.optional_int32 = 123 message.optional_int32 = 123
destination = unittest_pb2.TestEmptyMessage() destination = unittest_pb2.TestEmptyMessage()
destination.ParseFromString(message.SerializeToString()) destination.ParseFromString(message.SerializeToString())
unknown_field = destination.UnknownFields()[0] unknown_field = unknown_fields.UnknownFieldSet(destination)[0]
destination.Clear() destination.Clear()
with self.assertRaises(ValueError) as context: # TODO(jieluo): add this back after implement new cpp unknown fields
unknown_field.data # pylint: disable=pointless-statement # b/217277954
self.assertIn('The parent message might be cleared.', if api_implementation.Type() == 'cpp':
str(context.exception)) return
self.assertEqual(unknown_field.data, 123)
def testUnknownExtensions(self): def testUnknownExtensions(self):
message = unittest_pb2.TestEmptyMessageWithExtensions() message = unittest_pb2.TestEmptyMessageWithExtensions()
message.ParseFromString(self.all_fields_data) message.ParseFromString(self.all_fields_data)
self.assertEqual(len(message.UnknownFields()), 97) self.assertEqual(len(unknown_fields.UnknownFieldSet(message)), 97)
self.assertEqual(message.SerializeToString(), self.all_fields_data) self.assertEqual(message.SerializeToString(), self.all_fields_data)
@ -416,9 +415,9 @@ class UnknownEnumValuesTest(unittest.TestCase):
def CheckUnknownField(self, name, expected_value): def CheckUnknownField(self, name, expected_value):
field_descriptor = self.descriptor.fields_by_name[name] field_descriptor = self.descriptor.fields_by_name[name]
unknown_fields = self.missing_message.UnknownFields() unknown_field_set = unknown_fields.UnknownFieldSet(self.missing_message)
count = 0 count = 0
for field in unknown_fields: for field in unknown_field_set:
if field.field_number == field_descriptor.number: if field.field_number == field_descriptor.number:
count += 1 count += 1
if field_descriptor.label == descriptor.FieldDescriptor.LABEL_REPEATED: if field_descriptor.label == descriptor.FieldDescriptor.LABEL_REPEATED:
@ -458,8 +457,8 @@ class UnknownEnumValuesTest(unittest.TestCase):
self.assertEqual([], self.missing_message.packed_nested_enum) self.assertEqual([], self.missing_message.packed_nested_enum)
def testCheckUnknownFieldValueForEnum(self): def testCheckUnknownFieldValueForEnum(self):
unknown_fields = self.missing_message.UnknownFields() unknown_field_set = unknown_fields.UnknownFieldSet(self.missing_message)
self.assertEqual(len(unknown_fields), 5) self.assertEqual(len(unknown_field_set), 5)
self.CheckUnknownField('optional_nested_enum', self.CheckUnknownField('optional_nested_enum',
self.message.optional_nested_enum) self.message.optional_nested_enum)
self.CheckUnknownField('repeated_nested_enum', self.CheckUnknownField('repeated_nested_enum',

@ -53,6 +53,7 @@ from google.protobuf.internal import decoder
from google.protobuf.internal import type_checkers from google.protobuf.internal import type_checkers
from google.protobuf import descriptor from google.protobuf import descriptor
from google.protobuf import text_encoding from google.protobuf import text_encoding
from google.protobuf import unknown_fields
# pylint: disable=g-import-not-at-top # pylint: disable=g-import-not-at-top
__all__ = ['MessageToString', 'Parse', 'PrintMessage', 'PrintField', __all__ = ['MessageToString', 'Parse', 'PrintMessage', 'PrintField',
@ -136,8 +137,6 @@ def MessageToString(
Args: Args:
message: The protocol buffers message. message: The protocol buffers message.
as_utf8: Return unescaped Unicode for non-ASCII characters. as_utf8: Return unescaped Unicode for non-ASCII characters.
In Python 3 actual Unicode characters may appear as is in strings.
In Python 2 the return value will be valid UTF-8 rather than only ASCII.
as_one_line: Don't introduce newlines between fields. as_one_line: Don't introduce newlines between fields.
use_short_repeated_primitives: Use short repeated format for primitives. use_short_repeated_primitives: Use short repeated format for primitives.
pointy_brackets: If True, use angle brackets instead of curly braces for pointy_brackets: If True, use angle brackets instead of curly braces for
@ -223,6 +222,36 @@ def PrintMessage(message,
message_formatter=None, message_formatter=None,
print_unknown_fields=False, print_unknown_fields=False,
force_colon=False): force_colon=False):
"""Convert the message to text format and write it to the out stream.
Args:
message: The Message object to convert to text format.
out: A file handle to write the message to.
indent: The initial indent level for pretty print.
as_utf8: Return unescaped Unicode for non-ASCII characters.
as_one_line: Don't introduce newlines between fields.
use_short_repeated_primitives: Use short repeated format for primitives.
pointy_brackets: If True, use angle brackets instead of curly braces for
nesting.
use_index_order: If True, print fields of a proto message using the order
defined in source code instead of the field number. By default, use the
field number order.
float_format: If set, use this to specify float field formatting
(per the "Format Specification Mini-Language"); otherwise, shortest
float that has same value in wire will be printed. Also affect double
field if double_format is not set but float_format is set.
double_format: If set, use this to specify double field formatting
(per the "Format Specification Mini-Language"); if it is not set but
float_format is set, use float_format. Otherwise, str() is used.
use_field_number: If True, print field numbers instead of names.
descriptor_pool: A DescriptorPool used to resolve Any types.
message_formatter: A function(message, indent, as_one_line): unicode|None
to custom format selected sub-messages (usually based on message type).
Use to pretty print parts of the protobuf for easier diffing.
print_unknown_fields: If True, unknown fields will be printed.
force_colon: If set, a colon will be added after the field name even if
the field is a proto message.
"""
printer = _Printer( printer = _Printer(
out=out, indent=indent, as_utf8=as_utf8, out=out, indent=indent, as_utf8=as_utf8,
as_one_line=as_one_line, as_one_line=as_one_line,
@ -347,8 +376,6 @@ class _Printer(object):
out: To record the text format result. out: To record the text format result.
indent: The initial indent level for pretty print. indent: The initial indent level for pretty print.
as_utf8: Return unescaped Unicode for non-ASCII characters. as_utf8: Return unescaped Unicode for non-ASCII characters.
In Python 3 actual Unicode characters may appear as is in strings.
In Python 2 the return value will be valid UTF-8 rather than ASCII.
as_one_line: Don't introduce newlines between fields. as_one_line: Don't introduce newlines between fields.
use_short_repeated_primitives: Use short repeated format for primitives. use_short_repeated_primitives: Use short repeated format for primitives.
pointy_brackets: If True, use angle brackets instead of curly braces for pointy_brackets: If True, use angle brackets instead of curly braces for
@ -454,12 +481,12 @@ class _Printer(object):
self.PrintField(field, value) self.PrintField(field, value)
if self.print_unknown_fields: if self.print_unknown_fields:
self._PrintUnknownFields(message.UnknownFields()) self._PrintUnknownFields(unknown_fields.UnknownFieldSet(message))
def _PrintUnknownFields(self, unknown_fields): def _PrintUnknownFields(self, unknown_field_set):
"""Print unknown fields.""" """Print unknown fields."""
out = self.out out = self.out
for field in unknown_fields: for field in unknown_field_set:
out.write(' ' * self.indent) out.write(' ' * self.indent)
out.write(str(field.field_number)) out.write(str(field.field_number))
if field.wire_type == WIRETYPE_START_GROUP: if field.wire_type == WIRETYPE_START_GROUP:
@ -1199,7 +1226,7 @@ def _SkipFieldValue(tokenizer):
"""Skips over a field value. """Skips over a field value.
Args: Args:
tokenizer: A tokenizer to parse the field value. tokenizer: A tokenizer to parse the field name and values.
Raises: Raises:
ParseError: In case an invalid field value is found. ParseError: In case an invalid field value is found.

@ -0,0 +1,125 @@
# 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.
"""Contains Unknown Fields APIs.
Simple usage example:
unknown_field_set = UnknownFieldSet(message)
for unknown_field in unknown_field_set:
wire_type = unknown_field.wire_type
field_number = unknown_field.field_number
data = unknown_field.data
"""
from google.protobuf.internal import api_implementation
from google.protobuf.internal import decoder
from google.protobuf.internal import wire_format
if api_implementation.Type() == 'cpp':
def UnknownFieldSet(msg):
# New UnknownFieldSet in cpp extension has not implemented yet. Fall
# back to old API
# TODO(jieluo): Add UnknownFieldSet for cpp extension.
return msg.UnknownFields()
else:
class UnknownField:
"""A parsed unknown field."""
# Disallows assignment to other attributes.
__slots__ = ['_field_number', '_wire_type', '_data']
def __init__(self, field_number, wire_type, data):
self._field_number = field_number
self._wire_type = wire_type
self._data = data
return
@property
def field_number(self):
return self._field_number
@property
def wire_type(self):
return self._wire_type
@property
def data(self):
return self._data
class UnknownFieldSet:
"""UnknownField container."""
# Disallows assignment to other attributes.
__slots__ = ['_values']
def __init__(self, msg):
def InternalAdd(field_number, wire_type, data):
unknown_field = UnknownField(field_number, wire_type, data)
self._values.append(unknown_field)
self._values = []
msg_des = msg.DESCRIPTOR
# pylint: disable=protected-access
unknown_fields = msg._unknown_fields
if (msg_des.has_options and
msg_des.GetOptions().message_set_wire_format):
local_decoder = decoder.UnknownMessageSetItemDecoder()
for _, buffer in unknown_fields:
(field_number, data) = local_decoder(memoryview(buffer))
InternalAdd(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED, data)
else:
for tag_bytes, buffer in unknown_fields:
# pylint: disable=protected-access
(tag, _) = decoder._DecodeVarint(tag_bytes, 0)
field_number, wire_type = wire_format.UnpackTag(tag)
if field_number == 0:
raise RuntimeError('Field number 0 is illegal.')
(data, _) = decoder._DecodeUnknownField(
memoryview(buffer), 0, wire_type)
InternalAdd(field_number, wire_type, data)
def __getitem__(self, index):
size = len(self._values)
if index < 0:
index += size
if index < 0 or index >= size:
raise IndexError('index %d out of range'.index)
return self._values[index]
def __len__(self):
return len(self._values)
def __iter__(self):
return iter(self._values)

@ -115,8 +115,11 @@ def GenerateUnittestProtos():
GenProto('google/protobuf/internal/factory_test1.proto', False) GenProto('google/protobuf/internal/factory_test1.proto', False)
GenProto('google/protobuf/internal/factory_test2.proto', False) GenProto('google/protobuf/internal/factory_test2.proto', False)
GenProto('google/protobuf/internal/file_options_test.proto', False) GenProto('google/protobuf/internal/file_options_test.proto', False)
GenProto('google/protobuf/internal/import_test_package/import_public.proto', False) GenProto('google/protobuf/internal/import_test_package/import_public.proto',
GenProto('google/protobuf/internal/import_test_package/import_public_nested.proto', False) False)
GenProto(
'google/protobuf/internal/import_test_package/import_public_nested.proto',
False)
GenProto('google/protobuf/internal/import_test_package/inner.proto', False) GenProto('google/protobuf/internal/import_test_package/inner.proto', False)
GenProto('google/protobuf/internal/import_test_package/outer.proto', False) GenProto('google/protobuf/internal/import_test_package/outer.proto', False)
GenProto('google/protobuf/internal/missing_enum_values.proto', False) GenProto('google/protobuf/internal/missing_enum_values.proto', False)

@ -127,7 +127,7 @@ else
['x86-mingw32', 'x64-mingw32', 'x86_64-linux', 'x86-linux'].each do |plat| ['x86-mingw32', 'x64-mingw32', 'x86_64-linux', 'x86-linux'].each do |plat|
RakeCompilerDock.sh <<-"EOT", platform: plat RakeCompilerDock.sh <<-"EOT", platform: plat
bundle && \ bundle && \
IN_DOCKER=true rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem RUBY_CC_VERSION=3.0.0:2.7.0:2.6.0:2.5.0 IN_DOCKER=true rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem RUBY_CC_VERSION=3.1.0:3.0.0:2.7.0:2.6.0:2.5.0
EOT EOT
end end
end end
@ -135,7 +135,7 @@ else
if RUBY_PLATFORM =~ /darwin/ if RUBY_PLATFORM =~ /darwin/
task 'gem:native' do task 'gem:native' do
system "rake genproto" system "rake genproto"
system "rake cross native gem RUBY_CC_VERSION=3.0.0:2.7.0:2.6.0:2.5.1" system "rake cross native gem RUBY_CC_VERSION=3.1.0:3.0.0:2.7.0:2.6.0:2.5.1"
end end
else else
task 'gem:native' => [:genproto, 'gem:windows', 'gem:java'] task 'gem:native' => [:genproto, 'gem:windows', 'gem:java']

@ -21,6 +21,7 @@ class RepeatedFieldTest < Test::Unit::TestCase
:nitems, :iter_for_reverse_each, :indexes, :append, :prepend] :nitems, :iter_for_reverse_each, :indexes, :append, :prepend]
arr_methods -= [:union, :difference, :filter!] arr_methods -= [:union, :difference, :filter!]
arr_methods -= [:intersection, :deconstruct] # ruby 2.7 methods we can ignore arr_methods -= [:intersection, :deconstruct] # ruby 2.7 methods we can ignore
arr_methods -= [:intersect?] # ruby 3.1 methods we can ignore
arr_methods.each do |method_name| arr_methods.each do |method_name|
assert m.repeated_string.respond_to?(method_name) == true, "does not respond to #{method_name}" assert m.repeated_string.respond_to?(method_name) == true, "does not respond to #{method_name}"
end end

@ -340,19 +340,19 @@ uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
uint64_t seed) { uint64_t seed) {
switch (type_info.type) { switch (type_info.type) {
case kUpb_CType_Bool: case kUpb_CType_Bool:
return Wyhash(&val, 1, seed, kWyhashSalt); return _upb_Hash(&val, 1, seed);
case kUpb_CType_Float: case kUpb_CType_Float:
case kUpb_CType_Int32: case kUpb_CType_Int32:
case kUpb_CType_UInt32: case kUpb_CType_UInt32:
case kUpb_CType_Enum: case kUpb_CType_Enum:
return Wyhash(&val, 4, seed, kWyhashSalt); return _upb_Hash(&val, 4, seed);
case kUpb_CType_Double: case kUpb_CType_Double:
case kUpb_CType_Int64: case kUpb_CType_Int64:
case kUpb_CType_UInt64: case kUpb_CType_UInt64:
return Wyhash(&val, 8, seed, kWyhashSalt); return _upb_Hash(&val, 8, seed);
case kUpb_CType_String: case kUpb_CType_String:
case kUpb_CType_Bytes: case kUpb_CType_Bytes:
return Wyhash(val.str_val.data, val.str_val.size, seed, kWyhashSalt); return _upb_Hash(val.str_val.data, val.str_val.size, seed);
case kUpb_CType_Message: case kUpb_CType_Message:
return Message_Hash(val.msg_val, type_info.def.msgdef, seed); return Message_Hash(val.msg_val, type_info.def.msgdef, seed);
default: default:

@ -161,10 +161,8 @@ void Message_PrintMessage(StringBuilder* b, const upb_Message* msg,
if (upb_FieldDef_IsMap(field)) { if (upb_FieldDef_IsMap(field)) {
const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field); const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field);
const upb_FieldDef* key_f = const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1);
upb_MessageDef_FindFieldByNumberWithSize(entry_m, 1); const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
const upb_FieldDef* val_f =
upb_MessageDef_FindFieldByNumberWithSize(entry_m, 2);
TypeInfo val_info = TypeInfo_get(val_f); TypeInfo val_info = TypeInfo_get(val_f);
Map_Inspect(b, msgval.map_val, upb_FieldDef_CType(key_f), val_info); Map_Inspect(b, msgval.map_val, upb_FieldDef_CType(key_f), val_info);
} else if (upb_FieldDef_IsRepeated(field)) { } else if (upb_FieldDef_IsRepeated(field)) {
@ -365,7 +363,7 @@ static VALUE Message_field_accessor(VALUE _self, const upb_FieldDef* f,
upb_MessageValue wrapper = upb_Message_Get(self->msg, f); upb_MessageValue wrapper = upb_Message_Get(self->msg, f);
const upb_MessageDef* wrapper_m = upb_FieldDef_MessageSubDef(f); const upb_MessageDef* wrapper_m = upb_FieldDef_MessageSubDef(f);
const upb_FieldDef* value_f = const upb_FieldDef* value_f =
upb_MessageDef_FindFieldByNumberWithSize(wrapper_m, 1); upb_MessageDef_FindFieldByNumber(wrapper_m, 1);
upb_MessageValue value = upb_Message_Get(wrapper.msg_val, value_f); upb_MessageValue value = upb_Message_Get(wrapper.msg_val, value_f);
return Convert_UpbToRuby(value, TypeInfo_get(value_f), self->arena); return Convert_UpbToRuby(value, TypeInfo_get(value_f), self->arena);
} else { } else {
@ -377,8 +375,8 @@ static VALUE Message_field_accessor(VALUE _self, const upb_FieldDef* f,
if (argv[1] == Qnil) { if (argv[1] == Qnil) {
upb_Message_ClearField(msg, f); upb_Message_ClearField(msg, f);
} else { } else {
const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumberWithSize( const upb_FieldDef* val_f =
upb_FieldDef_MessageSubDef(f), 1); upb_MessageDef_FindFieldByNumber(upb_FieldDef_MessageSubDef(f), 1);
upb_MessageValue msgval = Convert_RubyToUpb( upb_MessageValue msgval = Convert_RubyToUpb(
argv[1], upb_FieldDef_Name(f), TypeInfo_get(val_f), arena); argv[1], upb_FieldDef_Name(f), TypeInfo_get(val_f), arena);
upb_Message* wrapper = upb_Message_Mutable(msg, f, arena).msg; upb_Message* wrapper = upb_Message_Mutable(msg, f, arena).msg;
@ -527,10 +525,8 @@ static int Map_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
static void Map_InitFromValue(upb_Map* map, const upb_FieldDef* f, VALUE val, static void Map_InitFromValue(upb_Map* map, const upb_FieldDef* f, VALUE val,
upb_Arena* arena) { upb_Arena* arena) {
const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f); const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
const upb_FieldDef* key_f = const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1);
upb_MessageDef_FindFieldByNumberWithSize(entry_m, 1); const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
const upb_FieldDef* val_f =
upb_MessageDef_FindFieldByNumberWithSize(entry_m, 2);
if (TYPE(val) != T_HASH) { if (TYPE(val) != T_HASH) {
rb_raise(rb_eArgError, rb_raise(rb_eArgError,
"Expected Hash object as initializer value for map field '%s' " "Expected Hash object as initializer value for map field '%s' "
@ -748,7 +744,7 @@ uint64_t Message_Hash(const upb_Message* msg, const upb_MessageDef* m,
&size); &size);
if (data) { if (data) {
uint64_t ret = Wyhash(data, size, seed, kWyhashSalt); uint64_t ret = _upb_Hash(data, size, seed);
upb_Arena_Free(arena); upb_Arena_Free(arena);
return ret; return ret;
} else { } else {
@ -847,10 +843,8 @@ static VALUE Message_CreateHash(const upb_Message* msg,
if (upb_FieldDef_IsMap(field)) { if (upb_FieldDef_IsMap(field)) {
const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field); const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field);
const upb_FieldDef* key_f = const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1);
upb_MessageDef_FindFieldByNumberWithSize(entry_m, 1); const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
const upb_FieldDef* val_f =
upb_MessageDef_FindFieldByNumberWithSize(entry_m, 2);
upb_CType key_type = upb_FieldDef_CType(key_f); upb_CType key_type = upb_FieldDef_CType(key_f);
msg_value = Map_CreateHash(msgval.map_val, key_type, TypeInfo_get(val_f)); msg_value = Map_CreateHash(msgval.map_val, key_type, TypeInfo_get(val_f));
} else if (upb_FieldDef_IsRepeated(field)) { } else if (upb_FieldDef_IsRepeated(field)) {
@ -1357,10 +1351,8 @@ const upb_Message* Message_GetUpbMessage(VALUE value, const upb_MessageDef* m,
upb_Message* msg = upb_Message_New(m, arena); upb_Message* msg = upb_Message_New(m, arena);
upb_MessageValue sec, nsec; upb_MessageValue sec, nsec;
struct timespec time; struct timespec time;
const upb_FieldDef* sec_f = const upb_FieldDef* sec_f = upb_MessageDef_FindFieldByNumber(m, 1);
upb_MessageDef_FindFieldByNumberWithSize(m, 1); const upb_FieldDef* nsec_f = upb_MessageDef_FindFieldByNumber(m, 2);
const upb_FieldDef* nsec_f =
upb_MessageDef_FindFieldByNumberWithSize(m, 2);
if (!rb_obj_is_kind_of(value, rb_cTime)) goto badtype; if (!rb_obj_is_kind_of(value, rb_cTime)) goto badtype;
@ -1375,10 +1367,8 @@ const upb_Message* Message_GetUpbMessage(VALUE value, const upb_MessageDef* m,
// Numeric -> Google::Protobuf::Duration // Numeric -> Google::Protobuf::Duration
upb_Message* msg = upb_Message_New(m, arena); upb_Message* msg = upb_Message_New(m, arena);
upb_MessageValue sec, nsec; upb_MessageValue sec, nsec;
const upb_FieldDef* sec_f = const upb_FieldDef* sec_f = upb_MessageDef_FindFieldByNumber(m, 1);
upb_MessageDef_FindFieldByNumberWithSize(m, 1); const upb_FieldDef* nsec_f = upb_MessageDef_FindFieldByNumber(m, 2);
const upb_FieldDef* nsec_f =
upb_MessageDef_FindFieldByNumberWithSize(m, 2);
if (!rb_obj_is_kind_of(value, rb_cNumeric)) goto badtype; if (!rb_obj_is_kind_of(value, rb_cNumeric)) goto badtype;

@ -42,12 +42,12 @@ VALUE cTypeError;
const upb_FieldDef *map_field_key(const upb_FieldDef *field) { const upb_FieldDef *map_field_key(const upb_FieldDef *field) {
const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field); const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field);
return upb_MessageDef_FindFieldByNumberWithSize(entry, 1); return upb_MessageDef_FindFieldByNumber(entry, 1);
} }
const upb_FieldDef *map_field_value(const upb_FieldDef *field) { const upb_FieldDef *map_field_value(const upb_FieldDef *field) {
const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field); const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field);
return upb_MessageDef_FindFieldByNumberWithSize(entry, 2); return upb_MessageDef_FindFieldByNumber(entry, 2);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -17,8 +17,7 @@ Gem::Specification.new do |s|
else else
s.files += Dir.glob('ext/**/*') s.files += Dir.glob('ext/**/*')
s.extensions= ["ext/google/protobuf_c/extconf.rb"] s.extensions= ["ext/google/protobuf_c/extconf.rb"]
s.add_development_dependency "rake-compiler-dock", "= 1.1.0" s.add_development_dependency "rake-compiler-dock", "= 1.2.1" end
end
s.test_files = ["tests/basic.rb", s.test_files = ["tests/basic.rb",
"tests/stress.rb", "tests/stress.rb",
"tests/generated_code_test.rb"] "tests/generated_code_test.rb"]

@ -21,6 +21,7 @@ class RepeatedFieldTest < Test::Unit::TestCase
:nitems, :iter_for_reverse_each, :indexes, :append, :prepend] :nitems, :iter_for_reverse_each, :indexes, :append, :prepend]
arr_methods -= [:union, :difference, :filter!] arr_methods -= [:union, :difference, :filter!]
arr_methods -= [:intersection, :deconstruct] # ruby 2.7 methods we can ignore arr_methods -= [:intersection, :deconstruct] # ruby 2.7 methods we can ignore
arr_methods -= [:intersect?] # ruby 3.1 methods we can ignore
arr_methods.each do |method_name| arr_methods.each do |method_name|
assert m.repeated_string.respond_to?(method_name) == true, "does not respond to #{method_name}" assert m.repeated_string.respond_to?(method_name) == true, "does not respond to #{method_name}"
end end

@ -129,6 +129,10 @@ Mac installations.
sudo /opt/local/bin/port install autoconf automake libtool sudo /opt/local/bin/port install autoconf automake libtool
Alternative for Homebrew users:
brew install autoconf automake libtool
Then follow the Unix instructions above. Then follow the Unix instructions above.
**Note for cross-compiling** **Note for cross-compiling**

@ -29,6 +29,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <google/protobuf/arena_test_util.h> #include <google/protobuf/arena_test_util.h>
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>

@ -33,9 +33,9 @@
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/arena.h>
namespace google { namespace google {
namespace protobuf { namespace protobuf {

@ -41,17 +41,17 @@
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena_test_util.h>
#include <google/protobuf/test_util.h> #include <google/protobuf/test_util.h>
#include <google/protobuf/unittest.pb.h> #include <google/protobuf/unittest.pb.h>
#include <google/protobuf/unittest_arena.pb.h> #include <google/protobuf/unittest_arena.pb.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/arena_test_util.h>
#include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.h>
#include <google/protobuf/extension_set.h> #include <google/protobuf/extension_set.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/message.h> #include <google/protobuf/message.h>
#include <google/protobuf/message_lite.h> #include <google/protobuf/message_lite.h>
#include <google/protobuf/repeated_field.h> #include <google/protobuf/repeated_field.h>

@ -339,19 +339,6 @@ TEST(GENERATED_MESSAGE_TEST_NAME, Clear) {
TestUtil::SetAllFields(&message); TestUtil::SetAllFields(&message);
message.Clear(); message.Clear();
TestUtil::ExpectClear(message); TestUtil::ExpectClear(message);
// Unlike with the defaults test, we do NOT expect that requesting embedded
// messages will return a pointer to the default instance. Instead, they
// should return the objects that were created when mutable_blah() was
// called.
EXPECT_NE(&UNITTEST::TestAllTypes::OptionalGroup::default_instance(),
&message.optionalgroup());
EXPECT_NE(&UNITTEST::TestAllTypes::NestedMessage::default_instance(),
&message.optional_nested_message());
EXPECT_NE(&UNITTEST::ForeignMessage::default_instance(),
&message.optional_foreign_message());
EXPECT_NE(&UNITTEST_IMPORT::ImportMessage::default_instance(),
&message.optional_import_message());
} }
TEST(GENERATED_MESSAGE_TEST_NAME, EmbeddedNullsInBytesCharStar) { TEST(GENERATED_MESSAGE_TEST_NAME, EmbeddedNullsInBytesCharStar) {
@ -503,6 +490,9 @@ TEST(GENERATED_MESSAGE_TEST_NAME, ADLSwap) {
// Note the address of one of the repeated fields, to verify it was swapped // Note the address of one of the repeated fields, to verify it was swapped
// rather than copied. // rather than copied.
const int32_t* addr = &message1.repeated_int32().Get(0); const int32_t* addr = &message1.repeated_int32().Get(0);
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
const int32_t value = *addr;
#endif
using std::swap; using std::swap;
swap(message1, message2); swap(message1, message2);
@ -512,7 +502,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, ADLSwap) {
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP #ifdef PROTOBUF_FORCE_COPY_IN_SWAP
EXPECT_NE(addr, &message2.repeated_int32().Get(0)); EXPECT_NE(addr, &message2.repeated_int32().Get(0));
EXPECT_EQ(*addr, message2.repeated_int32().Get(0)); EXPECT_EQ(value, message2.repeated_int32().Get(0));
#else #else
EXPECT_EQ(addr, &message2.repeated_int32().Get(0)); EXPECT_EQ(addr, &message2.repeated_int32().Get(0));
#endif #endif

@ -49,17 +49,6 @@ TEST(JavaDocCommentTest, Escaping) {
EXPECT_EQ("&#64;deprecated", EscapeJavadoc("@deprecated")); EXPECT_EQ("&#64;deprecated", EscapeJavadoc("@deprecated"));
} }
// TODO(kenton): It's hard to write a robust test of the doc comments -- we
// can only really compare the output against a golden value, which is a
// fairly tedious and fragile testing strategy. If we want to go that route,
// it probably makes sense to bite the bullet and write a test that compares
// the whole generated output for unittest.proto against a golden value, with
// a very simple script that can be run to regenerate it with the latest code.
// This would mean that updates to the golden file would have to be included
// in any change to the code generator, which would actually be fairly useful
// as it allows the reviewer to see clearly how the generated code is
// changing.
} // namespace } // namespace
} // namespace java } // namespace java
} // namespace compiler } // namespace compiler

@ -261,18 +261,18 @@ std::string UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field) {
return name; return name;
} }
bool IsForbiddenKotlin(const std::string& field_name) { // Names that should be avoided as field names in Kotlin.
// Names that should be avoided as field names in Kotlin. // All Kotlin hard keywords are in this list.
// All Kotlin hard keywords are in this list. const std::unordered_set<std::string>* kKotlinForbiddenNames =
const std::unordered_set<std::string>* kKotlinForbiddenNames =
new std::unordered_set<std::string>({ new std::unordered_set<std::string>({
"as", "as?", "break", "class", "continue", "do", "as", "as?", "break", "class", "continue", "do", "else",
"else", "false", "for", "fun", "if", "in", "false", "for", "fun", "if", "in", "!in", "interface",
"!in", "interface", "is", "!is", "null", "object", "is", "!is", "null", "object", "package", "return", "super",
"package", "return", "super", "this", "throw", "true", "this", "throw", "true", "try", "typealias", "typeof", "val",
"try", "typealias", "typeof", "val", "var", "when", "var", "when", "while",
"while",
}); });
bool IsForbiddenKotlin(const std::string& field_name) {
return kKotlinForbiddenNames->find(field_name) != return kKotlinForbiddenNames->find(field_name) !=
kKotlinForbiddenNames->end(); kKotlinForbiddenNames->end();
} }

@ -29,12 +29,9 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda) // Author: kenton@google.com (Kenton Varda)
//
// TODO(kenton): Share code with the versions of this test in other languages?
// It seemed like parameterizing it would add more complexity than it is
// worth.
#include <memory> #include <memory>
#include <string>
#include <google/protobuf/testing/file.h> #include <google/protobuf/testing/file.h>
#include <google/protobuf/testing/file.h> #include <google/protobuf/testing/file.h>
@ -42,6 +39,7 @@
#include <google/protobuf/compiler/command_line_interface.h> #include <google/protobuf/compiler/command_line_interface.h>
#include <google/protobuf/io/printer.h> #include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/testing/googletest.h> #include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@ -109,6 +107,25 @@ TEST(JavaPluginTest, PluginTest) {
test_out.c_str(), "test.proto"}; test_out.c_str(), "test.proto"};
EXPECT_EQ(0, cli.Run(5, argv)); EXPECT_EQ(0, cli.Run(5, argv));
// Loop over the lines of the generated code and verify that we find what we
// expect
std::string output;
GOOGLE_CHECK_OK(File::GetContents(TestTempDir() + "/Test.java", &output,
true));
std::vector<std::string> lines = Split(output, "\n");
bool found_generated_annotation = false;
bool found_do_not_edit = false;
for (const auto& line : lines) {
if (line.find(" DO NOT EDIT!") != std::string::npos) {
found_do_not_edit = true;
}
if (line.find("@com.google.protobuf.Generated") != std::string::npos) {
found_generated_annotation = true;
}
}
EXPECT_TRUE(found_do_not_edit);
} }
} // namespace } // namespace

@ -46,6 +46,7 @@
#include <google/protobuf/compiler/plugin.pb.h> #include <google/protobuf/compiler/plugin.pb.h>
#include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/io_win32.h> #include <google/protobuf/io/io_win32.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>

@ -29,12 +29,9 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda) // Author: kenton@google.com (Kenton Varda)
//
// TODO(kenton): Share code with the versions of this test in other languages?
// It seemed like parameterizing it would add more complexity than it is
// worth.
#include <memory> #include <memory>
#include <string>
#include <google/protobuf/testing/file.h> #include <google/protobuf/testing/file.h>
#include <google/protobuf/testing/file.h> #include <google/protobuf/testing/file.h>

@ -48,5 +48,4 @@ option cc_enable_arenas = true;
// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
// } // }
// //
// The JSON representation for `Empty` is empty JSON object `{}`.
message Empty {} message Empty {}

@ -359,7 +359,8 @@ int ExtensionSet::SpaceUsedExcludingSelf() const {
} }
size_t ExtensionSet::SpaceUsedExcludingSelfLong() const { size_t ExtensionSet::SpaceUsedExcludingSelfLong() const {
size_t total_size = (is_large() ? map_.large->size() : flat_capacity_) * sizeof(KeyValue); size_t total_size =
(is_large() ? map_.large->size() : flat_capacity_) * sizeof(KeyValue);
ForEach([&total_size](int /* number */, const Extension& ext) { ForEach([&total_size](int /* number */, const Extension& ext) {
total_size += ext.SpaceUsedExcludingSelfLong(); total_size += ext.SpaceUsedExcludingSelfLong();
}); });

@ -107,20 +107,6 @@ TEST(ExtensionSetTest, Clear) {
message.Clear(); message.Clear();
TestUtil::ExpectExtensionsClear(message); TestUtil::ExpectExtensionsClear(message);
// Unlike with the defaults test, we do NOT expect that requesting embedded
// messages will return a pointer to the default instance. Instead, they
// should return the objects that were created when mutable_blah() was
// called.
EXPECT_NE(&unittest::OptionalGroup_extension::default_instance(),
&message.GetExtension(unittest::optionalgroup_extension));
EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(),
&message.GetExtension(unittest::optional_nested_message_extension));
EXPECT_NE(
&unittest::ForeignMessage::default_instance(),
&message.GetExtension(unittest::optional_foreign_message_extension));
EXPECT_NE(&unittest_import::ImportMessage::default_instance(),
&message.GetExtension(unittest::optional_import_message_extension));
// Make sure setting stuff again after clearing works. (This takes slightly // Make sure setting stuff again after clearing works. (This takes slightly
// different code paths since the objects are reused.) // different code paths since the objects are reused.)
TestUtil::SetAllExtensions(&message); TestUtil::SetAllExtensions(&message);

@ -152,28 +152,6 @@ TEST(GeneratedMessageReflectionTest, GetStringReference) {
} }
TEST(GeneratedMessageReflectionTest, DefaultsAfterClear) {
// Check that after setting all fields and then clearing, getting an
// embedded message does NOT return the default instance.
unittest::TestAllTypes message;
TestUtil::ReflectionTester reflection_tester(
unittest::TestAllTypes::descriptor());
TestUtil::SetAllFields(&message);
message.Clear();
const Reflection* reflection = message.GetReflection();
EXPECT_NE(&unittest::TestAllTypes::OptionalGroup::default_instance(),
&reflection->GetMessage(message, F("optionalgroup")));
EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(),
&reflection->GetMessage(message, F("optional_nested_message")));
EXPECT_NE(&unittest::ForeignMessage::default_instance(),
&reflection->GetMessage(message, F("optional_foreign_message")));
EXPECT_NE(&unittest_import::ImportMessage::default_instance(),
&reflection->GetMessage(message, F("optional_import_message")));
}
class GeneratedMessageReflectionSwapTest : public testing::TestWithParam<bool> { class GeneratedMessageReflectionSwapTest : public testing::TestWithParam<bool> {
protected: protected:
void Swap(const Reflection* reflection, Message* lhs, Message* rhs) { void Swap(const Reflection* reflection, Message* lhs, Message* rhs) {

@ -35,18 +35,18 @@
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena_test_util.h>
#include <google/protobuf/map_lite_test_util.h>
#include <google/protobuf/map_lite_unittest.pb.h> #include <google/protobuf/map_lite_unittest.pb.h>
#include <google/protobuf/test_util_lite.h>
#include <google/protobuf/unittest_lite.pb.h> #include <google/protobuf/unittest_lite.pb.h>
#include <gtest/gtest.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/arena_test_util.h>
#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/map_lite_test_util.h>
#include <google/protobuf/test_util_lite.h>
#include <google/protobuf/wire_format_lite.h> #include <google/protobuf/wire_format_lite.h>
#include <gtest/gtest.h>
#include <google/protobuf/stubs/strutil.h>
namespace google { namespace google {
namespace protobuf { namespace protobuf {

@ -34,8 +34,6 @@
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena_test_util.h>
#include <google/protobuf/map_test_util.h>
#include <google/protobuf/map_unittest.pb.h> #include <google/protobuf/map_unittest.pb.h>
#include <google/protobuf/unittest.pb.h> #include <google/protobuf/unittest.pb.h>
#include <google/protobuf/arena.h> #include <google/protobuf/arena.h>
@ -44,6 +42,8 @@
#include <google/protobuf/message.h> #include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> #include <google/protobuf/repeated_field.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <google/protobuf/arena_test_util.h>
#include <google/protobuf/map_test_util.h>
// Must be included last. // Must be included last.
#include <google/protobuf/port_def.inc> #include <google/protobuf/port_def.inc>

@ -29,6 +29,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <google/protobuf/map_lite_test_util.h> #include <google/protobuf/map_lite_test_util.h>
#include <google/protobuf/map_lite_unittest.pb.h> #include <google/protobuf/map_lite_unittest.pb.h>
#include <google/protobuf/map_test_util_impl.h> #include <google/protobuf/map_test_util_impl.h>

@ -49,12 +49,17 @@
#include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/testing/file.h> #include <google/protobuf/testing/file.h>
#include <google/protobuf/arena_test_util.h>
#include <google/protobuf/test_util2.h> #include <google/protobuf/test_util2.h>
#include <google/protobuf/descriptor.pb.h>
#include <gmock/gmock.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/arena_test_util.h>
#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/tokenizer.h> #include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor_database.h> #include <google/protobuf/descriptor_database.h>
#include <google/protobuf/dynamic_message.h> #include <google/protobuf/dynamic_message.h>
@ -67,11 +72,6 @@
#include <google/protobuf/wire_format.h> #include <google/protobuf/wire_format.h>
#include <google/protobuf/util/message_differencer.h> #include <google/protobuf/util/message_differencer.h>
#include <google/protobuf/util/time_util.h> #include <google/protobuf/util/time_util.h>
#include <gmock/gmock.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/substitute.h>
// Must be included last. // Must be included last.

@ -28,8 +28,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <google/protobuf/map_test_util_impl.h>
#include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.h>
#include <google/protobuf/map_test_util_impl.h>
#include <google/protobuf/message.h> #include <google/protobuf/message.h>
namespace google { namespace google {

@ -872,8 +872,28 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase {
const Element& Get(int index) const; const Element& Get(int index) const;
Element* Mutable(int index); Element* Mutable(int index);
// Unlike std::vector, adding an element to a RepeatedPtrField doesn't always
// make a new element; it might re-use an element left over from when the
// field was Clear()'d or reize()'d smaller. For this reason, Add() is the
// fastest API for adding a new element.
Element* Add(); Element* Add();
// `Add(std::move(value));` is equivalent to `*Add() = std::move(value);`
// It will either move-construct to the end of this field, or swap value
// with the new-or-recycled element at the end of this field. Note that
// this operation is very slow if this RepeatedPtrField is not on the
// same Arena, if any, as `value`.
void Add(Element&& value); void Add(Element&& value);
// Copying to the end of this RepeatedPtrField is slowest of all; it can't
// reliably copy-construct to the last element of this RepeatedPtrField, for
// example (unlike std::vector).
// We currently block this API. The right way to add to the end is to call
// Add() and modify the element it points to.
// If you must add an existing value, call `*Add() = value;`
void Add(const Element& value) = delete;
// Append elements in the range [begin, end) after reserving // Append elements in the range [begin, end) after reserving
// the appropriate number of elements. // the appropriate number of elements.
template <typename Iter> template <typename Iter>

@ -422,6 +422,10 @@ build_ruby30() {
internal_build_cpp # For conformance tests. internal_build_cpp # For conformance tests.
cd ruby && bash travis-test.sh ruby-3.0.2 && cd .. cd ruby && bash travis-test.sh ruby-3.0.2 && cd ..
} }
build_ruby31() {
internal_build_cpp # For conformance tests.
cd ruby && bash travis-test.sh ruby-3.1.0 && cd ..
}
build_jruby92() { build_jruby92() {
internal_build_cpp # For conformance tests. internal_build_cpp # For conformance tests.
@ -593,6 +597,7 @@ Usage: $0 { cpp |
ruby26 | ruby26 |
ruby27 | ruby27 |
ruby30 | ruby30 |
ruby31 |
jruby92 | jruby92 |
jruby93 | jruby93 |
ruby_all | ruby_all |

@ -41,124 +41,88 @@ cc_toolchain_suite(
cc_toolchain_config( cc_toolchain_config(
name = "linux-aarch_64-config", name = "linux-aarch_64-config",
bit_flag = "-m64",
cpp_flag = "-lstdc++",
sysroot = "/opt/manylinux/2014/aarch64", sysroot = "/opt/manylinux/2014/aarch64",
linker_path = "/usr/bin/ld", linker_path = "/usr/bin/ld",
target_cpu = "aarch64", target_cpu = "aarch64",
target_full_name = "aarch64-linux-gnu", target_full_name = "aarch64-linux-gnu",
toolchain_name = "linux_aarch_64",
# Don't really need this, setting it because it's required.
toolchain_dir = "/opt/manylinux/2014/aarch64",
) )
cc_toolchain_config( cc_toolchain_config(
name = "linux-ppcle_64-config", name = "linux-ppcle_64-config",
bit_flag = "-m64",
cpp_flag = "-lstdc++",
linker_path = "/usr/bin/ld", linker_path = "/usr/bin/ld",
sysroot = "/opt/manylinux/2014/ppc64le", sysroot = "/opt/manylinux/2014/ppc64le",
target_cpu = "ppc64", target_cpu = "ppc64",
target_full_name = "powerpc64le-linux-gnu", target_full_name = "powerpc64le-linux-gnu",
toolchain_dir = "/opt/manylinux/2014/ppc64le",
toolchain_name = "linux_ppcle_64",
) )
cc_toolchain_config( cc_toolchain_config(
name = "linux-s390_64-config", name = "linux-s390_64-config",
bit_flag = "-m64",
cpp_flag = "-lstdc++",
linker_path = "/usr/bin/ld", linker_path = "/usr/bin/ld",
sysroot = "/opt/manylinux/2014/s390x", sysroot = "/opt/manylinux/2014/s390x",
target_cpu = "systemz", target_cpu = "systemz",
target_full_name = "s390x-linux-gnu", target_full_name = "s390x-linux-gnu",
toolchain_dir = "/opt/manylinux/2014/s390x",
toolchain_name = "linux_s390_64",
) )
cc_toolchain_config( cc_toolchain_config(
name = "linux-x86_32-config", name = "linux-x86_32-config",
bit_flag = "-m32",
cpp_flag = "-lstdc++",
linker_path = "/usr/bin/ld", linker_path = "/usr/bin/ld",
sysroot = "/opt/manylinux/2014/i686", sysroot = "/opt/manylinux/2014/i686",
target_cpu = "x86_32", target_cpu = "x86_32",
target_full_name = "i386-linux-gnu", target_full_name = "i386-linux-gnu",
toolchain_dir = "/opt/manylinux/2014/i686",
toolchain_name = "linux_x86_32",
) )
cc_toolchain_config( cc_toolchain_config(
name = "linux-x86_64-config", name = "linux-x86_64-config",
bit_flag = "-m64",
cpp_flag = "-lstdc++",
linker_path = "/usr/bin/ld", linker_path = "/usr/bin/ld",
sysroot = "/opt/manylinux/2014/x86_64", sysroot = "/opt/manylinux/2014/x86_64",
target_cpu = "x86_64", target_cpu = "x86_64",
target_full_name = "x86_64-linux-gnu", target_full_name = "x86_64-linux-gnu",
toolchain_dir = "/opt/manylinux/2014/x86_64",
toolchain_name = "linux_x86_64",
) )
cc_toolchain_config( cc_toolchain_config(
name = "osx-aarch_64-config", name = "osx-aarch_64-config",
bit_flag = "-m64",
cpp_flag = "-lc++",
extra_compiler_flags = [ extra_compiler_flags = [
"-I/usr/tools/apple_sdks/xcode_13_0/macosx/usr/include/c++/v1", "-I/usr/tools/apple_sdks/xcode_13_0/macosx/usr/include/c++/v1",
"-I/usr/tools/apple_sdks/xcode_13_0/macosx/usr/include" "-I/usr/tools/apple_sdks/xcode_13_0/macosx/usr/include"
], ],
extra_include = "/usr/include",
linker_path = "/usr/tools", linker_path = "/usr/tools",
sysroot = "/usr/tools/apple_sdks/xcode_13_0/macosx", sysroot = "/usr/tools/apple_sdks/xcode_13_0/macosx",
target_cpu = "aarch64", target_cpu = "aarch64",
target_full_name = "aarch64-apple-macosx11.3", target_full_name = "aarch64-apple-macosx11.3",
toolchain_dir = "/usr/tools/apple_sdks/xcode_13_0/macosx",
toolchain_name = "osx_aarch_64",
) )
cc_toolchain_config( cc_toolchain_config(
name = "osx-x86_64-config", name = "osx-x86_64-config",
bit_flag = "-m64",
cpp_flag = "-lc++",
extra_compiler_flags = [ extra_compiler_flags = [
"-I/usr/tools/apple_sdks/xcode_13_0/macosx/usr/include/c++/v1", "-I/usr/tools/apple_sdks/xcode_13_0/macosx/usr/include/c++/v1",
"-I/usr/tools/apple_sdks/xcode_13_0/macosx/usr/include" "-I/usr/tools/apple_sdks/xcode_13_0/macosx/usr/include"
], ],
extra_include = "/usr/include",
linker_path = "/usr/tools", linker_path = "/usr/tools",
sysroot = "/usr/tools/apple_sdks/xcode_13_0/macosx", sysroot = "/usr/tools/apple_sdks/xcode_13_0/macosx",
target_cpu = "x86_64", target_cpu = "x86_64",
target_full_name = "x86_64-apple-macosx11.3", target_full_name = "x86_64-apple-macosx11.3",
toolchain_dir = "/usr/tools/apple_sdks/xcode_13_0/macosx",
toolchain_name = "osx_x86_64",
) )
cc_toolchain_config( cc_toolchain_config(
name = "win32-config", name = "win32-config",
bit_flag = "-m32",
cpp_flag = "-lstdc++",
extra_compiler_flags = [ extra_compiler_flags = [
"-isystem/usr/lib/gcc/i686-w64-mingw32/8.3-posix/include/c++", "-isystem/usr/lib/gcc/i686-w64-mingw32/8.3-posix/include/c++",
"-isystem/usr/lib/gcc/i686-w64-mingw32/8.3-posix/include/c++/i686-w64-mingw32", "-isystem/usr/lib/gcc/i686-w64-mingw32/8.3-posix/include/c++/i686-w64-mingw32",
"-fsjlj-exceptions", "-fsjlj-exceptions",
], ],
extra_include = "/usr/lib/gcc/i686-w64-mingw32/8.3-posix/include", extra_include = "/usr/lib/gcc/i686-w64-mingw32",
extra_linker_flags = [ extra_linker_flags = [
"-L/usr/lib/gcc/i686-w64-mingw32/8.3-posix", "-L/usr/lib/gcc/i686-w64-mingw32/8.3-posix",
"-pthread", "-pthread",
], ],
linker_path = "/usr/bin/ld", linker_path = "/usr/bin/ld",
sysroot = "/usr/i686-w64-mingw32",
target_cpu = "x86_32", target_cpu = "x86_32",
target_full_name = "i686-w64-mingw32", target_full_name = "i686-w64-mingw32",
toolchain_dir = "/usr/i686-w64-mingw32/include",
toolchain_name = "i686-w64-mingw32",
) )
cc_toolchain_config( cc_toolchain_config(
name = "win64-config", name = "win64-config",
bit_flag = "-m64",
cpp_flag = "-lstdc++",
extra_compiler_flags = [ extra_compiler_flags = [
"-isystem/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/include/c++/", "-isystem/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/include/c++/",
"-isystem/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/include/c++/x86_64-w64-mingw32", "-isystem/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/include/c++/x86_64-w64-mingw32",
@ -168,8 +132,7 @@ cc_toolchain_config(
"-L/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix", "-L/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix",
], ],
linker_path = "/usr/bin/ld", linker_path = "/usr/bin/ld",
sysroot = "/usr/x86_64-w64-mingw32",
target_cpu = "x86_64", target_cpu = "x86_64",
target_full_name = "x86_64-w64-mingw32", target_full_name = "x86_64-w64-mingw32",
toolchain_dir = "/usr/x86_64-w64-mingw32/include",
toolchain_name = "x86_64-w64-mingw32",
) )

@ -28,7 +28,7 @@ all_compile_actions = [
] ]
def _impl(ctx): def _impl(ctx):
if 'mingw' in ctx.attr.target_full_name: if "mingw" in ctx.attr.target_full_name:
artifact_name_patterns = [ artifact_name_patterns = [
artifact_name_pattern( artifact_name_pattern(
category_name = "executable", category_name = "executable",
@ -96,7 +96,7 @@ def _impl(ctx):
flag_group( flag_group(
flags = [ flags = [
"-B" + ctx.attr.linker_path, "-B" + ctx.attr.linker_path,
ctx.attr.cpp_flag, "-lstdc++",
"--target=" + ctx.attr.target_full_name, "--target=" + ctx.attr.target_full_name,
] + ctx.attr.extra_linker_flags, ] + ctx.attr.extra_linker_flags,
), ),
@ -105,7 +105,7 @@ def _impl(ctx):
], ],
) )
if 'osx' in ctx.attr.target_full_name: if "osx" in ctx.attr.target_full_name:
sysroot_action_set = all_link_actions sysroot_action_set = all_link_actions
else: else:
sysroot_action_set = all_link_actions + all_compile_actions sysroot_action_set = all_link_actions + all_compile_actions
@ -129,6 +129,10 @@ def _impl(ctx):
], ],
) )
if ctx.attr.target_cpu == "x86_32":
bit_flag = "-m32"
else:
bit_flag = "-m64"
compiler_flags = feature( compiler_flags = feature(
name = "default_compile_flags", name = "default_compile_flags",
enabled = True, enabled = True,
@ -138,14 +142,14 @@ def _impl(ctx):
flag_groups = [ flag_groups = [
flag_group( flag_group(
flags = [ flags = [
ctx.attr.bit_flag, bit_flag,
"-Wall", "-Wall",
"-no-canonical-prefixes", "-no-canonical-prefixes",
"--target=" + ctx.attr.target_full_name, "--target=" + ctx.attr.target_full_name,
"-fvisibility=hidden", "-fvisibility=hidden",
] + ctx.attr.extra_compiler_flags + [ ] + ctx.attr.extra_compiler_flags + [
"-isystem", "-isystem",
ctx.attr.toolchain_dir, ctx.attr.sysroot,
], ],
), ),
], ],
@ -160,7 +164,7 @@ def _impl(ctx):
ctx = ctx, ctx = ctx,
compiler = "clang", compiler = "clang",
cxx_builtin_include_directories = [ cxx_builtin_include_directories = [
ctx.attr.toolchain_dir, ctx.attr.sysroot,
ctx.attr.extra_include, ctx.attr.extra_include,
"/usr/local/include", "/usr/local/include",
"/usr/local/lib/clang", "/usr/local/lib/clang",
@ -170,7 +174,7 @@ def _impl(ctx):
target_cpu = ctx.attr.target_cpu, target_cpu = ctx.attr.target_cpu,
target_libc = ctx.attr.target_cpu, target_libc = ctx.attr.target_cpu,
target_system_name = ctx.attr.target_full_name, target_system_name = ctx.attr.target_full_name,
toolchain_identifier = ctx.attr.toolchain_name, toolchain_identifier = ctx.attr.target_full_name,
tool_paths = tool_paths, tool_paths = tool_paths,
) )
@ -178,8 +182,6 @@ cc_toolchain_config = rule(
implementation = _impl, implementation = _impl,
attrs = { attrs = {
"abi_version": attr.string(default = "local"), "abi_version": attr.string(default = "local"),
"bit_flag": attr.string(mandatory = True, values = ["-m32", "-m64"]),
"cpp_flag": attr.string(mandatory = True),
"extra_compiler_flags": attr.string_list(), "extra_compiler_flags": attr.string_list(),
"extra_include": attr.string(mandatory = False), "extra_include": attr.string(mandatory = False),
"extra_linker_flags": attr.string_list(), "extra_linker_flags": attr.string_list(),
@ -187,8 +189,6 @@ cc_toolchain_config = rule(
"sysroot": attr.string(mandatory = False), "sysroot": attr.string(mandatory = False),
"target_cpu": attr.string(mandatory = True, values = ["aarch64", "ppc64", "systemz", "x86_32", "x86_64"]), "target_cpu": attr.string(mandatory = True, values = ["aarch64", "ppc64", "systemz", "x86_32", "x86_64"]),
"target_full_name": attr.string(mandatory = True), "target_full_name": attr.string(mandatory = True),
"toolchain_dir": attr.string(mandatory = True),
"toolchain_name": attr.string(mandatory = True),
}, },
provides = [CcToolchainConfigInfo], provides = [CcToolchainConfigInfo],
) )

@ -27,10 +27,6 @@ get_source_files() {
get_variable_value $@ | grep "cc$\|inc$" get_variable_value $@ | grep "cc$\|inc$"
} }
get_proto_files_blacklisted() {
get_proto_files $@ | sed '/^google\/protobuf\/unittest_enormous_descriptor.proto$/d'
}
get_proto_files() { get_proto_files() {
get_variable_value $@ | grep "pb.cc$" | sed "s/pb.cc/proto/" get_variable_value $@ | grep "pb.cc$" | sed "s/pb.cc/proto/"
} }
@ -58,7 +54,6 @@ LIBPROTOC_SOURCES=$(get_source_files $MAKEFILE libprotoc_la_SOURCES)
LIBPROTOC_HEADERS=$(get_variable_value $MAKEFILE nobase_include_HEADERS | grep /compiler/) LIBPROTOC_HEADERS=$(get_variable_value $MAKEFILE nobase_include_HEADERS | grep /compiler/)
LITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs) LITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs)
PROTOS=$(get_proto_files $MAKEFILE protoc_outputs) PROTOS=$(get_proto_files $MAKEFILE protoc_outputs)
PROTOS_BLACKLISTED=$(get_proto_files_blacklisted $MAKEFILE protoc_outputs)
WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA) WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA)
COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES) COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES)
COMMON_LITE_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_LITE_TEST_SOURCES) COMMON_LITE_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_LITE_TEST_SOURCES)
@ -124,7 +119,7 @@ set_cmake_value $CMAKE_DIR/libprotobuf.cmake libprotobuf_files $CMAKE_PREFIX $LI
set_cmake_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $CMAKE_PREFIX $LIBPROTOC_SOURCES set_cmake_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $CMAKE_PREFIX $LIBPROTOC_SOURCES
set_cmake_value $CMAKE_DIR/libprotoc.cmake libprotoc_headers $CMAKE_PREFIX $LIBPROTOC_HEADERS set_cmake_value $CMAKE_DIR/libprotoc.cmake libprotoc_headers $CMAKE_PREFIX $LIBPROTOC_HEADERS
set_cmake_value $CMAKE_DIR/tests.cmake lite_test_protos "" $LITE_PROTOS set_cmake_value $CMAKE_DIR/tests.cmake lite_test_protos "" $LITE_PROTOS
set_cmake_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS_BLACKLISTED set_cmake_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS
set_cmake_value $CMAKE_DIR/tests.cmake common_test_files $CMAKE_PREFIX '${common_lite_test_files}' $COMMON_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake common_test_files $CMAKE_PREFIX '${common_lite_test_files}' $COMMON_TEST_SOURCES
set_cmake_value $CMAKE_DIR/tests.cmake common_lite_test_files $CMAKE_PREFIX $COMMON_LITE_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake common_lite_test_files $CMAKE_PREFIX $COMMON_LITE_TEST_SOURCES
set_cmake_value $CMAKE_DIR/tests.cmake tests_files $CMAKE_PREFIX $TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake tests_files $CMAKE_PREFIX $TEST_SOURCES

Loading…
Cancel
Save