PageRenderTime 37ms CodeModel.GetById 2ms app.highlight 13ms RepoModel.GetById 11ms app.codeStats 0ms

/tags/ttn-post-libtool-1-4-3-upgrade/SWIG/Examples/php4/value/example.i

#
Swig | 31 lines | 20 code | 7 blank | 4 comment | 0 complexity | 7a6bb4959ce67ee98d29226552ace2c0 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 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 */
 9extern double dot_product(Vector a, Vector b);
10extern Vector vector_add(Vector a, Vector b);
11
12/* Include this because the vector_add() function will leak memory */
13void   free(void *);
14
15/* Some helper functions for our interface */
16%inline %{
17
18Vector *new_Vector(double x, double y, double z) {
19	/* We use the Zend memory manager */
20   Vector *v = (Vector *) emalloc(sizeof(Vector));
21   v->x = x;
22   v->y = y;
23   v->z = z;
24   return v;
25}
26
27void vector_print(Vector *v) {
28  printf("Vector %x = (%g, %g, %g)\n", v, v->x, v->y, v->z);
29}
30%}
31