Better handling of return values. Some bugfixes.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10618 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ea05035844
commit
f74439e215
16 changed files with 208 additions and 58 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* File : example.cxx */
|
||||
/* File : example.c */
|
||||
|
||||
#include "example.h"
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
|
@ -12,8 +12,7 @@ void Shape::move(double dx, double dy) {
|
|||
int Shape::nshapes = 0;
|
||||
|
||||
double Circle::area(void) {
|
||||
double xxx = M_PI*radius*radius;
|
||||
return xxx;
|
||||
return M_PI*radius*radius;
|
||||
}
|
||||
|
||||
double Circle::perimeter(void) {
|
||||
|
|
@ -27,4 +26,3 @@ double Square::area(void) {
|
|||
double Square::perimeter(void) {
|
||||
return 4*width;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
/* File : example.h */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
class Shape {
|
||||
public:
|
||||
Shape() {
|
||||
|
|
@ -35,3 +33,7 @@ public:
|
|||
virtual double perimeter(void);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,17 +3,35 @@
|
|||
#include "example_proxy.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Circle* pc = new_Circle(10.0);
|
||||
Square* ps = new_Square(10.0);
|
||||
printf("Creating some objects:\n");
|
||||
Circle* c = new_Circle(10);
|
||||
printf(" Created circle\n");
|
||||
Square* s = new_Square(10);
|
||||
printf(" Created square\n");
|
||||
|
||||
printf("Circle perim.=%f, area=%f\n", Circle_perimeter(pc), Circle_area(pc));
|
||||
printf("Square perim.=%f, area=%f\n", Square_perimeter(ps), Square_area(ps));
|
||||
printf("\nA total of %d shapes were created\n", 0);
|
||||
|
||||
printf("Circle pos.=(%f, %f)\n", Shape_get_x(pc), Shape_get_y(pc));
|
||||
Shape_move(pc, 5.0, -5.0);
|
||||
printf("After move pos.=(%f, %f)\n", Shape_get_x(pc), Shape_get_y(pc));
|
||||
|
||||
delete_Square(ps);
|
||||
delete_Circle(pc);
|
||||
printf("\nHere are some properties of the shapes:\n");
|
||||
Shape shapes[] = {c, s};
|
||||
int i;
|
||||
/*
|
||||
* TODO: support for virtual functions
|
||||
for (i = 0; i < 2; i++) {
|
||||
printf(" area = %f\n", Shape_area(shapes[i]));
|
||||
printf(" perimeter = %f\n", Shape_perimeter(shapes[i]));
|
||||
}
|
||||
*/
|
||||
|
||||
// call methods directly by now
|
||||
printf("Circle perim.=%f, area=%f\n", Circle_perimeter(c), Circle_area(c));
|
||||
printf("Square perim.=%f, area=%f\n", Square_perimeter(s), Square_area(s));
|
||||
|
||||
printf("\nGuess I'll clean up now\n");
|
||||
|
||||
delete_Square(s);
|
||||
delete_Circle(c);
|
||||
|
||||
printf("%d shapes remain\n", 0);
|
||||
printf("Goodbye\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue