aboutsummaryrefslogtreecommitdiff
path: root/php/ext/google/protobuf/storage.c
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2017-02-11 16:36:17 -0800
committerGitHub <noreply@github.com>2017-02-11 16:36:17 -0800
commit74eb9a0a304a3261f3c83e100f51081986ac8ba6 (patch)
treed7171743decd0b21fdf60fc76d5fd0509ebceeda /php/ext/google/protobuf/storage.c
parentef927cc428db7bf41d3a593a16a8f1a0fe6306c5 (diff)
downloadprotobuf-74eb9a0a304a3261f3c83e100f51081986ac8ba6.tar.gz
protobuf-74eb9a0a304a3261f3c83e100f51081986ac8ba6.tar.bz2
protobuf-74eb9a0a304a3261f3c83e100f51081986ac8ba6.zip
Add clear method to PHP message (#2700)
Diffstat (limited to 'php/ext/google/protobuf/storage.c')
-rw-r--r--php/ext/google/protobuf/storage.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c
index ba6ac59e..5e05b935 100644
--- a/php/ext/google/protobuf/storage.c
+++ b/php/ext/google/protobuf/storage.c
@@ -248,13 +248,30 @@ void native_slot_get_default(upb_fieldtype_t type, zval** cache TSRMLS_DC) {
CASE(DOUBLE, DOUBLE)
CASE(BOOL, BOOL)
CASE(INT32, LONG)
- CASE(INT64, LONG)
CASE(UINT32, LONG)
- CASE(UINT64, LONG)
CASE(ENUM, LONG)
#undef CASE
+#if SIZEOF_LONG == 4
+#define CASE(upb_type) \
+ case UPB_TYPE_##upb_type: { \
+ SEPARATE_ZVAL_IF_NOT_REF(cache); \
+ ZVAL_STRING(*cache, "0", 1); \
+ return; \
+ }
+#else
+#define CASE(upb_type) \
+ case UPB_TYPE_##upb_type: { \
+ SEPARATE_ZVAL_IF_NOT_REF(cache); \
+ ZVAL_LONG(*cache, 0); \
+ return; \
+ }
+#endif
+CASE(UINT64)
+CASE(INT64)
+#undef CASE
+
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: {
SEPARATE_ZVAL_IF_NOT_REF(cache);