Thread overview
Has anybody tried calling D from Ruby?
Apr 13, 2014
Atila Neves
Apr 13, 2014
Jacob Carlborg
Apr 14, 2014
Atila Neves
Apr 14, 2014
Jacob Carlborg
April 13, 2014
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
April 13, 2014
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
April 14, 2014
> 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

April 14, 2014
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