protobuf/php/ext/google/protobuf/message.c
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2014 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #include "message.h"
32 
33 #include <inttypes.h>
34 #include <php.h>
35 #include <stdlib.h>
36 
37 // This is not self-contained: it must be after other Zend includes.
38 #include <Zend/zend_exceptions.h>
39 #include <Zend/zend_inheritance.h>
40 
41 #include "arena.h"
42 #include "array.h"
43 #include "convert.h"
44 #include "def.h"
45 #include "map.h"
46 #include "php-upb.h"
47 #include "protobuf.h"
48 
49 // -----------------------------------------------------------------------------
50 // Message
51 // -----------------------------------------------------------------------------
52 
53 typedef struct {
54  zend_object std;
55  zval arena;
56  const Descriptor* desc;
58 } Message;
59 
60 zend_class_entry *message_ce;
61 static zend_object_handlers message_object_handlers;
62 
63 static void Message_SuppressDefaultProperties(zend_class_entry *class_type) {
64  // We suppress all default properties, because all our properties are handled
65  // by our read_property handler.
66  //
67  // This also allows us to put our zend_object member at the beginning of our
68  // struct -- instead of putting it at the end with pointer fixups to access
69  // our own data, as recommended in the docs -- because Zend won't add any of
70  // its own storage directly after the zend_object if default_properties_count
71  // == 0.
72  //
73  // This is not officially supported, but since it simplifies the code, we'll
74  // do it for as long as it works in practice.
75  class_type->default_properties_count = 0;
76 }
77 
78 // PHP Object Handlers /////////////////////////////////////////////////////////
79 
85 static zend_object* Message_create(zend_class_entry *class_type) {
86  Message *intern = emalloc(sizeof(Message));
88  zend_object_std_init(&intern->std, class_type);
89  intern->std.handlers = &message_object_handlers;
90  Arena_Init(&intern->arena);
91  return &intern->std;
92 }
93 
101 static void Message_dtor(zend_object* obj) {
102  Message* intern = (Message*)obj;
103  ObjCache_Delete(intern->msg);
104  zval_dtor(&intern->arena);
105  zend_object_std_dtor(&intern->std);
106 }
107 
114  const upb_msgdef *m = msg->desc->msgdef;
115  const upb_fielddef *f =
117 
118  if (!f) {
119  zend_throw_exception_ex(NULL, 0, "No such property %s.",
120  ZSTR_VAL(msg->desc->class_entry->name));
121  }
122 
123  return f;
124 }
125 
126 static void Message_get(Message *intern, const upb_fielddef *f, zval *rv) {
127  upb_arena *arena = Arena_Get(&intern->arena);
128 
129  if (upb_fielddef_ismap(f)) {
130  upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena);
131  MapField_GetPhpWrapper(rv, msgval.map, MapType_Get(f), &intern->arena);
132  } else if (upb_fielddef_isseq(f)) {
133  upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena);
135  &intern->arena);
136  } else {
137  if (upb_fielddef_issubmsg(f) && !upb_msg_has(intern->msg, f)) {
138  ZVAL_NULL(rv);
139  return;
140  }
141  upb_msgval msgval = upb_msg_get(intern->msg, f);
142  Convert_UpbToPhp(msgval, rv, TypeInfo_Get(f), &intern->arena);
143  }
144 }
145 
146 static bool Message_set(Message *intern, const upb_fielddef *f, zval *val) {
147  upb_arena *arena = Arena_Get(&intern->arena);
148  upb_msgval msgval;
149 
150  if (upb_fielddef_ismap(f)) {
151  msgval.map_val = MapField_GetUpbMap(val, MapType_Get(f), arena);
152  if (!msgval.map_val) return false;
153  } else if (upb_fielddef_isseq(f)) {
155  if (!msgval.array_val) return false;
156  } else if (upb_fielddef_issubmsg(f) && Z_TYPE_P(val) == IS_NULL) {
157  upb_msg_clearfield(intern->msg, f);
158  return true;
159  } else {
160  if (!Convert_PhpToUpb(val, &msgval, TypeInfo_Get(f), arena)) return false;
161  }
162 
163  upb_msg_set(intern->msg, f, msgval, arena);
164  return true;
165 }
166 
167 static bool MessageEq(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m);
168 
173  switch (type.type) {
174  case UPB_TYPE_BOOL:
175  return val1.bool_val == val2.bool_val;
176  case UPB_TYPE_INT32:
177  case UPB_TYPE_UINT32:
178  case UPB_TYPE_ENUM:
179  return val1.int32_val == val2.int32_val;
180  case UPB_TYPE_INT64:
181  case UPB_TYPE_UINT64:
182  return val1.int64_val == val2.int64_val;
183  case UPB_TYPE_FLOAT:
184  return val1.float_val == val2.float_val;
185  case UPB_TYPE_DOUBLE:
186  return val1.double_val == val2.double_val;
187  case UPB_TYPE_STRING:
188  case UPB_TYPE_BYTES:
189  return val1.str_val.size == val2.str_val.size &&
190  memcmp(val1.str_val.data, val2.str_val.data, val1.str_val.size) == 0;
191  case UPB_TYPE_MESSAGE:
192  return MessageEq(val1.msg_val, val2.msg_val, type.desc->msgdef);
193  default:
194  return false;
195  }
196 }
197 
201 static bool MessageEq(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m) {
203 
204  for(upb_msg_field_begin(&i, m);
206  upb_msg_field_next(&i)) {
207  const upb_fielddef *f = upb_msg_iter_field(&i);
208 
210  if (upb_msg_has(m1, f) != upb_msg_has(m2, f)) {
211  return false;
212  }
213  if (!upb_msg_has(m1, f)) continue;
214  }
215 
216  upb_msgval val1 = upb_msg_get(m1, f);
217  upb_msgval val2 = upb_msg_get(m2, f);
218 
219  if (upb_fielddef_ismap(f)) {
220  if (!MapEq(val1.map_val, val2.map_val, MapType_Get(f))) return false;
221  } else if (upb_fielddef_isseq(f)) {
222  if (!ArrayEq(val1.array_val, val2.array_val, TypeInfo_Get(f))) return false;
223  } else {
224  if (!ValueEq(val1, val2, TypeInfo_Get(f))) return false;
225  }
226  }
227 
228  return true;
229 }
230 
239 static int Message_compare_objects(zval *m1, zval *m2) {
240  Message* intern1 = (Message*)Z_OBJ_P(m1);
241  Message* intern2 = (Message*)Z_OBJ_P(m2);
242  const upb_msgdef *m = intern1->desc->msgdef;
243 
244  if (intern2->desc->msgdef != m) return 1;
245 
246  return MessageEq(intern1->msg, intern2->msg, m) ? 0 : 1;
247 }
248 
268  int has_set_exists,
269  void **cache_slot) {
271  const upb_fielddef *f = get_field(intern, member);
272 
273  if (!f) return 0;
274 
275  if (!upb_fielddef_haspresence(f)) {
276  zend_throw_exception_ex(
277  NULL, 0,
278  "Cannot call isset() on field %s which does not have presence.",
280  return 0;
281  }
282 
283  return upb_msg_has(intern->msg, f);
284 }
285 
303  void **cache_slot) {
305  const upb_fielddef *f = get_field(intern, member);
306 
307  if (!f) return;
308 
309  if (!upb_fielddef_haspresence(f)) {
310  zend_throw_exception_ex(
311  NULL, 0,
312  "Cannot call unset() on field %s which does not have presence.",
314  return;
315  }
316 
317  upb_msg_clearfield(intern->msg, f);
318 }
319 
320 
340  int type, void **cache_slot, zval *rv) {
342  const upb_fielddef *f = get_field(intern, member);
343 
344  if (!f) return &EG(uninitialized_zval);
345  Message_get(intern, f, rv);
346  return rv;
347 }
348 
371  PROTO_VAL *obj, PROTO_STR *member, zval *val, void **cache_slot) {
373  const upb_fielddef *f = get_field(intern, member);
374 
375  if (f && Message_set(intern, f, val)) {
376 #if PHP_VERSION_ID < 70400
377  return;
378 #else
379  return val;
380 #endif
381  } else {
382 #if PHP_VERSION_ID < 70400
383  return;
384 #else
385  return &EG(error_zval);
386 #endif
387  }
388 }
389 
398  int type,
399  void **cache_slot) {
400  return NULL; // We do not have a properties table.
401 }
402 
410 static zend_object *Message_clone_obj(PROTO_VAL *object) {
411  Message* intern = PROTO_VAL_P(object);
412  upb_msg *clone = upb_msg_new(intern->desc->msgdef, Arena_Get(&intern->arena));
413 
414  // TODO: copy unknown fields?
415  // TODO: use official upb msg copy function
416  memcpy(clone, intern->msg, upb_msgdef_layout(intern->desc->msgdef)->size);
417  zval ret;
418  Message_GetPhpWrapper(&ret, intern->desc, clone, &intern->arena);
419  return Z_OBJ_P(&ret);
420 }
421 
428 static HashTable *Message_get_properties(PROTO_VAL *object) {
429  return NULL; // We don't offer direct references to our properties.
430 }
431 
432 // C Functions from message.h. /////////////////////////////////////////////////
433 
434 // These are documented in the header file.
435 
437  zval *arena) {
438  if (!msg) {
439  ZVAL_NULL(val);
440  return;
441  }
442 
443  if (!ObjCache_Get(msg, val)) {
444  Message *intern = emalloc(sizeof(Message));
446  zend_object_std_init(&intern->std, desc->class_entry);
447  intern->std.handlers = &message_object_handlers;
448  ZVAL_COPY(&intern->arena, arena);
449  intern->desc = desc;
450  intern->msg = msg;
451  ZVAL_OBJ(val, &intern->std);
452  ObjCache_Add(intern->msg, &intern->std);
453  }
454 }
455 
457  upb_msg **msg) {
459 
460  if (Z_ISREF_P(val)) {
461  ZVAL_DEREF(val);
462  }
463 
464  if (Z_TYPE_P(val) == IS_OBJECT &&
465  instanceof_function(Z_OBJCE_P(val), desc->class_entry)) {
466  Message *intern = (Message*)Z_OBJ_P(val);
468  *msg = intern->msg;
469  return true;
470  } else {
471  zend_throw_exception_ex(zend_ce_type_error, 0,
472  "Given value is not an instance of %s.",
473  ZSTR_VAL(desc->class_entry->name));
474  return false;
475  }
476 }
477 
478 // Message PHP methods /////////////////////////////////////////////////////////
479 
505  upb_arena *arena) {
506  HashTable* table = HASH_OF(init);
507  HashPosition pos;
508 
509  if (Z_ISREF_P(init)) {
510  ZVAL_DEREF(init);
511  }
512 
513  if (Z_TYPE_P(init) != IS_ARRAY) {
514  zend_throw_exception_ex(NULL, 0,
515  "Initializer for a message %s must be an array.",
517  return false;
518  }
519 
520  zend_hash_internal_pointer_reset_ex(table, &pos);
521 
522  while (true) { // Iterate over key/value pairs.
523  zval key;
524  zval *val;
525  const upb_fielddef *f;
526  upb_msgval msgval;
527 
528  zend_hash_get_current_key_zval_ex(table, &key, &pos);
529  val = zend_hash_get_current_data_ex(table, &pos);
530 
531  if (!val) return true; // Finished iteration.
532 
533  if (Z_ISREF_P(val)) {
534  ZVAL_DEREF(val);
535  }
536 
537  f = upb_msgdef_ntof(m, Z_STRVAL_P(&key), Z_STRLEN_P(&key));
538 
539  if (!f) {
540  zend_throw_exception_ex(NULL, 0,
541  "No such field %s", Z_STRVAL_P(&key));
542  return false;
543  }
544 
545  if (upb_fielddef_ismap(f)) {
546  msgval.map_val = MapField_GetUpbMap(val, MapType_Get(f), arena);
547  if (!msgval.map_val) return false;
548  } else if (upb_fielddef_isseq(f)) {
550  if (!msgval.array_val) return false;
551  } else {
552  if (!Convert_PhpToUpbAutoWrap(val, &msgval, TypeInfo_Get(f), arena)) {
553  return false;
554  }
555  }
556 
557  upb_msg_set(msg, f, msgval, arena);
558  zend_hash_move_forward_ex(table, &pos);
559  zval_dtor(&key);
560  }
561 }
562 
564  intern->desc = desc;
565  intern->msg = upb_msg_new(desc->msgdef, Arena_Get(&intern->arena));
566  ObjCache_Add(intern->msg, &intern->std);
567 }
568 
575 PHP_METHOD(Message, __construct) {
576  Message* intern = (Message*)Z_OBJ_P(getThis());
577  const Descriptor* desc;
578  zend_class_entry *ce = Z_OBJCE_P(getThis());
579  upb_arena *arena = Arena_Get(&intern->arena);
580  zval *init_arr = NULL;
581 
582  // This descriptor should always be available, as the generated __construct
583  // method calls initOnce() to load the descriptor prior to calling us.
584  //
585  // However, if the user created their own class derived from Message, this
586  // will trigger an infinite construction loop and blow the stack. We
587  // temporarily clear create_object to break this loop (see check in
588  // NameMap_GetMessage()).
589  PBPHP_ASSERT(ce->create_object == Message_create);
590  ce->create_object = NULL;
592  ce->create_object = Message_create;
593 
594  if (!desc) {
595  zend_throw_exception_ex(
596  NULL, 0,
597  "Couldn't find descriptor. Note only generated code may derive from "
598  "\\Google\\Protobuf\\Internal\\Message");
599  return;
600  }
601 
603 
604  if (zend_parse_parameters(ZEND_NUM_ARGS(), "|a!", &init_arr) == FAILURE) {
605  return;
606  }
607 
608  if (init_arr) {
609  Message_InitFromPhp(intern->msg, desc->msgdef, init_arr, arena);
610  }
611 }
612 
618 PHP_METHOD(Message, discardUnknownFields) {
619  Message* intern = (Message*)Z_OBJ_P(getThis());
620  upb_msg_discardunknown(intern->msg, intern->desc->msgdef, 64);
621 }
622 
629  Message* intern = (Message*)Z_OBJ_P(getThis());
630  upb_msg_clear(intern->msg, intern->desc->msgdef);
631 }
632 
639 PHP_METHOD(Message, mergeFrom) {
640  Message* intern = (Message*)Z_OBJ_P(getThis());
641  Message* from;
642  upb_arena *arena = Arena_Get(&intern->arena);
643  const upb_msglayout *l = upb_msgdef_layout(intern->desc->msgdef);
644  zval* value;
645  char *pb;
646  size_t size;
647  bool ok;
648 
649  if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &value,
650  intern->desc->class_entry) == FAILURE) {
651  return;
652  }
653 
654  from = (Message*)Z_OBJ_P(value);
655 
656  // Should be guaranteed since we passed the class type to
657  // zend_parse_parameters().
658  PBPHP_ASSERT(from->desc == intern->desc);
659 
660  // TODO(haberman): use a temp arena for this once we can make upb_decode()
661  // copy strings.
662  pb = upb_encode(from->msg, l, arena, &size);
663 
664  if (!pb) {
665  zend_throw_exception_ex(NULL, 0, "Max nesting exceeded");
666  return;
667  }
668 
669  ok = upb_decode(pb, size, intern->msg, l, arena);
670  PBPHP_ASSERT(ok);
671 }
672 
679 PHP_METHOD(Message, mergeFromString) {
680  Message* intern = (Message*)Z_OBJ_P(getThis());
681  char *data = NULL;
682  char *data_copy = NULL;
683  zend_long data_len;
684  const upb_msglayout *l = upb_msgdef_layout(intern->desc->msgdef);
685  upb_arena *arena = Arena_Get(&intern->arena);
686 
687  if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &data, &data_len) ==
688  FAILURE) {
689  return;
690  }
691 
692  // TODO(haberman): avoid this copy when we can make the decoder copy.
693  data_copy = upb_arena_malloc(arena, data_len);
694  memcpy(data_copy, data, data_len);
695 
696  if (!upb_decode(data_copy, data_len, intern->msg, l, arena)) {
697  zend_throw_exception_ex(NULL, 0, "Error occurred during parsing");
698  return;
699  }
700 }
701 
708 PHP_METHOD(Message, serializeToString) {
709  Message* intern = (Message*)Z_OBJ_P(getThis());
710  const upb_msglayout *l = upb_msgdef_layout(intern->desc->msgdef);
711  upb_arena *tmp_arena = upb_arena_new();
712  char *data;
713  size_t size;
714 
715  data = upb_encode(intern->msg, l, tmp_arena, &size);
716 
717  if (!data) {
718  zend_throw_exception_ex(NULL, 0, "Error occurred during serialization");
719  upb_arena_free(tmp_arena);
720  return;
721  }
722 
723  RETVAL_STRINGL(data, size);
724  upb_arena_free(tmp_arena);
725 }
726 
733 PHP_METHOD(Message, mergeFromJsonString) {
734  Message* intern = (Message*)Z_OBJ_P(getThis());
735  char *data = NULL;
736  char *data_copy = NULL;
737  zend_long data_len;
738  upb_arena *arena = Arena_Get(&intern->arena);
740  zend_bool ignore_json_unknown = false;
741  int options = 0;
742 
743  if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &data, &data_len,
744  &ignore_json_unknown) == FAILURE) {
745  return;
746  }
747 
748  // TODO(haberman): avoid this copy when we can make the decoder copy.
749  data_copy = upb_arena_malloc(arena, data_len + 1);
750  memcpy(data_copy, data, data_len);
751  data_copy[data_len] = '\0';
752 
753  if (ignore_json_unknown) {
755  }
756 
758  if (!upb_json_decode(data_copy, data_len, intern->msg, intern->desc->msgdef,
760  &status)) {
761  zend_throw_exception_ex(NULL, 0, "Error occurred during parsing: %s",
763  return;
764  }
765 }
766 
773 PHP_METHOD(Message, serializeToJsonString) {
774  Message* intern = (Message*)Z_OBJ_P(getThis());
775  size_t size;
776  int options = 0;
777  char buf[1024];
778  zend_bool preserve_proto_fieldnames = false;
780 
781  if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b",
782  &preserve_proto_fieldnames) == FAILURE) {
783  return;
784  }
785 
786  if (preserve_proto_fieldnames) {
788  }
789 
791  size = upb_json_encode(intern->msg, intern->desc->msgdef,
793  sizeof(buf), &status);
794 
795  if (!upb_ok(&status)) {
796  zend_throw_exception_ex(NULL, 0,
797  "Error occurred during JSON serialization: %s",
799  return;
800  }
801 
802  if (size >= sizeof(buf)) {
803  char *buf2 = malloc(size + 1);
804  upb_json_encode(intern->msg, intern->desc->msgdef,
806  &status);
807  RETVAL_STRINGL(buf2, size);
808  free(buf2);
809  } else {
810  RETVAL_STRINGL(buf, size);
811  }
812 }
813 
827 PHP_METHOD(Message, readWrapperValue) {
828  Message* intern = (Message*)Z_OBJ_P(getThis());
829  char* member;
830  const upb_fielddef *f;
831  zend_long size;
832 
833  if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &member, &size) == FAILURE) {
834  return;
835  }
836 
837  f = upb_msgdef_ntof(intern->desc->msgdef, member, size);
838 
840  zend_throw_exception_ex(NULL, 0, "Message %s has no field %s",
841  upb_msgdef_fullname(intern->desc->msgdef), member);
842  return;
843  }
844 
845  if (upb_msg_has(intern->msg, f)) {
846  const upb_msg *wrapper = upb_msg_get(intern->msg, f).msg_val;
848  const upb_fielddef *val_f = upb_msgdef_itof(m, 1);
849  upb_msgval msgval = upb_msg_get(wrapper, val_f);
850  zval ret;
851  Convert_UpbToPhp(msgval, &ret, TypeInfo_Get(val_f), &intern->arena);
853  } else {
854  RETURN_NULL();
855  }
856 }
857 
873 PHP_METHOD(Message, writeWrapperValue) {
874  Message* intern = (Message*)Z_OBJ_P(getThis());
875  upb_arena *arena = Arena_Get(&intern->arena);
876  char* member;
877  const upb_fielddef *f;
878  upb_msgval msgval;
879  zend_long size;
880  zval* val;
881 
882  if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz", &member, &size, &val) ==
883  FAILURE) {
884  return;
885  }
886 
887  f = upb_msgdef_ntof(intern->desc->msgdef, member, size);
888 
890  zend_throw_exception_ex(NULL, 0, "Message %s has no field %s",
891  upb_msgdef_fullname(intern->desc->msgdef), member);
892  return;
893  }
894 
895  if (Z_ISREF_P(val)) {
896  ZVAL_DEREF(val);
897  }
898 
899  if (Z_TYPE_P(val) == IS_NULL) {
900  upb_msg_clearfield(intern->msg, f);
901  } else {
903  const upb_fielddef *val_f = upb_msgdef_itof(m, 1);
904  upb_msg *wrapper;
905 
906  if (!Convert_PhpToUpb(val, &msgval, TypeInfo_Get(val_f), arena)) {
907  return; // Error is already set.
908  }
909 
911  upb_msg_set(wrapper, val_f, msgval, arena);
912  }
913 }
914 
923 PHP_METHOD(Message, whichOneof) {
924  Message* intern = (Message*)Z_OBJ_P(getThis());
925  const upb_oneofdef* oneof;
926  const upb_fielddef* field;
927  char* name;
928  zend_long len;
929 
930  if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &len) == FAILURE) {
931  return;
932  }
933 
934  oneof = upb_msgdef_ntoo(intern->desc->msgdef, name, len);
935 
936  if (!oneof) {
937  zend_throw_exception_ex(NULL, 0, "Message %s has no oneof %s",
938  upb_msgdef_fullname(intern->desc->msgdef), name);
939  return;
940  }
941 
942  field = upb_msg_whichoneof(intern->msg, oneof);
943  RETURN_STRING(field ? upb_fielddef_name(field) : "");
944 }
945 
959 PHP_METHOD(Message, hasOneof) {
960  Message* intern = (Message*)Z_OBJ_P(getThis());
961  zend_long field_num;
962  const upb_fielddef* f;
963 
964  if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &field_num) == FAILURE) {
965  return;
966  }
967 
968  f = upb_msgdef_itof(intern->desc->msgdef, field_num);
969 
971  php_error_docref(NULL, E_USER_ERROR,
972  "Internal error, no such oneof field %d\n",
973  (int)field_num);
974  }
975 
976  RETVAL_BOOL(upb_msg_has(intern->msg, f));
977 }
978 
992 PHP_METHOD(Message, readOneof) {
993  Message* intern = (Message*)Z_OBJ_P(getThis());
994  zend_long field_num;
995  const upb_fielddef* f;
996  zval ret;
997 
998  if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &field_num) == FAILURE) {
999  return;
1000  }
1001 
1002  f = upb_msgdef_itof(intern->desc->msgdef, field_num);
1003 
1004  if (!f || !upb_fielddef_realcontainingoneof(f)) {
1005  php_error_docref(NULL, E_USER_ERROR,
1006  "Internal error, no such oneof field %d\n",
1007  (int)field_num);
1008  }
1009 
1010  if (upb_fielddef_issubmsg(f) && !upb_msg_has(intern->msg, f)) {
1011  RETURN_NULL();
1012  }
1013 
1014  {
1015  upb_msgval msgval = upb_msg_get(intern->msg, f);
1016  Convert_UpbToPhp(msgval, &ret, TypeInfo_Get(f), &intern->arena);
1017  }
1018 
1020 }
1021 
1042 PHP_METHOD(Message, writeOneof) {
1043  Message* intern = (Message*)Z_OBJ_P(getThis());
1044  zend_long field_num;
1045  const upb_fielddef* f;
1046  upb_arena *arena = Arena_Get(&intern->arena);
1047  upb_msgval msgval;
1048  zval* val;
1049 
1050  if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &field_num, &val) ==
1051  FAILURE) {
1052  return;
1053  }
1054 
1055  f = upb_msgdef_itof(intern->desc->msgdef, field_num);
1056 
1057  if (upb_fielddef_issubmsg(f) && Z_TYPE_P(val) == IS_NULL) {
1058  upb_msg_clearfield(intern->msg, f);
1059  return;
1060  } else if (!Convert_PhpToUpb(val, &msgval, TypeInfo_Get(f), arena)) {
1061  return;
1062  }
1063 
1064  upb_msg_set(intern->msg, f, msgval, arena);
1065 }
1066 
1067 ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 0)
1068  ZEND_ARG_INFO(0, data)
1069 ZEND_END_ARG_INFO()
1070 
1071 ZEND_BEGIN_ARG_INFO_EX(arginfo_mergeFrom, 0, 0, 1)
1072  ZEND_ARG_INFO(0, data)
1073 ZEND_END_ARG_INFO()
1074 
1075 ZEND_BEGIN_ARG_INFO_EX(arginfo_mergeFromWithArg, 0, 0, 1)
1076  ZEND_ARG_INFO(0, data)
1077  ZEND_ARG_INFO(0, arg)
1078 ZEND_END_ARG_INFO()
1079 
1080 ZEND_BEGIN_ARG_INFO_EX(arginfo_read, 0, 0, 1)
1081  ZEND_ARG_INFO(0, field)
1082 ZEND_END_ARG_INFO()
1083 
1084 ZEND_BEGIN_ARG_INFO_EX(arginfo_write, 0, 0, 2)
1085  ZEND_ARG_INFO(0, field)
1086  ZEND_ARG_INFO(0, value)
1087 ZEND_END_ARG_INFO()
1088 
1089 static zend_function_entry Message_methods[] = {
1090  PHP_ME(Message, clear, arginfo_void, ZEND_ACC_PUBLIC)
1091  PHP_ME(Message, discardUnknownFields, arginfo_void, ZEND_ACC_PUBLIC)
1092  PHP_ME(Message, serializeToString, arginfo_void, ZEND_ACC_PUBLIC)
1093  PHP_ME(Message, mergeFromString, arginfo_mergeFrom, ZEND_ACC_PUBLIC)
1094  PHP_ME(Message, serializeToJsonString, arginfo_void, ZEND_ACC_PUBLIC)
1095  PHP_ME(Message, mergeFromJsonString, arginfo_mergeFromWithArg, ZEND_ACC_PUBLIC)
1096  PHP_ME(Message, mergeFrom, arginfo_mergeFrom, ZEND_ACC_PUBLIC)
1097  PHP_ME(Message, readWrapperValue, arginfo_read, ZEND_ACC_PROTECTED)
1098  PHP_ME(Message, writeWrapperValue, arginfo_write, ZEND_ACC_PROTECTED)
1099  PHP_ME(Message, hasOneof, arginfo_read, ZEND_ACC_PROTECTED)
1100  PHP_ME(Message, readOneof, arginfo_read, ZEND_ACC_PROTECTED)
1101  PHP_ME(Message, writeOneof, arginfo_write, ZEND_ACC_PROTECTED)
1102  PHP_ME(Message, whichOneof, arginfo_read, ZEND_ACC_PROTECTED)
1103  PHP_ME(Message, __construct, arginfo_construct, ZEND_ACC_PROTECTED)
1104  ZEND_FE_END
1105 };
1106 
1107 // Well-known types ////////////////////////////////////////////////////////////
1108 
1109 static const char TYPE_URL_PREFIX[] = "type.googleapis.com/";
1110 
1111 static upb_msgval Message_getval(Message *intern, const char *field_name) {
1112  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, field_name);
1113  PBPHP_ASSERT(f);
1114  return upb_msg_get(intern->msg, f);
1115 }
1116 
1117 static void Message_setval(Message *intern, const char *field_name,
1118  upb_msgval val) {
1119  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, field_name);
1120  PBPHP_ASSERT(f);
1121  return upb_msg_set(intern->msg, f, val, Arena_Get(&intern->arena));
1122 }
1123 
1125  upb_msgval ret;
1126  ret.str_val = view;
1127  return ret;
1128 }
1129 
1131  size_t size = strlen(TYPE_URL_PREFIX);
1132  if (str->size < size || memcmp(TYPE_URL_PREFIX, str->data, size) != 0) {
1133  return false;
1134  }
1135  str->data += size;
1136  str->size -= size;
1137  return true;
1138 }
1139 
1140 static bool StrViewEq(upb_strview view, const char *str) {
1141  size_t size = strlen(str);
1142  return view.size == size && memcmp(view.data, str, size) == 0;
1143 }
1144 
1146  Message* intern = (Message*)Z_OBJ_P(getThis());
1150  const upb_msgdef *m;
1151  Descriptor *desc;
1152  zval ret;
1153 
1154  // Ensure that type_url has TYPE_URL_PREFIX as a prefix.
1155  if (!TryStripUrlPrefix(&type_url)) {
1156  zend_throw_exception(
1157  NULL, "Type url needs to be type.googleapis.com/fully-qualified",
1158  0);
1159  return;
1160  }
1161 
1163 
1164  if (m == NULL) {
1165  zend_throw_exception(
1166  NULL, "Specified message in any hasn't been added to descriptor pool",
1167  0);
1168  return;
1169  }
1170 
1172  PBPHP_ASSERT(desc->class_entry->create_object == Message_create);
1173  zend_object *obj = Message_create(desc->class_entry);
1174  Message *msg = (Message*)obj;
1176  ZVAL_OBJ(&ret, obj);
1177 
1178  // Get value.
1179  if (!upb_decode(value.data, value.size, msg->msg,
1180  upb_msgdef_layout(desc->msgdef), Arena_Get(&msg->arena))) {
1181  zend_throw_exception_ex(NULL, 0, "Error occurred during parsing");
1182  zval_dtor(&ret);
1183  return;
1184  }
1185 
1186  // Fuse since the parsed message could alias "value".
1187  upb_arena_fuse(Arena_Get(&intern->arena), Arena_Get(&msg->arena));
1188 
1190 }
1191 
1193  Message* intern = (Message*)Z_OBJ_P(getThis());
1194  upb_arena *arena = Arena_Get(&intern->arena);
1195  zval *val;
1196  Message *msg;
1199  const char *full_name;
1200  char *buf;
1201 
1202  if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &val) ==
1203  FAILURE) {
1204  return;
1205  }
1206 
1207  if (!instanceof_function(Z_OBJCE_P(val), message_ce)) {
1208  zend_error(E_USER_ERROR, "Given value is not an instance of Message.");
1209  return;
1210  }
1211 
1212  msg = (Message*)Z_OBJ_P(val);
1213 
1214  // Serialize and set value.
1215  value.data = upb_encode(msg->msg, upb_msgdef_layout(msg->desc->msgdef), arena,
1216  &value.size);
1217  Message_setval(intern, "value", StringVal(value));
1218 
1219  // Set type url: type_url_prefix + fully_qualified_name
1220  full_name = upb_msgdef_fullname(msg->desc->msgdef);
1221  type_url.size = strlen(TYPE_URL_PREFIX) + strlen(full_name);
1222  buf = upb_arena_malloc(arena, type_url.size + 1);
1224  memcpy(buf + strlen(TYPE_URL_PREFIX), full_name, strlen(full_name));
1225  type_url.data = buf;
1226  Message_setval(intern, "type_url", StringVal(type_url));
1227 }
1228 
1230  Message* intern = (Message*)Z_OBJ_P(getThis());
1232  zend_class_entry *klass = NULL;
1233  const upb_msgdef *m;
1234 
1235  if (zend_parse_parameters(ZEND_NUM_ARGS(), "C", &klass) ==
1236  FAILURE) {
1237  return;
1238  }
1239 
1241 
1242  if (m == NULL) {
1243  RETURN_BOOL(false);
1244  }
1245 
1246  RETURN_BOOL(TryStripUrlPrefix(&type_url) &&
1248 }
1249 
1251  Message* intern = (Message*)Z_OBJ_P(getThis());
1252  zval* datetime;
1253  const char *classname = "\\DatetimeInterface";
1254  zend_string *classname_str = zend_string_init(classname, strlen(classname), 0);
1255  zend_class_entry *date_interface_ce = zend_lookup_class(classname_str);
1256  zend_string_release(classname_str);
1257 
1258  if (date_interface_ce == NULL) {
1259  zend_error(E_ERROR, "Make sure date extension is enabled.");
1260  return;
1261  }
1262 
1263  if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &datetime,
1264  date_interface_ce) == FAILURE) {
1265  zend_error(E_USER_ERROR, "Expect DatetimeInterface.");
1266  return;
1267  }
1268 
1269  upb_msgval timestamp_seconds;
1270  {
1271  zval retval;
1272  zval function_name;
1273 
1274  ZVAL_STRING(&function_name, "date_timestamp_get");
1275 
1276  if (call_user_function(EG(function_table), NULL, &function_name, &retval, 1,
1277  datetime) == FAILURE ||
1278  !Convert_PhpToUpb(&retval, &timestamp_seconds,
1280  zend_error(E_ERROR, "Cannot get timestamp from DateTime.");
1281  return;
1282  }
1283 
1284  zval_dtor(&retval);
1285  zval_dtor(&function_name);
1286  }
1287 
1288  upb_msgval timestamp_nanos;
1289  {
1290  zval retval;
1291  zval function_name;
1292  zval format_string;
1293 
1294  ZVAL_STRING(&function_name, "date_format");
1295  ZVAL_STRING(&format_string, "u");
1296 
1297  zval params[2] = {
1298  *datetime,
1299  format_string,
1300  };
1301 
1302  if (call_user_function(EG(function_table), NULL, &function_name, &retval, 2,
1303  params) == FAILURE ||
1304  !Convert_PhpToUpb(&retval, &timestamp_nanos,
1306  zend_error(E_ERROR, "Cannot format DateTime.");
1307  return;
1308  }
1309 
1310  timestamp_nanos.int32_val *= 1000;
1311 
1312  zval_dtor(&retval);
1313  zval_dtor(&function_name);
1314  zval_dtor(&format_string);
1315  }
1316 
1317  Message_setval(intern, "seconds", timestamp_seconds);
1318  Message_setval(intern, "nanos", timestamp_nanos);
1319 
1320  RETURN_NULL();
1321 }
1322 
1324  Message* intern = (Message*)Z_OBJ_P(getThis());
1325  upb_msgval seconds = Message_getval(intern, "seconds");
1326  upb_msgval nanos = Message_getval(intern, "nanos");
1327 
1328  // Get formatted time string.
1329  char formatted_time[32];
1330  snprintf(formatted_time, sizeof(formatted_time), "%" PRId64 ".%06" PRId32,
1331  seconds.int64_val, nanos.int32_val / 1000);
1332 
1333  // Create Datetime object.
1334  zval datetime;
1335  zval function_name;
1336  zval format_string;
1337  zval formatted_time_php;
1338 
1339  ZVAL_STRING(&function_name, "date_create_from_format");
1340  ZVAL_STRING(&format_string, "U.u");
1341  ZVAL_STRING(&formatted_time_php, formatted_time);
1342 
1343  zval params[2] = {
1344  format_string,
1345  formatted_time_php,
1346  };
1347 
1348  if (call_user_function(EG(function_table), NULL, &function_name, &datetime, 2,
1349  params) == FAILURE) {
1350  zend_error(E_ERROR, "Cannot create DateTime.");
1351  return;
1352  }
1353 
1354  zval_dtor(&function_name);
1355  zval_dtor(&format_string);
1356  zval_dtor(&formatted_time_php);
1357 
1358  ZVAL_OBJ(return_value, Z_OBJ(datetime));
1359 }
1360 
1361 #include "wkt.inc"
1362 
1369  zend_class_entry tmp_ce;
1370  zend_object_handlers *h = &message_object_handlers;
1371 
1372  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Internal\\Message",
1373  Message_methods);
1374 
1375  message_ce = zend_register_internal_class(&tmp_ce);
1376  message_ce->create_object = Message_create;
1377 
1378  memcpy(h, &std_object_handlers, sizeof(zend_object_handlers));
1379  h->dtor_obj = Message_dtor;
1380 #if PHP_VERSION_ID < 80000
1381  h->compare_objects = Message_compare_objects;
1382 #else
1383  h->compare = Message_compare_objects;
1384 #endif
1385  h->read_property = Message_read_property;
1386  h->write_property = Message_write_property;
1387  h->has_property = Message_has_property;
1388  h->unset_property = Message_unset_property;
1389  h->get_properties = Message_get_properties;
1390  h->get_property_ptr_ptr = Message_get_property_ptr_ptr;
1391  h->clone_obj = Message_clone_obj;
1392 
1393  WellKnownTypes_ModuleInit(); /* From wkt.inc. */
1394 }
Convert_UpbToPhp
void Convert_UpbToPhp(upb_msgval upb_val, zval *php_val, TypeInfo type, zval *arena)
Definition: protobuf/php/ext/google/protobuf/convert.c:424
xds_interop_client.str
str
Definition: xds_interop_client.py:487
absl::time_internal::cctz::seconds
std::chrono::duration< std::int_fast64_t > seconds
Definition: abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h:40
obj
OPENSSL_EXPORT const ASN1_OBJECT * obj
Definition: x509.h:1671
upb_decode
bool upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l, upb_arena *arena)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:742
MessageEq
static bool MessageEq(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m)
Definition: protobuf/php/ext/google/protobuf/message.c:201
upb_mutmsgval::msg
upb_msg * msg
Definition: php-upb.h:4628
UPB_TYPE_UINT64
@ UPB_TYPE_UINT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:487
grpc::testing::val1
const char val1[]
Definition: client_context_test_peer_test.cc:34
PROTO_VAL
#define PROTO_VAL
Definition: protobuf/php/ext/google/protobuf/protobuf.h:59
upb_arena_malloc
UPB_INLINE void * upb_arena_malloc(upb_arena *a, size_t size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:383
MapType_Get
MapField_Type MapType_Get(const upb_fielddef *f)
Definition: protobuf/php/ext/google/protobuf/map.c:69
upb_arena
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2252
init
const char * init
Definition: upb/upb/bindings/lua/main.c:49
ObjCache_Add
void ObjCache_Add(const void *upb_obj, zend_object *php_obj)
Definition: protobuf/php/ext/google/protobuf/protobuf.c:219
upb_msgdef_ntoo
const upb_oneofdef * upb_msgdef_ntoo(const upb_msgdef *m, const char *name, size_t len)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3573
upb_status_clear
void upb_status_clear(upb_status *status)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2196
pos
int pos
Definition: libuv/docs/code/tty-gravity/main.c:11
upb_msg_field_next
void upb_msg_field_next(upb_msg_field_iter *iter)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3626
MapField_GetUpbMap
upb_map * MapField_GetUpbMap(zval *val, MapField_Type type, upb_arena *arena)
Definition: protobuf/php/ext/google/protobuf/map.c:187
upb_json_decode
bool upb_json_decode(const char *buf, size_t size, upb_msg *msg, const upb_msgdef *m, const upb_symtab *any_pool, int options, upb_arena *arena, upb_status *status)
Definition: php-upb.c:8775
UPB_TYPE_FLOAT
@ UPB_TYPE_FLOAT
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:476
PBPHP_ASSERT
#define PBPHP_ASSERT(x)
Definition: protobuf/php/ext/google/protobuf/protobuf.h:139
upb_msgval::array_val
const upb_array * array_val
Definition: php-upb.h:4622
Message_clone_obj
static zend_object * Message_clone_obj(PROTO_VAL *object)
Definition: protobuf/php/ext/google/protobuf/message.c:410
upb_status
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:197
upb_msglayout::size
uint16_t size
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:570
upb_msgval::map_val
const upb_map * map_val
Definition: php-upb.h:4620
ObjCache_Get
bool ObjCache_Get(const void *upb_obj, zval *val)
Definition: protobuf/php/ext/google/protobuf/protobuf.c:232
PROTO_STRLEN_P
#define PROTO_STRLEN_P(obj)
Definition: protobuf/php/ext/google/protobuf/protobuf.h:63
upb_fielddef_issubmsg
bool upb_fielddef_issubmsg(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3486
Message_GetPhpWrapper
void Message_GetPhpWrapper(zval *val, const Descriptor *desc, upb_msg *msg, zval *arena)
Definition: protobuf/php/ext/google/protobuf/message.c:436
Descriptor_GetFromClassEntry
Descriptor * Descriptor_GetFromClassEntry(zend_class_entry *ce)
Definition: protobuf/php/ext/google/protobuf/def.c:578
upb_msg_whichoneof
const upb_fielddef * upb_msg_whichoneof(const upb_msg *msg, const upb_oneofdef *o)
Definition: php-upb.c:7075
options
double_dict options[]
Definition: capstone_test.c:55
upb_arena_free
void upb_arena_free(upb_arena *a)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2391
upb_mutmsgval
Definition: php-upb.h:4626
PROTO_STRVAL_P
#define PROTO_STRVAL_P(obj)
Definition: protobuf/php/ext/google/protobuf/protobuf.h:62
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
Message_GetUpbMessage
bool Message_GetUpbMessage(zval *val, const Descriptor *desc, upb_arena *arena, upb_msg **msg)
Definition: protobuf/php/ext/google/protobuf/message.c:456
grpc::protobuf::Message
GRPC_CUSTOM_MESSAGE Message
Definition: include/grpcpp/impl/codegen/config_protobuf.h:78
Descriptor::msgdef
const upb_msgdef * msgdef
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:122
TypeInfo_Get
static TypeInfo TypeInfo_Get(const upb_fielddef *f)
Definition: protobuf/php/ext/google/protobuf/def.h:74
upb_msg_iter_field
upb_fielddef * upb_msg_iter_field(const upb_msg_field_iter *iter)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3632
upb_msgdef_iswrapper
bool upb_msgdef_iswrapper(const upb_msgdef *m)
Definition: php-upb.c:5473
upb_msg_new
upb_msg * upb_msg_new(const upb_msglayout *l, upb_arena *a)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1175
TypeInfo
Definition: protobuf/php/ext/google/protobuf/def.h:69
upb_msg_get
upb_msgval upb_msg_get(const upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7090
PROTO_RETURN_VAL
#define PROTO_RETURN_VAL
Definition: protobuf/php/ext/google/protobuf/protobuf.h:50
mingw.unpack
def unpack(archive, location, log=EmptyLogger())
Definition: bloaty/third_party/protobuf/third_party/benchmark/mingw.py:114
status
absl::Status status
Definition: rls.cc:251
UPB_TYPE_UINT32
@ UPB_TYPE_UINT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:478
upb_msg_has
bool upb_msg_has(const upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7062
setup.name
name
Definition: setup.py:542
PHP_METHOD
PHP_METHOD(Message, __construct)
Definition: protobuf/php/ext/google/protobuf/message.c:575
DescriptorPool_GetSymbolTable
upb_symtab * DescriptorPool_GetSymbolTable()
Definition: protobuf/php/ext/google/protobuf/def.c:755
upb_msgval::str_val
upb_strview str_val
Definition: php-upb.h:4623
upb_strview::data
const char * data
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:258
ZVAL_OBJ
#define ZVAL_OBJ(zval_ptr, call_create)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:238
ValueEq
bool ValueEq(upb_msgval val1, upb_msgval val2, TypeInfo type)
Definition: protobuf/php/ext/google/protobuf/message.c:172
protobuf.h
upb_msg_set
void upb_msg_set(upb_msg *msg, const upb_fielddef *f, upb_msgval val, upb_arena *a)
Definition: php-upb.c:7132
StringVal
static upb_msgval StringVal(upb_strview view)
Definition: protobuf/php/ext/google/protobuf/message.c:1124
upb_msg_clear
void upb_msg_clear(upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:7160
upb_msg
void upb_msg
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:548
UPB_JSONENC_PROTONAMES
@ UPB_JSONENC_PROTONAMES
Definition: php-upb.h:4806
message.h
Message::msg
upb_msg * msg
Definition: protobuf/php/ext/google/protobuf/message.c:57
Descriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:121
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
upb_fielddef_msgsubdef
const upb_msgdef * upb_fielddef_msgsubdef(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3476
RepeatedField_GetPhpWrapper
void RepeatedField_GetPhpWrapper(zval *val, upb_array *arr, TypeInfo type, zval *arena)
Definition: protobuf/php/ext/google/protobuf/array.c:152
Convert_PhpToUpb
bool Convert_PhpToUpb(zval *php_val, upb_msgval *upb_val, TypeInfo type, upb_arena *arena)
Definition: protobuf/php/ext/google/protobuf/convert.c:356
google_protobuf_Any
struct google_protobuf_Any google_protobuf_Any
Definition: any.upb.h:24
array.h
upb_symtab_lookupmsg2
const upb_msgdef * upb_symtab_lookupmsg2(const upb_symtab *s, const char *sym, size_t len)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:4571
message_object_handlers
static zend_object_handlers message_object_handlers
Definition: protobuf/php/ext/google/protobuf/message.c:61
from
size_t from
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1384
UPB_TYPE_BYTES
@ UPB_TYPE_BYTES
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:482
upb_msg_field_done
bool upb_msg_field_done(const upb_msg_field_iter *iter)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3628
upb_oneofdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2992
UPB_TYPE_ENUM
@ UPB_TYPE_ENUM
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:479
get_field
static const upb_fielddef * get_field(Message *msg, PROTO_STR *member)
Definition: protobuf/php/ext/google/protobuf/message.c:113
UPB_JSONDEC_IGNOREUNKNOWN
@ UPB_JSONDEC_IGNOREUNKNOWN
Definition: php-upb.h:4778
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
message_ce
zend_class_entry * message_ce
Definition: protobuf/php/ext/google/protobuf/message.c:60
Message_create
static zend_object * Message_create(zend_class_entry *class_type)
Definition: protobuf/php/ext/google/protobuf/message.c:85
Message_get_property_ptr_ptr
static zval * Message_get_property_ptr_ptr(PROTO_VAL *object, PROTO_STR *member, int type, void **cache_slot)
Definition: protobuf/php/ext/google/protobuf/message.c:397
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
upb_msgdef_fullname
const char * upb_msgdef_fullname(const upb_msgdef *m)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3532
MapField_GetPhpWrapper
void MapField_GetPhpWrapper(zval *val, upb_map *map, MapField_Type type, zval *arena)
Definition: protobuf/php/ext/google/protobuf/map.c:167
Message::arena
zval arena
Definition: protobuf/php/ext/google/protobuf/message.c:55
Arena_Init
void Arena_Init(zval *val)
Definition: arena.c:66
upb_status_errmsg
const char * upb_status_errmsg(const upb_status *status)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2204
Arena_Get
upb_arena * Arena_Get(zval *val)
Definition: arena.c:70
NameMap_GetMessage
const upb_msgdef * NameMap_GetMessage(zend_class_entry *ce)
Definition: protobuf/php/ext/google/protobuf/protobuf.c:261
upb_msg_discardunknown
bool upb_msg_discardunknown(upb_msg *msg, const upb_msgdef *m, int maxdepth)
Definition: php-upb.c:7250
Message_InitFromPhp
bool Message_InitFromPhp(upb_msg *msg, const upb_msgdef *m, zval *init, upb_arena *arena)
Definition: protobuf/php/ext/google/protobuf/message.c:504
member
int member
Definition: abseil-cpp/absl/base/invoke_test.cc:87
upb_inttable_iter
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:1113
Message_unset_property
static void Message_unset_property(PROTO_VAL *obj, PROTO_STR *member, void **cache_slot)
Definition: protobuf/php/ext/google/protobuf/message.c:302
arena.h
grpc::testing::val2
const char val2[]
Definition: client_context_test_peer_test.cc:35
Message::std
zend_object std
Definition: protobuf/php/ext/google/protobuf/message.c:54
TypeInfo_FromType
static TypeInfo TypeInfo_FromType(upb_fieldtype_t type)
Definition: protobuf/php/ext/google/protobuf/def.h:79
Message_compare_objects
static int Message_compare_objects(zval *m1, zval *m2)
Definition: protobuf/php/ext/google/protobuf/message.c:239
StrViewEq
static bool StrViewEq(upb_strview view, const char *str)
Definition: protobuf/php/ext/google/protobuf/message.c:1140
Message_get_properties
static HashTable * Message_get_properties(PROTO_VAL *object)
Definition: protobuf/php/ext/google/protobuf/message.c:428
ObjCache_Delete
void ObjCache_Delete(const void *upb_obj)
Definition: protobuf/php/ext/google/protobuf/protobuf.c:224
Message_get
static void Message_get(Message *intern, const upb_fielddef *f, zval *rv)
Definition: protobuf/php/ext/google/protobuf/message.c:126
upb_mutmsgval::array
upb_array * array
Definition: php-upb.h:4629
Z_OBJ_P
#define Z_OBJ_P(zval_p)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1497
upb_symtab
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3018
arg
Definition: cmdline.cc:40
upb_arena_new
UPB_INLINE upb_arena * upb_arena_new(void)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:392
def.h
upb_fielddef_ismap
bool upb_fielddef_ismap(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3503
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
upb_fielddef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2934
wrapper
grpc_channel_wrapper * wrapper
Definition: src/php/ext/grpc/channel.h:48
testing::internal::ArrayEq
bool ArrayEq(const T *lhs, size_t size, const U *rhs)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:996
Message_set
static bool Message_set(Message *intern, const upb_fielddef *f, zval *val)
Definition: protobuf/php/ext/google/protobuf/message.c:146
UPB_TYPE_INT32
@ UPB_TYPE_INT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:477
upb_msgdef_itof
const upb_fielddef * upb_msgdef_itof(const upb_msgdef *m, uint32_t i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3556
Message_write_property
static PROTO_RETURN_VAL Message_write_property(PROTO_VAL *obj, PROTO_STR *member, zval *val, void **cache_slot)
Definition: protobuf/php/ext/google/protobuf/message.c:370
Message_setval
static void Message_setval(Message *intern, const char *field_name, upb_msgval val)
Definition: protobuf/php/ext/google/protobuf/message.c:1117
Message_methods
static zend_function_entry Message_methods[]
Definition: protobuf/php/ext/google/protobuf/message.c:1089
upb_ok
bool upb_ok(const upb_status *status)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2202
upb_mutmsgval::map
upb_map * map
Definition: php-upb.h:4627
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
google_protobuf_Timestamp
struct google_protobuf_Timestamp google_protobuf_Timestamp
Definition: timestamp.upb.h:24
TryStripUrlPrefix
static bool TryStripUrlPrefix(upb_strview *str)
Definition: protobuf/php/ext/google/protobuf/message.c:1130
upb_json_encode
size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m, const upb_symtab *ext_pool, int options, char *buf, size_t size, upb_status *status)
Definition: php-upb.c:9501
value
const char * value
Definition: hpack_parser_table.cc:165
symtab
upb_symtab * symtab
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:774
upb_msgdef_ntof
const upb_fielddef * upb_msgdef_ntof(const upb_msgdef *m, const char *name, size_t len)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3562
Message_ModuleInit
void Message_ModuleInit()
Definition: protobuf/php/ext/google/protobuf/message.c:1368
upb_msglayout
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:565
upb_msgval
Definition: php-upb.h:4612
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
key
const char * key
Definition: hpack_parser_table.cc:164
UPB_TYPE_STRING
@ UPB_TYPE_STRING
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:481
TYPE_URL_PREFIX
static const char TYPE_URL_PREFIX[]
Definition: protobuf/php/ext/google/protobuf/message.c:1109
upb_fielddef_haspresence
bool upb_fielddef_haspresence(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3512
upb_msg_field_begin
void upb_msg_field_begin(upb_msg_field_iter *iter, const upb_msgdef *m)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3622
intern
upb_strtable_uninit & intern
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/map.c:222
upb_msg_clearfield
void upb_msg_clearfield(upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7145
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
Message_Initialize
static void Message_Initialize(Message *intern, const Descriptor *desc)
Definition: protobuf/php/ext/google/protobuf/message.c:563
PROTO_STR
#define PROTO_STR
Definition: protobuf/php/ext/google/protobuf/protobuf.h:60
upb_msgval::msg_val
const upb_msg * msg_val
Definition: php-upb.h:4621
Message_dtor
static void Message_dtor(zend_object *obj)
Definition: protobuf/php/ext/google/protobuf/message.c:101
upb_msgdef_layout
const upb_msglayout * upb_msgdef_layout(const upb_msgdef *m)
Definition: php-upb.c:5445
type_url
string * type_url
Definition: bloaty/third_party/protobuf/conformance/conformance_cpp.cc:72
ok
bool ok
Definition: async_end2end_test.cc:197
desc
#define desc
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:338
UPB_TYPE_MESSAGE
@ UPB_TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:483
buf2
static char buf2[32]
Definition: test-fs.c:127
upb_msg_mutable
upb_mutmsgval upb_msg_mutable(upb_msg *msg, const upb_fielddef *f, upb_arena *a)
Definition: php-upb.c:7098
Message_SuppressDefaultProperties
static void Message_SuppressDefaultProperties(zend_class_entry *class_type)
Definition: protobuf/php/ext/google/protobuf/message.c:63
upb_arena_fuse
bool upb_arena_fuse(upb_arena *a1, upb_arena *a2)
Definition: php-upb.c:2919
RepeatedField_GetUpbArray
upb_array * RepeatedField_GetUpbArray(zval *val, TypeInfo type, upb_arena *arena)
Definition: protobuf/php/ext/google/protobuf/array.c:172
Message_getval
static upb_msgval Message_getval(Message *intern, const char *field_name)
Definition: protobuf/php/ext/google/protobuf/message.c:1111
table
uint8_t table[256]
Definition: hpack_parser.cc:456
Message::desc
const Descriptor * desc
Definition: protobuf/php/ext/google/protobuf/message.c:56
upb_msgval::int32_val
int32_t int32_val
Definition: php-upb.h:4616
upb_strview
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:257
php-upb.h
Descriptor_GetFromMessageDef
Descriptor * Descriptor_GetFromMessageDef(const upb_msgdef *m)
Definition: protobuf/php/ext/google/protobuf/def.c:584
Message_read_property
static zval * Message_read_property(PROTO_VAL *obj, PROTO_STR *member, int type, void **cache_slot, zval *rv)
Definition: protobuf/php/ext/google/protobuf/message.c:339
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
MapEq
bool MapEq(const upb_map *m1, const upb_map *m2, MapField_Type type)
Definition: protobuf/php/ext/google/protobuf/map.c:236
RETURN_COPY_VALUE
#define RETURN_COPY_VALUE(zv)
Definition: protobuf/php/ext/google/protobuf/protobuf.h:68
run_grpclb_interop_tests.l
dictionary l
Definition: run_grpclb_interop_tests.py:410
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
regress.m
m
Definition: regress/regress.py:25
upb_fielddef_isseq
bool upb_fielddef_isseq(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3495
upb_encode
char * upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, size_t *size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1105
PROTO_VAL_P
#define PROTO_VAL_P(obj)
Definition: protobuf/php/ext/google/protobuf/protobuf.h:61
upb_fielddef_realcontainingoneof
const upb_oneofdef * upb_fielddef_realcontainingoneof(const upb_fielddef *f)
Definition: php-upb.c:5215
klass
zend_class_entry * klass
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:810
UPB_TYPE_DOUBLE
@ UPB_TYPE_DOUBLE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:485
upb_strview::size
size_t size
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:259
UPB_TYPE_BOOL
@ UPB_TYPE_BOOL
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:474
UPB_TYPE_INT64
@ UPB_TYPE_INT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:486
upb_msgdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2962
Message
Definition: protobuf/php/ext/google/protobuf/message.c:53
upb_msgdef_ntofz
const UPB_INLINE upb_fielddef * upb_msgdef_ntofz(const upb_msgdef *m, const char *name)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:3350
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
Message_has_property
static int Message_has_property(PROTO_VAL *obj, PROTO_STR *member, int has_set_exists, void **cache_slot)
Definition: protobuf/php/ext/google/protobuf/message.c:267
upb_fielddef_name
const char * upb_fielddef_name(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3367
map.h
convert.h
Convert_PhpToUpbAutoWrap
bool Convert_PhpToUpbAutoWrap(zval *val, upb_msgval *upb_val, TypeInfo type, upb_arena *arena)
Definition: protobuf/php/ext/google/protobuf/convert.c:482


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:24