diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 01d104e0d..001fe8b71 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -27,9 +27,9 @@
The wrapping of enums is quite the same as for constants. @@ -593,42 +593,100 @@ extern int divide(int n, int d, int *r); we only need a real value instead.
-- SWIG creates a set of accessor functions when encountering a structure or union. For example: +A C structure is wrapped through a pointer and getter and setter functions for access to the member variables. +For example of a struct with two members:
-%module example +-+%module example + %inline %{ + typedef struct { int x; + int y; } Foo; %}When wrapped, it would generate two main function: Foo_x_set(), which set the data value of the structure and Foo_x_get() which could obtain the value of the structure. Run it in Scilab: +
+Several functions are generated: +
+Following is an example of use:
---> a=new_Foo(); ---> Foo_x_set(a,100); +--> a = new_Foo(); +--> Foo_x_set(a, 100); --> Foo_x_get(a) ans = - 100 + 100. + +--> delete_Foo(a);
+Members of a structure that itself are a structure are also accepted and wrapped as a pointer:
+ + +
+%module example
+
+%inline %{
+
+typedef struct {
+ int x;
+} Bar;
+
+typedef struct {
+ Bar b;
+} Foo;
+
+%}
++
+--> b = new_Bar(); +--> Bar_x_set(b, 20.); + +--> f = new_Foo(); +--> Foo_b_set(f, b); + +--> b2 = Foo_b_get(f); +--> Bar_x_get(b2); +ans = + + 20. +
-The classes are wrapped in the same manner as structs, through functions. For example, the following class: +The classes are wrapped the way as structs, through functions. For example, the following class:
+%module example
+
+%inline %{
+
class Point {
public:
int x,y;
@@ -637,9 +695,12 @@ public:
return sqrt(pow(x-rhs.x,2)+pow(y-rhs.y,2));
}
void set(int _x,int _y) {
- x=_x; y=_y;
+ x=_x;
+ y=_y;
}
};
+
+%}
@@ -652,6 +713,9 @@ can be used from Scilab like this: --> p1.distance(p2) ans = 3.6056 + +--> delete_Point(p1); +--> delete_Point(p2);