[
https://issues.apache.org/jira/browse/THRIFT-2220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13789148#comment-13789148
]
Martin Vogt commented on THRIFT-2220:
-------------------------------------
Hello Henrique,
>It sounds like a nice idea, but have you thought about this on
> other strongly typed languages, >e.g. Java, C#?
>I think it might get quite tricky to implement but might be doable.
No not yet. My idea is to make my simple API network "aware". It currently
is written in C++/Qt and is a simple message API (see below).
If this is done, my idea is to check a different language binding.
And I don't have the intention to make this struct everywhere available.
(map or part of other structs, etc..)
It should only be in the method signature, and NOT in for example:
// No intention to support this
map<TBase> map;
struct User {
string name;
TBase something;
}
Only in a method for a FieldType eg:
service USB {
i32 read(i32 vfd ,TBase base)
}
regards,
Martin
My API which should be made network aware:
class TUSB {
public:
static TSignal<int,TBase> event;
static in write(int vfd,const TBase& base);
static int read(int vfd,TBase& base);
};
> Add a new struct structv?
> -------------------------
>
> Key: THRIFT-2220
> URL: https://issues.apache.org/jira/browse/THRIFT-2220
> Project: Thrift
> Issue Type: Improvement
> Components: C++ - Compiler
> Affects Versions: 0.9.1
> Reporter: Martin Vogt
> Priority: Minor
>
> Thrift cannot extend structs, but maybe its possible to add a virtual base
> struct?
> Today I updated the "TBase" patch for gen cpp.
> https://issues.apache.org/jira/browse/THRIFT-1712
> After that, I modified the compiler to accept a new struct type, which
> describes that the marshalled struct needs to be created before the
> read(iproto) starts. (write already is fine, because on writing the
> specialized class is already created, only the "read" needs some factory, for
> the real implementation)
> For example:
> {code}
> struct_v TMVBase <<-- struct_v tell the generator to created the
> TBase class with a factory ("v"
> for virtual)
> service USB {
> void martin(1:TMVBase base);
> }
> {code}
> This is then generated into someting like this:
> {code}
> uint32_t USB_martin_args::read(::apache::thrift::protocol::TProtocol* iprot) {
> [...]
> switch (fid) {
> case 1:
> if (ftype == ::apache::thrift::protocol::T_STRUCT) {
> // TBase struct create:this->base
> this->base=TMVBase::create(iprot);
> xfer += this->base->read(iprot);
> this->__isset.base = true;
> } else {
> xfer += iprot->skip(ftype);
> }
> break
> [..]
> {code}
> This would allow to create the derived classed (from TBase) during marshall,
> without the need to define every method with any possible struct. Curently I
> have modified thrifty.yy and some other things, so that
> yacc actually parse this new "struct_v" type. But the generated source
> for it needs to be changed some more.
> The Protocolhandlers need to write the struct name on the
> wire, of course (which they currenty don' do).
> I think I can make a working prototype and post the patch.
--
This message was sent by Atlassian JIRA
(v6.1#6144)