Wiki

Changes between Version 8 and Version 9 of PortingC

Show
Ignore:
Timestamp:
05/25/15 12:10:38 (10 years ago)
Author:
hopscc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PortingC

    v8 v9  
    7474 
    7575 
    76  9. Change any class instance attributes/fields to be prefixed with ''''var'''' 
    77     Change type and accessmodifier to cobra forms 
     76 9. Change any class instance attributes/fields to be prefixed with ''''var''''. 
     77 
     78    Change type and accessmodifier to cobra forms. 
    7879   {{{ 
    7980<Type> name = <init> ; 
     
    868710. Fixup class constructor definitions 
    8788     For initializer/constructor change lines like : 
    88         {{{ 
    89 #!cs public ClassName(params,...) : base(baseParams,...)  
     89{{{ 
     90#!cs 
     91public ClassName(params,...) : base(baseParams,...)  
    9092}}} 
    9193      to 
     
    154156#!cobra 
    155157def onFileChange(sender as Object, e as Event)   
    156  
    157     # no param method 
     158    }}} 
     159 
     160 
     161    No param method 
     162{{{ 
    158163#!cs 
    159164    public override bool OnInit() 
    160165    }}} 
    161      -> 
     166    turns into 
    162167    {{{ 
    163168#!cobra 
    164169def onInit as bool is override  
    165     # or def onInit as bool is public, override # explicit 
     170    # or  
     171def onInit as bool is public, override # explicit 
    166172}}} 
    167173             
     
    194200    the type definition (type inferred from the assignment) or can still be explicitly typed. 
    195201    {{{ 
     202#!cs 
    196203    DataItem info = new DataItem()  
    197       -> 
     204}}} 
     205      changes to 
     206{{{ 
     207#!cobra 
    198208    info = DataItem()     # or    info as DataItem = DataItem() 
    199209    }}} 
     
    20321316. Fixup 'For' loops 
    204214    {{{ 
     215#!cs 
    205216for ( <Type> name = start ; name < stop; ++name )  
    206         -> 
     217}}} 
     218  becomes 
     219{{{ 
     220#!cobra 
    207221for name as Type in start : stop : 1 # explicit or equally use shortcuts: 
    208222for name in start : stop : 1  
     
    210224for name in stop           # if start is zero (0) and step is one (1) 
    211225    # same as for name in 0 : stop : 1 
    212     }}} 
     226}}} 
    213227     
    214     e.g {{{ for ( int i = 0; i < 200; ++i ) -> for i in 0 : 200 }}}     
     228    e.g  
     229{{{ for ( int i = 0; i < 200; ++i ) -> for i in 0 : 200 }}}     
    215230 
    216231 
     
    225240    Put the expressions (suitably cobra converted) into the string inside [] 
    226241 
    227     e.g. {{{ "Value " + item.Value + " selected item: " + item.Selected  --->  "Value [item.value] selected item:[item.selected]" }}} 
     242    e.g.  
     243{{{ 
     244#!cs 
     245 "Value " + item.Value + " selected item: " + item.Selected  
     246}}} 
     247becomes   
     248{{{ 
     249#!cobra 
     250"Value [item.value] selected item:[item.selected]"  
     251}}} 
    228252 
    229253    if you have [ and ] symbols, these should be doubled 
     
    234258 
    23525920. Adding eventHandlers 
    236     Cobra uses the '''listen''' statement to register event handlers where C# uses an override on  
    237     the += operator.  [[br]] 
     260    Cobra uses the '''listen''' statement to register event handlers where C# uses an override on the += operator.  [[br]] 
    238261    Otherwise normal cobra mapping for method names and reference to methods (vs method calls) apply;[[br]] 
    239     Methodnames in Cobra must start with a lower case letter and calls to this instance names  
    240         are prefixed with ''''this.'''' or (easier) ''''.'''' 
     262    Methodnames in Cobra must start with a lower case letter and calls to this instance names are prefixed with ''''this.'''' or (easier) ''''.'''' 
    241263     
    242     When translating from a 'use'd library namespace,  calls to[[br]]  
    243         Capcased methodnames are referenced in cobra with the first '''char''' lowercased,[[br]]  
    244         Upcased methodnames  are referenced with the first '''word''' lowercased 
     264    When translating from a 'use'd library namespace,  calls to  
     265    capcased methodnames are referenced in cobra with the first '''char''' lowercased,[[br]]  
     266    Upcased methodnames  are referenced with the first '''word''' lowercased [[br]] 
    245267    so  
    246268    {{{ 
     269#!cs 
    247270    EVENT +=  new Listener(MethodName)  in C# becomes 
    248271    listen .EVENT,      Listener( ref .methodName )  
    249  
     272}}} 
     273becomes 
     274{{{ 
     275#!cobra 
    250276    EVENT += new Listener( EH_METHOD_NAME ) in C# becomes 
    251     listen .EVENT,      Listener( ref .eh_METHOD_NAME )  
     277    listen .EVENT, Listener( ref .eh_METHOD_NAME )  
    252278    }}} 
    253279    e.g. 
    254280    {{{ 
     281#!cs 
    255282    FileChange += new Listener( OnFileChange ) 
    256         -> 
     283}}} 
     284        turns into 
     285{{{ 
     286#!cobra 
    257287    listen .fileChange,    Listener(ref .onFileChange)  
    258     }}} 
     288}}} 
    259289 
    260290 
     
    275305 
    27630622. Multidimensional and/or fixed size jagged arrays 
    277     Multidimensional arrays are not supported by the langauge. Jagged arrays of fixed size are possible but difficult to initialise. See http://cobra-language.com/forums/viewtopic.php?f=4&t=654 for more information about these. 
     307    Multidimensional arrays are not supported by the language. 
     308   Jagged arrays of fixed size are possible but difficult to initialise. See http://cobra-language.com/forums/viewtopic.php?f=4&t=654 
     309 for more information about these.