문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top