From e5b6a8e72f693a4b533af6fc7c04599e8b99b981 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 2 Jul 2007 21:38:22 +0000 Subject: [PATCH] Add notes about typemaps and the preprocessor including the noblock attribute git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9860 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Preprocessor.html | 84 +++++++++++++++++++++++++++++++++--- Doc/Manual/Typemaps.html | 3 +- 2 files changed, 80 insertions(+), 7 deletions(-) diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 7ccb5bff3..e0d58e59a 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -16,8 +16,9 @@
  • Macro Expansion
  • SWIG Macros
  • C99 and GNU Extensions -
  • Preprocessing and %{ ... %} blocks -
  • Preprocessing and { ... } +
  • Preprocessing and %{ ... %} & " ... " delimiters +
  • Preprocessing and { ... } delimiters +
  • Preprocessor and Typemaps
  • Viewing preprocessor output
  • The #error and #warning directives @@ -306,7 +307,7 @@ interface building. However, they are used internally to implement a number of SWIG directives and are provided to make SWIG more compatible with C99 code.

    -

    7.7 Preprocessing and %{ ... %} blocks

    +

    7.7 Preprocessing and %{ ... %} & " ... " delimiters

    @@ -331,7 +332,7 @@ the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

    -

    7.8 Preprocessing and { ... }

    +

    7.8 Preprocessing and { ... } delimiters

    @@ -373,7 +374,78 @@ to actually go into the wrapper file, prefix the preprocessor directives with % and leave the preprocessor directive in the code.

    -

    7.9 Viewing preprocessor output

    +

    7.9 Preprocessor and Typemaps

    + + +

    +Typemaps support a special attribute where the { ... } delimiters can be used, +but the delimiters are not actually generated into the code. +The effect is then similar to using "" or %{ %} delimiters but the code is run through the preprocessor. For example: +

    + +
    +
    +#define SWIG_macro(CAST) (CAST)$input
    +%typemap(in) Int {$1= SWIG_macro(int);}
    +
    +
    + +

    +might generate +

    + +
    +
    +  {
    +    arg1=(int)jarg1;
    +  }
    +
    +
    + +

    +whereas +

    + +
    +
    +#define SWIG_macro(CAST) (CAST)$input
    +%typemap(in,noblock=1) Int {$1= SWIG_macro(int);}
    +
    +
    + +

    +might generate +

    + +
    +
    +  arg1=(int)jarg1;
    +
    +
    + +

    +and +

    + +
    +
    +#define SWIG_macro(CAST) (CAST)$input
    +%typemap(in) Int %{$1=SWIG_macro(int);%}
    +
    +
    + +

    +would generate +

    + +
    +
    +  arg1=SWIG_macro(int);
    +
    +
    + + +

    7.10 Viewing preprocessor output

    @@ -383,7 +455,7 @@ Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

    -

    7.10 The #error and #warning directives

    +

    7.11 The #error and #warning directives

    diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index b5bf6c849..f57783671 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -714,7 +714,8 @@ code : { ... }

    -Note that the preprocessor will expand code within the {} delimiters, but not in the last two styles of delimiters. +Note that the preprocessor will expand code within the {} delimiters, but not in the last two styles of delimiters, +see Preprocessor and Typemaps. Here are some examples of valid typemap specifications: