Create D binding for C struct containing templated class

Andre Pany andre at s-e-a-p.de
Thu Jun 28 18:43:11 UTC 2018


Hi,

I try to write a binding for the GRPC core. There is a struct 
which has some ugly fields:
(https://github.com/grpc/grpc/blob/master/src/core/lib/surface/call.cc#L229)

struct grpc_call {
   gpr_refcount ext_ref;
   gpr_arena* arena;
   ...
   grpc_core::ManualConstructor<grpc_core::SliceBufferByteStream> 
sending_stream;
   grpc_core::OrphanablePtr<grpc_core::ByteStream> 
receiving_stream;


ManualConstructor is defined as:
https://github.com/grpc/grpc/blob/50cecca24d4826dea4595b514a332fca5783074b/src/core/lib/gprpp/manual_constructor.h#L168

template <typename Type>
class ManualConstructor {
  public:
   Type* get() { return reinterpret_cast<Type*>(&space_); }
   const Type* get() const { return reinterpret_cast<const 
Type*>(&space_); }


My C / C++ knowledge is very limited and I also do not know how 
much D matured regarding C / C++ integration. Is it possible to 
write a binding in D for these constructs or isn't it supported 
by D?

Kind regards
André




More information about the Digitalmars-d-learn mailing list