protobuf/php/ext/google/protobuf/convert.c
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 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 "convert.h"
32 
33 #include <php.h>
34 
35 // This is not self-contained: it must be after other Zend includes.
36 #include <Zend/zend_exceptions.h>
37 
38 #include "array.h"
39 #include "map.h"
40 #include "message.h"
41 #include "php-upb.h"
42 #include "protobuf.h"
43 
44 // -----------------------------------------------------------------------------
45 // GPBUtil
46 // -----------------------------------------------------------------------------
47 
48 static zend_class_entry* GPBUtil_class_entry;
49 
50 // The implementation of type checking for primitive fields is empty. This is
51 // because type checking is done when direct assigning message fields (e.g.,
52 // foo->a = 1). Functions defined here are place holders in generated code for
53 // pure PHP implementation (c extension and pure PHP share the same generated
54 // code).
55 
56 PHP_METHOD(Util, checkInt32) {}
57 PHP_METHOD(Util, checkUint32) {}
58 PHP_METHOD(Util, checkInt64) {}
59 PHP_METHOD(Util, checkUint64) {}
60 PHP_METHOD(Util, checkEnum) {}
61 PHP_METHOD(Util, checkFloat) {}
62 PHP_METHOD(Util, checkDouble) {}
63 PHP_METHOD(Util, checkBool) {}
64 PHP_METHOD(Util, checkString) {}
65 PHP_METHOD(Util, checkBytes) {}
66 PHP_METHOD(Util, checkMessage) {}
67 
68 // The result of checkMapField() is assigned, so we need to return the first
69 // param:
70 // $arr = GPBUtil::checkMapField($var,
71 // \Google\Protobuf\Internal\GPBType::INT64,
72 // \Google\Protobuf\Internal\GPBType::INT32);
73 PHP_METHOD(Util, checkMapField) {
74  zval *val, *key_type, *val_type, *klass;
75  if (zend_parse_parameters(ZEND_NUM_ARGS(), "zzz|z", &val, &key_type,
76  &val_type, &klass) == FAILURE) {
77  return;
78  }
79  RETURN_COPY(val);
80 }
81 
82 // The result of checkRepeatedField() is assigned, so we need to return the
83 // first param:
84 // $arr = GPBUtil::checkRepeatedField(
85 // $var, \Google\Protobuf\Internal\GPBType::STRING);
86 PHP_METHOD(Util, checkRepeatedField) {
87  zval *val, *type, *klass;
88  if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz|z", &val, &type, &klass) ==
89  FAILURE) {
90  return;
91  }
92  RETURN_COPY(val);
93 }
94 
95 ZEND_BEGIN_ARG_INFO_EX(arginfo_checkPrimitive, 0, 0, 1)
96  ZEND_ARG_INFO(0, value)
97 ZEND_END_ARG_INFO()
98 
99 ZEND_BEGIN_ARG_INFO_EX(arginfo_checkString, 0, 0, 1)
100  ZEND_ARG_INFO(0, value)
101  ZEND_ARG_INFO(0, check_utf8)
102 ZEND_END_ARG_INFO()
103 
104 ZEND_BEGIN_ARG_INFO_EX(arginfo_checkMessage, 0, 0, 2)
105  ZEND_ARG_INFO(0, value)
106  ZEND_ARG_INFO(0, class)
107 ZEND_END_ARG_INFO()
108 
109 ZEND_BEGIN_ARG_INFO_EX(arginfo_checkMapField, 0, 0, 3)
110  ZEND_ARG_INFO(0, value)
111  ZEND_ARG_INFO(0, key_type)
112  ZEND_ARG_INFO(0, value_type)
113  ZEND_ARG_INFO(0, value_class)
114 ZEND_END_ARG_INFO()
115 
116 ZEND_BEGIN_ARG_INFO_EX(arginfo_checkRepeatedField, 0, 0, 2)
117  ZEND_ARG_INFO(0, value)
118  ZEND_ARG_INFO(0, type)
119  ZEND_ARG_INFO(0, class)
120 ZEND_END_ARG_INFO()
121 
122 static zend_function_entry util_methods[] = {
123  PHP_ME(Util, checkInt32, arginfo_checkPrimitive,
124  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
125  PHP_ME(Util, checkUint32, arginfo_checkPrimitive,
126  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
127  PHP_ME(Util, checkInt64, arginfo_checkPrimitive,
128  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
129  PHP_ME(Util, checkUint64, arginfo_checkPrimitive,
130  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
131  PHP_ME(Util, checkEnum, arginfo_checkMessage,
132  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
133  PHP_ME(Util, checkFloat, arginfo_checkPrimitive,
134  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
135  PHP_ME(Util, checkDouble, arginfo_checkPrimitive,
136  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
137  PHP_ME(Util, checkBool, arginfo_checkPrimitive,
138  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
139  PHP_ME(Util, checkString, arginfo_checkString,
140  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
141  PHP_ME(Util, checkBytes, arginfo_checkPrimitive,
142  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
143  PHP_ME(Util, checkMessage, arginfo_checkMessage,
144  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
145  PHP_ME(Util, checkMapField, arginfo_checkMapField,
146  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
147  PHP_ME(Util, checkRepeatedField, arginfo_checkRepeatedField,
148  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
149  ZEND_FE_END
150 };
151 
152 // -----------------------------------------------------------------------------
153 // Conversion functions used from C
154 // -----------------------------------------------------------------------------
155 
157  switch (type) {
158 #define CASE(descriptor_type, type) \
159  case UPB_DESCRIPTOR_TYPE_##descriptor_type: \
160  return UPB_TYPE_##type;
161 
162  CASE(FLOAT, FLOAT);
163  CASE(DOUBLE, DOUBLE);
164  CASE(BOOL, BOOL);
165  CASE(STRING, STRING);
166  CASE(BYTES, BYTES);
167  CASE(MESSAGE, MESSAGE);
168  CASE(GROUP, MESSAGE);
169  CASE(ENUM, ENUM);
170  CASE(INT32, INT32);
171  CASE(INT64, INT64);
172  CASE(UINT32, UINT32);
173  CASE(UINT64, UINT64);
174  CASE(SINT32, INT32);
175  CASE(SINT64, INT64);
176  CASE(FIXED32, UINT32);
177  CASE(FIXED64, UINT64);
178  CASE(SFIXED32, INT32);
179  CASE(SFIXED64, INT64);
180 
181 #undef CASE
182 
183  }
184 
185  zend_error(E_ERROR, "Unknown field type.");
186  return 0;
187 }
188 
189 static bool buftouint64(const char *ptr, const char *end, uint64_t *val) {
190  uint64_t u64 = 0;
191  while (ptr < end) {
192  unsigned ch = (unsigned)(*ptr - '0');
193  if (ch >= 10) break;
194  if (u64 > UINT64_MAX / 10 || u64 * 10 > UINT64_MAX - ch) {
195  return false;
196  }
197  u64 *= 10;
198  u64 += ch;
199  ptr++;
200  }
201 
202  if (ptr != end) {
203  // In PHP tradition, we allow truncation: "1.1" -> 1.
204  // But we don't allow 'e', eg. '1.1e2' or any other non-numeric chars.
205  if (*ptr++ != '.') return false;
206 
207  for (;ptr < end; ptr++) {
208  if (*ptr < '0' || *ptr > '9') {
209  return false;
210  }
211  }
212  }
213 
214  *val = u64;
215  return true;
216 }
217 
218 static bool buftoint64(const char *ptr, const char *end, int64_t *val) {
219  bool neg = false;
220  uint64_t u64;
221 
222  if (ptr != end && *ptr == '-') {
223  ptr++;
224  neg = true;
225  }
226 
227  if (!buftouint64(ptr, end, &u64) ||
228  u64 > (uint64_t)INT64_MAX + neg) {
229  return false;
230  }
231 
232  *val = neg ? -u64 : u64;
233  return true;
234 }
235 
236 static void throw_conversion_exception(const char *to, const zval *zv) {
237  zval tmp;
238  ZVAL_COPY(&tmp, zv);
239  convert_to_string(&tmp);
240 
241  zend_throw_exception_ex(NULL, 0, "Cannot convert '%s' to %s",
242  Z_STRVAL_P(&tmp), to);
243 
244  zval_ptr_dtor(&tmp);
245 }
246 
247 bool Convert_PhpToInt64(const zval *php_val, int64_t *i64) {
248  switch (Z_TYPE_P(php_val)) {
249  case IS_LONG:
250  *i64 = Z_LVAL_P(php_val);
251  return true;
252  case IS_DOUBLE: {
253  double dbl = Z_DVAL_P(php_val);
254  if (dbl > 9223372036854774784.0 || dbl < -9223372036854775808.0) {
255  zend_throw_exception_ex(NULL, 0, "Out of range");
256  return false;
257  }
258  *i64 = dbl; /* must be guarded, overflow here is UB */
259  return true;
260  }
261  case IS_STRING: {
262  const char *buf = Z_STRVAL_P(php_val);
263  // PHP would accept scientific notation here, but we're going to be a
264  // little more discerning and only accept pure integers.
265  bool ok = buftoint64(buf, buf + Z_STRLEN_P(php_val), i64);
266  if (!ok) {
267  throw_conversion_exception("integer", php_val);
268  }
269  return ok;
270  }
271  default:
272  throw_conversion_exception("integer", php_val);
273  return false;
274  }
275 }
276 
277 static bool to_double(zval *php_val, double *dbl) {
278  switch (Z_TYPE_P(php_val)) {
279  case IS_LONG:
280  *dbl = Z_LVAL_P(php_val);
281  return true;
282  case IS_DOUBLE:
283  *dbl = Z_DVAL_P(php_val);
284  return true;
285  case IS_STRING: {
286  zend_long lval;
287  switch (is_numeric_string(Z_STRVAL_P(php_val), Z_STRLEN_P(php_val), &lval,
288  dbl, false)) {
289  case IS_LONG:
290  *dbl = lval;
291  return true;
292  case IS_DOUBLE:
293  return true;
294  default:
295  goto fail;
296  }
297  }
298  default:
299  fail:
300  throw_conversion_exception("double", php_val);
301  return false;
302  }
303 }
304 
305 static bool to_bool(zval* from, bool* to) {
306  switch (Z_TYPE_P(from)) {
307  case IS_TRUE:
308  *to = true;
309  return true;
310  case IS_FALSE:
311  *to = false;
312  return true;
313  case IS_LONG:
314  *to = (Z_LVAL_P(from) != 0);
315  return true;
316  case IS_DOUBLE:
317  *to = (Z_LVAL_P(from) != 0);
318  return true;
319  case IS_STRING:
320  if (Z_STRLEN_P(from) == 0 ||
321  (Z_STRLEN_P(from) == 1 && Z_STRVAL_P(from)[0] == '0')) {
322  *to = false;
323  } else {
324  *to = true;
325  }
326  return true;
327  default:
329  return false;
330  }
331 }
332 
333 static bool to_string(zval* from) {
334  if (Z_ISREF_P(from)) {
335  ZVAL_DEREF(from);
336  }
337 
338  switch (Z_TYPE_P(from)) {
339  case IS_STRING:
340  return true;
341  case IS_TRUE:
342  case IS_FALSE:
343  case IS_LONG:
344  case IS_DOUBLE: {
345  zval tmp;
346  zend_make_printable_zval(from, &tmp);
347  ZVAL_COPY_VALUE(from, &tmp);
348  return true;
349  }
350  default:
351  throw_conversion_exception("string", from);
352  return false;
353  }
354 }
355 
356 bool Convert_PhpToUpb(zval *php_val, upb_msgval *upb_val, TypeInfo type,
357  upb_arena *arena) {
358  int64_t i64;
359 
360  if (Z_ISREF_P(php_val)) {
361  ZVAL_DEREF(php_val);
362  }
363 
364  switch (type.type) {
365  case UPB_TYPE_INT64:
366  return Convert_PhpToInt64(php_val, &upb_val->int64_val);
367  case UPB_TYPE_INT32:
368  case UPB_TYPE_ENUM:
369  if (!Convert_PhpToInt64(php_val, &i64)) {
370  return false;
371  }
372  upb_val->int32_val = i64;
373  return true;
374  case UPB_TYPE_UINT64:
375  if (!Convert_PhpToInt64(php_val, &i64)) {
376  return false;
377  }
378  upb_val->uint64_val = i64;
379  return true;
380  case UPB_TYPE_UINT32:
381  if (!Convert_PhpToInt64(php_val, &i64)) {
382  return false;
383  }
384  upb_val->uint32_val = i64;
385  return true;
386  case UPB_TYPE_DOUBLE:
387  return to_double(php_val, &upb_val->double_val);
388  case UPB_TYPE_FLOAT:
389  if (!to_double(php_val, &upb_val->double_val)) return false;
390  upb_val->float_val = upb_val->double_val;
391  return true;
392  case UPB_TYPE_BOOL:
393  return to_bool(php_val, &upb_val->bool_val);
394  case UPB_TYPE_STRING:
395  case UPB_TYPE_BYTES: {
396  char *ptr;
397  size_t size;
398 
399  if (!to_string(php_val)) return false;
400 
401  size = Z_STRLEN_P(php_val);
402 
403  // If arena is NULL we reference the input zval.
404  // The resulting upb_strview will only be value while the zval is alive.
405  if (arena) {
407  memcpy(ptr, Z_STRVAL_P(php_val), size);
408  } else {
409  ptr = Z_STRVAL_P(php_val);
410  }
411 
412  upb_val->str_val = upb_strview_make(ptr, size);
413  return true;
414  }
415  case UPB_TYPE_MESSAGE:
416  PBPHP_ASSERT(type.desc);
417  return Message_GetUpbMessage(php_val, type.desc, arena,
418  (upb_msg **)&upb_val->msg_val);
419  }
420 
421  return false;
422 }
423 
424 void Convert_UpbToPhp(upb_msgval upb_val, zval *php_val, TypeInfo type,
425  zval *arena) {
426  switch (type.type) {
427  case UPB_TYPE_INT64:
428 #if SIZEOF_ZEND_LONG == 8
429  ZVAL_LONG(php_val, upb_val.int64_val);
430 #else
431  {
432  char buf[20];
433  int size = sprintf(buf, "%lld", upb_val.int64_val);
434  ZVAL_NEW_STR(php_val, zend_string_init(buf, size, 0));
435  }
436 #endif
437  break;
438  case UPB_TYPE_UINT64:
439 #if SIZEOF_ZEND_LONG == 8
440  ZVAL_LONG(php_val, upb_val.uint64_val);
441 #else
442  {
443  char buf[20];
444  int size = sprintf(buf, "%lld", (int64_t)upb_val.uint64_val);
445  ZVAL_NEW_STR(php_val, zend_string_init(buf, size, 0));
446  }
447 #endif
448  break;
449  case UPB_TYPE_INT32:
450  case UPB_TYPE_ENUM:
451  ZVAL_LONG(php_val, upb_val.int32_val);
452  break;
453  case UPB_TYPE_UINT32: {
454  // Sign-extend for consistency between 32/64-bit builds.
455  zend_long val = (int32_t)upb_val.uint32_val;
456  ZVAL_LONG(php_val, val);
457  break;
458  }
459  case UPB_TYPE_DOUBLE:
460  ZVAL_DOUBLE(php_val, upb_val.double_val);
461  break;
462  case UPB_TYPE_FLOAT:
463  ZVAL_DOUBLE(php_val, upb_val.float_val);
464  break;
465  case UPB_TYPE_BOOL:
466  ZVAL_BOOL(php_val, upb_val.bool_val);
467  break;
468  case UPB_TYPE_STRING:
469  case UPB_TYPE_BYTES: {
470  upb_strview str = upb_val.str_val;
471  ZVAL_NEW_STR(php_val, zend_string_init(str.data, str.size, 0));
472  break;
473  }
474  case UPB_TYPE_MESSAGE:
475  PBPHP_ASSERT(type.desc);
476  Message_GetPhpWrapper(php_val, type.desc, (upb_msg *)upb_val.msg_val,
477  arena);
478  break;
479  }
480 }
481 
483  upb_arena *arena) {
484  const upb_msgdef *subm = type.desc ? type.desc->msgdef : NULL;
485  if (subm && upb_msgdef_iswrapper(subm) && Z_TYPE_P(val) != IS_OBJECT) {
486  // Assigning a scalar to a wrapper-typed value. We will automatically wrap
487  // the value, so the user doesn't need to create a FooWrapper(['value': X])
488  // message manually.
489  upb_msg *wrapper = upb_msg_new(subm, arena);
490  const upb_fielddef *val_f = upb_msgdef_itof(subm, 1);
491  upb_msgval msgval;
492  if (!Convert_PhpToUpb(val, &msgval, TypeInfo_Get(val_f), arena)) return false;
493  upb_msg_set(wrapper, val_f, msgval, arena);
494  upb_val->msg_val = wrapper;
495  return true;
496  } else {
497  // Convert_PhpToUpb doesn't auto-construct messages. This means that we only
498  // allow:
499  // ['foo_submsg': new Foo(['a' => 1])]
500  // not:
501  // ['foo_submsg': ['a' => 1]]
502  return Convert_PhpToUpb(val, upb_val, type, arena);
503  }
504 }
505 
506 void Convert_ModuleInit(void) {
507  const char *prefix_name = "TYPE_URL_PREFIX";
508  zend_class_entry class_type;
509 
510  INIT_CLASS_ENTRY(class_type, "Google\\Protobuf\\Internal\\GPBUtil",
511  util_methods);
512  GPBUtil_class_entry = zend_register_internal_class(&class_type);
513 
514  zend_declare_class_constant_string(GPBUtil_class_entry, prefix_name,
515  strlen(prefix_name),
516  "type.googleapis.com/");
517 }
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
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
UPB_TYPE_UINT64
@ UPB_TYPE_UINT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:487
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
upb_arena
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2252
MESSAGE
static const char MESSAGE[]
Definition: test-callback-stack.c:31
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::uint64_val
uint64_t uint64_val
Definition: php-upb.h:4619
Message_GetPhpWrapper
void Message_GetPhpWrapper(zval *val, const Descriptor *desc, upb_msg *msg, zval *arena)
Definition: protobuf/php/ext/google/protobuf/message.c:436
upb_strview_make
UPB_INLINE upb_strview upb_strview_make(const char *data, size_t size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:262
INT64_MAX
#define INT64_MAX
Definition: stdint-msvc2008.h:139
upb_fieldtype_t
upb_fieldtype_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:472
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
PHP_METHOD
PHP_METHOD(Util, checkInt32)
Definition: protobuf/php/ext/google/protobuf/convert.c:56
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
UINT64_MAX
#define UINT64_MAX
Definition: stdint-msvc2008.h:143
TypeInfo_Get
static TypeInfo TypeInfo_Get(const upb_fielddef *f)
Definition: protobuf/php/ext/google/protobuf/def.h:74
upb_msgdef_iswrapper
bool upb_msgdef_iswrapper(const upb_msgdef *m)
Definition: php-upb.c:5473
CASE
#define CASE(descriptor_type, type)
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_TYPE_UINT32
@ UPB_TYPE_UINT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:478
to
size_t to
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1385
upb_msgval::str_val
upb_strview str_val
Definition: php-upb.h:4623
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
upb_msg
void upb_msg
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:548
util_methods
static zend_function_entry util_methods[]
Definition: protobuf/php/ext/google/protobuf/convert.c:122
message.h
BOOL
int BOOL
Definition: undname.c:46
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
buftoint64
static bool buftoint64(const char *ptr, const char *end, int64_t *val)
Definition: protobuf/php/ext/google/protobuf/convert.c:218
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
array.h
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
GPBUtil_class_entry
static zend_class_entry * GPBUtil_class_entry
Definition: protobuf/php/ext/google/protobuf/convert.c:48
UPB_TYPE_ENUM
@ UPB_TYPE_ENUM
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:479
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
to_double
static bool to_double(zval *php_val, double *dbl)
Definition: protobuf/php/ext/google/protobuf/convert.c:277
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
grpc_core::fail
Poll< absl::StatusOr< std::tuple< T... > > > fail()
Definition: try_join_test.cc:45
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
upb_msgval::float_val
float float_val
Definition: php-upb.h:4614
upb_msgval::double_val
double double_val
Definition: php-upb.h:4615
absl::compare_internal::value_type
int8_t value_type
Definition: abseil-cpp/absl/types/compare.h:45
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
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
upb_msgval::bool_val
bool bool_val
Definition: php-upb.h:4613
value
const char * value
Definition: hpack_parser_table.cc:165
pbphp_dtype_to_type
upb_fieldtype_t pbphp_dtype_to_type(upb_descriptortype_t type)
Definition: protobuf/php/ext/google/protobuf/convert.c:156
upb_descriptortype_t
upb_descriptortype_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:498
upb_msgval
Definition: php-upb.h:4612
RETURN_COPY
#define RETURN_COPY(zv)
Definition: protobuf/php/ext/google/protobuf/protobuf.h:67
UPB_TYPE_STRING
@ UPB_TYPE_STRING
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:481
Convert_ModuleInit
void Convert_ModuleInit(void)
Definition: protobuf/php/ext/google/protobuf/convert.c:506
buftouint64
static bool buftouint64(const char *ptr, const char *end, uint64_t *val)
Definition: protobuf/php/ext/google/protobuf/convert.c:189
upb_msgval::msg_val
const upb_msg * msg_val
Definition: php-upb.h:4621
ok
bool ok
Definition: async_end2end_test.cc:197
UPB_TYPE_MESSAGE
@ UPB_TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:483
make_dist_html.GROUP
string GROUP
Definition: make_dist_html.py:52
Convert_PhpToInt64
bool Convert_PhpToInt64(const zval *php_val, int64_t *i64)
Definition: protobuf/php/ext/google/protobuf/convert.c:247
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
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
ch
char ch
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3621
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
key_type
upb_fieldtype_t key_type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1071
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
klass
zend_class_entry * klass
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:810
to_string
static bool to_string(zval *from)
Definition: protobuf/php/ext/google/protobuf/convert.c:333
to_bool
static bool to_bool(zval *from, bool *to)
Definition: protobuf/php/ext/google/protobuf/convert.c:305
UPB_TYPE_DOUBLE
@ UPB_TYPE_DOUBLE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:485
throw_conversion_exception
static void throw_conversion_exception(const char *to, const zval *zv)
Definition: protobuf/php/ext/google/protobuf/convert.c:236
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
upb_msgval::int64_val
int64_t int64_val
Definition: php-upb.h:4617
upb_msgval::uint32_val
uint32_t uint32_val
Definition: php-upb.h:4618
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:58:02