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

OCaml generator to take default values into account

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.3
    • 0.4
    • OCaml - Compiler
    • None
    • Patch Available

    Description

      A patch to the OCaml generator which uses default values defined in the .thrift file to initialize the members of the generated class.

      I've prepared an OCaml generator patch against the current Thrift SVN trunk. The generated code:

      • makes unwrapped types for all fields for which default values are defined,
      • honors the protocol-centric semantics for the "required" field: such fields are always serialized,
      • throws exception instead of skipping "required" fields which do not have a set value,
      • avoids encoding values of "optional" and absent-requiredness fields if the field value is structurally equivalent to the field's default value,
      • does not break compatibility with C++ receivers,
      • is drop-in compatibe with OCaml code generated by the OCaml generator in the unmodified trunk

      For the full description of changes see paragraph 3.2 in http://lionet.livejournal.com/66899.html

      Attachments

        1. thrift-trunk-962854.patch
          8 kB
          Lev Walkin

        Activity

          People

            vlm Lev Walkin
            vlm Lev Walkin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: