Merge github.com:grpc/grpc into cpp_bazelness

pull/9775/head
Craig Tiller 8 years ago
commit 4183e9d60b
  1. 52
      src/php/ext/grpc/call.c
  2. 13
      src/php/ext/grpc/call_credentials.c
  3. 35
      src/php/ext/grpc/channel.c
  4. 31
      src/php/ext/grpc/channel_credentials.c
  5. 36
      src/php/ext/grpc/server.c
  6. 8
      src/php/ext/grpc/server_credentials.c
  7. 68
      src/php/ext/grpc/timeval.c

@ -104,7 +104,8 @@ zval *grpc_parse_metadata_array(grpc_metadata_array
str_key = ecalloc(key_len + 1, sizeof(char));
memcpy(str_key, GRPC_SLICE_START_PTR(elem->key), key_len);
str_val = ecalloc(GRPC_SLICE_LENGTH(elem->value) + 1, sizeof(char));
memcpy(str_val, GRPC_SLICE_START_PTR(elem->value), GRPC_SLICE_LENGTH(elem->value));
memcpy(str_val, GRPC_SLICE_START_PTR(elem->value),
GRPC_SLICE_LENGTH(elem->value));
if (php_grpc_zend_hash_find(array_hash, str_key, key_len, (void **)&data)
== SUCCESS) {
if (Z_TYPE_P(data) != IS_ARRAY) {
@ -115,7 +116,8 @@ zval *grpc_parse_metadata_array(grpc_metadata_array
efree(str_val);
return NULL;
}
php_grpc_add_next_index_stringl(data, str_val, GRPC_SLICE_LENGTH(elem->value),
php_grpc_add_next_index_stringl(data, str_val,
GRPC_SLICE_LENGTH(elem->value),
false);
} else {
PHP_GRPC_MAKE_STD_ZVAL(inner_array);
@ -172,8 +174,10 @@ bool create_metadata_array(zval *array, grpc_metadata_array *metadata) {
if (Z_TYPE_P(value) != IS_STRING) {
return false;
}
metadata->metadata[metadata->count].key = grpc_slice_from_copied_string(key1);
metadata->metadata[metadata->count].value = grpc_slice_from_copied_buffer(Z_STRVAL_P(value), Z_STRLEN_P(value));
metadata->metadata[metadata->count].key =
grpc_slice_from_copied_string(key1);
metadata->metadata[metadata->count].value =
grpc_slice_from_copied_buffer(Z_STRVAL_P(value), Z_STRLEN_P(value));
metadata->count += 1;
PHP_GRPC_HASH_FOREACH_END()
PHP_GRPC_HASH_FOREACH_END()
@ -233,7 +237,8 @@ PHP_METHOD(Call, __construct) {
grpc_slice_from_copied_string(host_override) : grpc_empty_slice();
call->wrapped =
grpc_channel_create_call(channel->wrapped, NULL, GRPC_PROPAGATE_DEFAULTS,
completion_queue, method_slice, host_override != NULL ? &host_slice : NULL,
completion_queue, method_slice,
host_override != NULL ? &host_slice : NULL,
deadline->wrapped, NULL);
grpc_slice_unref(method_slice);
grpc_slice_unref(host_slice);
@ -384,8 +389,10 @@ PHP_METHOD(Call, startBatch) {
1 TSRMLS_CC);
goto cleanup;
}
send_status_details = grpc_slice_from_copied_string(Z_STRVAL_P(inner_value));
ops[op_num].data.send_status_from_server.status_details = &send_status_details;
send_status_details = grpc_slice_from_copied_string(
Z_STRVAL_P(inner_value));
ops[op_num].data.send_status_from_server.status_details =
&send_status_details;
} else {
zend_throw_exception(spl_ce_InvalidArgumentException,
"String status details is required",
@ -557,12 +564,33 @@ PHP_METHOD(Call, setCredentials) {
RETURN_LONG(error);
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 3)
ZEND_ARG_INFO(0, channel)
ZEND_ARG_INFO(0, method)
ZEND_ARG_INFO(0, deadline)
ZEND_ARG_INFO(0, host_override)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_startBatch, 0, 0, 1)
ZEND_ARG_INFO(0, ops)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_getPeer, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_cancel, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_setCredentials, 0, 0, 1)
ZEND_ARG_INFO(0, credentials)
ZEND_END_ARG_INFO()
static zend_function_entry call_methods[] = {
PHP_ME(Call, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Call, startBatch, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Call, getPeer, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Call, cancel, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Call, setCredentials, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Call, __construct, arginfo_construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Call, startBatch, arginfo_startBatch, ZEND_ACC_PUBLIC)
PHP_ME(Call, getPeer, arginfo_getPeer, ZEND_ACC_PUBLIC)
PHP_ME(Call, cancel, arginfo_cancel, ZEND_ACC_PUBLIC)
PHP_ME(Call, setCredentials, arginfo_setCredentials, ZEND_ACC_PUBLIC)
PHP_FE_END
};

@ -212,10 +212,19 @@ void plugin_destroy_state(void *ptr) {
efree(state);
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_createComposite, 0, 0, 2)
ZEND_ARG_INFO(0, creds1)
ZEND_ARG_INFO(0, creds2)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_createFromPlugin, 0, 0, 1)
ZEND_ARG_INFO(0, callback)
ZEND_END_ARG_INFO()
static zend_function_entry call_credentials_methods[] = {
PHP_ME(CallCredentials, createComposite, NULL,
PHP_ME(CallCredentials, createComposite, arginfo_createComposite,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(CallCredentials, createFromPlugin, NULL,
PHP_ME(CallCredentials, createFromPlugin, arginfo_createFromPlugin,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_FE_END
};

@ -243,12 +243,37 @@ PHP_METHOD(Channel, close) {
}
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 2)
ZEND_ARG_INFO(0, target)
ZEND_ARG_INFO(0, args)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_getTarget, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_getConnectivityState, 0, 0, 0)
ZEND_ARG_INFO(0, try_to_connect)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_watchConnectivityState, 0, 0, 2)
ZEND_ARG_INFO(0, last_state)
ZEND_ARG_INFO(0, deadline)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_close, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry channel_methods[] = {
PHP_ME(Channel, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Channel, getTarget, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Channel, getConnectivityState, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Channel, watchConnectivityState, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Channel, close, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Channel, __construct, arginfo_construct,
ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Channel, getTarget, arginfo_getTarget,
ZEND_ACC_PUBLIC)
PHP_ME(Channel, getConnectivityState, arginfo_getConnectivityState,
ZEND_ACC_PUBLIC)
PHP_ME(Channel, watchConnectivityState, arginfo_watchConnectivityState,
ZEND_ACC_PUBLIC)
PHP_ME(Channel, close, arginfo_close,
ZEND_ACC_PUBLIC)
PHP_FE_END
};

@ -199,16 +199,37 @@ PHP_METHOD(ChannelCredentials, createInsecure) {
RETURN_NULL();
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_setDefaultRootsPem, 0, 0, 1)
ZEND_ARG_INFO(0, pem_roots)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_createDefault, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_createSsl, 0, 0, 0)
ZEND_ARG_INFO(0, pem_root_certs)
ZEND_ARG_INFO(0, pem_private_key)
ZEND_ARG_INFO(0, pem_cert_chain)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_createComposite, 0, 0, 2)
ZEND_ARG_INFO(0, channel_creds)
ZEND_ARG_INFO(0, call_creds)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_createInsecure, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry channel_credentials_methods[] = {
PHP_ME(ChannelCredentials, setDefaultRootsPem, NULL,
PHP_ME(ChannelCredentials, setDefaultRootsPem, arginfo_setDefaultRootsPem,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(ChannelCredentials, createDefault, NULL,
PHP_ME(ChannelCredentials, createDefault, arginfo_createDefault,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(ChannelCredentials, createSsl, NULL,
PHP_ME(ChannelCredentials, createSsl, arginfo_createSsl,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(ChannelCredentials, createComposite, NULL,
PHP_ME(ChannelCredentials, createComposite, arginfo_createComposite,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(ChannelCredentials, createInsecure, NULL,
PHP_ME(ChannelCredentials, createInsecure, arginfo_createInsecure,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_FE_END
};

@ -116,8 +116,6 @@ PHP_METHOD(Server, __construct) {
/**
* Request a call on a server. Creates a single GRPC_SERVER_RPC_NEW event.
* @param long $tag_new The tag to associate with the new request
* @param long $tag_cancel The tag to use if the call is cancelled
* @return void
*/
PHP_METHOD(Server, requestCall) {
@ -239,12 +237,36 @@ PHP_METHOD(Server, start) {
grpc_server_start(server->wrapped);
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 0)
ZEND_ARG_INFO(0, args)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_requestCall, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_addHttp2Port, 0, 0, 1)
ZEND_ARG_INFO(0, addr)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_addSecureHttp2Port, 0, 0, 2)
ZEND_ARG_INFO(0, addr)
ZEND_ARG_INFO(0, server_creds)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_start, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry server_methods[] = {
PHP_ME(Server, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Server, requestCall, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Server, addHttp2Port, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Server, addSecureHttp2Port, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Server, start, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Server, __construct, arginfo_construct,
ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Server, requestCall, arginfo_requestCall,
ZEND_ACC_PUBLIC)
PHP_ME(Server, addHttp2Port, arginfo_addHttp2Port,
ZEND_ACC_PUBLIC)
PHP_ME(Server, addSecureHttp2Port, arginfo_addSecureHttp2Port,
ZEND_ACC_PUBLIC)
PHP_ME(Server, start, arginfo_start,
ZEND_ACC_PUBLIC)
PHP_FE_END
};

@ -117,8 +117,14 @@ PHP_METHOD(ServerCredentials, createSsl) {
RETURN_DESTROY_ZVAL(creds_object);
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_createSsl, 0, 0, 3)
ZEND_ARG_INFO(0, pem_root_certs)
ZEND_ARG_INFO(0, pem_private_key)
ZEND_ARG_INFO(0, pem_cert_chain)
ZEND_END_ARG_INFO()
static zend_function_entry server_credentials_methods[] = {
PHP_ME(ServerCredentials, createSsl, NULL,
PHP_ME(ServerCredentials, createSsl, arginfo_createSsl,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_FE_END
};

@ -245,17 +245,65 @@ PHP_METHOD(Timeval, sleepUntil) {
gpr_sleep_until(this->wrapped);
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 1)
ZEND_ARG_INFO(0, microseconds)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_add, 0, 0, 1)
ZEND_ARG_INFO(0, timeval)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_compare, 0, 0, 2)
ZEND_ARG_INFO(0, a_timeval)
ZEND_ARG_INFO(0, b_timeval)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_infFuture, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_infPast, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_now, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_similar, 0, 0, 3)
ZEND_ARG_INFO(0, a_timeval)
ZEND_ARG_INFO(0, b_timeval)
ZEND_ARG_INFO(0, threshold_timeval)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_sleepUntil, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_subtract, 0, 0, 1)
ZEND_ARG_INFO(0, timeval)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_zero, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry timeval_methods[] = {
PHP_ME(Timeval, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Timeval, add, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Timeval, compare, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, infFuture, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, infPast, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, now, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, similar, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, sleepUntil, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Timeval, subtract, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Timeval, zero, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, __construct, arginfo_construct,
ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Timeval, add, arginfo_add,
ZEND_ACC_PUBLIC)
PHP_ME(Timeval, compare, arginfo_compare,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, infFuture, arginfo_infFuture,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, infPast, arginfo_infPast,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, now, arginfo_now,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, similar, arginfo_similar,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, sleepUntil, arginfo_sleepUntil,
ZEND_ACC_PUBLIC)
PHP_ME(Timeval, subtract, arginfo_subtract,
ZEND_ACC_PUBLIC)
PHP_ME(Timeval, zero, arginfo_zero,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_FE_END
};

Loading…
Cancel
Save