Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-676

Change C++ code generator so that generated classes can be wrapped with SWIG

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.3
    • Fix Version/s: 0.4
    • Component/s: C++ - Compiler
    • Labels:
      None
    • Environment:

      Any C++

    • Patch Info:
      Patch Available

      Description

      There are times when it would be beneficial to wrap Thrift-generated C++ classes with the SWIG tool (http://www.swig.org). This is a problem, though, because SWIG does not yet handle nested class or structure definitions and the C++ code generator defines the __isset structure within the scope of the class definition to which it pertains.

      In order to make the Thrift-generated classes wrappable by SWIG, the __isset structure definition needs to be moved outside of the class definition. For a Thrift generated class called foo, the __isset definition would look like this:

      typedef struct foo_isset {
      foo_isset() : member0(false), member1(false) {}
      bool member0;
      bool member1;
      } foo_isset;

      and the using class would contain this line:
      foo_isset __isset;

      All existing code will continue to work, and can be regenerated at will.

      I have a patch for this.

        Attachments

        1. patchThrift-676.txt
          4 kB
          Rush Manbert

          Activity

            People

            • Assignee:
              rush Rush Manbert
              Reporter:
              rush Rush Manbert
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: