Wrapping a C Library: Allocation and duplication issues

Discussion in 'Ruby' started by jbonnar@gmail.com, Sep 11, 2006.

  1. Guest

    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/
    , Sep 11, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grzegorz Stasica
    Replies:
    2
    Views:
    332
    Tobias Schierge
    Feb 12, 2004
  2. Ken
    Replies:
    24
    Views:
    3,832
    Ben Bacarisse
    Nov 30, 2006
  3. chris
    Replies:
    6
    Views:
    971
    chris
    Oct 28, 2005
  4. Bjarke Hammersholt Roune
    Replies:
    14
    Views:
    1,167
    Bjarke Hammersholt Roune
    Mar 6, 2011
  5. Justin Bonnar
    Replies:
    7
    Views:
    113
    Lyle Johnson
    Sep 13, 2006
Loading...

Share This Page