diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index b879eaa04..e3478ae91 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -228,7 +228,6 @@
-SWIG will wrap all types of functions that have default arguments. For example member functions: -
- -
-class Foo {
-public:
- void bar(int x, int y = 3, int z = 4);
-};
-
--SWIG handles default arguments by generating an extra overloaded method for each defaulted argument. -SWIG is effectively handling methods with default arguments as if it was wrapping the equivalent overloaded methods. -Thus for the example above, it is as if we had instead given the following to SWIG: -
- -
-class Foo {
-public:
- void bar(int x, int y, int z);
- void bar(int x, int y);
- void bar(int x);
-};
-
--The wrappers produced are exactly the same as if the above code was instead fed into SWIG. -Details of this are covered later in the Wrapping Overloaded Functions and Methods section. -This approach allows SWIG to wrap all possible default arguments, but can be verbose. -For example if a method has ten default arguments, then eleven wrapper methods are generated. -
- --Please see the Features and default arguments -section for more information on using %feature with functions with default arguments. -The Ambiguity resolution and renaming section -also deals with using %rename and %ignore on methods with default arguments. -If you are writing your own typemaps for types used in methods with default arguments, you may also need to write a typecheck typemap. -See the Typemaps and overloading section for details or otherwise -use the compactdefaultargs feature flag as mentioned below. -
- --Compatibility note: Versions of SWIG prior to SWIG-1.3.23 wrapped default arguments slightly differently. -Instead a single wrapper method was generated and the default values were copied into the C++ wrappers -so that the method being wrapped was then called with all the arguments specified. -If the size of the wrappers are a concern then this approach to wrapping methods with default arguments -can be re-activated by using the compactdefaultargs -feature flag. -
- -
-%feature("compactdefaultargs") Foo::bar;
-class Foo {
-public:
- void bar(int x, int y = 3, int z = 4);
-};
-
--This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages, -such as C# and Java, -which don't have optional arguments in the language, -Another restriction of this feature is that it cannot handle default arguments that are not public. -The following example illustrates this: -
- -
-class Foo {
-private:
- static const int spam;
-public:
- void bar(int x, int y = spam); // Won't work with %feature("compactdefaultargs") -
- // private default value
-};
-
--This produces uncompilable wrapper code because default values in C++ are -evaluated in the same scope as the member function whereas SWIG -evaluates them in the scope of a wrapper function (meaning that the -values have to be public). -
- --The compactdefaultargs feature is automatically turned on when wrapping C code with default arguments. -Some target languages will also automatically turn on this feature -if the keyword arguments feature (kwargs) is specified for either C or C++ functions, and the target language supports kwargs, -the compactdefaultargs feature is also automatically turned on. -Keyword arguments are a language feature of some scripting languages, for example Ruby and Python. -SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used. -
- -@@ -1230,7 +1124,7 @@ until you explicitly give a `public:' declaration (This is the same convention used by C++).
-@@ -1260,7 +1154,7 @@ Swig_STOUT = Swig::STOUT Members declared as const are wrapped as read-only members and do not create constants.
-@@ -1321,7 +1215,7 @@ namespace bar { and a wrapper for the method 'blah' will not be generated.
-@@ -1421,7 +1315,7 @@ templates and the STL. This was first added in SWIG-1.3.12.
-@@ -1525,7 +1419,7 @@ classes that don't define a default constructor. It is not used for C++ pointers or references.
-@@ -1711,7 +1605,7 @@ functions for virtual members that are already defined in a base class.
-@@ -1843,6 +1737,112 @@ int y = B_function((B *) pB); In practice, the pointer is held as an integral number in the target language proxy class.
++SWIG will wrap all types of functions that have default arguments. For example member functions: +
+ +
+class Foo {
+public:
+ void bar(int x, int y = 3, int z = 4);
+};
+
++SWIG handles default arguments by generating an extra overloaded method for each defaulted argument. +SWIG is effectively handling methods with default arguments as if it was wrapping the equivalent overloaded methods. +Thus for the example above, it is as if we had instead given the following to SWIG: +
+ +
+class Foo {
+public:
+ void bar(int x, int y, int z);
+ void bar(int x, int y);
+ void bar(int x);
+};
+
++The wrappers produced are exactly the same as if the above code was instead fed into SWIG. +Details of this are covered later in the Wrapping Overloaded Functions and Methods section. +This approach allows SWIG to wrap all possible default arguments, but can be verbose. +For example if a method has ten default arguments, then eleven wrapper methods are generated. +
+ ++Please see the Features and default arguments +section for more information on using %feature with functions with default arguments. +The Ambiguity resolution and renaming section +also deals with using %rename and %ignore on methods with default arguments. +If you are writing your own typemaps for types used in methods with default arguments, you may also need to write a typecheck typemap. +See the Typemaps and overloading section for details or otherwise +use the compactdefaultargs feature flag as mentioned below. +
+ ++Compatibility note: Versions of SWIG prior to SWIG-1.3.23 wrapped default arguments slightly differently. +Instead a single wrapper method was generated and the default values were copied into the C++ wrappers +so that the method being wrapped was then called with all the arguments specified. +If the size of the wrappers are a concern then this approach to wrapping methods with default arguments +can be re-activated by using the compactdefaultargs +feature flag. +
+ +
+%feature("compactdefaultargs") Foo::bar;
+class Foo {
+public:
+ void bar(int x, int y = 3, int z = 4);
+};
+
++This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages, +such as C# and Java, +which don't have optional arguments in the language, +Another restriction of this feature is that it cannot handle default arguments that are not public. +The following example illustrates this: +
+ +
+class Foo {
+private:
+ static const int spam;
+public:
+ void bar(int x, int y = spam); // Won't work with %feature("compactdefaultargs") -
+ // private default value
+};
+
++This produces uncompilable wrapper code because default values in C++ are +evaluated in the same scope as the member function whereas SWIG +evaluates them in the scope of a wrapper function (meaning that the +values have to be public). +
+ ++The compactdefaultargs feature is automatically turned on when wrapping C code with default arguments. +Some target languages will also automatically turn on this feature +if the keyword arguments feature (kwargs) is specified for either C or C++ functions, and the target language supports kwargs, +the compactdefaultargs feature is also automatically turned on. +Keyword arguments are a language feature of some scripting languages, for example Ruby and Python. +SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used. +
+