add PHP_GRPC_FREE_CLASS_OBJECT macro

pull/7543/head
thinkerou 9 years ago
parent dacb2e3a5c
commit a24a0dd784
  1. 11
      src/php/ext/grpc/call.c
  2. 12
      src/php/ext/grpc/call_credentials.c
  3. 11
      src/php/ext/grpc/channel.c
  4. 12
      src/php/ext/grpc/channel_credentials.c
  5. 11
      src/php/ext/grpc/php7_wrapper.h
  6. 11
      src/php/ext/grpc/server.c
  7. 12
      src/php/ext/grpc/server_credentials.c
  8. 5
      src/php/ext/grpc/timeval.c

@ -76,16 +76,7 @@ php_grpc_zend_object create_wrapped_grpc_call(zend_class_entry *class_type
PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_call); PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_call);
zend_object_std_init(&intern->std, class_type TSRMLS_CC); zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type); object_properties_init(&intern->std, class_type);
#if PHP_MAJOR_VERSION < 7 PHP_GRPC_FREE_CLASS_OBJECT(wrapped_grpc_call, call_ce_handlers);
retval.handle = zend_objects_store_put(
intern, (zend_objects_store_dtor_t)zend_objects_destroy_object,
free_wrapped_grpc_call, NULL TSRMLS_CC);
retval.handlers = zend_get_std_object_handlers();
return retval;
#else
intern->std.handlers = &call_ce_handlers;
return &intern->std;
#endif
} }
/* Creates and returns a PHP array object with the data in a /* Creates and returns a PHP array object with the data in a

@ -70,16 +70,8 @@ php_grpc_zend_object create_wrapped_grpc_call_credentials(
PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_call_credentials); PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_call_credentials);
zend_object_std_init(&intern->std, class_type TSRMLS_CC); zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type); object_properties_init(&intern->std, class_type);
#if PHP_MAJOR_VERSION < 7 PHP_GRPC_FREE_CLASS_OBJECT(wrapped_grpc_call_credentials,
retval.handle = zend_objects_store_put( call_credentials_ce_handlers);
intern, (zend_objects_store_dtor_t)zend_objects_destroy_object,
free_wrapped_grpc_call_credentials, NULL TSRMLS_CC);
retval.handlers = zend_get_std_object_handlers();
return retval;
#else
intern->std.handlers = &call_credentials_ce_handlers;
return &intern->std;
#endif
} }
zval *grpc_php_wrap_call_credentials(grpc_call_credentials zval *grpc_php_wrap_call_credentials(grpc_call_credentials

@ -74,16 +74,7 @@ php_grpc_zend_object create_wrapped_grpc_channel(zend_class_entry *class_type
PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_channel); PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_channel);
zend_object_std_init(&intern->std, class_type TSRMLS_CC); zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type); object_properties_init(&intern->std, class_type);
#if PHP_MAJOR_VERSION < 7 PHP_GRPC_FREE_CLASS_OBJECT(wrapped_grpc_channel, channel_ce_handlers);
retval.handle = zend_objects_store_put(
intern, (zend_objects_store_dtor_t)zend_objects_destroy_object,
free_wrapped_grpc_channel, NULL TSRMLS_CC);
retval.handlers = zend_get_std_object_handlers();
return retval;
#else
intern->std.handlers = &channel_ce_handlers;
return &intern->std;
#endif
} }
void php_grpc_read_args_array(zval *args_array, void php_grpc_read_args_array(zval *args_array,

@ -80,16 +80,8 @@ php_grpc_zend_object create_wrapped_grpc_channel_credentials(
PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_channel_credentials); PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_channel_credentials);
zend_object_std_init(&intern->std, class_type TSRMLS_CC); zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type); object_properties_init(&intern->std, class_type);
#if PHP_MAJOR_VERSION < 7 PHP_GRPC_FREE_CLASS_OBJECT(wrapped_grpc_channel_credentials,
retval.handle = zend_objects_store_put( channel_credentials_ce_handlers);
intern, (zend_objects_store_dtor_t)zend_objects_destroy_object,
free_wrapped_grpc_channel_credentials, NULL TSRMLS_CC);
retval.handlers = zend_get_std_object_handlers();
return retval;
#else
intern->std.handlers = &channel_credentials_ce_handlers;
return &intern->std;
#endif
} }
zval *grpc_php_wrap_channel_credentials(grpc_channel_credentials zval *grpc_php_wrap_channel_credentials(grpc_channel_credentials

@ -72,6 +72,13 @@
intern = (class_object *)emalloc(sizeof(class_object)); \ intern = (class_object *)emalloc(sizeof(class_object)); \
memset(intern, 0, sizeof(class_object)); memset(intern, 0, sizeof(class_object));
#define PHP_GRPC_FREE_CLASS_OBJECT(class_object, handler) \
retval.handle = zend_objects_store_put( \
intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, \
free_##class_object, NULL TSRMLS_CC); \
retval.handlers = zend_get_std_object_handlers(); \
return retval;
#define PHP_GRPC_HASH_FOREACH_VAL_START(ht, data) \ #define PHP_GRPC_HASH_FOREACH_VAL_START(ht, data) \
zval **tmp_data = NULL; \ zval **tmp_data = NULL; \
for (zend_hash_internal_pointer_reset(ht); \ for (zend_hash_internal_pointer_reset(ht); \
@ -158,6 +165,10 @@ static inline int php_grpc_zend_hash_find(HashTable *ht, char *key, int len, voi
intern = ecalloc(1, sizeof(class_object) + \ intern = ecalloc(1, sizeof(class_object) + \
zend_object_properties_size(class_type)); zend_object_properties_size(class_type));
#define PHP_GRPC_FREE_CLASS_OBJECT(class_object, handler) \
intern->std.handlers = &handler; \
return &intern->std;
#define PHP_GRPC_HASH_FOREACH_VAL_START(ht, data) \ #define PHP_GRPC_HASH_FOREACH_VAL_START(ht, data) \
ZEND_HASH_FOREACH_VAL(ht, data) { ZEND_HASH_FOREACH_VAL(ht, data) {

@ -79,16 +79,7 @@ php_grpc_zend_object create_wrapped_grpc_server(zend_class_entry *class_type
PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_server); PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_server);
zend_object_std_init(&intern->std, class_type TSRMLS_CC); zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type); object_properties_init(&intern->std, class_type);
#if PHP_MAJOR_VERSION < 7 PHP_GRPC_FREE_CLASS_OBJECT(wrapped_grpc_server, server_ce_handlers);
retval.handle = zend_objects_store_put(
intern, (zend_objects_store_dtor_t)zend_objects_destroy_object,
free_wrapped_grpc_server, NULL TSRMLS_CC);
retval.handlers = zend_get_std_object_handlers();
return retval;
#else
intern->std.handlers = &server_ce_handlers;
return &intern->std;
#endif
} }
/** /**

@ -68,16 +68,8 @@ php_grpc_zend_object create_wrapped_grpc_server_credentials(
PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_server_credentials); PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_server_credentials);
zend_object_std_init(&intern->std, class_type TSRMLS_CC); zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type); object_properties_init(&intern->std, class_type);
#if PHP_MAJOR_VERSION < 7 PHP_GRPC_FREE_CLASS_OBJECT(wrapped_grpc_server_credentials,
retval.handle = zend_objects_store_put( server_credentials_ce_handlers);
intern, (zend_objects_store_dtor_t)zend_objects_destroy_object,
free_wrapped_grpc_server_credentials, NULL TSRMLS_CC);
retval.handlers = zend_get_std_object_handlers();
return retval;
#else
intern->std.handlers = &server_credentials_ce_handlers;
return &intern->std;
#endif
} }
zval *grpc_php_wrap_server_credentials(grpc_server_credentials zval *grpc_php_wrap_server_credentials(grpc_server_credentials

@ -66,7 +66,8 @@ php_grpc_zend_object create_wrapped_grpc_timeval(zend_class_entry *class_type
PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_timeval); PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_timeval);
zend_object_std_init(&intern->std, class_type TSRMLS_CC); zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type); object_properties_init(&intern->std, class_type);
#if PHP_MAJOR_VERSION < 7 PHP_GRPC_FREE_CLASS_OBJECT(wrapped_grpc_timeval, timeval_ce_handlers);
/*#if PHP_MAJOR_VERSION < 7
retval.handle = zend_objects_store_put( retval.handle = zend_objects_store_put(
intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, intern, (zend_objects_store_dtor_t)zend_objects_destroy_object,
free_wrapped_grpc_timeval, NULL TSRMLS_CC); free_wrapped_grpc_timeval, NULL TSRMLS_CC);
@ -75,7 +76,7 @@ php_grpc_zend_object create_wrapped_grpc_timeval(zend_class_entry *class_type
#else #else
intern->std.handlers = &timeval_ce_handlers; intern->std.handlers = &timeval_ce_handlers;
return &intern->std; return &intern->std;
#endif #endif*/
} }
zval *grpc_php_wrap_timeval(gpr_timespec wrapped TSRMLS_DC) { zval *grpc_php_wrap_timeval(gpr_timespec wrapped TSRMLS_DC) {

Loading…
Cancel
Save