Wiki

Changeset 2019

Show
Ignore:
Timestamp:
04/16/09 22:18:35 (3 years ago)
Author:
Chuck.Esterbrook
Message:

Introduce .typeOf as a cross platform means of getting the type of an object.

Location:
cobra/trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/HowTo/200-MakeAClassHierarchy.cobra

    r1983 r2019  
    101101        body 
    102102            sb = StringBuilder() 
    103             sb.append('[.getType.name]([_serialNum]')  # example: 'Foo(1001)' 
     103            sb.append('[.typeOf.name]([_serialNum]')  # example: 'Foo(1001)' 
    104104            .buildString(sb)  # so subclasses can add their fields 
    105105            sb.append(')') 
  • cobra/trunk/HowTo/300-ImplementIEnumerable1.cobra

    r1983 r2019  
    4545 
    4646    def toString as String is override 
    47         return '[.getType.name]([_serialNum], [_name])' 
     47        return '[.typeOf.name]([_serialNum], [_name])' 
    4848 
    4949 
  • cobra/trunk/HowTo/301-ImplementIEnumerable2.cobra

    r1983 r2019  
    3535 
    3636    def toString as String is override 
    37         return '[.getType.name]([_serialNum], [_name])' 
     37        return '[.typeOf.name]([_serialNum], [_name])' 
    3838 
    3939 
  • cobra/trunk/HowTo/310-IterateThroughRecursiveDataWithYield.cobra

    r1983 r2019  
    3232 
    3333    def toString as String is override 
    34         return '[.getType.name](item=[.item])' 
     34        return '[.typeOf.name](item=[.item])' 
    3535 
    3636    def dump 
  • cobra/trunk/HowTo/400-DeepCopyObjects.cobra

    r1236 r2019  
    1414    def copy(obj as Object) is shared 
    1515        require 
    16             obj.getType.isSerializable 
     16            obj.typeOf.isSerializable 
    1717        body 
    1818            try 
  • cobra/trunk/Samples/forth.cobra

    r1982 r2019  
    146146                methodName = word.toString['built-in:'.length:] 
    147147                methodName = methodName[0].toString.toUpper + methodName[1:] # because at run-time, method names are capped for compatibility with C# and VB 
    148                 method = .getType.getMethod(methodName) 
     148                method = .typeOf.getMethod(methodName) 
    149149                method.invoke(this, nil) 
    150150            else 
     
    396396        branch _which 
    397397            on WordType.String 
    398                 if _s == '' 
    399                     return '(EMPTY-STRING)' 
    400                 if _s.trim == '' 
    401                     return '(BLANK-STRING)' 
     398                if _s == '', return '(EMPTY-STRING)' 
     399                if _s.trim == '', return '(BLANK-STRING)' 
    402400                return _s to ! 
    403401            on WordType.Int 
     
    407405    def toTechString as String 
    408406        branch _which 
    409             on WordType.String, return '[.getType.name](string, "[_s]")' 
    410             on WordType.Int, return '[.getType.name](int, "[_i]")' 
     407            on WordType.String, return '[.typeOf.name](string, "[_s]")' 
     408            on WordType.Int, return '[.typeOf.name](int, "[_i]")' 
    411409        throw FallThroughException(_which) 
    412410 
  • cobra/trunk/Samples/Point.cobra

    r1929 r2019  
    8181 
    8282    def toString as String is override 
    83         return '[.getType.name]([.x], [.y])' 
     83        return '[.typeOf.name]([.x], [.y])' 
    8484 
    8585    def equals(other as Object?) as bool is override 
  • cobra/trunk/Samples/Shapes.cobra

    r1985 r2019  
    3737        their properties. 
    3838        """ 
    39         print 'Draw [.getType.name] at ([_x], [_y]), ' stop 
     39        print 'Draw [.typeOf.name] at ([_x], [_y]), ' stop 
    4040 
    4141 
  • cobra/trunk/Source/Cobra.Lang/Extensions.cobra

    r1957 r2019  
    22 
    33    extend System.Object 
     4 
     5        def typeOf as System.Type 
     6            """ Using.typeOf is portable between platforms in contrast to CLR .getType and JVM .getClass. """ 
     7            return .getType 
    48 
    59        def toTechString as String