Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#127 Implementation of SWIG_RubyInstanceFor and updated docs

closed
cfis
None
5
2005-09-24
2005-08-25
cfis
No

This patch implements the infamous
SWIG_RubyInstanceFor() described at the end of the Ruby
documentation. For details on how it works see
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/152816

The quick summary:

* Add support for SWIG to automatically track the
mappings between Ruby objects and C++ objects. This is
needed to implement "mark" functions for Ruby's garbage
collector.

* Implements the SWIG_RubyInstanceFor described in the
documentation.

* The mappings are stored using Ruby's built in C hash
tables (note the Perl module also uses a hash table to
track mappings from Perl objects to C++ objects.

* Tracking mappings introduces a slight performance hit
of 2 or 3 percent (see link above).

* By default this feature is *off*. To enable it you
must compile your Ruby SWIG bindings by define the
preprocessor item SWIG_RUBY_OBJECT_TRACKING.

* Enforces the rule that only one Ruby object wraps the
same C++ object. currently, multiple Ruby objects can
wrap the same C++ object

* Provides updated documentation.

Attached files:

* patches for ruby.cxx, ruby.swg, rubydef.swg
* new file called rubytracking.swg (goes into lib/ruby
directory)
* updated documenation - this should replace section
27.9.4 (assuming patch 1272995 has been applied first).

Discussion

  • cfis
    cfis
    2005-09-20

    Changes to ruby.cxx, ruby.swg, rubydef.swg and rubyhead.swg that enable object tracking

     
    Attachments
  • cfis
    cfis
    2005-09-20

    New file that contains the tracking api and implemenation. This should go in Lib/ruby

     
    Attachments
  • cfis
    cfis
    2005-09-20

    Zip file containing four new examples testing the new functionality. Should go under Example/ruby. Source files are in unix format.

     
    Attachments
  • cfis
    cfis
    2005-09-20

    Updated HTML Documentation

     
    Attachments
  • cfis
    cfis
    2005-09-20

    Logged In: YES
    user_id=1323508

    After a fair bit of struggling, I have to admit defeat again
    on patching ruby.html. For whatever reason, I cannot
    generate a diff file that patch can then apply (it always
    ends up as a malformed patch on the last line changed).

    So I've attached the whole file again. This time though the
    file is in unix format, and I have run make (on Linux) in
    the Manual directory to make sure it works as expected. It
    does.

    What's changed in the file - updated a few entries in the
    table of contents and replaced the whole memory management
    section.

    I'd be more than happy to keep hacking at this to get a
    patch...but I think I need a few pointers first on how other
    people do it.

     
  • cfis
    cfis
    2005-09-24

    • assigned_to: nobody --> cfis
    • status: open --> closed
     
  • cfis
    cfis
    2005-09-24

    Logged In: YES
    user_id=1323508

    This functionality has now bee checked in and will be in
    SWIG 1.3.26 release.