Thrift
  1. Thrift
  2. THRIFT-520

Constants break when a namespace/prefix is set.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Cocoa - Compiler
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      Given the following thrift file:

      namespace cocoa XX 
      
      const list<string> MY_THINGS = [ "a", "b", "c" ]
      const string MY_CONSTANT = "Hello!"
      

      The generated class looks like:

      static NSArray * XXMY_THINGS;
      static NSString * XXMY_CONSTANT = @"Hello!";
      
      @implementation XXfooConstants
      + (void) initialize {
        MY_THINGS = [[NSArray alloc] initWithObjects: @"a", @"b", @"c", nil];
      }
      + (NSArray *) MY_THINGS{
        return MY_THINGS;
      }
      + (NSString *) MY_CONSTANT{
        return MY_CONSTANT;
      }
      @end
      

      ... but, it needs to look as it does below with the correct prefixing in the initialize and getter methods:

      static NSArray * XXMY_THINGS;
      static NSString * XXMY_CONSTANT = @"Hello!";
      
      @implementation XXfooConstants
      + (void) initialize {
        XXMY_THINGS = [[NSArray alloc] initWithObjects: @"a", @"b", @"c", nil];
      }
      + (NSArray *) MY_THINGS{
        return XXMY_THINGS;
      }
      + (NSString *) MY_CONSTANT{
        return XXMY_CONSTANT;
      }
      @end
      
      

        Activity

        Hide
        Andrew McGeachie added a comment -

        Committed. Thanks Fred!

        Show
        Andrew McGeachie added a comment - Committed. Thanks Fred!

          People

          • Assignee:
            Andrew McGeachie
            Reporter:
            Fred Potter
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development