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

Bad AS3 syntax in constructors that set default values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.3
    • 0.7
    • AS3 - Compiler
    • None
    • Any.

    • Patch Available

    Description

      If your thrift definition declares static default values, such as:

      struct Chat {
      1: MessageType type = EVENT_CHAT,
      2: i32 eventId,
      3: string message,
      4: Date at
      }

      The generated AS3 object won't compile since the compiler uses the same function that generates member declarations. Patch is below.

      Index: compiler/cpp/src/generate/t_as3_generator.cc
      ===================================================================
      --- compiler/cpp/src/generate/t_as3_generator.cc        (revision 981076)
      +++ compiler/cpp/src/generate/t_as3_generator.cc        (working copy)
      @@ -696,7 +696,8 @@
      for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
        t_type* t = get_true_type((*m_iter)->get_type());
        if ((*m_iter)->get_value() != NULL) {
      -      print_const_value(out, "this." + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true);
      +      indent(out) << "this._" << (*m_iter)->get_name() << " = " << (*m_iter)->get_value()->get_integer() << ";" <<
      +      endl;
        }
      }
      indent_down();
      

      Attachments

        1. THRIFT-835.patch
          0.7 kB
          Justin Florentine

        Activity

          People

            butterstick Justin Florentine
            butterstick Justin Florentine
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: