diff --git a/SWIG/Doc/Manual/Ruby.html b/SWIG/Doc/Manual/Ruby.html index 7405b8216..331680632 100644 --- a/SWIG/Doc/Manual/Ruby.html +++ b/SWIG/Doc/Manual/Ruby.html @@ -67,7 +67,6 @@
@@ -1433,7 +1432,7 @@ following in an interface file: try { $action } - catch (RangeError) { + catch (const RangeError&) { static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError); rb_raise(cpperror, "Range error."); } @@ -1460,7 +1459,7 @@ exception handler to only apply to specific methods like this: try { $action } - catch (RangeError) { + catch (const RangeError&) { static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError); rb_raise(cpperror, "Range error in getitem."); } @@ -1470,7 +1469,7 @@ exception handler to only apply to specific methods like this: try { $action } - catch (RangeError) { + catch (const RangeError&) { static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError); rb_raise(cpperror, "Range error in setitem."); } @@ -1488,72 +1487,11 @@ exception handling. See the chapter on Customizati Features for more examples.-irb(main):001:0> b = Bar.new +irb(main):001:0> c = Child.new #<Bar:0x4016efd4> -irb(main):002:0> b.instance_of? Bar +irb(main):002:0> c.instance_of? Child true -irb(main):003:0> b.instance_of? Foo +irb(main):003:0> b.instance_of? Parent false -irb(main):004:0> b.is_a? Bar +irb(main):004:0> b.is_a? Child true -irb(main):005:0> b.is_a? Foo +irb(main):005:0> b.is_a? Parent true -irb(main):006:0> Bar < Foo +irb(main):006:0> Child < Parent true -irb(main):007:0> Bar > Foo +irb(main):007:0> Child > Parent false
-When raising a Ruby exception from C, use the rb_raise() +When raising a Ruby exception from C/C++, use the rb_raise() function as shown above. The first argument passed to rb_raise() is the exception type. You can raise a custom exception type (like the cpperror example -shown above) or one of the built-in Ruby exception types, listed here: - -
-- -These exceptions are actually organized into an hierarchy as shown below. - --rb_eException -rb_eStandardError -rb_eSystemExit -rb_eInterrupt -rb_eSignal -rb_eFatal -rb_eArgError -rb_eEOFError -rb_eIndexError -rb_eRangeError -rb_eIOError -rb_eRuntimeError -rb_eSecurityError -rb_eSystemCallError -rb_eTypeError -rb_eZeroDivError -rb_eNotImpError -rb_eNoMemError -rb_eNoMethodError -rb_eFloatDomainError - -rb_eScriptError -rb_eNameError -rb_eSyntaxError -rb_eLoadError - --
-+shown above) or one of the built-in Ruby exception types. For a list of the standard +Ruby exception classes, consult a Ruby reference such as Programming Ruby.-Exception - rb_eException -Fatal - rb_eFatal -Interrupt - rb_eInterrupt -NoMemoryError - rb_eNoMemError -Signal - rb_eSignal -ScriptError - rb_eScriptError - LoadError - rb_eLoadError - NameError - rb_eNameError - NotImpError - rb_eNotImpError - SyntaxError - rb_eSyntaxError - NoMethodError - rb_eNoMethodError -StandardError - rb_eStandardError - ArgError - rb_eArgError - FloatDomainError - rb_eFloatDomainError - IndexError - rb_eIndexError - IOError - rb_eIOError - EOFError - rb_eEOFError - SecurityError - rb_eSecurityError - RuntimeError - rb_eRuntimeError - SystemCallError - rb_eSystemCallError - TypeError - rb_eTypeError - ZeroDivError - rb_eZeroDivError - RangeError - rb_eRangeError -SystemExit --
+%module example
-%module Example
%typemap(in) int {
$1 = (int) NUM2INT($input);
printf("Received an integer : %d\n",$1);
}
+
extern int fact(int n);
@@ -1596,13 +1535,16 @@ code a number of special variables prefaced by a $ are used. The
$1 variable is placeholder for a local variable of type int.
The $input variable is the input Ruby object.
-When this example is compiled into a Ruby module, it operates as follows: +When this example is compiled into a Ruby module, the following sample code:
+prints the result: +require 'example' + puts Example.fact(6) ----- Prints +
@@ -1817,7 +1759,7 @@ The Ruby name of the wrapper function being created. When you write a typemap, you usually have to work directly with Ruby objects. The following functions may prove to be useful. (These functions plus many -more can be found in the "Programming Ruby" book written by David Thomas +more can be found in Programming Ruby, by David Thomas and Andrew Hunt.)Received an integer : 6 720
@@ -2411,13 +2353,10 @@ __ge__ - >= Note that although SWIG supports the __eq__ magic method name for defining an equivalence operator, there is no separate method for handling inequality since Ruby parses the expression a != b as !(a == b). -
@@ -2474,48 +2413,7 @@ irb(main):014:0> s_list[0]
-class CPP_Object;
-%template(CPP_ObjectPtrVector) vector<CPP_Object*>;
-
-%extend CPP_ObjectPtrVector {
- void each () {
- CPP_ObjectPtrVector::iterator i1 = self->begin();
- CPP_ObjectPtrVector::iterator i1end = self->end();
- for ( ; i1 != i1end; i1++)
- rb_yield(Data_Wrap_Struct(cCPP_Object.klass, NULL, NULL, *i1));
- }
-}
-
-
-Notice that the SWIG interface has created a cCPP_Object that is of
-type swig_class. This is an implementation detail that only works for
-SWIG 1.3.11; for previous versions of SWIG the data type of
-cCPP_Object was VALUE.
-
--
-typedef struct {
- VALUE klass;
- void (*mark)(void *);
- void (*destroy)(void *);
-} swig_class;
-
-
-Thus, to access the pointer to the CPP_Object, the variable
-klass is used.- -Also note that the call to Data_Wrap_Struct() sets the free -parameter for CPP_Object to NULL. That is done because C++, - owns the object and thus should free it, not Ruby. - -