Fix some typos in docs and examples and make the code look nicer.
This commit is contained in:
parent
70801d47d1
commit
8985c34809
45 changed files with 717 additions and 717 deletions
|
|
@ -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"
|
||||
|
|
@ -1267,7 +1267,7 @@ When wrapped, you will be able to use the functions in a natural way from Java.
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
SWIGTYPE_p_FILE f = example.fopen("junk","w");
|
||||
SWIGTYPE_p_FILE f = example.fopen("junk", "w");
|
||||
example.fputs("Hello World\n", f);
|
||||
example.fclose(f);
|
||||
</pre>
|
||||
|
|
@ -1341,7 +1341,7 @@ member variables. For example,
|
|||
|
||||
<div class="code"><pre>
|
||||
struct Vector {
|
||||
double x,y,z;
|
||||
double x, y, z;
|
||||
};
|
||||
|
||||
</pre></div>
|
||||
|
|
@ -1878,7 +1878,7 @@ submodules or packages. For example, if you have a file like this,
|
|||
namespace foo {
|
||||
int fact(int n);
|
||||
struct Vector {
|
||||
double x,y,z;
|
||||
double x, y, z;
|
||||
};
|
||||
};
|
||||
</pre>
|
||||
|
|
@ -1978,7 +1978,7 @@ struct pair {
|
|||
~pair();
|
||||
};
|
||||
|
||||
%template(pairii) pair<int,int>;
|
||||
%template(pairii) pair<int, int>;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -1988,7 +1988,7 @@ In Java:
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
pairii p = new pairii(3,4);
|
||||
pairii p = new pairii(3, 4);
|
||||
int first = p.getFirst();
|
||||
int second = p.getSecond();
|
||||
</pre>
|
||||
|
|
@ -4285,11 +4285,11 @@ From Java, you could then write code like this:
|
|||
<pre>
|
||||
Image im = new Image();
|
||||
SWIGTYPE_p_a_4__double a = example.new_mat44();
|
||||
example.mat44_set(a,0,0,1.0);
|
||||
example.mat44_set(a,1,1,1.0);
|
||||
example.mat44_set(a,2,2,1.0);
|
||||
example.mat44_set(a, 0, 0, 1.0);
|
||||
example.mat44_set(a, 1, 1, 1.0);
|
||||
example.mat44_set(a, 2, 2, 1.0);
|
||||
...
|
||||
example.set_transform(im,a);
|
||||
example.set_transform(im, a);
|
||||
example.free_mat44(a);
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -4317,13 +4317,13 @@ Here is a simple example:
|
|||
%}
|
||||
|
||||
struct Vector {
|
||||
double x,y,z;
|
||||
double x, y, z;
|
||||
};
|
||||
|
||||
%extend Vector {
|
||||
char *toString() {
|
||||
static char tmp[1024];
|
||||
sprintf(tmp,"Vector(%g,%g,%g)", $self->x,$self->y,$self->z);
|
||||
sprintf(tmp, "Vector(%g, %g, %g)", $self->x, $self->y, $self->z);
|
||||
return tmp;
|
||||
}
|
||||
Vector(double x, double y, double z) {
|
||||
|
|
@ -4343,7 +4343,7 @@ Now, in Java
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
Vector v = new Vector(2,3,4);
|
||||
Vector v = new Vector(2, 3, 4);
|
||||
System.out.println(v);
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -4354,7 +4354,7 @@ will display
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
Vector(2,3,4)
|
||||
Vector(2, 3, 4)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -4606,10 +4606,10 @@ In Java, this allows you to pass simple values. For example:
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
int result = example.sub(7,4);
|
||||
int result = example.sub(7, 4);
|
||||
System.out.println("7 - 4 = " + result);
|
||||
int[] sum = {0};
|
||||
example.add(3,4,sum);
|
||||
example.add(3, 4, sum);
|
||||
System.out.println("3 + 4 = " + sum[0]);
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -4754,7 +4754,7 @@ extern void add(int x, int y, int *result);
|
|||
</div>
|
||||
|
||||
<p>
|
||||
The <tt>%pointer_functions(type,name)</tt> macro generates five helper functions that can be used to create,
|
||||
The <tt>%pointer_functions(type, name)</tt> macro generates five helper functions that can be used to create,
|
||||
destroy, copy, assign, and dereference a pointer. In this case, the functions are as follows:
|
||||
</p>
|
||||
|
||||
|
|
@ -4775,20 +4775,20 @@ In Java, you would use the functions like this:
|
|||
<div class="code">
|
||||
<pre>
|
||||
SWIGTYPE_p_int intPtr = example.new_intp();
|
||||
example.add(3,4,intPtr);
|
||||
example.add(3, 4, intPtr);
|
||||
int result = example.intp_value(intPtr);
|
||||
System.out.println("3 + 4 = " + result);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
If you replace <tt>%pointer_functions(int,intp)</tt> by <tt>%pointer_class(int,intp)</tt>, the interface is more class-like.
|
||||
If you replace <tt>%pointer_functions(int, intp)</tt> by <tt>%pointer_class(int, intp)</tt>, the interface is more class-like.
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
intp intPtr = new intp();
|
||||
example.add(3,4,intPtr.cast());
|
||||
example.add(3, 4, intPtr.cast());
|
||||
int result = intPtr.value();
|
||||
System.out.println("3 + 4 = " + result);
|
||||
</pre>
|
||||
|
|
@ -4907,7 +4907,7 @@ int[] array = new int[10000000]; // Array of 10-million integers
|
|||
for (int i=0; i<array.length; i++) { // Set some values
|
||||
array[i] = i;
|
||||
}
|
||||
int sum = example.sumitems(array,10000);
|
||||
int sum = example.sumitems(array, 10000);
|
||||
System.out.println("Sum = " + sum);
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -4939,7 +4939,7 @@ For example:
|
|||
</div>
|
||||
|
||||
<p>
|
||||
The <tt>%array_functions(type,name)</tt> macro generates four helper functions that can be used to create and
|
||||
The <tt>%array_functions(type, name)</tt> macro generates four helper functions that can be used to create and
|
||||
destroy arrays and operate on elements. In this case, the functions are as follows:
|
||||
</p>
|
||||
|
||||
|
|
@ -4960,15 +4960,15 @@ In Java, you would use the functions like this:
|
|||
<pre>
|
||||
SWIGTYPE_p_int array = example.new_intArray(10000000); // Array of 10-million integers
|
||||
for (int i=0; i<10000; i++) { // Set some values
|
||||
example.intArray_setitem(array,i,i);
|
||||
example.intArray_setitem(array, i, i);
|
||||
}
|
||||
int sum = example.sumitems(array,10000);
|
||||
int sum = example.sumitems(array, 10000);
|
||||
System.out.println("Sum = " + sum);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
If you replace <tt>%array_functions(int,intp)</tt> by <tt>%array_class(int,intp)</tt>, the interface is more class-like
|
||||
If you replace <tt>%array_functions(int, intp)</tt> by <tt>%array_class(int, intp)</tt>, the interface is more class-like
|
||||
and a couple more helper functions are available for casting between the array and the type wrapper class.
|
||||
</p>
|
||||
|
||||
|
|
@ -4989,9 +4989,9 @@ For instance, you will be able to do this in Java:
|
|||
<pre>
|
||||
intArray array = new intArray(10000000); // Array of 10-million integers
|
||||
for (int i=0; i<10000; i++) { // Set some values
|
||||
array.setitem(i,i);
|
||||
array.setitem(i, i);
|
||||
}
|
||||
int sum = example.sumitems(array.cast(),10000);
|
||||
int sum = example.sumitems(array.cast(), 10000);
|
||||
System.out.println("Sum = " + sum);
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -5491,7 +5491,7 @@ parameter is omitted):
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
int c = example.count('e',"Hello World");
|
||||
int c = example.count('e', "Hello World");
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -5814,7 +5814,7 @@ Note that when the 'pre' or 'post' attributes are specified and the associated t
|
|||
|
||||
|
||||
<p>
|
||||
The standard SWIG special variables are available for use within typemaps as described in the <a href="Typemaps.html#Typemaps">Typemaps documentation</a>, for example <tt>$1</tt>, <tt>$input</tt>,<tt>$result</tt> etc.
|
||||
The standard SWIG special variables are available for use within typemaps as described in the <a href="Typemaps.html#Typemaps">Typemaps documentation</a>, for example <tt>$1</tt>, <tt>$input</tt>, <tt>$result</tt> etc.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
@ -6337,7 +6337,7 @@ For example, integers are converted as follows:
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%typemap(directorin,descriptor="I") int "$input = (jint) $1;"
|
||||
%typemap(directorin, descriptor="I") int "$input = (jint) $1;"
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -7072,7 +7072,7 @@ public class runme {
|
|||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
String animals[] = {"Cat","Dog","Cow","Goat"};
|
||||
String animals[] = {"Cat", "Dog", "Cow", "Goat"};
|
||||
example.print_args(animals);
|
||||
String args[] = example.get_args();
|
||||
for (int i=0; i<args.length; i++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue