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:

Meta-model based translation

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".

Transformations

There are a lot of concepts that map one to one between the two languages. Others are different. Therefore the used-meta model is a unification of the Objective-C and C# meta model. I use meta-model transformations to move concepts only found in the Objective-C meta-model to the C# meta-model.

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; ... }

Single source approach

Porting large applications to new programming languages and frameworks takes time. It is undesirable to stop the maintenance of the "legacy" system while doing the port. Therefore my compiler supports a "single source" approach. The compiler generates error messages for unportable code. By adding directives or by altering the Objective-C code, you can "c-sharpify" your old software and alter or extend it at the same time.

Model Driven Architecture

The design and implementation of my compiler uses the meta-model and transformation based MDA framework from LIANTIS. Instead of using the UML/XMI plugin to load the model data, I use an Objective-C grammar to create the meta-model instance. After the transformations, a simple "commit" call to the framework dumps all created C# code to the file-system. Needless to say that the compiler is itself 100% UML modelled and generated.

Substitution of framework classes

But simple language translation is not enough: Openstep code uses the Foundation and AppKit framework for container classes, serialisation, user interfaces etc. For example NSString and NSMutableString are the Openstep UNICODE character sequence abstractions. .NET has similar abstractions: "string" and "StringBuilder". To get a real .NET application, all uses of Foundation classes are replaced by their .NET counterparts.

Contact me

If you are interested in porting Openstep applications using my technology, don't hesitate to contact me.