lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <>
Subject [lucy-dev] Ruby CFBind glue code
Date Mon, 09 Jan 2012 21:12:14 GMT

Now that Logan has gotten the Ruby bindings for CFC fleshed out well enough to
generate all Lucy core code, our next task is to write routines that convert
between Clownfish types and Ruby types.

For instance, here's a function which translates between a CharBuf and a Ruby

    #include "ruby.h"
    #include "ruby/encoding.h"
    // ...

    static rb_encoding *utf8_encoding = (rb_encoding*)-1;

    CFBind_cb_to_str(const cfish_CharBuf *charbuf) {
        if (!charbuf) {
            return Qnil;
        else {
            if (utf8_encoding == (rb_encoding*)-1) {
                utf8_encoding = rb_utf8_encoding();
            const char *ptr = (const char*)Cfish_CB_Get_Ptr8(charbuf);
            long size = (long)Cfish_CB_Get_Size(charbuf);
            return rb_enc_str_new(ptr, size, utf8_encoding);

In Lucy's Perl bindings, these routines live in trunk/perl/xs/XSBind.*.
Eventually, this content should move under clownfish/, but for now, I think it
makes sense for the Ruby files to live at trunk/ruby/src/CFBind.*.

To get started, we should perform the following "svn copy" command:

    svn copy \

More explanatory notes are available in trunk/example-lang/README.

I've opened LUCY-207 to track progress on this task.

Marvin Humphrey

View raw message