diff --git a/SWIG/CHANGES b/SWIG/CHANGES index 28d5707bd..9f40f843f 100644 --- a/SWIG/CHANGES +++ b/SWIG/CHANGES @@ -3,6 +3,14 @@ SWIG (Simplified Wrapper and Interface Generator) Version 1.3 Alpha 4 (not yet released) ====================================== +7/22/00 : beazley + A variety of old type handling functions such as print_type(), + print_full(), print_mangle(), etc... are gone and have been + replaced with a smaller set of functions. See the file + Doc/internals.html for details. This will break all third + party language modules. + *** POTENTIAL INCOMPATIBILITY *** + 7/20/00 : beazley Deprecated the %val and %out directives. These directives shouldn't really be necessary since typemaps can be used diff --git a/SWIG/Doc/internals.html b/SWIG/Doc/internals.html index 4eb0b2ea9..dfa8ed83f 100644 --- a/SWIG/Doc/internals.html +++ b/SWIG/Doc/internals.html @@ -192,7 +192,7 @@ which uses the callbacks registered by SWIG_main() above.
  • 4. Parsing
  • 5. Difference Between SWIG 1.1 and SWIG 1.3
  • 6. Plans for SWIG 2.0 -
  • 7. Reserved +
  • 7. C/C++ Wrapper Support Functions
  • 8. Reserved
  • 9. Reserved
  • 10. Guile Support @@ -461,7 +461,7 @@ of which must be reassignable types since they are the targets of conversions fr representation.

    -

  • DataType_caststr(DataType *t, char *name). +
  • DataType_rcaststr(DataType *t, char *name).
    This function produces a string that casts a type produced by the lstr() function to the type produced by the str() function. You might view it as the inverse of lstr(). This function only produces @@ -470,7 +470,7 @@ name can be supplied when the cast is to be applied to a specific name. Exampl
    -Original Datatype             caststr()
    +Original Datatype             rcaststr()
     ------------------            ---------
     char *a                       
     const char *a                 (const char *) name
    @@ -480,6 +480,27 @@ double &a                     (double &) *name
     
    + +

    +

  • DataType_lcaststr(DataType *t, char *name). +
    This function produces a string +that casts a type produced by the str() function to the type produced by the +lstr() function. This function only produces +output when it needs to (when str() and lstr() produce different results). Furthermore, an optional +name can be supplied when the cast is to be applied to a specific name. + +
    +
    +Original Datatype             lcaststr()
    +------------------            ---------
    +char *a                       
    +const char *a                 (char *) name
    +double a[20]                  (double *) name
    +double a[20][30]              (double *) name
    +double &a                     (double *) &name
    +
    +
    +

  • DataType_manglestr(DataType *t).
    Produces a type-string that is used to identify this datatype in the target scripting language. @@ -489,7 +510,6 @@ references, and arrays---producing a mangled version of the type produced by the - The following example illustrates the intended use of the above functions when creating wrapper functions using shorthand pseudocode. Suppose you had a function like this: @@ -577,9 +597,203 @@ repeated calls without making any copies. [TODO] -

    7. Reserved

    +

    7. C/C++ Wrapper Support Functions

    +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: + +

    + +All of these transformations are handled by a collection of functions found +in the file Source/Swig/cwrap.c. + + + +Here is a short example showing how these functions could be used. Suppose you had a +C function like this: + +
    +
    +double dot_product(Vector a, Vector b);
    +
    +
    + +Here's how you might write a really simple wrapper function + +
    +
    +ParmList *l = ... parameter list of the function ...
    +DataType *t = ... return type of the function ...
    +char     *name = ... name of the function ...
    +Wrapper *w = NewWrapper();
    +Printf(w->def,"void wrap_%s() {\n", name);
    +
    +/* Declare all of the local variables */
    +Swig_cargs(w, l);
    +
    +/* Convert all of the arguments */
    +...
    +
    +/* Make the function call and declare the result variable */
    +Swig_cresult(w,t,"result",Swig_cfunction(name,l));
    +
    +/* Convert the result into whatever */
    +...
    +
    +Printf(w->code,"}\n");
    +Wrapper_print(w,out);
    +
    +
    + +The output of this would appear as follows: + +
    +
    +void wrap_dot_product() {
    +    Vector *arg0;
    +    Vector *arg1;
    +    double  result;
    +
    +    ...
    +    result = dot_product(*arg0, *arg1);
    +    ...
    +}
    +
    +
    + +Notice that the Swig_cargs(), Swig_cresult(), and Swig_cfunction() functions +have taken care of the type conversions for the Vector type automatically. + +

    +Notes: +

    + + + + + + +

    8. Reserved