1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Automatic code generation for Objective C to C++ bridge

Discussion in 'Mac Programming' started by aks86, Apr 1, 2009.

  1. macrumors newbie

    #1
    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!
     
  2. macrumors 6502a

    #2
    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
     
  3. macrumors 68040

    lee1210

    #3
    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
     
  4. macrumors newbie

    #4
    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.
     
  5. macrumors 6502a

    #5
    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
     
  6. macrumors newbie

    #6
    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...
     

Share This Page