I am writing a library that uses NativeCall
, it would be very convenient for me to be able to return a Raku Hash
from an exported function. How can I do this?
For example, in Ruby, if I wanted to return a Hash
from C, I would do something like:
#include "ruby.h"
VALUE make_hash() {
VALUE hash = rb_hash_new();
return hash;
}
I am interested to see if this can be done, I was thinking that maybe I would need to use a MoarVM header or something. But I'm not sure.
What I'm trying to do is write a C function that takes in a String does some stuff, then returns a Raku hash.
I have done roughly this for Rust over here (this is a collection of some Raku-Rust Nativecall code examples, not a module)...
First the raku:
Then the Rust:
Obviously the C side of affairs will need to be quite different, but hopefully this gives enough clues.