From 320a83627c0ef33140481a8c6176df2feaf1c8e1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 Feb 2012 20:28:16 +0000 Subject: [PATCH] Expand docs on advanced %ignore git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12907 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 1 + Doc/Manual/SWIG.html | 52 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 7cae25e7f..105bbcf7e 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -156,6 +156,7 @@
  • Simple renaming of specific identifiers
  • Advanced renaming support
  • Limiting global renaming rules +
  • Ignoring everything then wrapping a few selected symbols
  • Default/optional arguments
  • Pointers to functions and callbacks diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index bcfcc60f5..58a3c8e55 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -48,6 +48,7 @@
  • Simple renaming of specific identifiers
  • Advanced renaming support
  • Limiting global renaming rules +
  • Ignoring everything then wrapping a few selected symbols
  • Default/optional arguments
  • Pointers to functions and callbacks @@ -1996,9 +1997,10 @@ such match expressions, for example

    will capitalize the names of all the enum elements but not change the case of -the other declarations. Similarly, %$isclass, %$isfunction +the other declarations. Similarly, %$isclass, %$isfunction, +%$isconstructor, %$isunion, %$istemplate, and %$isvariable can be used. Many other checks are possible and this -documentation is not exhaustive, see "%rename predicates" section of +documentation is not exhaustive, see the "%rename predicates" section in swig.swg for the full list of supported match expressions.

    @@ -2023,9 +2025,13 @@ declaration name directly can be preferable and can also be done using %rename("$ignore", regextarget=1) "Old$"; + +

    Notice that the check is done only against the name of the declaration itself, if you need to match the full name of a C++ declaration you must use fullname attribute: +

    +
     %rename("$ignore", regextarget=1, fullname=1) "NameSpace::ClassName::.*Old$";
    @@ -2050,6 +2056,48 @@ wrap C++ overloaded functions and methods or C++ methods which use default argum
     

    +

    5.4.7.4 Ignoring everything then wrapping a few selected symbols

    + + +

    +Using the techniques described above it is possible to ignore everything in a header and then +selectively wrap a few chosen methods or classes. For example, consider a header, myheader.h +which has many classes in it and just the one class called Star is wanted within this header, +the following approach could be taken: +

    + +
    +
    +%ignore ""; // Ignore everything
    +
    +// Unignore chosen class 'Star'
    +%rename("%s") Star;
    +
    +// As the ignore everything will include the constructor, destructor, methods etc
    +// in the class, these have to be explicitly unignored too:
    +%rename("%s") Star::Star;
    +%rename("%s") Star::~Star;
    +%rename("%s") Star::shine; // named method
    +
    +%include "myheader.h"
    +
    +
    + +

    +Another approach which might be more suitable as it does not require naming all the methods in the +chosen class is to begin by ignoring just the classes. This does not add an explicit ignore to any +members of the class, so when the chosen class is unignored, all of its methods will be wrapped. +

    + +
    +
    +%rename($ignore, %$isclass) ""; // Only ignore all classes
    +%rename("%s") Star; // Unignore 'Star'
    +%include "myheader.h"
    +
    +
    + +

    5.4.8 Default/optional arguments