diff --git a/Doc/internals.html b/Doc/internals.html
index cb72328d5..3b24c6f11 100644
--- a/Doc/internals.html
+++ b/Doc/internals.html
@@ -648,15 +648,15 @@ repeated calls without making any copies.
[TODO]
-7. C/C++ Wrapper Support Functions
+7. The C/C++ Wrapping Layer
Added: Dave Beazley (July 22, 2000)
-When generating wrappers, SWIG tries to provide a mostly
-seamless with the original code. However, there are a number of
-problematic features of C/C++ that are handled in the following manner:
+When SWIG generates wrappers, it tries to provide a mostly seamless integration
+with the original code. However, there are a number of problematic features
+of C/C++ programs that complicate this interface.
- Passing and returning structures by value. When used, SWIG converts
@@ -711,10 +711,84 @@ that return a reference.
qualifiers from the interface presented to the target language.
Besides, what in the heck is "const" in Perl anyways?
+
+
- Instance Methods. Method invocations are handled as a function call in which
+a pointer to the object (the "this" pointer) appears as the first argument. For example, in
+the following class:
+
+
+
+class Foo {
+public:
+ double bar(double);
+};
+
+
+
+The "bar" method is wrapped by a function like this:
+
+
+
+double Foo_bar(Foo *self, double arg0) {
+ return self->bar(arg0);
+}
+
+
+
+
+
- Structure/class data members. Data members are handled by creating a pair
+of wrapper functions that set and get the value respectively. For example:
+
+
+
+struct Foo {
+ int x;
+};
+
+
+
+gets wrapped as follows:
+
+
+
+int Foo_x_get(Foo *self) {
+ return self->x;
+}
+int Foo_x_set(Foo *self, int value) {
+ return (self->x = value);
+}
+
+
+
+
+
- Constructors. Constructors for C/C++ data structures are wrapped by
+a function like this:
+
+
+
+Foo *new_Foo() {
+ return new Foo;
+}
+
+
+Note: For C, new objects are created using the calloc() function.
+
+
+
- Destructors. Destructors for C/C++ data structures are wrapper like this:
+
+
+
+void delete_Foo(Foo *self) {
+ delete self;
+}
+
+
+Note: For C, objects are destroyed using free().
+
-All of these transformations are handled by a collection of functions found
-in the file Source/Swig/cwrap.c.
+The creation of wrappers and various type transformations are handled by a collection of functions
+found in the file Source/Swig/cwrap.c.
-
@@ -724,6 +798,11 @@ type t, name name, and default value value. This loc
variable is stripped of all qualifiers and will be a pointer if the type is a reference
or user defined type.
+
+
-
+DataType *Swig_clocal_type(DataType *t)
+Returns a type object corresponding to the type string produced by the Swig_clocal() function.
+
- char *Swig_clocal_deref(DataType *t, char *name)
This function is the inverse of the clocal() function. Given a type and a name,
@@ -758,18 +837,21 @@ result, resultname is the name of the result variable, and decl
- - char *Swig_cfunction(char *name, ParmList *parms)
+
- Wrapper *Swig_cfunction_wrapper(char *fname, DataType *rtype, ParmList *parms, char *code)
+Create a wrapper around a normal function declaration. fname is the name of the wrapper,
+rtype is the return type, parms are the function parameters, and code is a
+string containing the code in the function body.
+
+
+
- Wrapper *Swig_cmethod_wrapper(char *classname, char *methodname, DataType *rtype, DataType *parms, char *code)
+
+
+
- char *Swig_cfunction_call(char *name, ParmList *parms)
This function produces a string containing the code needed to call a C function.
The string that is produced contains all of the transformations needed to convert
pass-by-value into pass-by-reference as well as handle C++ references. Produces
a string like "name(arg0, arg1, ..., argn)".
-
-
- char *Swig_cmethod(char *name, ParmList *parms)
-This function produces a string containing the code needed to call a C++ class
-method. parms should be a complete list of arguments where the first
-argument is the "this" variable. Produces a string like "arg0->name(arg1, ..., argn)".
-
Here is a short example showing how these functions could be used. Suppose you had a