Changes between Version 8 and Version 9 of PortingC
- Timestamp:
- 05/25/15 12:10:38 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PortingC
v8 v9 74 74 75 75 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. 78 79 {{{ 79 80 <Type> name = <init> ; … … 86 87 10. Fixup class constructor definitions 87 88 For initializer/constructor change lines like : 88 {{{ 89 #!cs public ClassName(params,...) : base(baseParams,...) 89 {{{ 90 #!cs 91 public ClassName(params,...) : base(baseParams,...) 90 92 }}} 91 93 to … … 154 156 #!cobra 155 157 def onFileChange(sender as Object, e as Event) 156 157 # no param method 158 }}} 159 160 161 No param method 162 {{{ 158 163 #!cs 159 164 public override bool OnInit() 160 165 }}} 161 ->166 turns into 162 167 {{{ 163 168 #!cobra 164 169 def onInit as bool is override 165 # or def onInit as bool is public, override # explicit 170 # or 171 def onInit as bool is public, override # explicit 166 172 }}} 167 173 … … 194 200 the type definition (type inferred from the assignment) or can still be explicitly typed. 195 201 {{{ 202 #!cs 196 203 DataItem info = new DataItem() 197 -> 204 }}} 205 changes to 206 {{{ 207 #!cobra 198 208 info = DataItem() # or info as DataItem = DataItem() 199 209 }}} … … 203 213 16. Fixup 'For' loops 204 214 {{{ 215 #!cs 205 216 for ( <Type> name = start ; name < stop; ++name ) 206 -> 217 }}} 218 becomes 219 {{{ 220 #!cobra 207 221 for name as Type in start : stop : 1 # explicit or equally use shortcuts: 208 222 for name in start : stop : 1 … … 210 224 for name in stop # if start is zero (0) and step is one (1) 211 225 # same as for name in 0 : stop : 1 212 226 }}} 213 227 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 }}} 215 230 216 231 … … 225 240 Put the expressions (suitably cobra converted) into the string inside [] 226 241 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 }}} 247 becomes 248 {{{ 249 #!cobra 250 "Value [item.value] selected item:[item.selected]" 251 }}} 228 252 229 253 if you have [ and ] symbols, these should be doubled … … 234 258 235 259 20. 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]] 238 261 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) ''''.'''' 241 263 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''' lowercased264 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]] 245 267 so 246 268 {{{ 269 #!cs 247 270 EVENT += new Listener(MethodName) in C# becomes 248 271 listen .EVENT, Listener( ref .methodName ) 249 272 }}} 273 becomes 274 {{{ 275 #!cobra 250 276 EVENT += new Listener( EH_METHOD_NAME ) in C# becomes 251 listen .EVENT, 277 listen .EVENT, Listener( ref .eh_METHOD_NAME ) 252 278 }}} 253 279 e.g. 254 280 {{{ 281 #!cs 255 282 FileChange += new Listener( OnFileChange ) 256 -> 283 }}} 284 turns into 285 {{{ 286 #!cobra 257 287 listen .fileChange, Listener(ref .onFileChange) 258 288 }}} 259 289 260 290 … … 275 305 276 306 22. 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.