Changes between Version 3 and Version 4 of WxWidgetsPort
- Timestamp:
- 10/29/09 12:47:07 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WxWidgetsPort
v3 v4 1 = Porting wxWidgets wx.NETC# source file to cobra =1 = Porting wxWidgets (wx.NET) C# source file to cobra = 2 2 3 3 The .NET wrapper library ([http://wxnet.sourceforge.net wx.NET]) for [http://www.wxwidgets.org wxWidgets] is an interesting case for cobra since it is one of the few .NET libraries that … … 5 5 Consequently there are some complications with persuading cobra to work with it conveniently. 6 6 7 see [wiki:C#Diffs Cobra differences fm C#] 8 9 Heres a process for C# generally with some notes re wx.NET generated from converting wx.NET sample file [wiki:ListViewCode ListView.cs to ListView.cobra] 7 see [wiki:C#Diffs Cobra differences from C#] 8 9 Heres a process for C# generally with some notes re wx.NET generated from converting wx.NET sample file ListView.cs.[[br]] 10 (See !ListView.cs and converted !ListView.cobra attachment files at end of this page.) 11 12 10 13 11 14 1 Take .cs file, rename to .cobra file. 12 15 13 16 14 2. Change multi line comments from multiple // or /* */ bounded to be /# #/ bounded.[[br]]17 2. Change multi-line comments from multiple // or /* */ bounded to be /# #/ bounded.[[br]] 15 18 Change single line comments to use leading '#' 16 19 … … 56 59 }}} 57 60 58 5. Namespace decl61 6. Namespace decl 59 62 Namespaces in cobra need to start with an upcased letter. 60 63 Remove any ''''wx.'''' prefix from namespace line ; … … 62 65 63 66 64 5a. Correct any Enum definitions. [[br]]67 7. Correct any Enum definitions. [[br]] 65 68 After applying the above its basically removing trailing ',' and ensuring indentation 66 69 of enum items is the same … … 94 97 95 98 96 6. Fix class declaration syntax99 8. Fix class declaration syntax 97 100 Change lines like ''''class X : Y'''' to ''''class X inherits Y'''' 98 101 99 102 100 7. Change any class instance attributes/fields to be prefixed with ''''var''''103 9. Change any class instance attributes/fields to be prefixed with ''''var'''' 101 104 change type and accessmodifier to cobra forms 102 105 {{{ … … 106 109 }}} 107 110 108 8. Fixup class constructor definitions111 10. Fixup class constructor definitions 109 112 For initializer/constructor change lines like 110 113 {{{ public ClassName(params,...) : base(baseParams,...) }}} … … 131 134 }}} 132 135 133 9. Remove any uses of ''''new'''' to construct a class instance,136 11. Remove any uses of ''''new'''' to construct a class instance, 134 137 instead just make a call to the class type passing any initializer args, i.e just remove 'new'[[br]] 135 138 e.g. … … 146 149 147 150 148 1 0. Methods:151 12. Methods: 149 152 Prefix methods with '''def'''.[[br]] 150 153 Change methodnames to start with a lowercase letter, [[br]] … … 178 181 }}} 179 182 180 1 1. Calls to methods, properties and attributes/fields.183 13. Calls to methods, properties and attributes/fields. 181 184 Instance method names, properties and fields are called with a prefix of ''''this.'''' or just ''''.'''' [[br]] 182 185 and they all must be named starting with a lowercase letter so these calls and settings[[br]] … … 197 200 If a method takes no args then any empty trailing () on a method call can/should be left off. 198 201 199 1 2. Property definition. Depending on the property use, prefix properties with :[[br]]202 14. Property definition. Depending on the property use, prefix properties with :[[br]] 200 203 * get - readable property only 201 204 * set - settable property only … … 205 208 206 209 207 1 3. Local variables declared and assigned on first use can usually be changed to remove210 15. Local variables declared and assigned on first use can usually be changed to remove 208 211 the type definition (type inferred from the assignment) or can continue to be explicitly typed 209 212 (if that compiles). … … 233 236 234 237 235 1 2. Fixup 'For' loops238 16. Fixup 'For' loops 236 239 {{{ 237 240 for ( <Type> name = start ; name < stop; ++name ) … … 250 253 251 254 252 1 3. Casting255 17. Casting 253 256 Casts of form '(Type)name' become 'name to Type' 254 257 e.g. … … 267 270 }}} 268 271 269 1 4. String catenated with an expression (converted to string)272 18. String catenated with an expression (converted to string) 270 273 Put the expression (cobra converted) in the string inside [] 271 274 e.g. … … 276 279 }}} 277 280 278 1 5. Adding eventHandlers281 19. Adding eventHandlers 279 282 Cobra uses the '''listen''' statement to register event handlers where C# uses an override on 280 283 the += operator. !WxWidgets wraps method calls in an !EventHandler delegate class instance.[[br]] … … 323 326 }}} 324 327 325 16. Main method328 20. Main method 326 329 'public void' is default, static is an accessmodifier which becomes ''''shared'''' in cobra, 327 330 C# attributes (!MetaInformation) are denoted with ''''has'''' … … 336 339 }}} 337 340 338 17. Lowercased namespace names (as in wx.NET) used to disambiguate or otherwise explicitly [[br]]341 21. Lowercased namespace names (as in wx.NET) used to disambiguate or otherwise explicitly [[br]] 339 342 specify the namespace on types (inherits ..., as ....) as opposed to methods or constants [[br]] 340 343 can (may/will) generate compile errors of the form: [[br]] … … 367 370 Eventually it would be preferable if cobra became a little more flexible in these cases.. 368 371 372 ----- 369 373 370 374 Other weirdnesses: