/trunk/Examples/tcl/value/example.i
Swig | 32 lines | 22 code | 7 blank | 3 comment | 0 complexity | 140e005847e87329ecc4fa03d091a3d3 MD5 | raw file
1// Tests SWIG's handling of pass-by-value for complex datatypes 2%module example 3 4%{ 5#include "example.h" 6%} 7 8/* Some functions that manipulate Vectors by value */ 9%inline %{ 10extern double dot_product(Vector a, Vector b); 11extern Vector vector_add(Vector a, Vector b); 12%} 13 14/* Include this because the vector_add() function will leak memory */ 15void free(void *); 16 17/* Some helper functions for our interface */ 18%inline %{ 19 20Vector *new_Vector(double x, double y, double z) { 21 Vector *v = (Vector *) malloc(sizeof(Vector)); 22 v->x = x; 23 v->y = y; 24 v->z = z; 25 return v; 26} 27 28void vector_print(Vector *v) { 29 printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z); 30} 31%} 32