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

c_glib: Expose as properties members of generated structs



    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.9.1
    • 0.9.2
    • C glib - Compiler
    • Fedora 20 64-bit on x86_64

    • Patch Available


      Currently the c_glib compiler generates a GObject class for each Thrift struct, with a corresponding field for each of the struct's members. However it doesn't register the members as properties of the object, expecting client code to instead access the object's fields directly—an unconventional and bad practice.

      This set of patches changes the compiler so it exposes struct members as object properties, allowing them to be accessed and modified in the conventional manner. (This doesn't prevent objects' fields from being accessed directly, though, so existing code will continue to work.)

      The changes are, in order:

      1. Initialize list members with their default values, if specified, in the constructor of generated struct classes. (Not strictly tied to this issue, but used in the test cases I'm submitting.)
      2. Add get_min_value and get_max_value methods to t_enum, allowing the compiler to determine the valid range for properties representing an enumerated type.
      3. Output a property enumeration, property setter and property getter for each generated class representing a struct, and register the class' properties in its class initializer.
      4. Gently reformat testdebugproto.c (as I have now completely rewritten it) so my previous work matches the structure of this current work.




            roger Roger Meier
            simonsouth Simon South
            0 Vote for this issue
            5 Start watching this issue