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

Constants break when a namespace/prefix is set.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • Cocoa - Compiler
    • None
    • 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
      
      

      Attachments

        1. thrift-520.patch
          1 kB
          Fred Potter

        Activity

          People

            geechorama Andrew McGeachie
            fpotter Fred Potter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: