From a7515a725e22e7375d10c90727fba860fb56757b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2013 23:18:50 +0100 Subject: [PATCH] Remove use of monospace in Ruby docs and unncessary usage of
--- Doc/Manual/Ruby.html | 737 +++++++++++++++++++++---------------------- 1 file changed, 359 insertions(+), 378 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index d1dcbfab0..1798d1df7 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -166,7 +166,7 @@ of Ruby.

option:

-
$ swig -ruby example.i
+
$ swig -ruby example.i
 
@@ -174,7 +174,7 @@ option:

option:

-
$ swig -c++ -ruby example.i
+
$ swig -c++ -ruby example.i
 
@@ -200,7 +200,7 @@ location is typical. If you are not entirely sure where Ruby is installed, you can run Ruby to find out. For example:

-
$ ruby -e 'puts $:.join("\n")'
+
$ ruby -e 'puts $:.join("\n")'
 /usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
 /usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
 
@@ -226,7 +226,10 @@ looks like the following:

  • Type the following to build the extension:

    -
    $ ruby extconf.rb
    $ make
    $ make install +
    +$ ruby extconf.rb
    +$ make
    +$ make install
         
  • @@ -254,10 +257,10 @@ called example.c, a typical sequence of commands for the Linux operating system would look something like this:

    -
    $ swig -ruby example.i
    -$ gcc -c example.c
    -$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux 
    -$ gcc -shared example.o example_wrap.o -o example.so
    +
    $ swig -ruby example.i
    +$ gcc -c example.c
    +$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
    +$ gcc -shared example.o example_wrap.o -o example.so
     
    @@ -291,7 +294,7 @@ name for your extension. So for example, a SWIG interface file that begins with:

    -
    %module example
    +
    %module example

    will result in an extension module using the feature name @@ -319,7 +322,11 @@ finally rebuilding Ruby.

    using the C++ compiler. For example:

    -
    $ swig -c++ -ruby example.i
    $ g++ -c example.cxx
    $ g++ -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
    $ g++ -shared example.o example_wrap.o -o example.so +
    +$ swig -c++ -ruby example.i
    +$ g++ -c example.cxx
    +$ g++ -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
    +$ g++ -shared example.o example_wrap.o -o example.so
     
    @@ -349,7 +356,10 @@ script) will work with Windows as well; you should be able to build your code into a DLL by typing:

    -
    C:\swigtest> ruby extconf.rb
    C:\swigtest> nmake
    C:\swigtest> nmake install +
    +C:\swigtest> ruby extconf.rb
    +C:\swigtest> nmake
    +C:\swigtest> nmake install
     
    @@ -414,7 +424,10 @@ example if you have this ruby file run.rb:

    directory, then run the Ruby script from the DOS/Command prompt:

    -
    C:\swigtest> ruby run.rb
    Foo = 3.0
    +
    +C:\swigtest> ruby run.rb
    +Foo = 3.0
    +

    36.3 The Ruby-to-C/C++ Mapping

    @@ -443,33 +456,34 @@ quotes, e.g.

    An alternate method of specifying a nested module name is to -use the -prefix +use the -prefix option on the SWIG command line. The prefix that you specify with this -option will be prepended to the module name specified with the %module +option will be prepended to the module name specified with the %module directive in your SWIG interface file. So for example, this declaration -at the top of your SWIG interface file:
    - +at the top of your SWIG interface file:

    %module "foo::bar::spam"
    -

    will result in a nested module name of Foo::Bar::Spam, +

    will result in a nested module name of Foo::Bar::Spam, but you can achieve the same -effect by specifying:
    +effect by specifying:

    %module spam
    -

    and then running SWIG with the -prefix command -line option:
    +

    and then running SWIG with the -prefix command +line option:

    -
    $ swig -ruby -prefix "foo::bar::" example.i
    +
    +$ swig -ruby -prefix "foo::bar::" example.i
    +

    Starting with SWIG 1.3.20, you can also choose to wrap @@ -477,7 +491,9 @@ everything into the global module by specifying the -globalmodule option on the SWIG command line, i.e.

    -
    $ swig -ruby -globalmodule example.i
    +
    +$ swig -ruby -globalmodule example.i
    +

    Note that this does not relieve you of the requirement of @@ -721,7 +737,7 @@ utility methods work normally:

    Furthermore, if you have a function like this:

    -
    void spam(Parent *f);
    +
    void spam(Parent *f);

    then the function spam() accepts Parent* @@ -758,7 +774,9 @@ an optional feature that you can activate with the -minherit command-line option:

    -
    $ swig -c++ -ruby -minherit example.i
    +
    +$ swig -c++ -ruby -minherit example.i
    +

    Using our previous example, if your SWIG interface file @@ -1004,45 +1022,37 @@ do that, you need to define a container that contains a swig::GC_VALUE, like:

    -
    %module -nativevector
    -
    +
    +%module nativevector
     
    -%{
    -std::vector< swig::GC_VALUE > NativeVector;
    -%}
    -
    +%{ +std::vector< swig::GC_VALUE > NativeVector; +%} -%template(NativeVector) std::vector< swig::GC_VALUE >;
    +%template(NativeVector) std::vector< swig::GC_VALUE >; +
    -
    -

    This vector can then contain any Ruby object, making them almost identical to Ruby's own Array class.

    -
    require 'nativevector'
    +
    +
    require 'nativevector'
    +include NativeVector
     
    -include NativeVector
    +v = NativeVector.new +v << 1 +v << [1,2] +v << 'hello' -
    +class A; end -v = NativeVector.new
    -v << 1
    -v << -[1,2]
    -v << -'hello'
    -
    -class A; end
    -
    -v << -A.new
    -
    -puts v
    -=> -[1, [1,2], 'hello', #<A:0x245325>]
    -
    +v << A.new + +puts v +=> [1, [1,2], 'hello', #<A:0x245325>] + +

    Obviously, there is a lot more to template wrapping than shown in these examples. More details can be found in the SWIG and C++ @@ -1053,7 +1063,7 @@ chapter.

    Some containers in the STL allow you to modify their default behavior by using so called functors or function objects. - Functors are often just a very simple struct with operator() + Functors are often just a very simple struct with operator() redefined or an actual C/C++ function.  This allows you, for example, to always keep the sort order of a STL container to your liking.

    @@ -1062,58 +1072,51 @@ liking.

    that support functors using Ruby procs or methods, instead.  Currently, -this includes std::set, -set::map, -std::multiset -and std::multimap.

    +this includes std::set, +set::map, +std::multiset +and std::multimap.

    -

    The functors in swig are called swig::UnaryFunction -and swig::BinaryFunction.
    +

    The functors in swig are called swig::UnaryFunction +and swig::BinaryFunction. -For C++ predicates (ie. functors that must return bool as a result) swig::UnaryPredicate -and swig::BinaryPredicate +For C++ predicates (ie. functors that must return bool as a result) swig::UnaryPredicate +and swig::BinaryPredicate are provided.

    As an example, if given this swig file:

    -
    %module -intset;
    -
    -%include <std_set.i>
    -
    +
    +%module intset;
     
    -%typemap(IntSet)  std::set< int, swig::BinaryPredicate
    ->;
    +%include <std_set.i> + +%typemap(IntSet)  std::set< int, swig::BinaryPredicate >; +

    You can then use the set from Ruby with or without a proc object as a predicate:

    -
    require -'intset'
    +
    +require 'intset'
    +include Intset
     
    -include Intset
    -
    -# Default sorting behavior defined in C++
    -a = IntSet.new
    - -a << 1
    -a << 2
    -a << 3
    -a
    - -=> - [1,2,3]
    -
    +# Default sorting behavior defined in C++ +a = IntSet.new +a << 1 +a << 2 +a << 3 +a +=> [1,2,3] # Custom sorting behavior defined by a Ruby proc -
    b = IntSet.new( proc { -|a,b| a > b } )
    -b << 1
    -b << 2
    -b << 3
    -b
    -=> - [3,2,1]
    +b = IntSet.new( proc { |a,b| a > b } ) +b << 1 +b << 2 +b << 3 +b +=>  [3,2,1] +

    36.3.15 C++ STL Iterators

    @@ -1127,8 +1130,8 @@ values they point at, while the non-const iterators can both read and modify the values.

    The Ruby STL wrappings support both type of iterators by using -a proxy class in-between.  This proxy class is swig::Iterator or -swig::ConstIterator.  Derived from them are template +a proxy class in-between.  This proxy class is swig::Iterator or +swig::ConstIterator.  Derived from them are template classes that need to be initialized with the actual iterator for the container you are wrapping and often times with the beginning and ending points of the iteration range. 

    @@ -1136,86 +1139,68 @@ ending points of the iteration range. 

    The SWIG STL library already provides typemaps to all the standard containers to do this wrapping automatically for you, but if you have your own STL-like iterator, you will need to write your own -typemap for them.  For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

    +typemap for them.  For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

    These can be used either like:

    -
    make_const_iterator( iterator, rubyclass );
    +
    +make_const_iterator( iterator, rubyclass );
    +make_const_iterator( iterator, iterator_begin, iterator_end, rubyclass );
    +
    -make_const_iterator( iterator, iterator_begin, iterator_end, rubyclass );
    - -

    The iterators support a next() and previous() member function to -just change the iterator without returning anything.  previous() +

    The iterators support a next() and previous() member function to +just change the iterator without returning anything.  previous() should obviously only be used for bidirectional iterators.  You can also advance the iterator multiple steps by using standard math -operations like +=.

    +operations like +=.

    The -value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. -  For non-const iterators, a value=() function +value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. +  For non-const iterators, a value=() function is also provided which allows you to change the value pointed by the -iterator.  This is equivalent to the C++ construct of dereferencing and assignment, like *i = something. 

    +iterator.  This is equivalent to the C++ construct of dereferencing and assignment, like *i = something. 

    Thus, given say a vector class of doubles defined as:

    -
    %module doublevector
    +
    +
    +%module doublevector
     
    -
    +%include std_vector.i -%include std_vector.i

    - -
    - -%template(DoubleVector) std::vector<double>;
    +%template(DoubleVector) std::vector<double>; + +

    Its iterator can then be used from Ruby like:

    -
    require -'doublevector'
    +
    +
    +require 'doublevector'
    +include Doublevector
     
    -include Doublevector
    +v = DoubleVector.new +v << 1 +v << 2 +v << 3 -
    +# +# an elaborate and less efficient way of doing v.map! { |x| x+2 } +# +i = v.begin +e = v.end +while i != e +  val = i.value +  val += 2 +  i.value = val +  i.next +end +i +>> [3, 4, 5 ] +
    +
    -v = DoubleVector.new
    - -v << 1
    - -v << 2
    - -v << 3
    - -
    - -#
    - -# an elaborate and less efficient way of doing v.map! { |x| x+2 }
    - -#
    - -i = v.begin
    - -e = v.end
    - -while i != e
    - -  val = i.value
    - -  val += 2
    - -  i.value = val
    - -  i.next
    - -end
    - -i
    - ->> [3, 4, 5 ]
    - -
    - -

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    +

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    36.3.16 C++ Smart Pointers

    @@ -1321,7 +1306,7 @@ constant, class and method names to conform with the standard Ruby naming conventions. For example:

    -
    $ swig -ruby -autorename example.i
    +
    $ swig -ruby -autorename example.i
     
    @@ -1637,37 +1622,38 @@ construction:

    Then, in ruby, it can be used like:

    -
    Window.new(0,0,360,480) -{ |w|
    - -    w.color = Fltk::RED
    - -    w.border = false
    - -}
    +
    +Window.new(0,0,360,480) { |w|
    +    w.color = Fltk::RED
    +    w.border = false
    +}
    +
    +

    For other methods, you can usually use a dummy parameter with a special in typemap, like:

    -
    //
    +
    +//
    +// original function was:
    +//
    +// void func(int x);
     
    -// original function was:
    -//
    -// void func(int x);
    -
    -%typemap(in,numinputs=0) int RUBY_YIELD_SELF {
    -     if ( !rb_block_given_p() )
    +%typemap(in,numinputs=0) int RUBY_YIELD_SELF { +     if ( !rb_block_given_p() )             -rb_raise("No block given");
    -     return rb_yield(self);
    -}
    -
    -%extend {
    +rb_raise("No block given"); +     return rb_yield(self); +} + +%extend {         void func(int x, int -RUBY_YIELD_SELF );
    -}
    +RUBY_YIELD_SELF ); +} + +

    For more information on typemaps, see Typemaps.

    @@ -1685,118 +1671,118 @@ from SWIG error codes to Ruby exceptions:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
    +
    SWIG_MemoryError
    +
    rb_eNoMemError
    +
    SWIG_IOError
    +
    rb_eIOError
    +
    SWIG_RuntimeError
    +
    rb_eRuntimeError
    +
    SWIG_IndexError
    +
    rb_eIndexError
    +
    SWIG_TypeError
    +
    rb_eTypeError
    +
    SWIG_DivisionByZero
    +
    rb_eZeroDivError
    +
    SWIG_OverflowError
    +
    rb_eRangeError
    +
    SWIG_SyntaxError
    +
    rb_eSyntaxError
    +
    SWIG_ValueError
    +
    rb_eArgError
    +
    SWIG_SystemError
    +
    rb_eFatal
    +
    SWIG_AttributeError
    +
    rb_eRuntimeError
    +
    SWIG_NullReferenceError
    +
    rb_eNullReferenceError*
    +
    SWIG_ObjectPreviouslyDeletedError
    +
    rb_eObjectPreviouslyDeleted*
    +
    SWIG_UnknownError
    +
    rb_eRuntimeError
    * These error classes are created by SWIG and are not built-in Ruby exception classes
    @@ -1812,10 +1798,9 @@ Obj is a C++ instance of an exception class, type is a string specifying the type of exception (for example, "MyError") and desc is the SWIG description of the exception class. For example:

    -
    -%raise(SWIG_NewPointerObj(e, -SWIGTYPE_p_AssertionFailedException, -0), ":AssertionFailedException", SWIGTYPE_p_AssertionFailedException);
    +
    +%raise(SWIG_NewPointerObj(e, SWIGTYPE_p_AssertionFailedException, 0), ":AssertionFailedException", SWIGTYPE_p_AssertionFailedException);
    +

    This is useful when you want to pass the current exception object @@ -1849,7 +1834,7 @@ providing for a more natural integration between C++ code and Ruby code.

    foo = Foo.new
    begin
    foo.test()
    rescue CustomError => e
    puts "Caught custom error"
    end
    -

    For another example look at swig/Examples/ruby/exception_class.
    +

    For another example look at swig/Examples/ruby/exception_class.

    @@ -1876,8 +1861,11 @@ attached to a specific C datatype. The general form of this declaration is as follows ( parts enclosed in [...] are optional ):    

    -
    %typemap( method [, modifiers...] ) typelist -code;
    +
    +
    +%typemap( method [, modifiers...] ) typelist code;
    +
    +

    method is a simply a name that specifies what kind of typemap is being defined. It is usually a name like "in", @@ -1936,7 +1924,10 @@ following sample code:

    prints the result:

    -
    Received an integer : 6
    720
    +
    +Received an integer : 6
    +720
    +

    In this example, the typemap is applied to all occurrences of @@ -2122,33 +2113,33 @@ function arguments. For example: - - + - - + - - + - - + - - + - - + @@ -2205,33 +2196,33 @@ to a Ruby object.

    $input Input object + $input Input object holding value to be converted.
    $symname Name of + $symname Name of function/method being wrapped
    $1...n Argument being + $1...n Argument being sent to the function
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    - - + - - + - - + - - + - - + - - + @@ -2301,18 +2292,18 @@ example:

    $result Result object + $result Result object returned to target language.
    $symname Name of + $symname Name of function/method being wrapped
    $1...n Argument being + $1...n Argument being wrapped
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    - - + - - + - - + @@ -2441,38 +2432,38 @@ typemap.
    $result Result object + $result Result object returned to target language.
    $input The original + $input The original input object passed.
    $symname Name of + $symname Name of function/method being wrapped.
    - - + - - + - - + - - + - - + - - + - - + @@ -2488,15 +2479,11 @@ of the "out" typemap, making its rule often similar to the "in" typemap.

    -

    - -%typemap(directorout) int {

    - -   $result = NUM2INT($1);

    - -}
    - -
    +
    +%typemap(directorout) int {
    +   $result = NUM2INT($1);
    +
    +

    The following special variables are available:

    @@ -2504,35 +2491,35 @@ typemap.
    $result Result object + $result Result object returned to target language.
    $symname Name of + $symname Name of function/method being wrapped
    $1...n Argument being + $1...n Argument being wrapped
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    this C++ this, + this C++ this, referring to the class itself.
    - - + + - - + + - - + + - - + - - + - - + - - + @@ -2540,17 +2527,18 @@ referring to the class itself.

    Currently, the directorout nor the out typemap support the -option numoutputs, +option numoutputs, but the Ruby module provides that functionality through a %feature directive.  Thus, a function can be made to return "nothing" if you do:

    -
    %feature("numoutputs","0") -MyClass::function;
    +
    +%feature("numoutputs","0") MyClass::function;
    +

    This feature can be useful if a function returns a status code, which you want to discard but still use the typemap to raise an -exception.
    +exception.

    @@ -2560,12 +2548,12 @@ exception.

    Output argument processing in director member functions.

    -
    %typemap(directorargout, -fragment="output_helper") int {
    - -$result = output_helper( $result, NUM2INT($1) );

    - -}
    +
    +%typemap(directorargout,
    +fragment="output_helper") int {
    +  $result = output_helper( $result, NUM2INT($1) );
    +}
    +

    The following special variables are available:

    @@ -2573,39 +2561,39 @@ $result = output_helper( $result, NUM2INT($1) );
    $inputRuby object being sent to the function$inputRuby object being sent to the function
    $symname Name of function/method being wrapped$symname Name of function/method being wrapped
    $1...n Argument being sent to the function$1...n Argument being sent to the function
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    this C++ this, + this C++ this, referring to the class itself.
    - - + + - - + + - - + + - - + + - - + - - + - - + - - + @@ -2702,28 +2690,28 @@ across multiple languages.

    - - + + - - + + - - + + - - + + - - + @@ -2735,65 +2723,65 @@ SWIG_From_float(float)

    Here, while the Ruby versions return the value directly, the SWIG -versions do not, but return a status value to indicate success (SWIG_OK). While more akward to use, this allows you to write typemaps that report more helpful error messages, like:

    -

    -%typemap(in) size_t (int ok)
    - 
    -  ok = SWIG_AsVal_size_t($input, &$1);
    -  if (!SWIG_IsOK(ok)) {
    -    SWIG_exception_fail(SWIG_ArgError(ok), -Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -));
    -   }
    -
    -}
    -
      
    +versions do not, but return a status value to indicate success (SWIG_OK). While more akward to use, this allows you to write typemaps that report more helpful error messages, like:

    + +
    +
    +%typemap(in) size_t (int ok)
    +  ok = SWIG_AsVal_size_t($input, &$1);
    +  if (!SWIG_IsOK(ok)) {
    +    SWIG_exception_fail(SWIG_ArgError(ok), Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input));
    +  }
    +}
    +
    +
    +
    $resultResult that the director function returns$resultResult that the director function returns
    $inputRuby object being sent to the function$inputRuby object being sent to the function
    $symnamename of the function/method being wrapped$symnamename of the function/method being wrapped
    $1...nArgument being sent to the function$1...nArgument being sent to the function
    $1_nameName of the + $1_nameName of the argument (if provided)
    $1_typeThe actual C + $1_typeThe actual C datatype matched by the typemap
    $1_ltypeThe assignable + $1_ltypeThe assignable version of the C datatype matched by the typemap
    thisC++ this, + thisC++ this, referring to the instance of the class itself
    INT2NUM(long or int) SWIG_From_int(int x)INT2NUM(long or int) SWIG_From_int(int x) int to Fixnum or Bignum
    INT2FIX(long or int) INT2FIX(long or int) int to Fixnum (faster than INT2NUM)
    CHR2FIX(char) SWIG_From_char(char x)CHR2FIX(char) SWIG_From_char(char x) char to Fixnum
    rb_str_new2(char*) SWIG_FromCharPtrAndSize(char*, size_t)rb_str_new2(char*) SWIG_FromCharPtrAndSize(char*, size_t) char* to String
    rb_float_new(double) SWIG_From_double(double),
    +
    rb_float_new(double) SWIG_From_double(double),
    SWIG_From_float(float)
    float/double to Float
    - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + +
    int NUM2INT(Numeric)SWIG_AsVal_int(VALUE, int*)int NUM2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
    int FIX2INT(Numeric)SWIG_AsVal_int(VALUE, int*)int FIX2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
    unsigned int NUM2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)unsigned int NUM2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    unsigned int FIX2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)unsigned int FIX2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    long NUM2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)long NUM2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
    long FIX2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)long FIX2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
    unsigned long FIX2ULONG(Numeric)SWIG_AsVal_unsigned_SS_long(VALUE, unsigned long*)unsigned long FIX2ULONG(Numeric)SWIG_AsVal_unsigned_SS_long(VALUE, unsigned long*)
    char NUM2CHR(Numeric or String)SWIG_AsVal_char(VALUE, int*)char NUM2CHR(Numeric or String)SWIG_AsVal_char(VALUE, int*)
    char * StringValuePtr(String)SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc)char * StringValuePtr(String)SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc)
    char * rb_str2cstr(String, int*length)char * rb_str2cstr(String, int*length)
    double NUM2DBL(Numeric)(double) SWIG_AsVal_int(VALUE) or similardouble NUM2DBL(Numeric)(double) SWIG_AsVal_int(VALUE) or similar
    @@ -3250,16 +3238,17 @@ generated file. 

    For example, to generate html web pages from a C++ file, you'd do: 

    -
    -$ -rdoc -E cxx=c -f html file_wrap.cxx
    +
    +
    +$ rdoc -E cxx=c -f html file_wrap.cxx
    +

    To generate ri documentation from a c wrap file, you could do:

    -
    $ rdoc --r file_wrap.c -
    +
    +$ rdoc -r file_wrap.c
    +

    36.8.1 Module docstring

    @@ -3611,7 +3600,7 @@ that defines a derived class:

    extension module:

    -
    $ swig -c++ -ruby shape.i
    +
    $ swig -c++ -ruby shape.i
     
    @@ -3887,7 +3876,7 @@ class library models a zoo and the animals it contains.

    %module zoo

    %{
    #include <string>
    #include <vector>

    #include "zoo.h"
    %}

    class Animal
    {
    private:
    typedef std::vector<Animal*> AnimalsType;
    typedef AnimalsType::iterator IterType;
    protected:
    AnimalsType animals;
    protected:
    std::string name_;
    public:
    // Construct an animal with this name
    Animal(const char* name) : name_(name) {}

    // Return the animal's name
    const char* get_name() const { return name.c_str(); }
    };

    class Zoo
    {
    protected:
    std::vector<animal *=""> animals;

    public:
    // Construct an empty zoo
    Zoo() {}

    /* Create a new animal. */
    static Animal* Zoo::create_animal(const char* name)
    {
    return new Animal(name);
    }

    // Add a new animal to the zoo
    void add_animal(Animal* animal) {
    animals.push_back(animal);
    }

    Animal* remove_animal(size_t i) {
    Animal* result = this->animals[i];
    IterType iter = this->animals.begin();
    std::advance(iter, i);
    this->animals.erase(iter);

    return result;
    }

    // Return the number of animals in the zoo
    size_t get_num_animals() const {
    return animals.size();
    }

    // Return a pointer to the ith animal
    Animal* get_animal(size_t i) const {
    return animals[i];
    }
    };

    -

    Let's say you SWIG this code and then run IRB:
    +

    Let's say you SWIG this code and then run IRB:

    @@ -3968,8 +3957,7 @@ class-by-class basis if needed. To fix the example above:

    %module example

    %{
    #include "example.h"
    %}

    /* Tell SWIG that create_animal creates a new object */
    %newobject Zoo::create_animal;

    /* Tell SWIG to keep track of mappings between C/C++ structs/classes. */
    %trackobjects;

    %include "example.h"
    -

    When this code runs we see:
    - +

    When this code runs we see:

    @@ -4013,7 +4001,7 @@ has problems. For example:

    The problem is that Ruby does not know that the zoo object contains a reference to a Ruby object. Thus, when Ruby garbage -collects tiger1 +collects tiger1 it frees the underlying C++ object.

    This can be fixed by implementing a mark @@ -4086,8 +4074,8 @@ above.

    To show how to use the %freefunc directive, let's slightly change our example. Assume that the zoo object is responsible for freeing animal that it contains. This means -that the Zoo::add_animal -function should be marked with a DISOWN typemap +that the Zoo::add_animal +function should be marked with a DISOWN typemap and the destructor should be updated as below:

    @@ -4283,19 +4271,12 @@ collect any VALUE objects defined from that point on.  

    To mark functions to either reset the ruby stack or not, you can use:

    -
    %initstack -  Class::memberfunction;  // only re-init the stack -in this director method
    - -%ignorestack Class::memberfunction;  // do not re-init the -stack in this director method
    - -%initstack   Class;       -        // init the stack on all -the methods of this class
    - -%initstack;   // all director functions will -re-init the stack
    +
    +%initstack Class::memberfunction;   // only re-init the stack in this director method
    +%ignorestack Class::memberfunction; // do not re-init the stack in this director method
    +%initstack Class;                   // init the stack on all the methods of this class
    +%initstack;                         // all director functions will re-init the stack
    +