Objective-C to Python converter

2009-10-13

I’ve been doing a lot of PyObjC lately and I’m always annoyed at having to convert small snippets from Objective-C to Python. After some time I decided enough was enough so I spent some time coding it up finally. I present to you the Objective-C to Python converter! It will only convert the new style for loops and it has some other limitations, so you have to look over it to see that it’s correct, but it’s WAY smoother than doing it all manually. If you give it your entire .m file it will be pretty close to complete. Try this example code:

// create a new instance
Fraction *frac = [[Fraction alloc] init];
if (foo){ // set the values
[frac setNumerator: 1];  [frac setDenominator: 3];
}
else {
    // print it
    printf( "The fraction is: " );
    [frac print];
    printf( "\n" );
}
// free memory
[frac release];

return 0;

The source code is public domain.

– Möller

Advertisements

Kommentera

Fyll i dina uppgifter nedan eller klicka på en ikon för att logga in:

WordPress.com Logo

Du kommenterar med ditt WordPress.com-konto. Logga ut / Ändra )

Twitter-bild

Du kommenterar med ditt Twitter-konto. Logga ut / Ändra )

Facebook-foto

Du kommenterar med ditt Facebook-konto. Logga ut / Ändra )

Google+ photo

Du kommenterar med ditt Google+-konto. Logga ut / Ändra )

Ansluter till %s

%d bloggare gillar detta: