diff options
Diffstat (limited to 'src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi')
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi | 18 |
1 files changed, 18 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..2239e26b32 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi @@ -34,6 +34,22 @@ 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 grpc_arg _unwrap_grpc_arg(tuple wrapped_arg): + cdef _GrpcArgWrapper wrapped = wrapped_arg[1] + return wrapped.arg + + cdef class _ArgumentProcessor: cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references): @@ -51,6 +67,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 |