thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ringerc <...@git.apache.org>
Subject [GitHub] thrift issue #84: Tree/Recursive struct support in thrift
Date Wed, 31 Jan 2018 04:42:50 GMT
Github user ringerc commented on the issue:

    https://github.com/apache/thrift/pull/84
  
    I see a bunch of mutual recursive structure support in the tests, but nothing for an optional
single self-referential member, like
    
    ```
    struct RecSelf {
       1: i16 item
       2: optional RecSelf 
     }
    ```
    
    Thift does not appear to generate sensible code for this. The example I am working with
is from the opentracing jaeger toolset, namely the IDL
    
    ```
    struct Downstream {
        1: required string serviceName
        2: required string serverRole
        3: required string host
        4: required string port
        5: required Transport transport
        6: optional Downstream downstream
    }
    ```
    
    This works fine in Java, Go, etc. But in C++ it produces the nonsensical code
    
    ```
    class Downstream {
     public:
     
      /* blah elided blah */
    
      virtual ~Downstream() throw();
      std::string serviceName;
      std::string serverRole;
      std::string host;
      std::string port;
      Transport::type transport;
      Downstream downstream;
    
      _Downstream__isset __isset;
    
      /* blah elided blah */
    };
    ```
    
    in which the class is a by-value member of its self.
    
    I think the ideal solution here would be to adopt something like `std::optional` (c++17
proposal) as a `thrift::optional` and use that instead of the `__isset` stuff for optional
members. But backwards compatibility could be a problem.


---

Mime
View raw message