Skip to content
Browse files

Further cleaning up of class examples

  • Loading branch information...
1 parent 7f40ae3 commit 0de4cf13a8aa4612ddead85b2680694fa1bf585e @ojwb ojwb committed Feb 24, 2014
View
26 Doc/Manual/Android.html
@@ -435,30 +435,30 @@
}
virtual ~Shape() {
nshapes--;
- };
+ }
double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
</pre>
</div>
@@ -482,19 +482,19 @@
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
</pre>
View
8 Examples/android/class/jni/example.cpp
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
View
20 Examples/android/class/jni/example.h
@@ -7,28 +7,28 @@ class Shape {
}
virtual ~Shape() {
nshapes--;
- };
- double x, y;
+ }
+ double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
View
25 Examples/chicken/class/example.h
@@ -7,11 +7,11 @@ class Shape {
}
virtual ~Shape() {
nshapes--;
- };
- double x, y;
+ }
+ double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
enum SomeEnum {
@@ -26,21 +26,16 @@ class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
-
-
-
-
-
View
1 Examples/chicken/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
25 Examples/csharp/class/example.h
@@ -7,33 +7,28 @@ class Shape {
}
virtual ~Shape() {
nshapes--;
- };
- double x, y;
+ }
+ double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
-
-
-
-
-
View
1 Examples/csharp/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
18 Examples/d/class/example.h
@@ -7,28 +7,28 @@ class Shape {
}
virtual ~Shape() {
nshapes--;
- };
+ }
double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
View
1 Examples/d/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
25 Examples/go/class/example.h
@@ -7,33 +7,28 @@ class Shape {
}
virtual ~Shape() {
nshapes--;
- };
- double x, y;
+ }
+ double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
-
-
-
-
-
View
1 Examples/go/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
18 Examples/guile/class/example.h
@@ -7,28 +7,28 @@ class Shape {
}
virtual ~Shape() {
nshapes--;
- };
+ }
double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
View
1 Examples/java/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
25 Examples/lua/class/example.h
@@ -7,33 +7,28 @@ class Shape {
}
virtual ~Shape() {
nshapes--;
- };
- double x, y;
+ }
+ double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
-
-
-
-
-
View
1 Examples/lua/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
44 Examples/modula3/class/example.h
@@ -1,44 +1,34 @@
/* File : example.h */
-class Shape
-{
+class Shape {
public:
- Shape ()
- {
+ Shape() {
nshapes++;
}
- virtual ~ Shape ()
- {
+ virtual ~Shape() {
nshapes--;
- };
- double x, y;
- void move (double dx, double dy);
- virtual double area (void) const = 0;
- virtual double perimeter (void) const = 0;
-protected:
- static int nshapes;
+ }
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
+ static int nshapes;
};
-class Circle:public Shape
-{
+class Circle : public Shape {
private:
double radius;
public:
- Circle (double r):radius (r)
- {
- };
- virtual double area (void) const;
- virtual double perimeter (void) const;
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
-class Square:public Shape
-{
+class Square : public Shape {
private:
double width;
public:
- Square (double w):width (w)
- {
- };
- virtual double area (void) const;
- virtual double perimeter (void) const;
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
View
18 Examples/octave/class/example.h
@@ -7,28 +7,28 @@ class Shape {
}
virtual ~Shape() {
nshapes--;
- };
+ }
double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
View
1 Examples/perl5/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
1 Examples/php/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
32 Examples/pike/class/example.cxx
@@ -1,46 +1,28 @@
-/* File : example.c */
+/* File : example.cxx */
#include "example.h"
-
-#include <stdio.h>
-
#define M_PI 3.14159265358979323846
-// Static member initializer
-int Shape::nshapes = 0;
-
-// Constructor
-Shape::Shape() {
- nshapes++;
-}
-
-// Move the shape to a new location
+/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
-// Destructor
-Shape::~Shape() {
- nshapes--;
-}
+int Shape::nshapes = 0;
-// Circle area
-double Circle::area() const {
+double Circle::area() {
return M_PI*radius*radius;
}
-// Circle perimeter
-double Circle::perimeter() const {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-// Square area
-double Square::area() const {
+double Square::area() {
return width*width;
}
-// Square perimeter
-double Square::perimeter() const {
+double Square::perimeter() {
return 4*width;
}
View
31 Examples/pike/class/example.h
@@ -2,34 +2,33 @@
class Shape {
public:
- Shape();
- virtual ~Shape();
- double x, y;
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ }
+ double x, y;
void move(double dx, double dy);
- virtual double area() const = 0;
- virtual double perimeter() const = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area() const;
- virtual double perimeter() const;
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area() const;
- virtual double perimeter() const;
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
-
-
-
-
-
View
1 Examples/pike/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
1 Examples/python/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
25 Examples/r/class/example.h
@@ -7,33 +7,28 @@ class Shape {
}
virtual ~Shape() {
nshapes--;
- };
- double x, y;
+ }
+ double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
-
-
-
-
-
View
6 Examples/r/class/example.i
@@ -1,9 +1,9 @@
/* File : example.i */
%module example
-%inline %{
+%{
#include "example.h"
%}
-%include "example.h"
-
+/* Let's just grab the original header file here */
+%include "example.h"
View
1 Examples/ruby/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
4 Examples/ruby/class/index.html
@@ -12,7 +12,7 @@
<H2>Wrapping a simple C++ class</H2>
<p>
-This example illustrates wrapping a simple C++ class to give a Python class.
+This example illustrates wrapping a simple C++ class to give a Ruby class.
<h2>The C++ Code</h2>
@@ -147,7 +147,7 @@
<li>SWIG <b>does</b> know how to properly perform upcasting of objects in
an inheritance hierarchy except for multiple inheritance.
-<li>C++ Namespaces - %nspace isn't yet supported for Python.
+<li>C++ Namespaces - %nspace isn't yet supported for Ruby.
</ul>
View
1 Examples/tcl/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
View
4 Examples/tcl/class/index.html
@@ -229,11 +229,11 @@
<li>The low-level function interface is much faster than the high-level interface.
In fact, all the higher level interface does is call functions in the low-level interface.
-<li>SWIG *does* know how to properly perform upcasting of objects in an inheritance
+<li>SWIG <b>does</b> know how to properly perform upcasting of objects in an inheritance
hierarchy (including multiple inheritance). Therefore it is perfectly safe to pass
an object of a derived class to any function involving a base class.
-<li>C++ Namespaces - %nspace isn't yet supported for Python.
+<li>C++ Namespaces - %nspace isn't yet supported for Tcl.
</ul>

0 comments on commit 0de4cf1

Please sign in to comment.
Something went wrong with that request. Please try again.