swig/SWIG/Lib/ocaml/carray.i
Art Yerkes 47d747477f Proper handling of arrays finally in the works, no special typemaps needed.
Some corrections for use with -small.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4420 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-03-01 07:53:24 +00:00

22 lines
592 B
OpenEdge ABL

template < class T > class SWIG_OCAML_ARRAY_WRAPPER {
public:
SWIG_OCAML_ARRAY_WRAPPER( T *t ) : t(t) { }
SWIG_OCAML_ARRAY_WRAPPER( T &t ) : t(&t) { }
SWIG_OCAML_ARRAY_WRAPPER( T t[] ) : t(&t[0]) { }
T &operator[]( int n ) { return t[n]; }
SWIG_OCAML_ARRAY_WRAPPER offset( int elts ) {
return SWIG_OCAML_ARRAY_WRAPPER( t + elts );
}
T *operator & () { return t; }
void own() { owned = true; }
void disown() { owned = false; }
~SWIG_OCAML_ARRAY_WRAPPER() {
if( owned ) delete t;
}
private:
T *t;
int owned;
};
%apply SWIGTYPE [ANY] {SWIG_OCAML_ARRAY_WRAPPER};