Merge pull request #299 from haberman/google3-fixes

Applied changes from google3.
pull/13171/head
Joshua Haberman 5 years ago committed by GitHub
commit 1479f2d7ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      bazel/upb_proto_library.bzl
  2. 6
      tests/test_cpp.cc
  3. 6
      upb/handlers.h
  4. 4
      upbc/generator.cc

@ -120,6 +120,9 @@ _WrappedGeneratedSrcsInfo = provider(fields = ["srcs"])
_WrappedDefsGeneratedSrcsInfo = provider(fields = ["srcs"]) _WrappedDefsGeneratedSrcsInfo = provider(fields = ["srcs"])
def _compile_upb_protos(ctx, proto_info, proto_sources, ext): def _compile_upb_protos(ctx, proto_info, proto_sources, ext):
if len(proto_sources) == 0:
return GeneratedSrcsInfo(srcs = [], hdrs = [])
srcs = [_generate_output_file(ctx, name, ext + ".c") for name in proto_sources] srcs = [_generate_output_file(ctx, name, ext + ".c") for name in proto_sources]
hdrs = [_generate_output_file(ctx, name, ext + ".h") for name in proto_sources] hdrs = [_generate_output_file(ctx, name, ext + ".h") for name in proto_sources]
transitive_sets = proto_info.transitive_descriptor_sets.to_list() transitive_sets = proto_info.transitive_descriptor_sets.to_list()

@ -50,7 +50,7 @@ static const int kExpectedHandlerData = 1232323;
class StringBufTesterBase { class StringBufTesterBase {
public: public:
static const int kFieldNumber = 3; static constexpr int kFieldNumber = 3;
StringBufTesterBase() : seen_(false), handler_data_val_(0) {} StringBufTesterBase() : seen_(false), handler_data_val_(0) {}
@ -286,7 +286,7 @@ class StartMsgTesterBase {
public: public:
// We don't need the FieldDef it will create, but the test harness still // We don't need the FieldDef it will create, but the test harness still
// requires that we provide one. // requires that we provide one.
static const int kFieldNumber = 3; static constexpr int kFieldNumber = 3;
StartMsgTesterBase() : seen_(false), handler_data_val_(0) {} StartMsgTesterBase() : seen_(false), handler_data_val_(0) {}
@ -437,7 +437,7 @@ class StartMsgTesterBoolMethodWithHandlerData : public StartMsgTesterBase {
class Int32ValueTesterBase { class Int32ValueTesterBase {
public: public:
static const int kFieldNumber = 1; static constexpr int kFieldNumber = 1;
Int32ValueTesterBase() : seen_(false), val_(0), handler_data_val_(0) {} Int32ValueTesterBase() : seen_(false), val_(0), handler_data_val_(0) {}

@ -106,7 +106,7 @@ typedef struct {
#define UPB_HANDLERATTR_INIT {NULL, NULL, NULL, false} #define UPB_HANDLERATTR_INIT {NULL, NULL, NULL, false}
/* Bufhandle, data passed along with a buffer to indicate its provenance. */ /* Bufhandle, data passed along with a buffer to indicate its provenance. */
typedef struct { struct upb_bufhandle {
/* The beginning of the buffer. This may be different than the pointer /* The beginning of the buffer. This may be different than the pointer
* passed to a StringBuf handler because the handler may receive data * passed to a StringBuf handler because the handler may receive data
* that is from the middle or end of a larger buffer. */ * that is from the middle or end of a larger buffer. */
@ -133,7 +133,9 @@ typedef struct {
: NULL; : NULL;
} }
#endif #endif
} upb_bufhandle; };
typedef struct upb_bufhandle upb_bufhandle;
#define UPB_BUFHANDLE_INIT {NULL, 0, NULL, NULL} #define UPB_BUFHANDLE_INIT {NULL, 0, NULL, NULL}

@ -281,7 +281,9 @@ std::string FieldDefault(const protobuf::FieldDescriptor* field) {
case protobuf::FieldDescriptor::CPPTYPE_BOOL: case protobuf::FieldDescriptor::CPPTYPE_BOOL:
return field->default_value_bool() ? "true" : "false"; return field->default_value_bool() ? "true" : "false";
case protobuf::FieldDescriptor::CPPTYPE_ENUM: case protobuf::FieldDescriptor::CPPTYPE_ENUM:
return EnumValueSymbol(field->default_value_enum()); // Use a number instead of a symbolic name so that we don't require
// this enum's header to be included.
return absl::StrCat(field->default_value_enum()->number());
} }
ABSL_ASSERT(false); ABSL_ASSERT(false);
return "XXX"; return "XXX";

Loading…
Cancel
Save