diff options
author | 2018-07-30 22:24:36 -0700 | |
---|---|---|
committer | 2018-07-30 22:24:36 -0700 | |
commit | fbfebd8e4e92067145127e23bbdbe3d596234634 (patch) | |
tree | 551e30f8522cdd9c9ec9651cc38af6eec100c549 /src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi | |
parent | 682d093868a2b7ba7b139d22eb7096cec78a9979 (diff) |
Add Cython functionality to directly wrap grpc_arg
Diffstat (limited to 'src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi')
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi index aecd3d7b11..c94c03eee8 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi @@ -34,6 +34,18 @@ cdef int _compare_pointer(void* first_pointer, void* second_pointer): return 0 +cdef class _GrpcArgWrapper: + + cdef grpc_arg arg + + +cdef tuple _wrap_grpc_arg(grpc_arg arg): + + wrapped = _GrpcArgWrapper() + wrapped.arg = arg + return ("grpc.python._cygrpc._GrpcArgWrapper", wrapped) + + cdef class _ArgumentProcessor: cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references): @@ -51,6 +63,8 @@ cdef class _ArgumentProcessor: if encoded_value is not value: references.append(encoded_value) self.c_argument.value.string = encoded_value + elif isinstance(value, _GrpcArgWrapper): + self.c_argument = (<_GrpcArgWrapper>value).arg elif hasattr(value, '__int__'): # Pointer objects must override __int__() to return # the underlying C address (Python ints are word size). The |