Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
4b9740bf
Commit
4b9740bf
authored
8 years ago
by
thinkerou
Browse files
Options
Downloads
Patches
Plain Diff
use php7_wrapper to reduce dup-codes
parent
9ee78aa1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/php/ext/grpc/call.c
+2
-15
2 additions, 15 deletions
src/php/ext/grpc/call.c
src/php/ext/grpc/timeval.c
+4
-40
4 additions, 40 deletions
src/php/ext/grpc/timeval.c
with
6 additions
and
55 deletions
src/php/ext/grpc/call.c
+
2
−
15
View file @
4b9740bf
...
...
@@ -380,8 +380,6 @@ PHP_METHOD(Call, __construct) {
*/
PHP_METHOD
(
Call
,
startBatch
)
{
#if PHP_MAJOR_VERSION < 7
wrapped_grpc_call
*
call
=
(
wrapped_grpc_call
*
)
zend_object_store_get_object
(
getThis
()
TSRMLS_CC
);
zval
**
value
;
zval
**
inner_value
;
HashPosition
array_pointer
;
...
...
@@ -395,7 +393,6 @@ PHP_METHOD(Call, startBatch) {
MAKE_STD_ZVAL
(
result
);
object_init
(
result
);
#else
wrapped_grpc_call
*
call
=
Z_WRAPPED_GRPC_CALL_P
(
getThis
());
zval
*
value
;
zval
*
inner_value
;
zval
*
message_value
;
...
...
@@ -405,6 +402,7 @@ PHP_METHOD(Call, startBatch) {
zval
recv_status
;
object_init
(
return_value
);
#endif
wrapped_grpc_call
*
call
=
Z_WRAPPED_GRPC_CALL_P
(
getThis
());
grpc_op
ops
[
8
];
size_t
op_num
=
0
;
...
...
@@ -829,14 +827,8 @@ cleanup:
* @return string The URI of the endpoint
*/
PHP_METHOD
(
Call
,
getPeer
)
{
#if PHP_MAJOR_VERSION < 7
wrapped_grpc_call
*
call
=
(
wrapped_grpc_call
*
)
zend_object_store_get_object
(
getThis
()
TSRMLS_CC
);
RETURN_STRING
(
grpc_call_get_peer
(
call
->
wrapped
),
1
);
#else
wrapped_grpc_call
*
call
=
Z_WRAPPED_GRPC_CALL_P
(
getThis
());
RETURN_STRING
(
grpc_call_get_peer
(
call
->
wrapped
));
#endif
PHP_GRPC_RETURN_STRING
(
grpc_call_get_peer
(
call
->
wrapped
),
1
);
}
/**
...
...
@@ -844,12 +836,7 @@ PHP_METHOD(Call, getPeer) {
* has not already ended with another status.
*/
PHP_METHOD
(
Call
,
cancel
)
{
#if PHP_MAJOR_VERSION < 7
wrapped_grpc_call
*
call
=
(
wrapped_grpc_call
*
)
zend_object_store_get_object
(
getThis
()
TSRMLS_CC
);
#else
wrapped_grpc_call
*
call
=
Z_WRAPPED_GRPC_CALL_P
(
getThis
());
#endif
grpc_call_cancel
(
call
->
wrapped
,
NULL
);
}
...
...
This diff is collapsed.
Click to expand it.
src/php/ext/grpc/timeval.c
+
4
−
40
View file @
4b9740bf
...
...
@@ -124,12 +124,7 @@ void grpc_php_wrap_timeval(gpr_timespec wrapped, zval *timeval_object) {
* @param long $usec The number of microseconds in the interval
*/
PHP_METHOD
(
Timeval
,
__construct
)
{
#if PHP_MAJOR_VERSION < 7
wrapped_grpc_timeval
*
timeval
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
getThis
()
TSRMLS_CC
);
#else
wrapped_grpc_timeval
*
timeval
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
getThis
());
#endif
php_grpc_long
microseconds
;
/* "l" == 1 long */
...
...
@@ -159,19 +154,14 @@ PHP_METHOD(Timeval, add) {
"add expects a Timeval"
,
1
TSRMLS_CC
);
return
;
}
wrapped_grpc_timeval
*
self
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
getThis
());
wrapped_grpc_timeval
*
other
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
other_obj
);
#if PHP_MAJOR_VERSION < 7
wrapped_grpc_timeval
*
self
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
getThis
()
TSRMLS_CC
);
wrapped_grpc_timeval
*
other
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
other_obj
TSRMLS_CC
);
zval
*
sum
=
grpc_php_wrap_timeval
(
gpr_time_add
(
self
->
wrapped
,
other
->
wrapped
)
TSRMLS_CC
);
RETURN_DESTROY_ZVAL
(
sum
);
#else
wrapped_grpc_timeval
*
self
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
getThis
());
wrapped_grpc_timeval
*
other
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
other_obj
);
grpc_php_wrap_timeval
(
gpr_time_add
(
self
->
wrapped
,
other
->
wrapped
),
return_value
);
RETURN_DESTROY_ZVAL
(
return_value
);
...
...
@@ -194,18 +184,14 @@ PHP_METHOD(Timeval, subtract) {
"subtract expects a Timeval"
,
1
TSRMLS_CC
);
return
;
}
wrapped_grpc_timeval
*
self
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
getThis
());
wrapped_grpc_timeval
*
other
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
other_obj
);
#if PHP_MAJOR_VERSION < 7
wrapped_grpc_timeval
*
self
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
getThis
()
TSRMLS_CC
);
wrapped_grpc_timeval
*
other
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
other_obj
TSRMLS_CC
);
zval
*
diff
=
grpc_php_wrap_timeval
(
gpr_time_sub
(
self
->
wrapped
,
other
->
wrapped
)
TSRMLS_CC
);
RETURN_DESTROY_ZVAL
(
diff
);
#else
wrapped_grpc_timeval
*
self
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
getThis
());
wrapped_grpc_timeval
*
other
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
other_obj
);
grpc_php_wrap_timeval
(
gpr_time_sub
(
self
->
wrapped
,
other
->
wrapped
),
return_value
);
RETURN_DESTROY_ZVAL
(
return_value
);
...
...
@@ -231,15 +217,8 @@ PHP_METHOD(Timeval, compare) {
"compare expects two Timevals"
,
1
TSRMLS_CC
);
return
;
}
#if PHP_MAJOR_VERSION < 7
wrapped_grpc_timeval
*
a
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
a_obj
TSRMLS_CC
);
wrapped_grpc_timeval
*
b
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
b_obj
TSRMLS_CC
);
#else
wrapped_grpc_timeval
*
a
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
a_obj
);
wrapped_grpc_timeval
*
b
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
b_obj
);
#endif
long
result
=
gpr_time_cmp
(
a
->
wrapped
,
b
->
wrapped
);
RETURN_LONG
(
result
);
}
...
...
@@ -264,19 +243,9 @@ PHP_METHOD(Timeval, similar) {
"compare expects three Timevals"
,
1
TSRMLS_CC
);
return
;
}
#if PHP_MAJOR_VERSION < 7
wrapped_grpc_timeval
*
a
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
a_obj
TSRMLS_CC
);
wrapped_grpc_timeval
*
b
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
b_obj
TSRMLS_CC
);
wrapped_grpc_timeval
*
thresh
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
thresh_obj
TSRMLS_CC
);
#else
wrapped_grpc_timeval
*
a
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
a_obj
);
wrapped_grpc_timeval
*
b
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
b_obj
);
wrapped_grpc_timeval
*
thresh
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
thresh_obj
);
#endif
int
result
=
gpr_time_similar
(
a
->
wrapped
,
b
->
wrapped
,
thresh
->
wrapped
);
RETURN_BOOL
(
result
);
}
...
...
@@ -349,12 +318,7 @@ PHP_METHOD(Timeval, infPast) {
* @return void
*/
PHP_METHOD
(
Timeval
,
sleepUntil
)
{
#if PHP_MAJOR_VERSION < 7
wrapped_grpc_timeval
*
this
=
(
wrapped_grpc_timeval
*
)
zend_object_store_get_object
(
getThis
()
TSRMLS_CC
);
#else
wrapped_grpc_timeval
*
this
=
Z_WRAPPED_GRPC_TIMEVAL_P
(
getThis
());
#endif
gpr_sleep_until
(
this
->
wrapped
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment