google-protobuf 3.3.0-universal-darwin → 3.4.0.2-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23ef1df5d404554e0d1e363555252382da0c6720
4
- data.tar.gz: 86658bf2fbb5851ccb0acd4ff9b042c99fe69e34
3
+ metadata.gz: 6751f39d4c76d6a57c8979ba445eabad145878ea
4
+ data.tar.gz: 4398686a5620b4d03e34d18793d2ce73b393eef4
5
5
  SHA512:
6
- metadata.gz: 54fbd2aa28871cb80c530bf6d1b7ef14f550edc9baf04fffda2f028cee53340ee5287a7f7794764316643f86a3325d9d3ff760acf277e604bfa98d9678e9351c
7
- data.tar.gz: 22a98278051e54c637b012019f7b193a02faa14f1ab3fa7fad72c0bfa7457acee42277f10e73453bf2b89f58d495430a816c65c9097348d4875231f11d497d61
6
+ metadata.gz: 71d70539087fe7240447342e7cf114d4711fbf69ba3f713c9e43ff7501d58263d35c2827993d3d81c295aac07c5c15a8ddd0cc5a37500d06a70a9960c482921c
7
+ data.tar.gz: ff686a6a30ee945fa960fae1ff18ea3fdf96f2d9ef8bad0e758195429fe508b4d2edc4fe7a481718d17e939f5a4d4394de8e0de60cdb38b06ba8f3bcd9f87d36
@@ -914,13 +914,9 @@ void stringsink_uninit(stringsink *sink) {
914
914
  // semantics, which means that we have true field presence, we will want to
915
915
  // modify msgvisitor so that it emits all present fields rather than all
916
916
  // non-default-value fields.
917
- //
918
- // Likewise, when implementing JSON serialization, we may need to have a
919
- // 'verbose' mode that outputs all fields and a 'concise' mode that outputs only
920
- // those with non-default values.
921
917
 
922
918
  static void putmsg(VALUE msg, const Descriptor* desc,
923
- upb_sink *sink, int depth);
919
+ upb_sink *sink, int depth, bool emit_defaults);
924
920
 
925
921
  static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) {
926
922
  upb_selector_t ret;
@@ -952,7 +948,7 @@ static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) {
952
948
  }
953
949
 
954
950
  static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink,
955
- int depth) {
951
+ int depth, bool emit_defaults) {
956
952
  upb_sink subsink;
957
953
  VALUE descriptor;
958
954
  Descriptor* subdesc;
@@ -963,12 +959,12 @@ static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink,
963
959
  subdesc = ruby_to_Descriptor(descriptor);
964
960
 
965
961
  upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink);
966
- putmsg(submsg, subdesc, &subsink, depth + 1);
962
+ putmsg(submsg, subdesc, &subsink, depth + 1, emit_defaults);
967
963
  upb_sink_endsubmsg(sink, getsel(f, UPB_HANDLER_ENDSUBMSG));
968
964
  }
969
965
 
970
966
  static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink,
971
- int depth) {
967
+ int depth, bool emit_defaults) {
972
968
  upb_sink subsink;
973
969
  upb_fieldtype_t type = upb_fielddef_type(f);
974
970
  upb_selector_t sel = 0;
@@ -1005,7 +1001,7 @@ static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink,
1005
1001
  putstr(*((VALUE *)memory), f, &subsink);
1006
1002
  break;
1007
1003
  case UPB_TYPE_MESSAGE:
1008
- putsubmsg(*((VALUE *)memory), f, &subsink, depth);
1004
+ putsubmsg(*((VALUE *)memory), f, &subsink, depth, emit_defaults);
1009
1005
  break;
1010
1006
 
1011
1007
  #undef T
@@ -1019,7 +1015,8 @@ static void put_ruby_value(VALUE value,
1019
1015
  const upb_fielddef *f,
1020
1016
  VALUE type_class,
1021
1017
  int depth,
1022
- upb_sink *sink) {
1018
+ upb_sink *sink,
1019
+ bool emit_defaults) {
1023
1020
  upb_selector_t sel = 0;
1024
1021
  if (upb_fielddef_isprimitive(f)) {
1025
1022
  sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
@@ -1059,12 +1056,12 @@ static void put_ruby_value(VALUE value,
1059
1056
  putstr(value, f, sink);
1060
1057
  break;
1061
1058
  case UPB_TYPE_MESSAGE:
1062
- putsubmsg(value, f, sink, depth);
1059
+ putsubmsg(value, f, sink, depth, emit_defaults);
1063
1060
  }
1064
1061
  }
1065
1062
 
1066
1063
  static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink,
1067
- int depth) {
1064
+ int depth, bool emit_defaults) {
1068
1065
  Map* self;
1069
1066
  upb_sink subsink;
1070
1067
  const upb_fielddef* key_field;
@@ -1090,9 +1087,9 @@ static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink,
1090
1087
  &entry_sink);
1091
1088
  upb_sink_startmsg(&entry_sink);
1092
1089
 
1093
- put_ruby_value(key, key_field, Qnil, depth + 1, &entry_sink);
1090
+ put_ruby_value(key, key_field, Qnil, depth + 1, &entry_sink, emit_defaults);
1094
1091
  put_ruby_value(value, value_field, self->value_type_class, depth + 1,
1095
- &entry_sink);
1092
+ &entry_sink, emit_defaults);
1096
1093
 
