Wrapping a C Library: Allocation and duplication issues

J

jbonnar

I'm writing a wrapper for a C library [1] written in a very object
orientated style. Since C isn't an OO language, it uses conventions
instead. All of the "classes" are created with a librdf_new_classname
method which acts almost the same as Ruby's Class#new.

The problem I'm having is cleanly separating allocation from
initialization. Since most of the class construction functions require
arguments to initialize the object, I can't define separate alloc and
initialize functions.

The only option I see is to use Ruby 1.6 style code and define a
Klass.new method for my classes, but how should Klass#clone and
Klass#dup methods be written that take into account object freezing,
taint, etc?

Thanks,
Justin

[1] http://librdf.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,787
Messages
2,569,631
Members
45,338
Latest member
41Pearline46

Latest Threads

Top