digitalmars.D - Is there any prior art of calling D functions in Perl?
- Christian Walde (5/5) Nov 04 2013 Perl has a method to call functions from C code or libraries
- Chris (2/7) Nov 04 2013 http://dlang.org/interfaceToC.html
- John Colvin (6/11) Nov 04 2013 to get the ABI right, just use extern(C) on the relevant D
- Christian Walde (4/9) Nov 05 2013 Yeah, that was what i suspected, but hoped to avoid by reusing
- Iain Buclaw (7/17) Nov 05 2013 I made a small start some time ago for a proof of concept package (in a
Perl has a method to call functions from C code or libraries directly in Perl code, called XS. This works via a macro language that wraps around C and DTRT. Has anyone done something like this with D in Perl before? Failing that, is there prior art of calling D code from C?
Nov 04 2013
On Monday, 4 November 2013 at 18:10:58 UTC, Christian Walde wrote:Perl has a method to call functions from C code or libraries directly in Perl code, called XS. This works via a macro language that wraps around C and DTRT. Has anyone done something like this with D in Perl before? Failing that, is there prior art of calling D code from C?http://dlang.org/interfaceToC.html
Nov 04 2013
On Monday, 4 November 2013 at 18:10:58 UTC, Christian Walde wrote:Perl has a method to call functions from C code or libraries directly in Perl code, called XS. This works via a macro language that wraps around C and DTRT. Has anyone done something like this with D in Perl before? Failing that, is there prior art of calling D code from C?to get the ABI right, just use extern(C) on the relevant D functions. however, if the perl interface needs to write wrapper functions based on C headers you will have to write a C header containing the relevant function declarations.
Nov 04 2013
to get the ABI right, just use extern(C) on the relevant D functions.Wow, ok, that was well hidden. I'd strongly suggest that block in http://dlang.org/interfaceToC.html get its own heading.however, if the perl interface needs to write wrapper functions based on C headers you will have to write a C header containing the relevant function declarations.Yeah, that was what i suspected, but hoped to avoid by reusing someone else's efforts. :)
Nov 05 2013
On 5 November 2013 14:41, Christian Walde <walde.christian gmail.com> wrote:to get the ABI right, just use extern(C) on the relevant D functions.I made a small start some time ago for a proof of concept package (in a little over 150 lines of code). http://iainbuclaw.wordpress.com/2010/06/22/d-perlembed -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';Wow, ok, that was well hidden. I'd strongly suggest that block in http://dlang.org/interfaceToC.html get its own heading. however, if the perl interface needs to write wrapper functions based onC headers you will have to write a C header containing the relevant function declarations.Yeah, that was what i suspected, but hoped to avoid by reusing someone else's efforts. :)
Nov 05 2013