fix extern declarations documentation
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7323 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
62552082be
commit
06adaed870
8 changed files with 89 additions and 4 deletions
|
|
@ -313,9 +313,11 @@ rebuild the interpreter. For example:
|
|||
<div class="code"><pre>
|
||||
%module example
|
||||
|
||||
%inline %{
|
||||
extern int fact(int);
|
||||
extern int mod(int, int);
|
||||
extern double My_variable;
|
||||
%}
|
||||
|
||||
%include embed.i // Include code for a static version of Python
|
||||
|
||||
|
|
@ -830,8 +832,10 @@ For example, consider this interface
|
|||
// SWIG interface file with global variables
|
||||
%module example
|
||||
...
|
||||
%inline %{
|
||||
extern int My_variable;
|
||||
extern double density;
|
||||
%}
|
||||
...
|
||||
</pre></div>
|
||||
<p>
|
||||
|
|
@ -874,6 +878,9 @@ To make ordinary variables read-only, you can use the <tt>%immutable</tt> direct
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%{
|
||||
extern char *path;
|
||||
%}
|
||||
%immutable;
|
||||
extern char *path;
|
||||
%mutable;
|
||||
|
|
@ -891,6 +898,9 @@ If you just want to make a specific variable immutable, supply a declaration nam
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%{
|
||||
extern char *path;
|
||||
%}
|
||||
%immutable path;
|
||||
...
|
||||
extern char *path; // Read-only (due to %immutable)
|
||||
|
|
@ -3406,7 +3416,10 @@ If you must work with simple pointers such as <tt>int *</tt> or <tt>double *</tt
|
|||
%module example
|
||||
%include "cpointer.i"
|
||||
|
||||
%inline %{
|
||||
extern void add(int x, int y, int *result);
|
||||
%}
|
||||
|
||||
%pointer_functions(int, intp);
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -3632,7 +3645,9 @@ you might define a typemap like this:
|
|||
$1 = (int) PyLong_AsLong($input);
|
||||
printf("Received an integer : %d\n",$1);
|
||||
}
|
||||
%inline %{
|
||||
extern int fact(int n);
|
||||
%}
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -3671,7 +3686,9 @@ You can refine this by supplying an optional parameter name. For example:
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
%inline %{
|
||||
extern int fact(int nonnegative);
|
||||
%}
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -3692,8 +3709,10 @@ the typemap system follows <tt>typedef</tt> declarations. For example:
|
|||
$1 = (int) PyLong_AsLong($input);
|
||||
printf("n = %d\n",$1);
|
||||
}
|
||||
%inline %{
|
||||
typedef int Integer;
|
||||
extern int fact(Integer n); // Above typemap is applied
|
||||
%}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue