Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I didn't find anything satisfactory and came up with a prototype that, given the following informal protocol:</p> <pre><code>- (NSString*)concatString:(NSString*)s1 withString:(NSString*)s2; </code></pre> <p>and this C++ code:</p> <pre><code>struct CppClass { std::string concatStrings(const std::string&amp; s1, const std::string&amp; s2) const { return s1+s2; } }; std::string concatStrings(const std::string&amp; s1, const std::string&amp; s2) { return s1+s2; } </code></pre> <p>allows creating and passing a delegate:</p> <pre><code>CppClass cpp; og::ObjcClass objc("MyGlueClass"); objc.add_handler&lt;NSString* (NSString*, NSString*)&gt; ("concatString:withString:", &amp;cpp, &amp;CppClass::concatStrings); // or using a free function: objc.add_handler&lt;NSString* (NSString*, NSString*)&gt; ("concatString:withString:", &amp;concatStrings); [someInstance setDelegate:objc.get_instance()]; </code></pre> <p>which can then be used:</p> <pre><code>NSString* result = [delegate concatString:@"abc" withString:@"def"]; assert([result compare:@"abcdef"] == NSOrderedSame); </code></pre> <p><em>Boost.Function</em> objects can also be passed, which means <em>Boost.Bind</em> can easily be used as well.</p> <p>While the basic idea works, this is still a prototype. I did a short <a href="http://colonelpanic.net/2010/03/objectiveglue/" rel="nofollow noreferrer">blog post</a> on the subject and the prototype source is available <a href="http://bitbucket.org/cygmatic/cygmatic/src/tip/og/" rel="nofollow noreferrer">via bitbucket</a>. Constructive input and ideas welcome.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload