[redland-dev] ruby-rdf

Dominic.E.Sisneros at faa.gov Dominic.E.Sisneros at faa.gov
Tue Apr 6 17:26:33 BST 2004


Thanks Dan for your reply to my message.  One other thing that I would like
changed in the build for ruby is I would like to change
the module or packaging somewhat like the perls so that I don't conflict
with Dan Brinkleys or anyone elses version.

RDF::Redland::Core instead of Redland.  And my wrapper is going to be
RDF::Redland::Node or whatever like in the perl version.

I am not sure where in your configuration or Makefile this is determined.
Could you give my some help on this?

The change for the identifiers like char *inStrOrNull would work great.

Thanks,

Dominic

801-320-2377On Mon, 5 Apr 2004 21:44:26 -0600, dominic sisneros <dom at
sisna.com> wrote:

> Just writing to let you know, I am building a wrapper for redland in
> ruby.
>
> http://rubyforge.org/projects/ruby-rdf/

Great!

I tried to grab the '.gem' file but the ruby I had here couldn't do
anything with it - no optparse, no gem - so I checked out the CVS.

[I've copied this mail to Dan Brickley who has an interest in this
and made the original attempt at redland with ruby.]

The API seems nicely ruby-ified as far as my minimal ruby knowledge
goes.  I see you are turning the iterators and streams into proper
streaming arrays using 'yield'.

I'm not quite sure what you are doing with the ObjectSpace and
cleanup stuff, but I assume it is the right thing.  (you might try
using valgrind if you are running on linux to check for leaks)

> I did find a problem in the Redland.i file.  The function
> librdf_new_node_from_blank_identifier(librdf_world *world, const char
> *identifier);
> needs to either accept a nil or a char string.  Right now it gives an
> error if I give a
> nil value so I cannot do blank nodes without and identifier.  If you
> could add the following:
> to Redland.i, it works as required.
>
> %typemap(ruby,in) const char *identifier{
$1 = NULL;
>    }
>    else{
>        }
> }
> librdf_node* librdf_new_node_from_blank_identifier(librdf_world *world,
> const char *identifier);

Yeah, that seems to be needed since ruby does not have a null object,
but has a separate nil term.  This might affect some other classes.

I was looking at the Redland.i in your CVS and it's a little old compared
to what I have now.  Another thing I noticed was that maybe it
would be useful to add some defaults to other parameters.

So instead I'm thinking of something like this change to Redland.i:
----------------------------------------------------------------------
@@ -367,6 +367,11 @@
 #endif
 %}

+/* optional input strings - can be NULL, need special conversions */
+%typemap(ruby,in) const char *inStrOrNull {
+  $1 = ($input == Qnil) ? NULL : STR2CSTR($input);
+}
+

 typedef struct librdf_world_s librdf_world;
 typedef struct librdf_hash_s librdf_hash;
@@ -419,10 +424,10 @@
 librdf_node* librdf_new_node(librdf_world *world);
 librdf_node* librdf_new_node_from_uri_string(librdf_world *world, const
char *string);
 librdf_node* librdf_new_node_from_uri(librdf_world *world, librdf_uri
*uri);
-librdf_node* librdf_new_node_from_literal(librdf_world *world, const char
*string, const char *xml_language, int is_wf_xml);
-librdf_node* librdf_new_node_from_typed_literal(librdf_world *world, const
char *string, const char *xml_language, librdf_uri* datatype_uri);
+librdf_node* librdf_new_node_from_literal(librdf_world *world, const char
*string, const char *inStrOrNull=NULL, int is_wf_xml=0);
+librdf_node* librdf_new_node_from_typed_literal(librdf_world *world, const
char *string, const char *inStrOrNull=NULL, librdf_uri* datatype_uri=NULL);
 librdf_node* librdf_new_node_from_node(librdf_node *node);
-librdf_node* librdf_new_node_from_blank_identifier(librdf_world *world,
const char *identifier);
+librdf_node* librdf_new_node_from_blank_identifier(librdf_world *world,
const char *inStrOrNull=NULL);
 void librdf_free_node(librdf_node *r);
 librdf_uri* librdf_node_get_uri(librdf_node* node);
 int librdf_node_get_type(librdf_node* node);
----------------------------------------------------------------------

since it makes sense for optional things like literal languages and
datatype URIs to be defaulted.  The literal language also need the
nil check for ruby.

> Thanks in advance and thanks for the library

Thanks a lot.

Dave





More information about the redland-dev mailing list