<div class="gmail_quote">On 21 February 2012 23:06, 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">
On 2012-02-21 22:01, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 21 February 2012 22:35, Jacob Carlborg <<a href="mailto:doob@me.com" target="_blank">doob@me.com</a><div class="im"><br>
<mailto:<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>>> wrote:<br>
<br>
On 2012-02-21 20:45, Manu wrote:<br>
<br>
On 21 February 2012 20:12, Jacob Carlborg <<a href="mailto:doob@me.com" target="_blank">doob@me.com</a><br>
<mailto:<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> <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>
<<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>><br></div>
<mailto:<a href="mailto:michel.fortin@michelf." target="_blank">michel.fortin@michelf.</a><u></u>__com<div class="im"><br>
<mailto:<a href="mailto:michel.fortin@michelf.com" target="_blank">michel.fortin@michelf.<u></u>com</a>>><br>
<br>
I have some experience bridging Objective-C and D. I<br>
once<br>
built a<br>
complete wrapper system for Objective-C objects,<br>
each object was<br>
wrapped by a D one. It worked very well, but it<br>
generated so<br>
much<br>
bloat that it became unusable as soon as I started<br>
defining<br>
enough<br>
classes for it to be useful. See the D/Objective-C<br>
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><div class="h5"><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>
<<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>
<<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<br>
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<br>
throw a<br>
series of templates. This is for making it possible (less<br>
verbose)<br>
to create bindings.<br>
<br>
It might be possible to decrease the template bloat by<br>
having a tool<br>
that automatically generates the bindings and outputs what the<br>
templates do inline.<br>
<br>
<br>
Why aren't the templates inline themselves? Although if the<br>
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,<br>
what was<br>
involved? What did you have to do in addition to what a regular<br>
Obj-C<br>
function call would have done?<br>
<br>
<br>
Michel Fortin explained this better in two of his answers. You can<br>
also read the documentation of my implementation, very similar to<br>
Michel's:<br>
<br></div></div>
<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><div class="im"><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<br>
method. Basically each time "invokeObjcSelf" is called a new<br>
instantiation of the template is created and that is put in the<br>
symbol table. "invokeObjcSelf" then calls several more template<br>
functions making the template bloat increase exponentially.<br>
<br>
<br></div><div class="im">
But they should all be inlined, and the symbol table should be stripped,<br>
which shouldn't leave anything in the end other than the inlined<br>
function calling code, and in my examples, this will be basically the<br>
exact same code that you'd have to write anyway to call through some<br>
vm's API...<br>
</div></blockquote>
<br>
Well, that's not what happen with templates.</blockquote><div><br></div><div>... really? why?</div><div>You've just made me very very scared for my simd module :/</div><div><br></div><div>I've had a serious concern about D's lack of a force-inline for quite a while...</div>
</div>