Realign for some comments.

This commit is contained in:
sunoru 2016-12-31 23:29:45 +08:00
commit 9a6f82ab31
12 changed files with 35 additions and 35 deletions

View file

@ -602,7 +602,7 @@ For the <tt>%array_functions</tt> example, the equivalent usage would be:
<pre> <pre>
SWIGTYPE_p_double a = example.new_doubleArray(10); // Create an array SWIGTYPE_p_double a = example.new_doubleArray(10); // Create an array
for (int i=0; i&lt;10; i++) for (int i=0; i&lt;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.print_array(a); // Pass to C
example.delete_doubleArray(a); // Destroy array example.delete_doubleArray(a); // Destroy array
</pre> </pre>
@ -2160,8 +2160,8 @@ The typemaps to achieve this are shown below.
%typemap(cstype) CDate &amp; "out System.DateTime" %typemap(cstype) CDate &amp; "out System.DateTime"
%typemap(csin, %typemap(csin,
pre=" CDate temp$csinput = new CDate();", pre=" CDate temp$csinput = new CDate();",
post=" $csinput = new System.DateTime(temp$csinput.getYear(), " post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
cshin="out $csinput" cshin="out $csinput"
) CDate &amp; ) CDate &amp;
"$csclassname.getCPtr(temp$csinput)" "$csclassname.getCPtr(temp$csinput)"
@ -2266,8 +2266,8 @@ will be possible with the following <tt>CDate *</tt> typemaps
%typemap(csin, %typemap(csin,
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
post=" $csinput = new System.DateTime(temp$csinput.getYear(), " post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
cshin="ref $csinput" cshin="ref $csinput"
) CDate * ) CDate *
"$csclassname.getCPtr(temp$csinput)" "$csclassname.getCPtr(temp$csinput)"
@ -2305,8 +2305,8 @@ The <tt>subtractYears</tt> method is nearly identical to the above <tt>addYears<
<pre> <pre>
%typemap(csin, %typemap(csin,
pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {", pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
post=" $csinput = new System.DateTime(temp$csinput.getYear(), " post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
terminator=" } // terminate temp$csinput using block", terminator=" } // terminate temp$csinput using block",
cshin="ref $csinput" cshin="ref $csinput"
) CDate * ) CDate *
@ -2377,8 +2377,8 @@ The typemap type required is thus <tt>CDate *</tt>. Given that the previous sect
%typemap(csin, %typemap(csin,
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
post=" $csinput = new System.DateTime(temp$csinput.getYear(), " post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
cshin="ref $csinput" cshin="ref $csinput"
) CDate * ) CDate *
"$csclassname.getCPtr(temp$csinput)" "$csclassname.getCPtr(temp$csinput)"

View file

@ -295,9 +295,9 @@
<p> <p>
The author of TinyCLOS, Gregor Kiczales, describes TinyCLOS as: 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 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) weighing in at around 850 lines of code, including (some)
comments and documentation." comments and documentation."
</p> </p>
@ -420,7 +420,7 @@ See the
Loading-extension-libraries in the eval unit inside the CHICKEN manual for more information.</p> 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> <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"> <div class="targetlang">
<pre> <pre>

View file

@ -645,7 +645,7 @@ you can attach it to class members and parameterized declarations as before. Fo
<div class="code"> <div class="code">
<pre> <pre>
%newobject ::blah(); // Only applies to global blah %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 %newobject *::copy; // Copy method in all classes
... ...
</pre> </pre>
@ -914,13 +914,13 @@ int red; // mutable
%feature("immutable"); // global enable %feature("immutable"); // global enable
int orange; // immutable int orange; // immutable
%feature("immutable", "0"); // global disable %feature("immutable", "0"); // global disable
int yellow; // mutable int yellow; // mutable
%feature("immutable", "1"); // another form of global enable %feature("immutable", "1"); // another form of global enable
int green; // immutable int green; // immutable
%feature("immutable", ""); // clears the global feature %feature("immutable", ""); // clears the global feature
int blue; // mutable int blue; // mutable
</pre> </pre>
</div> </div>

View file

@ -1337,7 +1337,7 @@ func Modf(x float64) (fracPart float64, intPart float64) {
<p>For classes, since swig generates an interface, you can add additional <p>For classes, since swig generates an interface, you can add additional
methods by defining another interface that includes the swig-generated methods by defining another interface that includes the swig-generated
interface. For example, </p> interface. For example,</p>
<div class="code"> <div class="code">
<pre> <pre>
%rename(Wrapped_MyClass) MyClass; %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> 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 <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"> <div class="code">
<pre> <pre>
%go_import("fmt", _ "unusedPackage", rp "renamed/package") %go_import("fmt", _ "unusedPackage", rp "renamed/package")

View file

@ -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 <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 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> <div class="targetlang"><pre>
(use-modules ((Test-primitive) #:renamer (symbol-prefix-proc 'primitive:))) (use-modules ((Test-primitive) #:renamer (symbol-prefix-proc 'primitive:)))
(use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))

View file

@ -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 "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>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>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 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>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" <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"

View file

@ -195,7 +195,7 @@ Now, in Python:
<pre> <pre>
&gt;&gt;&gt; import example &gt;&gt;&gt; import example
&gt;&gt;&gt; c = example.new_intp() # Create an "int" for storing result &gt;&gt;&gt; c = example.new_intp() # Create an "int" for storing result
&gt;&gt;&gt; example.add(3, 4, c) # Call function &gt;&gt;&gt; example.add(3, 4, c) # Call function
&gt;&gt;&gt; example.intp_value(c) # Dereference &gt;&gt;&gt; example.intp_value(c) # Dereference
7 7
&gt;&gt;&gt; example.delete_intp(c) # Delete &gt;&gt;&gt; example.delete_intp(c) # Delete
@ -275,7 +275,7 @@ Now, in Python (using proxy classes)
<pre> <pre>
&gt;&gt;&gt; import example &gt;&gt;&gt; import example
&gt;&gt;&gt; c = example.intp() # Create an "int" for storing result &gt;&gt;&gt; c = example.intp() # Create an "int" for storing result
&gt;&gt;&gt; example.add(3, 4, c) # Call function &gt;&gt;&gt; example.add(3, 4, c) # Call function
&gt;&gt;&gt; c.value() # Dereference &gt;&gt;&gt; c.value() # Dereference
7 7
</pre> </pre>
@ -413,11 +413,11 @@ Now, in a scripting language, you might write this:
<div class="code"> <div class="code">
<pre> <pre>
a = new_doubleArray(10) # Create an array a = new_doubleArray(10) # Create an array
for i in range(0, 10): for i in range(0, 10):
doubleArray_setitem(a, i, 2*i) # Set a value doubleArray_setitem(a, i, 2*i) # Set a value
print_array(a) # Pass to C print_array(a) # Pass to C
delete_doubleArray(a) # Destroy array delete_doubleArray(a) # Destroy array
</pre> </pre>
</div> </div>

View file

@ -1109,7 +1109,7 @@ Now, in Lua
&gt; e = c + d &gt; e = c + d
&gt; print(e) -- print uses __str__ to get the string form to print &gt; print(e) -- print uses __str__ to get the string form to print
Complex(10, 12) Complex(10, 12)
&gt; print(e==Complex(10, 12)) -- testing the == operator &gt; print(e==Complex(10, 12)) -- testing the == operator
true true
&gt; print(e!=Complex(12, 12)) -- the != uses the == operator &gt; print(e!=Complex(12, 12)) -- the != uses the == operator
true 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> <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"> <div class="code">
<pre>char *foo() { <pre>char *foo() {
char *result = (char *) malloc(...); char *result = (char *) malloc(...);

View file

@ -841,7 +841,7 @@ In Perl:
<div class="targetlang"> <div class="targetlang">
<pre> <pre>
use example; use example;
print $example::FOO, "\n"; # OK print $example::FOO, "\n"; # OK
$example::FOO = 2; # Error $example::FOO = 2; # Error
</pre> </pre>
</div> </div>
@ -1004,7 +1004,7 @@ These functions are then used to access structure data from Perl as follows:
<div class="targetlang"><pre> <div class="targetlang"><pre>
$v = example::new_Vector(); $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 example::Vector_x_set($v, 7.8); # Change x component
</pre></div> </pre></div>
@ -1286,7 +1286,7 @@ a single Perl module. The name of the module is determined by the
<div class="targetlang"><pre> <div class="targetlang"><pre>
$ perl5 $ perl5
use example; # load the example module 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 24
</pre></div> </pre></div>
@ -2216,7 +2216,7 @@ use argv;
@a = ("Dave", "Mike", "John", "Mary"); # Create an array of strings @a = ("Dave", "Mike", "John", "Mary"); # Create an array of strings
argv::print_args(\@a); # Pass it to our C function argv::print_args(\@a); # Pass it to our C function
$b = argv::get_args(); # Get array of strings from C $b = argv::get_args(); # Get array of strings from C
print @$b, "\n"; # Print it out print @$b, "\n"; # Print it out
</pre></div> </pre></div>

View file

@ -4941,7 +4941,7 @@ in SWIG-1.3.26. and later.</p>
SWIG automatically keeps track of mappings between C++ objects and Ruby SWIG automatically keeps track of mappings between C++ objects and Ruby
objects. Note that enabling object tracking causes a slight performance objects. Note that enabling object tracking causes a slight performance
degradation. Test results show this degradation to be about 3% to 5% 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>, <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 it uses the same name matching rules as other kinds of features (see

View file

@ -649,7 +649,7 @@ print cvar.foo # Print value of foo
# Perl # Perl
$foo = 3.5; # Set foo to 3.5 $foo = 3.5; # Set foo to 3.5
print $foo, "\n"; # Print value of foo print $foo, "\n"; # Print value of foo
# Ruby # Ruby
Module.foo = 3.5 # Set foo to 3.5 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> <div class="code"><pre>
%immutable; // Make all variables read-only %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 x;
double y; double y;

View file

@ -4421,7 +4421,7 @@ You can access the functions in a normal way from the scripting interpreter:
# Python # Python
foo(3) # foo(int) foo(3) # foo(int)
foo(3.5) # foo(double) foo(3.5) # foo(double)
foo("hello", 5) # foo(char *, int) foo("hello", 5) # foo(char *, int)
# Tcl # Tcl
foo 3 # foo(int) foo 3 # foo(int)