Reputation: 2979
I need to synthesize, at runtime, classes as a proxy to underlying C++ classes. I already know how to gather the methods and synthesize, via template magic, C++ free functions to turn around and call the corresponding object. However, I need to know that the prototype of the implementation for methods with references should be.
Here is a concrete example:
If I have a C++ method like this:
void set ( string const& string , shared_ptr<Object> const& pObject ) ;
A literal translation into Objective-C++ (note: this wouldn't use a literal translation, but there are others that would) would be:
- (void) setObject:(shared_ptr<Object> const&)object forKey:(std::string const&)key ;
The literal C IMP would be:
void MyFakeProxyClass_setObjectForKey ( MyFakeProxyClass* self , SEL cmd , shared_ptr<Object> const& object , string const& key ) ;
But knowing how Objective-C uses variargs for message passing, this function can't be taking a reference as an argument.
So does Objective-C++ convert references into pointers? Or what?
Any insight would be greatly appreciated!
Upvotes: 1
Views: 123
Reputation: 8012
Objective-C does not use varargs for messages. The implementation of an Objective-C method that takes a reference parameter is the same as a C++ function that takes a reference parameter.
Upvotes: 2