<div class="gmail_quote">On 21 February 2012 22:35, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com">doob@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 2012-02-21 20:45, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 21 February 2012 20:12, Jacob Carlborg <<a href="mailto:doob@me.com" target="_blank">doob@me.com</a><br></div><div class="im">
<mailto:<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>>> wrote:<br>
<br>
    On 2012-02-21 18:03, Manu wrote:<br>
<br>
        On 21 February 2012 16:59, Michel Fortin<br></div>
        <<a href="mailto:michel.fortin@michelf.com" target="_blank">michel.fortin@michelf.com</a> <mailto:<a href="mailto:michel.fortin@michelf.com" target="_blank">michel.fortin@michelf.<u></u>com</a>><div class="im">
<br>
            I have some experience bridging Objective-C and D. I once<br>
        built a<br>
            complete wrapper system for Objective-C objects, each object was<br>
            wrapped by a D one. It worked very well, but it generated so<br>
        much<br>
            bloat that it became unusable as soon as I started defining<br>
        enough<br>
            classes for it to be useful. See the D/Objective-C bridge:<br></div>
        <<a href="http://michelf.com/projects/____d-objc-bridge/" target="_blank">http://michelf.com/projects/_<u></u>___d-objc-bridge/</a><br>
        <<a href="http://michelf.com/projects/__d-objc-bridge/" target="_blank">http://michelf.com/projects/_<u></u>_d-objc-bridge/</a>><div class="im"><br>
        <<a href="http://michelf.com/projects/__d-objc-bridge/" target="_blank">http://michelf.com/projects/_<u></u>_d-objc-bridge/</a><br>
        <<a href="http://michelf.com/projects/d-objc-bridge/" target="_blank">http://michelf.com/projects/<u></u>d-objc-bridge/</a>>>>.<br>
<br>
<br>
        What was the primary cause of the bloat? I can't imagine my proposal<br>
        causing any more bloat than the explicit jni call (or<br>
        equivalent) woudl<br>
        have otherwise.<br>
<br>
<br>
    Template bloat. Every call bridging D/Objective-C is made throw a<br>
    series of templates. This is for making it possible (less verbose)<br>
    to create bindings.<br>
<br>
    It might be possible to decrease the template bloat by having a tool<br>
    that automatically generates the bindings and outputs what the<br>
    templates do inline.<br>
<br>
<br></div><div class="im">
Why aren't the templates inline themselves? Although if the templates do<br>
a lot of work, wouldn't that INCREASE the code volume?<br>
I can't really imagine how Obj-C linkage could bloat so much, what was<br>
involved? What did you have to do in addition to what a regular Obj-C<br>
function call would have done?<br>
</div></blockquote>
<br>
Michel Fortin explained this better in two of his answers. You can also read the documentation of my implementation, very similar to Michel's:<br>
<br>
<a href="http://www.dsource.org/projects/dstep/wiki/ObjcBridge/BridgeInternals" target="_blank">http://www.dsource.org/<u></u>projects/dstep/wiki/<u></u>ObjcBridge/BridgeInternals</a><br>
<br>
But to give a quick example:<br>
<br>
class Foo : NSObject<br>
{               <br>
    Foo foo ()<br>
    {<br>
        return invokeObjcSelf!(Foo, "foo");<br>
    }<br>
<br>
    Foo bar ()<br>
    {<br>
        return invokeObjcSelf!(Foo, "bar");<br>
    }<br>
}<br>
<br>
"invokeObjcSelf" is a template function that calls an Objective-C method. Basically each time "invokeObjcSelf" is called a new instantiation of the template is created and that is put in the symbol table. "invokeObjcSelf" then calls several more template functions making the template bloat increase exponentially.</blockquote>
<div><br></div><div>But they should all be inlined, and the symbol table should be stripped, which shouldn't leave anything in the end other than the inlined function calling code, and in my examples, this will be basically the exact same code that you'd have to write anyway to call through some vm's API...</div>
</div>