Automatic code generation for Objective-C bridge in C ++

I am looking for an opinion from Mac / iPhone developers about a new project. The idea is to run an open source initiative using swig (www.swig.org) to automatically create a bridge from object c to C ++ so that you can access C ++ applications from cocoa / cocoa touch.

Apple provides very good support for mixing object c and C ++ using object C ++, but manually writing these bridges can be tedious and error prone. The goal of this project is to provide a way to automatically create object c-interfaces and wrappers on top of C ++ so that any cocoa or cocoa application-application will detect an object-oriented object c-interface with C ++ under it.

I would really appreciate any opinion or suggestions on this idea.

+5
source share
2 answers

I do not think this is necessary. With Objective-C ++, you don't need a bridge at all. Given a specific C ++ class

class Foo {
  public:
    void someMethod(void);
}

you can use this class anywhere in Objective-C ++ code. For example, as part of a method:

- (void)myObjCMethod {
  Foo myFoo;

  myFoo.someMethod();

  //etc.
}

You can have instance variables that point to C ++ classes, so you can define an Objective-C class, for example

@interface Bar : NSObject {
  Foo *foo;
}

@property (assign) Foo * foo;
@end

@implementation
@synthesize foo;

- (void)dalloc {
  delete foo;
  [super dealloc];
}

- (id)init {
  if(self = [super init]) {
    foo = new Foo();
  }

  return self;
}

- (void)aMethod {
   self.foo->barMethod();
} 

I don't think you can create an Objective-C template, but instances of C ++ templates in Objective-C ++ are fair game. Just as Objective-C is a strict superset of C, Objective-C ++ is a superset of C ++ that adds Objective-C classes and message passing.

"" ++, , , , Objective-C.

+4

, , - . , ++ (, .mm), .

+1

All Articles