Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>SWIG provides a <code>%rename</code> directive that allows the names to be different in the client and implementation languages. <strike>But doing this will nearly double the length of the interface file.</strike></p> <p>Actually, SWIG provides bulk renaming. See <a href="http://swig.org/Doc2.0/SWIG.html#SWIG_advanced_renaming" rel="nofollow">the documentation</a></p> <blockquote> <p>5.4.7.2 Advanced renaming support</p> <p>While writing %rename 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, 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> <pre><code>%rename("myprefix_%s") ""; // print -&gt; myprefix_print </code></pre> <p>This also shows that the argument of %rename doesn't have to be a literal string but can be a printf()-like format string. In the simplest form, "%s" 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 do_something_long() as more Java-like doSomethingLong() you can use the "lowercamelcase" extended format specifier like this:</p> <pre><code>%rename("%(lowercamelcase)s") ""; // foo_bar -&gt; fooBar; FooBar -&gt; fooBar </code></pre> <p>Some functions can be parametrized, for example the "strip" 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:</p> <pre><code>%rename("%(strip:[wx])s") ""; // wxHello -&gt; Hello; FooBar -&gt; FooBar </code></pre> </blockquote> <p>My recommendation is just to leave it as-is. You're calling C++ functions, they have C++ names. If anything, this helps you remember that you're calling out to C++ and need to follow C++ rules for object lifetime management, there's a slight JNI performance penalty, etc.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload