PDA

View Full Version : Automatic code generation for Objective C to C++ bridge




aks86
Apr 1, 2009, 10:19 PM
Greetings!

I am seeking an opinion from the experienced mac developers here about a new project. The idea is to start an open source initiative using swig (www.swig.org) for automatically generating the bridge from objective c to c++ so that one can access c++ applications from cocoa.

Apple provides a very good support for mixing objective c and c++ via objective c++ but writing those bridges by hand could be tedious and bug prone. What this project intend to do is to provide a way of automaically generating objective c interfaces and wrappers over c++ so that any cocoa or cocoa touch application happens to see the obeject oriented objective c interface with c++ underneath.

I would greatly appreciate any opinion or suggestions over this idea.

Thanks!



lazydog
Apr 2, 2009, 07:59 AM
Hi aks86

Maybe I'm being a bit slow today but I'm not sure I understand exactly what you want to do. I can understand wanting to bridge C++ to Cocoa but I can't see what needs bridging the other way, ie Objective-C to C++.

b e n

lee1210
Apr 2, 2009, 08:04 AM
The way i interpreted it, and this could be way off, the OP wants something that can be fed C++ classes and have an Objective-C class generated for it, perhaps with the original class as an ivar, or perhaps with each method reimplemented in Obj-C methods, etc. I don't feel like I need this, but i guess the gain would be "consistent" method invocation via message passing rather than a mix of dotted or -> method calls and messages passes.

-Lee

aks86
Apr 2, 2009, 11:00 AM
I don't feel like I need this, but i guess the gain would be "consistent" method invocation via message passing rather than a mix of dotted or -> method calls and messages passes.

-Lee

Thanks Lee! Infact, that is where my motivation comes from. Given that we do not yet have good objective c solutions, for example,for CORBA and SOAP, and we do have it for C++, it might make sense to wrap c++ libraries to get pure objective c interfaces which can be used from inside cocoa/cocoa touch.

lazydog
Apr 2, 2009, 11:20 AM
Ah right.
I haven't looked at swig but I think there might be a problem. In C++ you don't need to declare the names of method parameters in class declarations, yet you would need these to auto-generate the method signatures for the Objective-C class wrappers.

b e n

aks86
Apr 3, 2009, 06:33 PM
yah! you are right... its one of the problem that needs to be tackled..and seemingly the only way to tackle is to have appropriate parameter names for arguments, else we can choose to generate arbitrary (but nice looking) method names ourselves...