mirror of https://github.com/swig/swig
Realign for some comments.
This commit is contained in:
parent
8985c34809
commit
9a6f82ab31
|
@ -602,7 +602,7 @@ For the <tt>%array_functions</tt> example, the equivalent usage would be:
|
|||
<pre>
|
||||
SWIGTYPE_p_double a = example.new_doubleArray(10); // Create an array
|
||||
for (int i=0; i<10; i++)
|
||||
example.doubleArray_setitem(a, i, 2*i); // Set a value
|
||||
example.doubleArray_setitem(a, i, 2*i); // Set a value
|
||||
example.print_array(a); // Pass to C
|
||||
example.delete_doubleArray(a); // Destroy array
|
||||
</pre>
|
||||
|
@ -2160,8 +2160,8 @@ The typemaps to achieve this are shown below.
|
|||
%typemap(cstype) CDate & "out System.DateTime"
|
||||
%typemap(csin,
|
||||
pre=" CDate temp$csinput = new CDate();",
|
||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(), "
|
||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||
cshin="out $csinput"
|
||||
) CDate &
|
||||
"$csclassname.getCPtr(temp$csinput)"
|
||||
|
@ -2266,8 +2266,8 @@ will be possible with the following <tt>CDate *</tt> typemaps
|
|||
|
||||
%typemap(csin,
|
||||
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
|
||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(), "
|
||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||
cshin="ref $csinput"
|
||||
) CDate *
|
||||
"$csclassname.getCPtr(temp$csinput)"
|
||||
|
@ -2305,8 +2305,8 @@ The <tt>subtractYears</tt> method is nearly identical to the above <tt>addYears<
|
|||
<pre>
|
||||
%typemap(csin,
|
||||
pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
|
||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(), "
|
||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||
terminator=" } // terminate temp$csinput using block",
|
||||
cshin="ref $csinput"
|
||||
) CDate *
|
||||
|
@ -2377,8 +2377,8 @@ The typemap type required is thus <tt>CDate *</tt>. Given that the previous sect
|
|||
|
||||
%typemap(csin,
|
||||
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
|
||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(), "
|
||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||
cshin="ref $csinput"
|
||||
) CDate *
|
||||
"$csclassname.getCPtr(temp$csinput)"
|
||||
|
|
|
@ -295,9 +295,9 @@
|
|||
|
||||
<p>
|
||||
The author of TinyCLOS, Gregor Kiczales, describes TinyCLOS as:
|
||||
"Tiny CLOS is a Scheme implementation of a `kernelized' CLOS, with a
|
||||
"Tiny CLOS is a Scheme implementation of a 'kernelized' CLOS, with a
|
||||
metaobject protocol. The implementation is even simpler than
|
||||
the simple CLOS found in `The Art of the Metaobject Protocol, '
|
||||
the simple CLOS found in 'The Art of the Metaobject Protocol',
|
||||
weighing in at around 850 lines of code, including (some)
|
||||
comments and documentation."
|
||||
</p>
|
||||
|
@ -420,7 +420,7 @@ See the
|
|||
Loading-extension-libraries in the eval unit inside the CHICKEN manual for more information.</p>
|
||||
|
||||
<p>Another alternative is to run SWIG normally and create a scheme file that contains <code>(declare (uses <i>modname</i>))</code>
|
||||
and then compile that file into the shared library as well. For example, inside the <tt>mod_load.scm</tt> file, </p>
|
||||
and then compile that file into the shared library as well. For example, inside the <tt>mod_load.scm</tt> file,</p>
|
||||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
|
|
|
@ -645,7 +645,7 @@ you can attach it to class members and parameterized declarations as before. Fo
|
|||
<div class="code">
|
||||
<pre>
|
||||
%newobject ::blah(); // Only applies to global blah
|
||||
%newobject Object::blah(int, double); // Only blah(int, double) in Object
|
||||
%newobject Object::blah(int, double); // Only blah(int, double) in Object
|
||||
%newobject *::copy; // Copy method in all classes
|
||||
...
|
||||
</pre>
|
||||
|
@ -914,13 +914,13 @@ int red; // mutable
|
|||
%feature("immutable"); // global enable
|
||||
int orange; // immutable
|
||||
|
||||
%feature("immutable", "0"); // global disable
|
||||
%feature("immutable", "0"); // global disable
|
||||
int yellow; // mutable
|
||||
|
||||
%feature("immutable", "1"); // another form of global enable
|
||||
%feature("immutable", "1"); // another form of global enable
|
||||
int green; // immutable
|
||||
|
||||
%feature("immutable", ""); // clears the global feature
|
||||
%feature("immutable", ""); // clears the global feature
|
||||
int blue; // mutable
|
||||
</pre>
|
||||
</div>
|
||||
|
|
|
@ -1337,7 +1337,7 @@ func Modf(x float64) (fracPart float64, intPart float64) {
|
|||
|
||||
<p>For classes, since swig generates an interface, you can add additional
|
||||
methods by defining another interface that includes the swig-generated
|
||||
interface. For example, </p>
|
||||
interface. For example,</p>
|
||||
<div class="code">
|
||||
<pre>
|
||||
%rename(Wrapped_MyClass) MyClass;
|
||||
|
@ -1372,7 +1372,7 @@ few, then you might as well define your own struct that includes the
|
|||
swig-wrapped object, instead of adding methods to the swig-generated object.</p>
|
||||
|
||||
<p>If you need to import other go packages, you can do this with
|
||||
<code>%go_import</code>. For example, </p>
|
||||
<code>%go_import</code>. For example,</p>
|
||||
<div class="code">
|
||||
<pre>
|
||||
%go_import("fmt", _ "unusedPackage", rp "renamed/package")
|
||||
|
|
|
@ -727,7 +727,7 @@ In the previous example, the GOOPS definitions will be in a file named Test.scm.
|
|||
|
||||
<p>Because of the naming conflicts, you can't in general use both the <code>-primitive</code> and the GOOPS
|
||||
guile-modules at the same time. To do this, you need to rename the exported symbols from one or both
|
||||
guile-modules. For example, </p>
|
||||
guile-modules. For example,</p>
|
||||
<div class="targetlang"><pre>
|
||||
(use-modules ((Test-primitive) #:renamer (symbol-prefix-proc 'primitive:)))
|
||||
(use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))
|
||||
|
|
|
@ -563,7 +563,7 @@ Don't worry if the wrapper file doesn't exist yet--Visual Studio will keep a ref
|
|||
<li>Enter "SWIG" in the description field.
|
||||
<li>Enter "<tt>swig -java -o $(ProjDir)\$(InputName)_wrap.c $(InputPath)</tt>" in the "Build command(s) field"
|
||||
<li>Enter "<tt>$(ProjDir)\$(InputName)_wrap.c</tt>" in the "Output files(s) field".
|
||||
<li>Next, select the settings for the entire project and go to C/C++ tab and select the Preprocessor category . Add the include directories to the JNI header files under "Additional include directories", eg "C:\jdk1.3\include, C:\jdk1.3\include\win32".
|
||||
<li>Next, select the settings for the entire project and go to C/C++ tab and select the Preprocessor category. Add the include directories to the JNI header files under "Additional include directories", eg "C:\jdk1.3\include, C:\jdk1.3\include\win32".
|
||||
<li>Next, select the settings for the entire project and go to Link tab and select the General category. Set the name of the output file to match the name of your Java module (ie. example.dll).
|
||||
<li>Next, select the example.c and example_wrap.c files and go to the C/C++ tab and select the Precompiled Headers tab in the project settings. Disabling precompiled headers for these files will overcome any precompiled header errors while building.
|
||||
<li>Finally, add the java compilation as a post build rule in the Post-build step tab in project settings, eg, "c:\jdk1.3\bin\javac *.java"
|
||||
|
|
|
@ -195,7 +195,7 @@ Now, in Python:
|
|||
<pre>
|
||||
>>> import example
|
||||
>>> c = example.new_intp() # Create an "int" for storing result
|
||||
>>> example.add(3, 4, c) # Call function
|
||||
>>> example.add(3, 4, c) # Call function
|
||||
>>> example.intp_value(c) # Dereference
|
||||
7
|
||||
>>> example.delete_intp(c) # Delete
|
||||
|
@ -275,7 +275,7 @@ Now, in Python (using proxy classes)
|
|||
<pre>
|
||||
>>> import example
|
||||
>>> c = example.intp() # Create an "int" for storing result
|
||||
>>> example.add(3, 4, c) # Call function
|
||||
>>> example.add(3, 4, c) # Call function
|
||||
>>> c.value() # Dereference
|
||||
7
|
||||
</pre>
|
||||
|
@ -413,11 +413,11 @@ Now, in a scripting language, you might write this:
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
a = new_doubleArray(10) # Create an array
|
||||
a = new_doubleArray(10) # Create an array
|
||||
for i in range(0, 10):
|
||||
doubleArray_setitem(a, i, 2*i) # Set a value
|
||||
print_array(a) # Pass to C
|
||||
delete_doubleArray(a) # Destroy array
|
||||
print_array(a) # Pass to C
|
||||
delete_doubleArray(a) # Destroy array
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1109,7 +1109,7 @@ Now, in Lua
|
|||
> e = c + d
|
||||
> print(e) -- print uses __str__ to get the string form to print
|
||||
Complex(10, 12)
|
||||
> print(e==Complex(10, 12)) -- testing the == operator
|
||||
> print(e==Complex(10, 12)) -- testing the == operator
|
||||
true
|
||||
> print(e!=Complex(12, 12)) -- the != uses the == operator
|
||||
true
|
||||
|
@ -1121,7 +1121,7 @@ Extend works with both C and C++ code, on classes and structs. It does not modif
|
|||
<H3><a name="Lua_nn20">28.3.13 Using %newobject to release memory</a></H3>
|
||||
|
||||
|
||||
<p> If you have a function that allocates memory like this, </p>
|
||||
<p> If you have a function that allocates memory like this,</p>
|
||||
<div class="code">
|
||||
<pre>char *foo() {
|
||||
char *result = (char *) malloc(...);
|
||||
|
|
|
@ -841,7 +841,7 @@ In Perl:
|
|||
<div class="targetlang">
|
||||
<pre>
|
||||
use example;
|
||||
print $example::FOO, "\n"; # OK
|
||||
print $example::FOO, "\n"; # OK
|
||||
$example::FOO = 2; # Error
|
||||
</pre>
|
||||
</div>
|
||||
|
@ -1004,7 +1004,7 @@ These functions are then used to access structure data from Perl as follows:
|
|||
|
||||
<div class="targetlang"><pre>
|
||||
$v = example::new_Vector();
|
||||
print example::Vector_x_get($v), "\n"; # Get x component
|
||||
print example::Vector_x_get($v), "\n"; # Get x component
|
||||
example::Vector_x_set($v, 7.8); # Change x component
|
||||
</pre></div>
|
||||
|
||||
|
@ -1286,7 +1286,7 @@ a single Perl module. The name of the module is determined by the
|
|||
<div class="targetlang"><pre>
|
||||
$ perl5
|
||||
use example; # load the example module
|
||||
print example::fact(4), "\n" # Call a function in it
|
||||
print example::fact(4), "\n" # Call a function in it
|
||||
24
|
||||
</pre></div>
|
||||
|
||||
|
@ -2216,7 +2216,7 @@ use argv;
|
|||
@a = ("Dave", "Mike", "John", "Mary"); # Create an array of strings
|
||||
argv::print_args(\@a); # Pass it to our C function
|
||||
$b = argv::get_args(); # Get array of strings from C
|
||||
print @$b, "\n"; # Print it out
|
||||
print @$b, "\n"; # Print it out
|
||||
</pre></div>
|
||||
|
||||
|
||||
|
|
|
@ -4941,7 +4941,7 @@ in SWIG-1.3.26. and later.</p>
|
|||
SWIG automatically keeps track of mappings between C++ objects and Ruby
|
||||
objects. Note that enabling object tracking causes a slight performance
|
||||
degradation. Test results show this degradation to be about 3% to 5%
|
||||
when creating and destroying 100, 000 animals in a row.</p>
|
||||
when creating and destroying 100,000 animals in a row.</p>
|
||||
|
||||
<p>Since <tt>%trackobjects</tt> is implemented as a <tt>%feature</tt>,
|
||||
it uses the same name matching rules as other kinds of features (see
|
||||
|
|
|
@ -649,7 +649,7 @@ print cvar.foo # Print value of foo
|
|||
|
||||
# Perl
|
||||
$foo = 3.5; # Set foo to 3.5
|
||||
print $foo, "\n"; # Print value of foo
|
||||
print $foo, "\n"; # Print value of foo
|
||||
|
||||
# Ruby
|
||||
Module.foo = 3.5 # Set foo to 3.5
|
||||
|
@ -1648,7 +1648,7 @@ If you wanted to make all wrapped variables read-only, barring one or two, it mi
|
|||
|
||||
<div class="code"><pre>
|
||||
%immutable; // Make all variables read-only
|
||||
%feature("immutable", "0") x; // except, make x read/write
|
||||
%feature("immutable", "0") x; // except, make x read/write
|
||||
...
|
||||
double x;
|
||||
double y;
|
||||
|
|
|
@ -4421,7 +4421,7 @@ You can access the functions in a normal way from the scripting interpreter:
|
|||
# Python
|
||||
foo(3) # foo(int)
|
||||
foo(3.5) # foo(double)
|
||||
foo("hello", 5) # foo(char *, int)
|
||||
foo("hello", 5) # foo(char *, int)
|
||||
|
||||
# Tcl
|
||||
foo 3 # foo(int)
|
||||
|
|
Loading…
Reference in New Issue