www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Has anybody tried calling D from Ruby?

reply "Atila Neves" <atila.neves gmail.com> writes:
The best I could manage was to use the C/C++ API and have that
call the linked in D code by hacking the automatically generated
Makefile. But at least that worked, up to a point. Even though I
linked in Phobos, it crashed when I called writeln (but
core.stdc.stdio.printf was ok).

Trying to use the C API directly from D didn't really work. I
tried dstep on ruby.h and it threw an exception. Ah, macros...

Atila
Apr 13 2014
next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2014-04-13 11:20, Atila Neves wrote:
 The best I could manage was to use the C/C++ API and have that
 call the linked in D code by hacking the automatically generated
 Makefile. But at least that worked, up to a point. Even though I
 linked in Phobos, it crashed when I called writeln (but
 core.stdc.stdio.printf was ok).

I have embedded Ruby in a D application. Called methods in both directions. I had no problem. Have a look at this mostly abandoned project [1]. The bindings where created from 1.9.1 (ABI version). Here [2] are the C bindings and here [3] are some wrappers.
 Trying to use the C API directly from D didn't really work. I
 tried dstep on ruby.h and it threw an exception. Ah, macros...

Please report an issue. It shouldn't be throwing an exception. [1] https://github.com/jacob-carlborg/orbit [2] https://github.com/jacob-carlborg/orbit/tree/master/ruby/c [3] https://github.com/jacob-carlborg/orbit/tree/master/ruby/core -- /Jacob Carlborg
Apr 13 2014
parent Jacob Carlborg <doob me.com> writes:
On 14/04/14 09:54, Atila Neves wrote:

 Interesting. How did you generate ruby.d and the other necessary
 interface files, by hand?

I think it was with DStep and some manual tweaks. Otherwise it was just manually. -- /Jacob Carlborg
Apr 14 2014
prev sibling parent "Atila Neves" <atila.neves gmail.com> writes:
 I have embedded Ruby in a D application. Called methods in both 
 directions. I had no problem. Have a look at this mostly 
 abandoned project [1]. The bindings where created from 1.9.1 
 (ABI version). Here [2] are the C bindings and here [3] are 
 some wrappers.

Interesting. How did you generate ruby.d and the other necessary interface files, by hand?
 Trying to use the C API directly from D didn't really work. I
 tried dstep on ruby.h and it threw an exception. Ah, macros...

Please report an issue. It shouldn't be throwing an exception.

I will. Atila
Apr 14 2014