/* -----------------------------------------------------------------------------
* Author(s): David Beazley (beazley@cs.uchicago.edu)
* This library file contains macros that can be used to manipulate simple
* $Header: /cvsroot/swig/SWIG/Lib/cpointer.i,v 1.4 2004/10/06 16:51:19 marcelomatus Exp $
* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* %pointer_class(type,name)
* Places a simple proxy around a simple type like 'int', 'float', or whatever.
* The proxy provides this interface:
* void assign(type value);
* %pointer_class(int, intp);
* int add(int *x, int *y) { return *x + *y; }
* In python (with proxies)
* As a general rule, this macro should not be used on class/structures that
* are already defined in the interface.
* ----------------------------------------------------------------------------- */
%define %pointer_class(TYPE, NAME)
return (TYPE *) calloc(1,sizeof(TYPE));
void assign(TYPE value) {
static NAME * frompointer(TYPE *t) {
/* -----------------------------------------------------------------------------
* %pointer_functions(type,name)
* Create functions for allocating/deallocating pointers. This can be used
* if you don't want to create a proxy class or if the pointer is complex.
* %pointer_functions(int, intp)
* int add(int *x, int *y) { return *x + *y; }
* In python (with proxies)
* ----------------------------------------------------------------------------- */
%define %pointer_functions(TYPE,NAME)
static TYPE *new_##NAME() { %}
%{ return (TYPE *) calloc(1,sizeof(TYPE)); %}
static TYPE *copy_##NAME(TYPE value) { %}
%{ return new TYPE(value); %}
%{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE));
static void delete_##NAME(TYPE *self) { %}
%{ if (self) delete self; %}
%{ if (self) free(self); %}
static void NAME ##_assign(TYPE *self, TYPE value) {
static TYPE NAME ##_value(TYPE *self) {
TYPE *copy_##NAME(TYPE value);
void delete_##NAME(TYPE *self);
void NAME##_assign(TYPE *self, TYPE value);
TYPE NAME##_value(TYPE *self);
/* -----------------------------------------------------------------------------
* %pointer_cast(type1,type2,name)
* Generates a pointer casting function.
* ----------------------------------------------------------------------------- */
%define %pointer_cast(TYPE1,TYPE2,NAME)