From: <ol...@us...> - 2008-07-27 12:51:18
|
Revision: 10714 http://swig.svn.sourceforge.net/swig/?rev=10714&view=rev Author: olly Date: 2008-07-27 12:51:16 +0000 (Sun, 27 Jul 2008) Log Message: ----------- Fix "can can" typo in docs (SF#2026756) Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2008-07-26 14:18:37 UTC (rev 10713) +++ trunk/Doc/Manual/SWIG.html 2008-07-27 12:51:16 UTC (rev 10714) @@ -53,7 +53,7 @@ <li><a href="#SWIG_nn33">Character strings and structures</a> <li><a href="#SWIG_nn34">Array members</a> <li><a href="#SWIG_structure_data_members">Structure data members</a> -<li><a href="#SWIG_nn36">C constructors and destructors </a> +<li><a href="#SWIG_nn36">C constructors and destructors</a> <li><a href="#SWIG_adding_member_functions">Adding member functions to C structures</a> <li><a href="#SWIG_nested_structs">Nested structures</a> <li><a href="#SWIG_nn39">Other things to note about structure wrapping</a> @@ -224,7 +224,7 @@ contains everything that is needed to construct a extension module for the target scripting language. SWIG is not a stub compiler nor is it usually necessary to edit the output file (and if you look at the output, -you probably won't want to). To build the final extension module, the +you probably won't want to). To build the final extension module, the SWIG output file is compiled and linked with the rest of your C/C++ program to create a shared library. </p> @@ -232,7 +232,7 @@ <p> Many target languages will also generate proxy class files in the target language. The default output directory for these language -specific files is the same directory as the generated C/C++ file. This can +specific files is the same directory as the generated C/C++ file. This can be modified using the <tt>-outdir</tt> option. For example: </p> @@ -2219,13 +2219,13 @@ <p> -<b>Compatibility Note: </b> SWIG-1.3.11 and earlier releases transformed all non-primitive member datatypes -to pointers. Starting in SWIG-1.3.12, this transformation <em>only</em> occurs if a datatype is known to be a structure, -class, or union. This is unlikely to break existing code. However, if you need to tell SWIG that an undeclared +<b>Compatibility Note:</b> SWIG-1.3.11 and earlier releases transformed all non-primitive member datatypes +to pointers. Starting in SWIG-1.3.12, this transformation <em>only</em> occurs if a datatype is known to be a structure, +class, or union. This is unlikely to break existing code. However, if you need to tell SWIG that an undeclared datatype is really a struct, simply use a forward struct declaration such as <tt>"struct Foo;"</tt>. </p> -<H3><a name="SWIG_nn36"></a>5.5.5 C constructors and destructors </H3> +<H3><a name="SWIG_nn36"></a>5.5.5 C constructors and destructors</H3> <p> @@ -2282,7 +2282,7 @@ Since ignoring the implicit or default destructors most of the times produce memory leaks, SWIG will always try to generate them. If needed, however, you can selectively disable the generation of the -default/implicit destructor by using <tt>%nodefaultdtor </tt> +default/implicit destructor by using <tt>%nodefaultdtor</tt> </p> <div class="code"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2008-11-23 23:29:36
|
Revision: 10946 http://swig.svn.sourceforge.net/swig/?rev=10946&view=rev Author: wsfulton Date: 2008-11-23 23:29:33 +0000 (Sun, 23 Nov 2008) Log Message: ----------- remove docs on old php4 switch Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2008-11-23 23:28:37 UTC (rev 10945) +++ trunk/Doc/Manual/SWIG.html 2008-11-23 23:29:33 UTC (rev 10946) @@ -120,7 +120,6 @@ -mzscheme Generate Mzscheme wrappers -ocaml Generate Ocaml wrappers -perl Generate Perl wrappers --php4 Generate PHP4 wrappers -php5 Generate PHP5 wrappers -pike Generate Pike wrappers -python Generate Python wrappers This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2009-02-20 08:04:00
|
Revision: 11134 http://swig.svn.sourceforge.net/swig/?rev=11134&view=rev Author: wsfulton Date: 2009-02-20 08:03:49 +0000 (Fri, 20 Feb 2009) Log Message: ----------- minor correction about %begin Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2009-02-20 07:52:24 UTC (rev 11133) +++ trunk/Doc/Manual/SWIG.html 2009-02-20 08:03:49 UTC (rev 11134) @@ -2771,8 +2771,8 @@ </p> <p> -The <tt>%begin</tt> section is empty by default -and is provided as a way for users to insert code at the top of the wrapper file. +The <tt>%begin</tt> section is effectively empty as it just contains the SWIG banner by default. +This section is provided as a way for users to insert code at the top of the wrapper file before any other code is generated. Everything in a code insertion block is copied verbatim into the output file and is not parsed by SWIG. Most SWIG input files have at least one such block to include header files and support C code. Additional code blocks may be placed anywhere in a This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2009-08-12 22:07:56
|
Revision: 11541 http://swig.svn.sourceforge.net/swig/?rev=11541&view=rev Author: wsfulton Date: 2009-08-12 22:07:49 +0000 (Wed, 12 Aug 2009) Log Message: ----------- Correct docs wrt C preprocessor constants with a cast Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2009-08-12 16:50:17 UTC (rev 11540) +++ trunk/Doc/Manual/SWIG.html 2009-08-12 22:07:49 UTC (rev 11541) @@ -667,7 +667,6 @@ enum months {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}; %constant double BLAH = 42.37; -#define F_CONST (double) 5 // A floating pointer constant with cast #define PI_4 PI/4 #define FLAGS 0x04 | 0x08 | 0x40 @@ -706,8 +705,15 @@ <p> defines a constant because <tt>PI</tt> was already defined as a constant and the value is known. +However, for the same conservative reasons even a constant with a simple cast will be ignored, such as </p> +<div class="code"> +<pre> +#define F_CONST (double) 5 // A floating pointer constant with cast +</pre> +</div> + <p> The use of constant expressions is allowed, but SWIG does not evaluate them. Rather, it passes them through to the output file and lets the C This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2009-08-14 22:11:36
|
Revision: 11573 http://swig.svn.sourceforge.net/swig/?rev=11573&view=rev Author: wsfulton Date: 2009-08-14 22:11:27 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Add some notes about \%extend and constructors Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2009-08-14 21:05:06 UTC (rev 11572) +++ trunk/Doc/Manual/SWIG.html 2009-08-14 22:11:27 UTC (rev 11573) @@ -2388,6 +2388,10 @@ <p> Note the usage of the <tt>$self</tt> special variable. Its usage is identical to a C++ 'this' pointer and should be used whenever access to the struct instance is required. +Also note that C++ constructor and destructor syntax has been used to simulate a constructor and destructor, even for C code. +There is one subtle difference to a normal C++ constructor implementation though and that is although the constructor declaration +is as per a normal C++ constructor, the newly constructed object must be returned <b>as if</b> the constructor declaration +had a return value, a <tt>Vector *</tt> in this case. </p> <p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2009-08-14 22:13:30
|
Revision: 11574 http://swig.svn.sourceforge.net/swig/?rev=11574&view=rev Author: wsfulton Date: 2009-08-14 22:13:21 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Fill in missing bit about the begin section Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2009-08-14 22:11:27 UTC (rev 11573) +++ trunk/Doc/Manual/SWIG.html 2009-08-14 22:13:21 UTC (rev 11574) @@ -2716,6 +2716,10 @@ </p> <ul> +<li><b>Begin section</b>. <br> +A placeholder to put code at the beginning of the C/C++ wrapper file. +</li> + <li><b>Runtime code</b>. <br> This code is internal to SWIG and is used to include type-checking and other support functions that are used by the rest of the module. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2009-12-20 01:19:57
|
Revision: 11791 http://swig.svn.sourceforge.net/swig/?rev=11791&view=rev Author: wsfulton Date: 2009-12-20 01:19:48 +0000 (Sun, 20 Dec 2009) Log Message: ----------- Make docs on c++ source files more technically correct and fix some html errors Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2009-12-20 00:24:34 UTC (rev 11790) +++ trunk/Doc/Manual/SWIG.html 2009-12-20 01:19:48 UTC (rev 11791) @@ -330,11 +330,13 @@ </p> <ul> -<li>Non-conventional type declarations. + <li> +<p> +Non-conventional type declarations. For example, SWIG does not support declarations such as the following (even though this is legal C): -<p> +</p> <div class="code"> <pre> /* Non-conventional placement of storage specifier (extern) */ @@ -348,7 +350,6 @@ </pre> </div> -</p> <p> In practice, few (if any) C programmers actually write code like @@ -357,27 +358,32 @@ </p> </li> -<li>Running SWIG on C++ source files (what would appear in a .C or .cxx file) -is not recommended. Even though SWIG can parse C++ class declarations, -it ignores declarations that are decoupled from their -original class definition (the declarations are parsed, but a lot of warning -messages may be generated). For example: +<li> <p> +Running SWIG on C++ source files (the code in a .C, .cpp or .cxx file) is not recommended. +The usual approach is to feed SWIG header files for parsing C++ definitions and declarations. +The main reason is if SWIG parses a scoped definition or declaration (as is normal for C++ source files), +it is ignored, unless a declaration for the symbol was parsed earlier. +For example +</p> <div class="code"> <pre> -/* Not supported by SWIG */ +/* bar not wrapped unless foo has been defined and + the declaration of bar within foo has already been parsed */ int foo::bar(int) { ... whatever ... } </pre> </div> -</p> </li> -<li>Certain advanced features of C++ such as nested classes -are not yet fully supported. Please see the <a href="SWIGPlus.html">C++ section</a> +<li> +<p> +Certain advanced features of C++ such as nested classes +are not yet fully supported. Please see the C++ <a href="SWIGPlus.html#SWIGPlus_nested_classes">Nested classes</a> section for more information. +</p> </ul> <p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2010-04-29 19:46:21
|
Revision: 11998 http://swig.svn.sourceforge.net/swig/?rev=11998&view=rev Author: wsfulton Date: 2010-04-29 19:46:14 +0000 (Thu, 29 Apr 2010) Log Message: ----------- Remove confusion about ignoring header include guards Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2010-04-25 14:07:14 UTC (rev 11997) +++ trunk/Doc/Manual/SWIG.html 2010-04-29 19:46:14 UTC (rev 11998) @@ -1672,7 +1672,7 @@ // interface.i %rename(my_print) print; -extern void print(char *); +extern void print(const char *); %rename(foo) a_really_long_and_annoying_name; extern int a_really_long_and_annoying_name; @@ -1725,9 +1725,10 @@ <div class="code"> <pre> %ignore print; // Ignore all declarations named print -%ignore _HAVE_FOO_H; // Ignore an include guard constant +%ignore MYMACRO; // Ignore a macro ... -%include "foo.h" // Grab a header file +#define MYMACRO 123 +void print(const char *); ... </pre> </div> @@ -1752,7 +1753,7 @@ <div class="code"> <pre> -%name(output) extern void print(char *); +%name(output) extern void print(const char *); </pre> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <va...@us...> - 2010-07-22 16:59:51
|
Revision: 12168 http://swig.svn.sourceforge.net/swig/?rev=12168&view=rev Author: vadz Date: 2010-07-22 16:59:45 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Document advanced %rename capabilities. Document the possibility to apply %rename to all declarations or only those of a particular type. Also document extended format strings used with it and the functions which can be used in them. Also clarify that %ignore is basically just a %rename alias. Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2010-07-22 16:59:29 UTC (rev 12167) +++ trunk/Doc/Manual/SWIG.html 2010-07-22 16:59:45 UTC (rev 12168) @@ -1661,6 +1661,7 @@ <H3><a name="SWIG_rename_ignore"></a>5.4.7 Renaming and ignoring declarations</H3> +<H4>5.4.7.1 Simple renaming of specific identifiers</H4> <p> Normally, the name of a C declaration is used when that declaration is @@ -1742,12 +1743,6 @@ </p> <p> -More powerful variants of <tt>%rename</tt> and <tt>%ignore</tt> directives can be used to help -wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the -<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a> section in the C++ chapter. -</p> - -<p> <b>Compatibility note: </b> Older versions of SWIG provided a special <tt>%name</tt> directive for renaming declarations. For example: </p> @@ -1763,6 +1758,193 @@ directive is more powerful and better supports wrapping of raw header file information. </p> +<H4>5.4.7.2 Advanced renaming support</H4> + +<p> +While writing <tt>%rename</tt> for specific declarations is simple enough, +sometimes the same renaming rule needs to be applied to many, maybe all, +identifiers in the SWIG input. For example, it may be necessary to apply some +transformation to all the names in the target language to better follow its +naming conventions, e.g. add a specific prefix to all the functions. Doing it +for each function is impractical so SWIG supports applying a renaming rule to +all declarations if the name of the identifier to be renamed is not specified: +</p> + +<div class="code"> +<pre> +%rename("myprefix_%s") ""; // print -> myprefix_print +</pre> +</div> + +<p> +This also shows that the argument of <tt>%rename</tt> doesn't have to be a +literal string but can be a <tt>printf()</tt>-like format string. In the +simplest form, <tt>"%s"</tt> is replaced with the name of the original +declaration, as shown above. However this is not always enough and SWIG +provides extensions to the usual format string syntax to allow applying a +(SWIG-defined) function to the argument. For example, to wrap all C functions +<tt>do_something_long()</tt> as more Java-like <tt>doSomethingLong()</tt> you +can use the <tt>"lowercamelcase"</tt> extended format specifier like this: +</p> + +<div class="code"> +<pre> +%rename("%(lowercamelcase)s") ""; // foo_bar -> fooBar; FooBar -> fooBar +</pre> +</div> + +<p> +Some functions can be parametrized, for example the <tt>"strip"</tt> one +strips the provided prefix from its argument. The prefix is specified as part +of the format string, following a colon after the function name: +<div class="code"> +<pre> +%rename("%(strip:[wx])s") ""; // wxHello -> Hello; FooBar -> fooBar +</pre> +</div> +</p> + +<p> +Here is the table summarizing all currently defined functions with an example +of applying each one (notice that some of them have two names, a shorter one +and a more descriptive one, but the two functions are otherwise equivalent): +</p> +<table summary="Format string functions" border="1" cellpadding="5"> +<tr> + <th>Function</th><th>Returns</th><th colspan=2>Example (in/out)</th> +</tr> +<tr> + <td><tt>upper</tt> or <tt>uppercase</tt></td> + <td>Upper-case version of the string.</td> + <td><tt>Print</tt></td><td><tt>PRINT</tt></td> +</tr> +<tr> + <td><tt>lower</tt> or <tt>lowercase</tt></td> + <td>Lower-case version of the string.</td> + <td><tt>Print</tt></td><td><tt>print</tt></td> +</tr> +<tr> + <td><tt>title</tt></td> + <td>String with first letter capitalized and the rest in lower case.</td> + <td><tt>print</tt></td><td><tt>Print</tt></td> +</tr> +<tr> + <td><tt>firstuppercase</tt></td> + <td>String with the first letter capitalized and the rest unchanged.</td> + <td><tt>printIt</tt></td><td><tt>PrintIt</tt></td> +</tr> +<tr> + <td><tt>firstlowercase</tt></td> + <td>String with the first letter in lower case and the rest unchanged.</td> + <td><tt>PrintIt</tt></td><td><tt>printIt</tt></td> +</tr> +<tr> + <td><tt>ctitle</tt> or <tt>camelcase</tt></td> + <td>String with capitalized first letter and any letter following an + underscore (which are removed in the process) and rest in lower case.</td> + <td><tt>print_it</tt></td><td><tt>PrintIt</tt></td> +</tr> +<tr> + <td><tt>lctitle</tt> or <tt>lowercamelcase</tt></td> + <td>String with every letter following an underscore (which is removed in + the process) capitalized and rest, including the first letter, in lower + case.</td> + <td><tt>print_it</tt></td><td><tt>printIt</tt></td> +</tr> +<tr> + <td><tt>utitle</tt> or <tt>undercase</tt></td> + <td>Lower case string with underscores inserted before every upper-case + letter in the original string and any number not at the end of string. + Logically, this is the reverse of <tt>ccase</tt>.</td> + <td><tt>PrintIt</tt></td><td><tt>print_it</tt></td> +</tr> +<tr> + <td><tt>schemify</tt></td> + <td>String with all underscores replaced with dashes, resulting in more + Lispers/Schemers-pleasing name.</td> + <td><tt>print_it</tt></td><td><tt>print-it</tt></td> +</tr> +<tr> + <td><tt>strip:[prefix]</tt></td> + <td>String without the given prefix or the original string if it doesn't + start with this prefix. Note that square brackets should be used + literally, e.g. <tt>%rename("strip:[wx]")</tt></td> + <td><tt>wxPrint</tt></td><td><tt>Print</tt></td> +</tr> +<tr> + <td><tt>command:cmd</tt></td> + <td>Output of an external command <tt>cmd</tt> with the string passed to + it as input. Notice that this function is extremely slow compared to all + the other ones as it involves spawning a separate process and using it for + many declarations is not recommended. The <i>cmd</i> is not enclosed in + square brackets but must be terminated with a triple <tt>'<'</tt> sign, + e.g. <tt>%rename("command:tr -d aeiou <<<")</tt> + (nonsensical example removing all vowels)</td> + <td><tt>Print</tt></td><td><tt>Prnt</tt></td> +</tr> +</table> + +<p> +As before, everything that was said above about <tt>%rename</tt> also applies to +<tt>%ignore</tt>. In fact, the latter is just a special case of the former and +ignoring an identifier is the same as renaming it to the special +<tt>"$ignore"</tt> value. So the following snippets +</p> + +<div class="code"> +<pre> +%ignore print; +</pre> +</div> + +<p> +and +</p> + +<div class="code"> +<pre> +%rename("$ignore") print; +</pre> +</div> + +<p> +are exactly equivalent and <tt>%rename</tt> can be used to selectively ignore +multiple declarations using the previously described matching possibilities. +</p> + +<H4>5.4.7.3 Limiting global renaming rules</H4> + +<p> +As explained in the previous sections, it is possible to either rename +individual declarations or apply a rename rule to all of them at once. In +practice, the latter is however rarely appropriate as there are always some +exceptions to the general rules. To deal with them, the scope of an unnamed +<tt>%rename</tt> can be limited using a second parameter. +</p> + +<p> +The simplest possibility is to match the declaration type, for example: +</p> +<div class="code"> +<pre> +%rename("%(title)s", %$isenumitem) ""; +</pre> +</div> +<p> +will capitalize the names of all the enum elements but not change the case of +the other declarations. Similarly, <tt>%$isclass</tt>, <tt>%$isfunction</tt> +and <tt>%$isvariable</tt> can be used. Many other checks are possible and this +documentation is not exhaustive, see "%rename predicates" section of +<tt>Lib/swig.swg</tt> for the full list of supported match expressions. +</p> + +<p> +Finally, even more powerful variants of <tt>%rename</tt> and <tt>%ignore</tt> directives can be used to help +wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the +<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a> section in the C++ chapter. +</p> + + <H3><a name="SWIG_default_args"></a>5.4.8 Default/optional arguments</H3> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <va...@us...> - 2010-07-22 17:01:22
|
Revision: 12172 http://swig.svn.sourceforge.net/swig/?rev=12172&view=rev Author: vadz Date: 2010-07-22 17:01:16 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Improve %rename(match) documentation. Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2010-07-22 17:00:59 UTC (rev 12171) +++ trunk/Doc/Manual/SWIG.html 2010-07-22 17:01:16 UTC (rev 12172) @@ -1931,14 +1931,30 @@ individual declarations or apply a rename rule to all of them at once. In practice, the latter is however rarely appropriate as there are always some exceptions to the general rules. To deal with them, the scope of an unnamed -<tt>%rename</tt> can be limited using a second parameter. +<tt>%rename</tt> can be limited using subsequent <tt>match</tt> parameters. +They can be applied to any of the attributes associated by SWIG with the +declarations appearing in its input. One of them is the declaration name and </p> - +<div class="code"> +<pre> +%rename("foo", match$name="bar") ""; +</pre> +</div> <p> -The simplest possibility is to match the declaration type, for example: +can be used to achieve the same effect as the simpler </p> <div class="code"> <pre> +%rename("foo") bar; +</pre> +</div> +<p> +However <tt>match</tt> can also be applied to the declaration type, for +example <tt>match="class"</tt> restricts the match to class declarations only +(in C++) and <tt>match="enumitem"</tt> restricts it to the enum elements. SWIG +also provides convenience macros for such match expressions, for example +<div class="code"> +<pre> %rename("%(title)s", %$isenumitem) ""; </pre> </div> @@ -1951,6 +1967,22 @@ </p> <p> +Another important feature of <tt>match</tt> is that it can be applied not +only to the declaration itself but also to its enclosing declaration. So +<tt>match$parentNode$name="SomeClass"</tt> would be true only for members of +the C++ class with the specified name. This can, of course, be combined with +more complicated matches making it possible to write +</p> +<div class="code"> +<pre> +%rename("%(lower)s", match$parentNode$name="SomeClass", %$isenum) ""; +</pre> +</div> +<p> +to rename all enums nested in the given class to lower case. +</p> + +<p> Finally, even more powerful variants of <tt>%rename</tt> and <tt>%ignore</tt> directives can be used to help wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the <a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a> section in the C++ chapter. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2010-07-23 07:21:52
|
Revision: 12179 http://swig.svn.sourceforge.net/swig/?rev=12179&view=rev Author: wsfulton Date: 2010-07-23 07:21:46 +0000 (Fri, 23 Jul 2010) Log Message: ----------- minor edits in %rename sections Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2010-07-23 07:17:15 UTC (rev 12178) +++ trunk/Doc/Manual/SWIG.html 2010-07-23 07:21:46 UTC (rev 12179) @@ -1765,7 +1765,7 @@ sometimes the same renaming rule needs to be applied to many, maybe all, identifiers in the SWIG input. For example, it may be necessary to apply some transformation to all the names in the target language to better follow its -naming conventions, e.g. add a specific prefix to all the functions. Doing it +naming conventions, like adding a specific prefix to all wrapped functions. Doing it individually for each function is impractical so SWIG supports applying a renaming rule to all declarations if the name of the identifier to be renamed is not specified: </p> @@ -1799,28 +1799,28 @@ of the format string, following a colon after the function name: <div class="code"> <pre> -%rename("%(strip:[wx])s") ""; // wxHello -> Hello; FooBar -> fooBar +%rename("%(strip:[wx])s") ""; // wxHello -> Hello; FooBar -> FooBar </pre> </div> </p> <p> -Here is the table summarizing all currently defined functions with an example -of applying each one (notice that some of them have two names, a shorter one -and a more descriptive one, but the two functions are otherwise equivalent): +Below is the table summarizing all currently defined functions with an example +of applying each one. Note that some of them have two names, a shorter one +and a more descriptive one, but the two functions are otherwise equivalent: </p> <table summary="Format string functions" border="1" cellpadding="5"> <tr> <th>Function</th><th>Returns</th><th colspan=2>Example (in/out)</th> </tr> <tr> - <td><tt>upper</tt> or <tt>uppercase</tt></td> - <td>Upper-case version of the string.</td> + <td><tt>uppercase</tt> or <tt>upper</tt></td> + <td>Upper case version of the string.</td> <td><tt>Print</tt></td><td><tt>PRINT</tt></td> </tr> <tr> - <td><tt>lower</tt> or <tt>lowercase</tt></td> - <td>Lower-case version of the string.</td> + <td><tt>lowercase</tt> or <tt>lower</tt></td> + <td>Lower case version of the string.</td> <td><tt>Print</tt></td><td><tt>print</tt></td> </tr> <tr> @@ -1839,23 +1839,23 @@ <td><tt>PrintIt</tt></td><td><tt>printIt</tt></td> </tr> <tr> - <td><tt>ctitle</tt> or <tt>camelcase</tt></td> + <td><tt>camelcase</tt> or <tt>ctitle</tt></td> <td>String with capitalized first letter and any letter following an underscore (which are removed in the process) and rest in lower case.</td> <td><tt>print_it</tt></td><td><tt>PrintIt</tt></td> </tr> <tr> - <td><tt>lctitle</tt> or <tt>lowercamelcase</tt></td> + <td><tt>lowercamelcase</tt> or <tt>lctitle</tt></td> <td>String with every letter following an underscore (which is removed in the process) capitalized and rest, including the first letter, in lower case.</td> <td><tt>print_it</tt></td><td><tt>printIt</tt></td> </tr> <tr> - <td><tt>utitle</tt> or <tt>undercase</tt></td> - <td>Lower case string with underscores inserted before every upper-case + <td><tt>undercase</tt> or <tt>utitle</tt></td> + <td>Lower case string with underscores inserted before every upper case letter in the original string and any number not at the end of string. - Logically, this is the reverse of <tt>ccase</tt>.</td> + Logically, this is the reverse of <tt>camelcase</tt>.</td> <td><tt>PrintIt</tt></td><td><tt>print_it</tt></td> </tr> <tr> @@ -1933,7 +1933,7 @@ exceptions to the general rules. To deal with them, the scope of an unnamed <tt>%rename</tt> can be limited using subsequent <tt>match</tt> parameters. They can be applied to any of the attributes associated by SWIG with the -declarations appearing in its input. One of them is the declaration name and +declarations appearing in its input. For example: </p> <div class="code"> <pre> @@ -1965,7 +1965,7 @@ the other declarations. Similarly, <tt>%$isclass</tt>, <tt>%$isfunction</tt> and <tt>%$isvariable</tt> can be used. Many other checks are possible and this documentation is not exhaustive, see "%rename predicates" section of -<tt>Lib/swig.swg</tt> for the full list of supported match expressions. +<tt>swig.swg</tt> for the full list of supported match expressions. </p> <p> @@ -1985,10 +1985,10 @@ </p> <p> -And in addition to literally matching some string with <tt>match</tt> you can -also use <tt>regexmatch</tt> or <tt>notregexmatch</tt>to match a string +In addition to literally matching some string with <tt>match</tt> you can +also use <tt>regexmatch</tt> or <tt>notregexmatch</tt> to match a string against a regular expression. For example, to ignore all functions having -"Old" suffix you could use +"Old" as a suffix you could use </p> <div class="code"> <pre> @@ -1997,7 +1997,7 @@ </div> <p> For simple cases like this, specifying the regular expression for the -declaration name directly can be preferable and can be done using +declaration name directly can be preferable and can also be done using <tt>regextarget</tt>: </p> <div class="code"> @@ -2008,8 +2008,8 @@ <p> As for <tt>notregexmatch</tt>, it restricts the match only to the strings not -matching the specified regular expression. So to rename to lower case versions -all declarations except those consisting from capital letters only: +matching the specified regular expression. So to rename all declarations to lower case +except those consisting of capital letters only: </p> <div class="code"> <pre> @@ -2187,7 +2187,7 @@ <p> SWIG provides a number of extensions to standard C printf formatting that may be useful in this context. For instance, the following -variation installs the callbacks as all upper-case constants such as +variation installs the callbacks as all upper case constants such as <tt>ADD</tt>, <tt>SUB</tt>, and <tt>MUL</tt>: </p> @@ -2201,7 +2201,7 @@ </pre></div> <p> -A format string of <tt>"%(lower)s"</tt> converts all characters to lower-case. +A format string of <tt>"%(lower)s"</tt> converts all characters to lower case. A string of <tt>"%(title)s"</tt> capitalizes the first character and converts the rest to lower case. </p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <va...@us...> - 2010-08-14 14:12:45
|
Revision: 12188 http://swig.svn.sourceforge.net/swig/?rev=12188&view=rev Author: vadz Date: 2010-08-14 14:12:39 +0000 (Sat, 14 Aug 2010) Log Message: ----------- Add more regex function usage examples in %rename section. Mention the examples from the test suite and the change log file in the manual as well. Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2010-08-14 14:12:23 UTC (rev 12187) +++ trunk/Doc/Manual/SWIG.html 2010-08-14 14:12:39 UTC (rev 12188) @@ -1905,6 +1905,28 @@ </table> <p> +The most general function of all of the above ones (not counting +<tt>command</tt> which is even more powerful in principle but which should +generally be avoided because of performance considerations) is the +<tt>regex</tt> one. Here are some more examples of its use: +<div class="code"> +<pre> +// Strip the wx prefix from all identifiers except those starting with wxEVT +%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; // wxSomeWidget -> SomeWidget + // wxEVT_PAINT -> wxEVT_PAINT + +// Apply a rule for renaming the enum elements to avoid the common prefixes +// which are redundant in C#/Java +%rename("%(regex:/^([A-Z][a-z]+)+_(.*)/\\2/)s", %$isenumitem) ""; // Colour_Red -> Red + +// Remove all "Set/Get" prefixes. +%rename("%(regex:/^(Set|Get)(.*)/\\2/)s") ""; // SetValue -> Value + // GetValue -> Value +</pre> +</div> +</p> + +<p> As before, everything that was said above about <tt>%rename</tt> also applies to <tt>%ignore</tt>. In fact, the latter is just a special case of the former and ignoring an identifier is the same as renaming it to the special This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2010-10-04 05:46:48
|
Revision: 12249 http://swig.svn.sourceforge.net/swig/?rev=12249&view=rev Author: wsfulton Date: 2010-10-04 05:46:42 +0000 (Mon, 04 Oct 2010) Log Message: ----------- html fixes Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2010-10-04 05:36:49 UTC (rev 12248) +++ trunk/Doc/Manual/SWIG.html 2010-10-04 05:46:42 UTC (rev 12249) @@ -1881,7 +1881,7 @@ <td><tt>wxPrint</tt></td><td><tt>Print</tt></td> </tr> <tr> - <td><span style="white-space: nowrap;"><tt>regex:/pattern/subst/</tt></span</td> + <td><span style="white-space: nowrap;"><tt>regex:/pattern/subst/</tt></span></td> <td>String after (Perl-like) regex substitution operation. This function allows to apply arbitrary regular expressions to the identifier names. The <i>pattern</i> part is a regular expression in Perl syntax (as supported This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <va...@us...> - 2010-11-16 14:08:56
|
Revision: 12291 http://swig.svn.sourceforge.net/swig/?rev=12291&view=rev Author: vadz Date: 2010-11-16 14:08:50 +0000 (Tue, 16 Nov 2010) Log Message: ----------- Correct explanation of how to match on class name in %rename. Replace incorrect documentation of $parentNode from %rename discussion: it advised using match$parentNode but this doesn't work because the parent node is not yet set when %rename is parsed. Document the "fullname" attribute of %rename which can be used to restrict the match to the given full name of a declaration only. Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2010-11-12 16:43:03 UTC (rev 12290) +++ trunk/Doc/Manual/SWIG.html 2010-11-16 14:08:50 UTC (rev 12291) @@ -2003,22 +2003,6 @@ </p> <p> -Another important feature of <tt>match</tt> is that it can be applied not -only to the declaration itself but also to its enclosing declaration. So -<tt>match$parentNode$name="SomeClass"</tt> would be true only for members of -the C++ class with the specified name. This can, of course, be combined with -more complicated matches making it possible to write -</p> -<div class="code"> -<pre> -%rename("%(lowercase)s", match$parentNode$name="SomeClass", %$isenum) ""; -</pre> -</div> -<p> -to rename all enums nested in the given class to lower case. -</p> - -<p> In addition to literally matching some string with <tt>match</tt> you can also use <tt>regexmatch</tt> or <tt>notregexmatch</tt> to match a string against a regular expression. For example, to ignore all functions having @@ -2039,6 +2023,14 @@ %rename("$ignore", regextarget=1) "Old$"; </pre> </div> +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 <tt>fullname</tt> attribute: +<div class="code"> +<pre> +%rename("$ignore", regextarget=1, fullname=1) "NameSpace::ClassName::.*Old$"; +</pre> +</div> <p> As for <tt>notregexmatch</tt>, it restricts the match only to the strings not This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2011-02-04 19:51:01
|
Revision: 12429 http://swig.svn.sourceforge.net/swig/?rev=12429&view=rev Author: wsfulton Date: 2011-02-04 19:50:55 +0000 (Fri, 04 Feb 2011) Log Message: ----------- SF #3141139 better callback documentation Modified Paths: -------------- trunk/Doc/Manual/SWIG.html Modified: trunk/Doc/Manual/SWIG.html =================================================================== --- trunk/Doc/Manual/SWIG.html 2011-02-04 19:43:24 UTC (rev 12428) +++ trunk/Doc/Manual/SWIG.html 2011-02-04 19:50:55 UTC (rev 12429) @@ -2236,7 +2236,8 @@ And now, a final note about function pointer support. Although SWIG does not normally allow callback functions to be written in the target language, this can be accomplished with the use of typemaps and other advanced SWIG features. -This is described in a later chapter. +See the <a href="Typemaps.html#Typemaps">Typemaps chapter</a> for more about typemaps +and individual target language chapters for more on callbacks and the 'director' feature. </p> <H2><a name="SWIG_nn31"></a>5.5 Structures and unions</H2> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |