From 04923fc26e1ca9f935fe10fb0de0fa932f7aa8b4 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 19 Jan 2019 19:38:03 -0800 Subject: Some fixes for PHP. --- upb/def.c | 21 +++++++++++++-------- upb/pb/encoder.c | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'upb') diff --git a/upb/def.c b/upb/def.c index 5b239dd..f816c4f 100644 --- a/upb/def.c +++ b/upb/def.c @@ -818,7 +818,7 @@ bool upb_oneof_done(upb_oneof_iter *iter) { } upb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter) { - return (upb_fielddef*)upb_value_getptr(upb_inttable_iter_value(iter)); + return (upb_fielddef *)upb_value_getconstptr(upb_inttable_iter_value(iter)); } void upb_oneof_iter_setdone(upb_oneof_iter *iter) { @@ -936,9 +936,6 @@ typedef struct { } symtab_addctx; static char* strviewdup(const symtab_addctx *ctx, upb_strview view) { - if (view.size == 0) { - return NULL; - } return upb_strdup2(view.data, view.size, ctx->alloc); } @@ -1329,6 +1326,8 @@ static bool create_enumdef( } } + upb_inttable_compact2(&e->iton, ctx->alloc); + return true; } @@ -1378,6 +1377,7 @@ static bool create_msgdef(const symtab_addctx *ctx, const char *prefix, CHK(assign_msg_indices(m, ctx->status)); assign_msg_wellknowntype(m); + upb_inttable_compact2(&m->itof, ctx->alloc); /* This message is built. Now build nested messages and enums. */ @@ -1571,10 +1571,15 @@ static bool build_filedef( /* Read options. */ file_options_proto = google_protobuf_FileDescriptorProto_options(file_proto); if (file_options_proto) { - file->phpprefix = strviewdup( - ctx, google_protobuf_FileOptions_php_class_prefix(file_options_proto)); - file->phpnamespace = strviewdup( - ctx, google_protobuf_FileOptions_php_namespace(file_options_proto)); + if (google_protobuf_FileOptions_has_php_class_prefix(file_options_proto)) { + file->phpprefix = strviewdup( + ctx, + google_protobuf_FileOptions_php_class_prefix(file_options_proto)); + } + if (google_protobuf_FileOptions_has_php_namespace(file_options_proto)) { + file->phpnamespace = strviewdup( + ctx, google_protobuf_FileOptions_php_namespace(file_options_proto)); + } } /* Verify dependencies. */ diff --git a/upb/pb/encoder.c b/upb/pb/encoder.c index 2da34db..5f74010 100644 --- a/upb/pb/encoder.c +++ b/upb/pb/encoder.c @@ -433,6 +433,7 @@ T(sint64, int64_t, upb_zzenc_64, encode_varint) /* code to build the handlers *************************************************/ +#include static void newhandlers_callback(const void *closure, upb_handlers *h) { const upb_msgdef *m; upb_msg_field_iter i; -- cgit v1.2.3