1097
1094
  upb_sink_endmsg(&entry_sink, &status);
1098
1095
  upb_sink_endsubmsg(&subsink, getsel(f, UPB_HANDLER_ENDSUBMSG));
@@ -1102,7 +1099,7 @@ static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink,
1102
1099
  }
1103
1100
 
1104
1101
  static void putmsg(VALUE msg_rb, const Descriptor* desc,
1105
- upb_sink *sink, int depth) {
1102
+ upb_sink *sink, int depth, bool emit_defaults) {
1106
1103
  MessageHeader* msg;
1107
1104
  upb_msg_field_iter i;
1108
1105
  upb_status status;
@@ -1144,31 +1141,31 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
1144
1141
 
1145
1142
  if (is_map_field(f)) {
1146
1143
  VALUE map = DEREF(msg, offset, VALUE);
1147
- if (map != Qnil) {
1148
- putmap(map, f, sink, depth);
1144
+ if (map != Qnil || emit_defaults) {
1145
+ putmap(map, f, sink, depth, emit_defaults);
1149
1146
  }
1150
1147
  } else if (upb_fielddef_isseq(f)) {
1151
1148
  VALUE ary = DEREF(msg, offset, VALUE);
1152
1149
  if (ary != Qnil) {
1153
- putary(ary, f, sink, depth);
1150
+ putary(ary, f, sink, depth, emit_defaults);
1154
1151
  }
1155
1152
  } else if (upb_fielddef_isstring(f)) {
1156
1153
  VALUE str = DEREF(msg, offset, VALUE);
1157
- if (is_matching_oneof || RSTRING_LEN(str) > 0) {
1154
+ if (is_matching_oneof || emit_defaults || RSTRING_LEN(str) > 0) {
1158
1155
  putstr(str, f, sink);
1159
1156
  }
1160
1157
  } else if (upb_fielddef_issubmsg(f)) {
1161
- putsubmsg(DEREF(msg, offset, VALUE), f, sink, depth);
1158
+ putsubmsg(DEREF(msg, offset, VALUE), f, sink, depth, emit_defaults);
1162
1159
  } else {
1163
1160
  upb_selector_t sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
1164
1161
 
1165
- #define T(upbtypeconst, upbtype, ctype, default_value) \
1166
- case upbtypeconst: { \
1167
- ctype value = DEREF(msg, offset, ctype); \
1168
- if (is_matching_oneof || value != default_value) { \
1169
- upb_sink_put##upbtype(sink, sel, value); \
1170
- } \
1171
- } \
1162
+ #define T(upbtypeconst, upbtype, ctype, default_value) \
1163
+ case upbtypeconst: { \
1164
+ ctype value = DEREF(msg, offset, ctype); \
1165
+ if (is_matching_oneof || emit_defaults || value != default_value) { \
1166
+ upb_sink_put##upbtype(sink, sel, value); \
1167
+ } \
1168
+ } \
1172
1169
  break;
1173
1170
 
1174
1171
  switch (upb_fielddef_type(f)) {
@@ -1246,7 +1243,7 @@ VALUE Message_encode(VALUE klass, VALUE msg_rb) {
1246
1243
  stackenv_init(&se, "Error occurred during encoding: %s");
1247
1244
  encoder = upb_pb_encoder_create(&se.env, serialize_handlers, &sink.sink);
1248
1245
 
1249
- putmsg(msg_rb, desc, upb_pb_encoder_input(encoder), 0);
1246
+ putmsg(msg_rb, desc, upb_pb_encoder_input(encoder), 0, false);
1250
1247
 
1251
1248
  ret = rb_str_new(sink.ptr, sink.len);
1252
1249
 
@@ -1268,6 +1265,7 @@ VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
1268
1265
  Descriptor* desc = ruby_to_Descriptor(descriptor);
1269
1266
  VALUE msg_rb;
1270
1267
  VALUE preserve_proto_fieldnames = Qfalse;
1268
+ VALUE emit_defaults = Qfalse;
1271
1269
  stringsink sink;
1272
1270
 
1273
1271
  if (argc < 1 || argc > 2) {
@@ -1283,6 +1281,9 @@ VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
1283
1281
  }
1284
1282
  preserve_proto_fieldnames = rb_hash_lookup2(
1285
1283
  hash_args, ID2SYM(rb_intern("preserve_proto_fieldnames")), Qfalse);
1284
+
1285
+ emit_defaults = rb_hash_lookup2(
1286
+ hash_args, ID2SYM(rb_intern("emit_defaults")), Qfalse);
1286
1287
  }
1287
1288
 
1288
1289
  stringsink_init(&sink);
@@ -1297,7 +1298,7 @@ VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
1297
1298
  stackenv_init(&se, "Error occurred during encoding: %s");
1298
1299
  printer = upb_json_printer_create(&se.env, serialize_handlers, &sink.sink);
1299
1300
 
1300
- putmsg(msg_rb, desc, upb_json_printer_input(printer), 0);
1301
+ putmsg(msg_rb, desc, upb_json_printer_input(printer), 0, RTEST(emit_defaults));
1301
1302
 
1302
1303
  ret = rb_enc_str_new(sink.ptr, sink.len, rb_utf8_encoding());
1303
1304