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

Lämna en kommentar

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logga ut / Ändra )

Twitter-bild

You are commenting using your Twitter account. Logga ut / Ändra )

Facebook-foto

You are commenting using your Facebook account. Logga ut / Ändra )

Ansluter till %s

Follow

Get every new post delivered to your Inbox.