~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Examples/chicken/class/precsi.scm

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-09-01 18:35:55 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050901183555-eq59uwhq8b62e44c
Tags: 1.3.24-1ubuntu4
* Use php5-dev instead of php4-dev, to kick php4 out of main.
* Drop support for generation of pike bindings, as nothing uses it,
  and swig is the only thing keeping pike7.6 in main (Ubuntu #13796)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
(declare (unit precsi))
2
 
(declare (uses example))
3
 
 
4
 
(if (not (member "-quiet" (cdr (argv))))
5
 
    (begin
6
 
      ;; display prelude to csi
7
 
      (display "class\n\n")
8
 
 
9
 
      (display "  A SWIG example for the CHICKEN compiler\n")
10
 
      (display "  Author: Jonah Beckford, December 2002\n\n")
11
 
 
12
 
      (display "C++ Interface\n")
13
 
      (display "-------------\n")
14
 
      (display "
15
 
class Shape {
16
 
public:
17
 
  Shape();
18
 
  virtual ~Shape();
19
 
  double  x, y;   
20
 
  void    move(double dx, double dy);
21
 
  virtual double area(void) = 0;
22
 
  virtual double perimeter(void) = 0;
23
 
  static  int nshapes;
24
 
  enum SomeEnum {
25
 
    First = 0,
26
 
    Second,
27
 
    Third,
28
 
    Last = 1000
29
 
  };
30
 
};
31
 
 
32
 
class Circle : public Shape {
33
 
private:
34
 
  double radius;
35
 
public:
36
 
  Circle(double r);
37
 
  virtual double area(void);
38
 
  virtual double perimeter(void);
39
 
};
40
 
 
41
 
class Square : public Shape {
42
 
private:
43
 
  double width;
44
 
public:
45
 
  Square(double w);
46
 
  virtual double area(void);
47
 
  virtual double perimeter(void);
48
 
};
49
 
")
50
 
 
51
 
      (display "\n")
52
 
 
53
 
      (display "CHICKEN Low-Level Procedures\n")
54
 
      (display "----------------------------\n")
55
 
      (display "
56
 
  (define A-CIRCLE-SHAPE (example:new-Circle %radius))
57
 
  (example:Circle-area %circle)
58
 
  (example:Circle-perimeter %circle)
59
 
  (example:delete-Circle %circle)
60
 
 
61
 
  (define A-SQUARE-SHAPE (example:new-Square %width))
62
 
  (example:Square-area %square)
63
 
  (example:Square-perimeter %square)
64
 
  (example:delete-Square %square)
65
 
 
66
 
  (example:delete-Shape %shape)
67
 
  (example:Shape-x-set %shape %x)
68
 
  (example:Shape-x-get %shape)
69
 
  (example:Shape-y-set %shape %y)
70
 
  (example:Shape-y-get %shape)
71
 
  (example:Shape-move %shape %dx %dy)
72
 
  (example:Shape-area %shape)
73
 
  (example:Shape-perimeter %shape)
74
 
  (example:Shape-nshapes)
75
 
  (example:Shape-nshapes %nshapes-int)
76
 
  (example:Shape-First)
77
 
  (example:Shape-Second)
78
 
  (example:Shape-Third)
79
 
  (example:Shape-Last)
80
 
")
81
 
 
82
 
      (display "\n")
83
 
 
84
 
      (display "TinyCLOS Classes\n")
85
 
      (display "----------------\n")
86
 
      (display "
87
 
  ;; ALL generic methods must be included first
88
 
  (include \"example-generic\")
89
 
  ;; After generic methods are defined, can include TinyCLOS code
90
 
  (include \"example-clos\")
91
 
 
92
 
  (define A-CIRCLE-SHAPE (make <example:Circle> %radius))
93
 
  (-get-x- %shapeObject)
94
 
  (-set-x!- %shapeObject %x)
95
 
  (-get-y- %shapeObject)
96
 
  (-set-y!- %shapeObject %y)
97
 
  (-move!- %shapeObject %dx %dy)
98
 
  (-area- %shapeObject)
99
 
  (-perimeter- %shapeObject)
100
 
  (+example:Shape-nshapes+)
101
 
  (+example:Shape-nshapes+ %nshapes-int)
102
 
  ;; do not use (example:delete-Shape (slot-ref %shapeObject 'this))
103
 
  ;; as %shapeObject is always garbage-collected
104
 
")
105
 
      (display "\n")))