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

C++ Compiler Virtual Function Option

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 0.2, 0.3
    • 0.11.0
    • C++ - Compiler
    • None
    • Cygwin 1.7.1 on Windows XP SP3, Thrift 0.2.0 & r760184 & Trunk

    Description

      The C++ Compiler currelty emits most functions in the *Client class as non-virtual.

      This makes it difficult to subclass the generated *Client class and override its functions.

      In particular, if a subclass overrides the *_send and *_recv functions, it must also override the function itself.
      Otherwise, the *Client version of the function calls the *Client versions of *_send and *_recv.

      A workaround is to inherit from the interface class *If, which has virtual functions,
      and use them to call *Client class member functions.
      But this can be cumbersome in some situations, and still requires additional functions to be overridden.

      I propose to add a virtual option to the C++ compiler that emits function declarations as virtual.

      I have attached a patched version of t_cpp_generator.cc from Thrift 0.2.0 - I can work out how to turn it into a patch file if needed.

      Is this worth merging into the trunk?

      Attachments

        1. t_cpp_generator.cc
          100 kB
          Tim Wilson-Brown
        2. cpp_virtual_thrift020.patch
          4 kB
          Tim Wilson-Brown

        Activity

          People

            jking3 James E. King III
            twilsonb Tim Wilson-Brown
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified