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
|
|
@ -282,13 +282,13 @@ class FooProxy {
|
|||
delete_Foo(self);
|
||||
}
|
||||
int bar(int x) {
|
||||
return Foo_bar(self,x);
|
||||
return Foo_bar(self, x);
|
||||
}
|
||||
int x_get() {
|
||||
return Foo_x_get(self);
|
||||
}
|
||||
void x_set(int x) {
|
||||
Foo_x_set(self,x);
|
||||
Foo_x_set(self, x);
|
||||
}
|
||||
};
|
||||
</pre>
|
||||
|
|
@ -306,15 +306,15 @@ class Foo:
|
|||
self.this = new_Foo()
|
||||
def __del__(self):
|
||||
delete_Foo(self.this)
|
||||
def bar(self,x):
|
||||
return Foo_bar(self.this,x)
|
||||
def __getattr__(self,name):
|
||||
def bar(self, x):
|
||||
return Foo_bar(self.this, x)
|
||||
def __getattr__(self, name):
|
||||
if name == 'x':
|
||||
return Foo_x_get(self.this)
|
||||
...
|
||||
def __setattr__(self,name,value):
|
||||
def __setattr__(self, name, value):
|
||||
if name == 'x':
|
||||
Foo_x_set(self.this,value)
|
||||
Foo_x_set(self.this, value)
|
||||
...
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -442,7 +442,7 @@ class SpamProxy {
|
|||
return FooPtrProxy(Spam_value_get(self));
|
||||
}
|
||||
void value_set(FooProxy *v) {
|
||||
Spam_value_set(self,v->self);
|
||||
Spam_value_set(self, v->self);
|
||||
v->disown();
|
||||
}
|
||||
...
|
||||
|
|
@ -1435,7 +1435,7 @@ following:
|
|||
Vector *wrap_cross_product(Vector *a, Vector *b) {
|
||||
Vector x = *a;
|
||||
Vector y = *b;
|
||||
Vector r = cross_product(x,y);
|
||||
Vector r = cross_product(x, y);
|
||||
return new Vector(r);
|
||||
}</pre>
|
||||
</div>
|
||||
|
|
@ -1457,7 +1457,7 @@ called the "Fulton Transform". This produces a wrapper that looks like this:
|
|||
Vector cross_product(Vector *a, Vector *b) {
|
||||
SwigValueWrapper<Vector> x = *a;
|
||||
SwigValueWrapper<Vector> y = *b;
|
||||
SwigValueWrapper<Vector> r = cross_product(x,y);
|
||||
SwigValueWrapper<Vector> r = cross_product(x, y);
|
||||
return new Vector(r);
|
||||
}
|
||||
</pre>
|
||||
|
|
@ -1550,7 +1550,7 @@ the full C++ code has been omitted.</p>
|
|||
|
||||
class Shape {
|
||||
public:
|
||||
double x,y;
|
||||
double x, y;
|
||||
virtual double area() = 0;
|
||||
virtual double perimeter() = 0;
|
||||
void set_location(double x, double y);
|
||||
|
|
@ -1586,7 +1586,7 @@ $ python
|
|||
153.93804004599999757
|
||||
>>> print shapes.Shape_area(square)
|
||||
100.00000000000000000
|
||||
>>> shapes.Shape_set_location(square,2,-3)
|
||||
>>> shapes.Shape_set_location(square, 2, -3)
|
||||
>>> print shapes.Shape_perimeter(square)
|
||||
40.00000000000000000
|
||||
>>>
|
||||
|
|
@ -1892,7 +1892,7 @@ it might be used like this
|
|||
>>> f = Foo() # Create a Foo
|
||||
>>> f.bar(3)
|
||||
>>> g = Foo(f) # Copy Foo
|
||||
>>> f.bar("hello",2)
|
||||
>>> f.bar("hello", 2)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -2129,7 +2129,7 @@ If you get an error message such as the following,
|
|||
<pre>
|
||||
foo.i:6. Overloaded declaration ignored. Spam::foo(double )
|
||||
foo.i:5. Previous declaration is Spam::foo(int )
|
||||
foo.i:7. Overloaded declaration ignored. Spam::foo(Bar *,Spam *,int )
|
||||
foo.i:7. Overloaded declaration ignored. Spam::foo(Bar *, Spam *, int )
|
||||
foo.i:5. Previous declaration is Spam::foo(int )
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -2674,8 +2674,8 @@ operator normally. For example:
|
|||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
>>> a = Complex(3,4)
|
||||
>>> b = Complex(5,2)
|
||||
>>> a = Complex(3, 4)
|
||||
>>> b = Complex(5, 2)
|
||||
>>> c = a + b # Invokes __add__ method
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -2698,8 +2698,8 @@ The resulting scripting interface might work like this:
|
|||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
a = Complex(3,4)
|
||||
b = Complex(5,2)
|
||||
a = Complex(3, 4)
|
||||
b = Complex(5, 2)
|
||||
c = a.add(b) # Call a.operator+(b)
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -2807,14 +2807,14 @@ example :
|
|||
|
||||
class Vector {
|
||||
public:
|
||||
double x,y,z;
|
||||
double x, y, z;
|
||||
Vector();
|
||||
~Vector();
|
||||
... bunch of C++ methods ...
|
||||
%extend {
|
||||
char *__str__() {
|
||||
static char temp[256];
|
||||
sprintf(temp,"[ %g, %g, %g ]", $self->x,$self->y,$self->z);
|
||||
sprintf(temp, "[ %g, %g, %g ]", $self->x, $self->y, $self->z);
|
||||
return &temp[0];
|
||||
}
|
||||
}
|
||||
|
|
@ -2899,7 +2899,7 @@ is expected in an interface file. For example:
|
|||
<div class="code">
|
||||
<pre>
|
||||
void foo(vector<int> *a, int n);
|
||||
void bar(list<int,100> *x);
|
||||
void bar(list<int, 100> *x);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -2912,9 +2912,9 @@ and '>' within a constant expressions currently is not supported by SWIG
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
void bar(list<int,100> *x); // OK
|
||||
void bar(list<int,2*50> *x); // OK
|
||||
void bar(list<int,(2>1 ? 100 : 50)> *x) // Not supported
|
||||
void bar(list<int, 100> *x); // OK
|
||||
void bar(list<int, 2*50> *x); // OK
|
||||
void bar(list<int, (2>1 ? 100 : 50)> *x) // Not supported
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -3085,7 +3085,7 @@ template vector<typename T, int max=100> class vector {
|
|||
};
|
||||
|
||||
%template(intvec) vector<int>; // OK
|
||||
%template(vec1000) vector<int,1000>; // OK
|
||||
%template(vec1000) vector<int, 1000>; // OK
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -3205,8 +3205,8 @@ use the empty template instantiation, that is, <tt>%template</tt> with no name.
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
// Instantiate traits<double,double>, but don't wrap it.
|
||||
%template() traits<double,double>;
|
||||
// Instantiate traits<double, double>, but don't wrap it.
|
||||
%template() traits<double, double>;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -3466,8 +3466,8 @@ template<class T1, class T2> struct pair {
|
|||
T2 second;
|
||||
pair() : first(T1()), second(T2()) { }
|
||||
pair(const T1 &x, const T2 &y) : first(x), second(y) { }
|
||||
template<class U1, class U2> pair(const pair<U1,U2> &x)
|
||||
: first(x.first),second(x.second) { }
|
||||
template<class U1, class U2> pair(const pair<U1, U2> &x)
|
||||
: first(x.first), second(x.second) { }
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -3481,7 +3481,7 @@ in the template class itself. For example:
|
|||
<div class="code">
|
||||
<pre>
|
||||
%extend pair {
|
||||
%template(pair) pair<T1,T2>; // Generate default copy constructor
|
||||
%template(pair) pair<T1, T2>; // Generate default copy constructor
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -3498,18 +3498,18 @@ Alternatively, you could expand the constructor template in selected instantiati
|
|||
<div class="code">
|
||||
<pre>
|
||||
// Instantiate a few versions
|
||||
%template(pairii) pair<int,int>;
|
||||
%template(pairdd) pair<double,double>;
|
||||
%template(pairii) pair<int, int>;
|
||||
%template(pairdd) pair<double, double>;
|
||||
|
||||
// Create a default constructor only
|
||||
%extend pair<int,int> {
|
||||
%template(paird) pair<int,int>; // Default constructor
|
||||
%extend pair<int, int> {
|
||||
%template(paird) pair<int, int>; // Default constructor
|
||||
};
|
||||
|
||||
// Create default and conversion constructors
|
||||
%extend pair<double,double> {
|
||||
%template(paird) pair<double,dobule>; // Default constructor
|
||||
%template(pairc) pair<int,int>; // Conversion constructor
|
||||
%extend pair<double, double> {
|
||||
%template(paird) pair<double, dobule>; // Default constructor
|
||||
%template(pairc) pair<int, int>; // Conversion constructor
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -3522,9 +3522,9 @@ instead:
|
|||
<div class="code">
|
||||
<pre>
|
||||
// Create default and conversion constructors
|
||||
%extend pair<double,double> {
|
||||
%template(pair) pair<double,dobule>; // Default constructor
|
||||
%template(pair) pair<int,int>; // Conversion constructor
|
||||
%extend pair<double, double> {
|
||||
%template(pair) pair<double, dobule>; // Default constructor
|
||||
%template(pair) pair<int, int>; // Conversion constructor
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -3745,7 +3745,7 @@ namespace math {
|
|||
double cos(double);
|
||||
|
||||
class Complex {
|
||||
double im,re;
|
||||
double im, re;
|
||||
public:
|
||||
...
|
||||
};
|
||||
|
|
@ -4364,7 +4364,7 @@ write code like this:
|
|||
f = Foo()
|
||||
try:
|
||||
f.blah()
|
||||
except Error,e:
|
||||
except Error, e:
|
||||
# e is a wrapped instance of "Error"
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -4403,14 +4403,14 @@ struct Error2 : EBase { };
|
|||
struct Error3 : EBase { };
|
||||
struct Error4 : EBase { };
|
||||
|
||||
%catches(Error1,Error2,...) Foo::bar();
|
||||
%catches(Error1, Error2, ...) Foo::bar();
|
||||
%catches(EBase) Foo::blah();
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
...
|
||||
void bar();
|
||||
void blah() throw(Error1,Error2,Error3,Error4);
|
||||
void blah() throw(Error1, Error2, Error3, Error4);
|
||||
...
|
||||
};
|
||||
</pre>
|
||||
|
|
@ -4441,9 +4441,9 @@ For example:
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
double do_op(Object *o, double (Object::*callback)(double,double));
|
||||
extern double (Object::*fooptr)(double,double);
|
||||
%constant double (Object::*FOO)(double,double) = &Object::foo;
|
||||
double do_op(Object *o, double (Object::*callback)(double, double));
|
||||
extern double (Object::*fooptr)(double, double);
|
||||
%constant double (Object::*FOO)(double, double) = &Object::foo;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue