More consistent formatting of examples in documentation

This commit is contained in:
William S Fulton 2017-07-30 13:56:47 +01:00
commit 8052211ac5
6 changed files with 76 additions and 77 deletions

View file

@ -997,9 +997,9 @@ When the following C# code is executed:
<div class="code"> <div class="code">
<pre> <pre>
public class runme { public class runme {
static void Main() { static void Main() {
example.positivesonly(-1); example.positivesonly(-1);
} }
} }
</pre> </pre>
</div> </div>
@ -1846,12 +1846,12 @@ and the following usage from C# after running the code through SWIG:
<div class="code"> <div class="code">
<pre> <pre>
Wheel wheel = new Bike(10).getWheel(); Wheel wheel = new Bike(10).getWheel();
Console.WriteLine("wheel size: " + wheel.size); Console.WriteLine("wheel size: " + wheel.size);
// Simulate a garbage collection // Simulate a garbage collection
global::System.GC.Collect(); global::System.GC.Collect();
global::System.GC.WaitForPendingFinalizers(); global::System.GC.WaitForPendingFinalizers();
global::System.Console.WriteLine("wheel size: " + wheel.size); global::System.Console.WriteLine("wheel size: " + wheel.size);
</pre> </pre>
</div> </div>
@ -1980,9 +1980,9 @@ and more or less equivalent usage from C#
<div class="code"> <div class="code">
<pre> <pre>
Container container = new Container(); Container container = new Container();
Element element = new Element(20); Element element = new Element(20);
container.setElement(element); container.setElement(element);
</pre> </pre>
</div> </div>
@ -1993,14 +1993,14 @@ In order to understand why, consider a garbage collection occuring...
<div class="code"> <div class="code">
<pre> <pre>
Container container = new Container(); Container container = new Container();
Element element = new Element(20); Element element = new Element(20);
container.setElement(element); container.setElement(element);
Console.WriteLine("element.value: " + container.getElement().value); Console.WriteLine("element.value: " + container.getElement().value);
// Simulate a garbage collection // Simulate a garbage collection
global::System.GC.Collect(); global::System.GC.Collect();
global::System.GC.WaitForPendingFinalizers(); global::System.GC.WaitForPendingFinalizers();
global::System.Console.WriteLine("element.value: " + container.getElement().value); global::System.Console.WriteLine("element.value: " + container.getElement().value);
</pre> </pre>
</div> </div>

View file

@ -516,7 +516,7 @@ The special variables are often used in situations where method calls are logged
$action $action
} }
catch (MemoryError) { catch (MemoryError) {
croak("Out of memory in $decl"); croak("Out of memory in $decl");
} }
} }
void log(const char *message); void log(const char *message);

View file

@ -2592,36 +2592,36 @@ command line options, simply use code similar to this:
<pre> <pre>
void Language::main(int argc, char *argv[]) { void Language::main(int argc, char *argv[]) {
for (int i = 1; i &lt; argc; i++) { for (int i = 1; i &lt; argc; i++) {
if (argv[i]) { if (argv[i]) {
if (strcmp(argv[i], "-interface") == 0) { if (strcmp(argv[i], "-interface") == 0) {
if (argv[i+1]) { if (argv[i+1]) {
interface = NewString(argv[i+1]); interface = NewString(argv[i+1]);
Swig_mark_arg(i); Swig_mark_arg(i);
Swig_mark_arg(i+1); Swig_mark_arg(i+1);
i++; i++;
} else { } else {
Swig_arg_error(); Swig_arg_error();
} }
} else if (strcmp(argv[i], "-globals") == 0) { } else if (strcmp(argv[i], "-globals") == 0) {
if (argv[i+1]) { if (argv[i+1]) {
global_name = NewString(argv[i+1]); global_name = NewString(argv[i+1]);
Swig_mark_arg(i); Swig_mark_arg(i);
Swig_mark_arg(i+1); Swig_mark_arg(i+1);
i++; i++;
} else { } else {
Swig_arg_error(); Swig_arg_error();
} }
} else if ((strcmp(argv[i], "-proxy") == 0)) { } else if ((strcmp(argv[i], "-proxy") == 0)) {
proxy_flag = 1; proxy_flag = 1;
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (strcmp(argv[i], "-keyword") == 0) { } else if (strcmp(argv[i], "-keyword") == 0) {
use_kw = 1; use_kw = 1;
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (strcmp(argv[i], "-help") == 0) { } else if (strcmp(argv[i], "-help") == 0) {
fputs(usage, stderr); fputs(usage, stderr);
}
...
} }
...
}
} }
} }
</pre> </pre>

View file

@ -3935,9 +3935,9 @@ where <tt>Swig::DirectorException::raise</tt> is a helper method in the Director
<div class="code"> <div class="code">
<pre> <pre>
static void raise(JNIEnv *jenv, jthrowable throwable) { static void raise(JNIEnv *jenv, jthrowable throwable) {
throw DirectorException(jenv, throwable); throw DirectorException(jenv, throwable);
} }
</pre> </pre>
</div> </div>
@ -4335,16 +4335,16 @@ struct Vector {
%extend Vector { %extend Vector {
char *toString() { char *toString() {
static char tmp[1024]; static char tmp[1024];
sprintf(tmp, "Vector(%g, %g, %g)", $self-&gt;x, $self-&gt;y, $self-&gt;z); sprintf(tmp, "Vector(%g, %g, %g)", $self-&gt;x, $self-&gt;y, $self-&gt;z);
return tmp; return tmp;
} }
Vector(double x, double y, double z) { Vector(double x, double y, double z) {
Vector *v = (Vector *) malloc(sizeof(Vector)); Vector *v = (Vector *) malloc(sizeof(Vector));
v-&gt;x = x; v-&gt;x = x;
v-&gt;y = y; v-&gt;y = y;
v-&gt;z = z; v-&gt;z = z;
return v; return v;
} }
}; };
</pre> </pre>

View file

@ -1633,9 +1633,8 @@ class DoubleArray {
void setitem(int i, double val) { void setitem(int i, double val) {
if ((i &gt;= 0) &amp;&amp; (i &lt; n)) if ((i &gt;= 0) &amp;&amp; (i &lt; n))
ptr[i] = val; ptr[i] = val;
else { else
throw RangeError(); throw RangeError();
}
} }
}; };
</pre></div> </pre></div>
@ -2985,7 +2984,7 @@ sub set_transform
for (my $j = 0; $j &lt; 4, $j++) for (my $j = 0; $j &lt; 4, $j++)
{ {
mat44_set($a, $i, $j, $x-&gt;[i][j]) mat44_set($a, $i, $j, $x-&gt;[i][j])
} }
} }
example.set_transform($im, $a); example.set_transform($im, $a);
free_mat44($a); free_mat44($a);

View file

@ -346,8 +346,8 @@ public:
class Spam { class Spam {
public: public:
Foo *value; Foo *value;
... ...
}; };
</pre> </pre>
</div> </div>
@ -726,7 +726,7 @@ public:
class Grok : public Bar { class Grok : public Bar {
public: public:
Grok(); // Not wrapped. No implementation of abstract spam(). Grok(); // Not wrapped. No implementation of abstract spam().
}; };
</pre> </pre>
</div> </div>
@ -4915,19 +4915,19 @@ base classes. For example:
<pre> <pre>
class Foo { class Foo {
public: public:
int blah(int x); int blah(int x);
}; };
class Bar { class Bar {
public: public:
double blah(double x); double blah(double x);
}; };
class FooBar : public Foo, public Bar { class FooBar : public Foo, public Bar {
public: public:
using Foo::blah; using Foo::blah;
using Bar::blah; using Bar::blah;
char *blah(const char *x); char *blah(const char *x);
}; };
</pre> </pre>
</div> </div>
@ -5008,14 +5008,14 @@ correctly, you can always change the interface to the following:
class FooBar : public Foo, public Bar { class FooBar : public Foo, public Bar {
public: public:
#ifndef SWIG #ifndef SWIG
using Foo::blah; using Foo::blah;
using Bar::blah; using Bar::blah;
#else #else
int blah(int x); // explicitly tell SWIG about other declarations int blah(int x); // explicitly tell SWIG about other declarations
double blah(double x); double blah(double x);
#endif #endif
char *blah(const char *x); char *blah(const char *x);
}; };
</pre> </pre>
</div> </div>