From b0ba1cae761810b896f8de7f6c6315c722addb5e Mon Sep 17 00:00:00 2001
From: William S Fulton
Notes:
+
-
Following is an example of the wrapping of the C FILE* pointer: @@ -854,6 +853,7 @@ ans =
Using the previous SWIG_this() and SWIG_ptr(), it is possible to create and check null pointers:
@@ -904,6 +904,7 @@ Several functions are generated: +Usage example:
@@ -963,7 +964,7 @@ ans =Note: the pointer to the struct works as described in Pointers. For example, the type of the struct pointer can be get with typeof, as following: -
+
--> example_Init(); @@ -1027,7 +1028,7 @@ ans =Note: like structs, class pointers are mapped as described in Pointers. Let's give an example which shows that each class pointer type is a new type in Scilab that can be used for example (through overloading) to implement a custom print for the Point class: -
+
--> function %_p_Point_p(p) @@ -1120,27 +1121,26 @@ But we can use either use the get_perimeter() function of the parent cl39.3.10 C++ overloading
+As explained in 6.15 SWIG provides support for overloaded functions and constructors.
As SWIG knows pointer types, the overloading works also with pointer types, here is is an example with a function magnify overloaded for the previous classes Shape and Circle: +
-
- -%module example void magnify(Square *square, double factor) { - square->size *= factor; + square->size *= factor; }; void magnify(Circle *circle, double factor) { - square->radius *= factor; + square->radius *= factor; };
---> example_Init(); --> c = new_Circle(3); @@ -1157,7 +1157,6 @@ void magnify(Circle *circle, double factor) { 20;39.3.11 Pointers, references, values, and arrays