Changeset 1608

Show
Ignore:
Timestamp:
09/03/08 14:50:52 (4 months ago)
Author:
Chuck.Esterbrook
Message:

Added support for attributes on class/object variables (also know as "fields").

Location:
cobra/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Developer/IntermediateReleaseNotes.text

    r1597 r1608  
    7171* Added new Visitor class to the Cobra standard library. Subclasses can easily implement the visitor pattern and the classes being visited require no additional modification. See the doc string of `Visitor` in CobraLang.cobra for details. 
    7272 
     73* Added support for attributes on class/object variables (also know as "fields"). 
     74 
    7375* Cobra now prints '[1, 2, 3]' for a list of integers rather than 'System.Collections.Generic.List`1[System.Int32]'. It still uses the standard List<of> class. 
    7476 
  • cobra/trunk/Source/Boxes.cobra

    r1606 r1608  
    10451045                                if fieldInfo.isStatic 
    10461046                                        isNames.add('shared') 
    1047                                 varr = BoxVar(TokenFix.empty, this, Utils.cobraNameForSharpMemberName(fieldInfo.name), _memberTypeResultProxy(fieldInfo, fieldInfo.fieldType), isNames, nil, '') 
     1047                                varr = BoxVar(TokenFix.empty, this, Utils.cobraNameForSharpMemberName(fieldInfo.name), _memberTypeResultProxy(fieldInfo, fieldInfo.fieldType), isNames, nil, nil, '') 
    10481048                                varr.binaryName = fieldInfo.name 
    10491049                                .addDecl(varr) 
  • cobra/trunk/Source/CobraParser.cobra

    r1605 r1608  
    11661166                        docString = .docString 
    11671167                        .dedent 
    1168                 return BoxVar(tok, .curBox, identifier, type, isNames, initExpr, docString) 
     1168                return BoxVar(tok, .curBox, identifier, type, isNames, initExpr, attribs, docString) 
    11691169 
    11701170        def declareInvariant 
  • cobra/trunk/Source/Members.cobra

    r1607 r1608  
    464464        var _isAssignedTo as bool 
    465465 
    466         def init(token as IToken, box as Box, name as String, typeNode as ITypeProxy?, isNames as List<of String>, initExpr as Expr?, docString as String) 
    467                 base.init(token, box, name, isNames, AttributeList(), docString) 
     466        def init(token as IToken, box as Box, name as String, typeNode as ITypeProxy?, isNames as List<of String>, initExpr as Expr?, attribs as AttributeList?, docString as String) 
     467                base.init(token, box, name, isNames, attribs ? AttributeList(), docString) 
    468468                _typeNode = typeNode 
    469469                _initExpr = initExpr 
     
    591591        def writeSharpDef(sw as SharpWriter) is override 
    592592                base.writeSharpDef(sw) 
     593                .writeSharpAttribs(sw) 
    593594                .writeSharpIsNames(sw) 
    594595                sw.write(_type.sharpRef) 
  • cobra/trunk/Tests/320-misc-two/800-attributes/100-attributes.cobra

    r1177 r1608  
    5959 
    6060        def getHashCode as int is override 
    61                 return $sharp('_x << 8 | _y') 
     61                return _x << 8 | _y 
    6262 
    6363 
     
    9090                checkCount = 0 
    9191                for member in t.getMembers 
    92                         if v 
    93                                 print member 
     92                        if v, print member 
    9493                        name = member.name 
    9594                        if name.startsWith('Attrib') or name.startsWith('Item') 
    9695                                attribs = List<of FooAttribute>() 
    9796                                for attrib in member.getCustomAttributes(true) 
    98                                         if v 
    99                                                 print '   ', attrib 
     97                                        if v, print '   ', attrib 
    10098                                        if attrib inherits FooAttribute 
    10199                                                attribs.add(attrib) 
     
    217215#               has Foo(x=3) 
    218216#               pass 
     217 
     218        # var 
     219        var attribVar2a_0_0_2_3 as int 
     220                has Foo, Bar(x=2, y=3)