How To Call D Code from Objective C?

Mike McKee via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 10 22:01:36 PST 2015


Is there a way to call D code from Objective C on OSX?

Here's something cool I was thinking about doing:

* I've learned how to make Cocoa UI Objective C apps on OSX.

* I've learned how to load the native OSX webkit widget in a 
Cocoa app. It provides a rich user interface using ordinary HTML, 
CSS, and Javascript/jQuery. It's much better than anything Qt has 
with its widgets or QML. It's much better than anything Apple 
allows with its other Aqua Cocoa widgets. I can make any kind of 
widget you can think of, colored and styled anyway I want, using 
webkit.

* I've learned how to enable a bridge between Javascript to 
Objective C. This lets me make an Objective C function that 
Javascript can call. So, if I need my webkit app to do something 
powerful like show a file chooser dialog, I can call an object 
called "objc" and so something like:

var sFilePath = objc.chooseFile();

* Now all I want to do is to bridge Objective C to D. That way, 
my webkit pages can call Objective C, which can then call D. I 
can put much of the heavy lifting work in D for my app. If I need 
to call an Apple Foundation Class library, I can have D call back 
to Objective C just for that special thing.



More information about the Digitalmars-d mailing list