Openstep/Objective-C to .NET/C# Migration |
This project is no longer supported - sorry!
I have developed a unique complier that translates Objective-C/Openstep applications to C#/.NET. Here's how it works:
The complier reads Objective-C implementation files, headers and C files into an internal meta-model. For every little statement like "i++", two objects a created: one of class "IncrementStatement" and one of class "LocalVariableLiteral", referencing the declaration of the local variable "i". The source is parsed without a prior run of the C pre-processor, leaving all #DEFINE directives unaltered in the final C# dump.
The approach I have chosen is much more powerful than a sophisticated "find and replace" tool like "tops", the thing I used to port Nextstep to Openstep applications long time ago. Because the full meta-model instance of the source is build, very sophisticated transformations become possible. Let's say "inst" is an instance variable of some class. An operation implementation might contain the following code fragment:
if(inst) ...
If inst is an object type, my compiler produces the following C# code:
if(inst == null) ...
If inst is of type "BOOL", the If statement is unaltered, only the type of the instance variable is changed to the C# type "bool".
Simple transformations like name changes (for example "takeValue:from:" into "TakeValue") are also done by transformations.
If extra information is required for a particular transformation, special directives are added to the Objective-C code. These directives always start with the characters "//" so they are ignored by the Objective-C compiler. For example you can tell the compiler to add the following define directive as a public (h file) or private (m file) constant static member to some class "Foo":
#DEFINE PI 3.14
becomes
public class Foo { public static float PI = 3.14; ... }