diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi | 5 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi index 853bf6f8e0..f5baf8db3f 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi @@ -1,4 +1,4 @@ -# Copyright 2018 gRPC authors. +# Copyright 2018 The gRPC Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,6 +22,9 @@ cdef void _destroy_pointer(void* pointer) cdef int _compare_pointer(void* first_pointer, void* second_pointer) +cdef tuple _wrap_grpc_arg(grpc_arg arg) + + cdef class _ArgumentProcessor: cdef grpc_arg c_argument 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 |