Member variable and function wrappers. The simple 'class' test passed.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10538 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2008-06-21 14:51:02 +00:00
commit 2620bb218c
6 changed files with 249 additions and 58 deletions

View file

@ -1106,7 +1106,7 @@ c: $(SRCS)
c_cpp: $(SRCS)
$(SWIG) -c++ -c $(SWIGOPT) $(INTERFACE)
$(CC) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(SO)
$(CC) $(MAIN) $(TARGET)_proxy.c -L. -l$(LIBPREFIX)_$(TARGET)

View file

@ -12,7 +12,8 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
double Circle::area(void) {
return M_PI*radius*radius;
double xxx = M_PI*radius*radius;
return xxx;
}
double Circle::perimeter(void) {

View file

@ -1,5 +1,7 @@
/* File : example.h */
#include <stdio.h>
class Shape {
public:
Shape() {

View file

@ -3,10 +3,17 @@
#include "example_proxy.h"
int main(int argc, char **argv) {
struct CircleObj* pc = new_Circle(10.0);
Circle* pc = new_Circle(10.0);
Square* ps = new_Square(10.0);
// ...
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("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);
}

View file

@ -6,7 +6,7 @@ int main(int argc, char **argv) {
int a = 35;
int b = 15;
printf("Foo is %f\n", Foo);
printf("Foo by ptr is \%f (%d)\n", *Foo_ptr, (int) Foo_ptr);
printf("Foo by ptr is \%f\n", *Foo_ptr);
printf("my_str is: %s\n", my_str);
printf("array_of_strs contains %s and %s\n", get_str(0), get_str(1));
printf("GCD(%d, %d)=%d\n", a, b, gcd(a, b));