From fdff34f4855b84438b5bff3f79cba33d6bf35865 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Fri, 4 Apr 2014 14:09:10 +0200 Subject: more swig trickery: automaticall free the pool, add a disown method --- bindings/solv.i | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'bindings/solv.i') diff --git a/bindings/solv.i b/bindings/solv.i index eab2430..41cb49a 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -421,7 +421,18 @@ SWIG_AsValDepId(void *obj, int *val) { } - +%typemap(out) disown_helper { +#ifdef SWIGRUBY + SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Pool, SWIG_POINTER_DISOWN | 0 ); +#endif +#ifdef SWIGPYTHON + SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Pool, SWIG_POINTER_DISOWN | 0 ); +#endif +#ifdef SWIGPERL + SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Pool, SWIG_POINTER_DISOWN | 0 ); +#endif + $result = SWIG_From_int((int)(0)); +} %include "typemaps.i" @@ -599,6 +610,8 @@ typedef struct { typedef Dataiterator Datamatch; +typedef int disown_helper; + %} #ifdef SWIGRUBY @@ -1102,8 +1115,6 @@ typedef struct { Pool *pool = pool_create(); return pool; } - ~Pool() { - } void set_debuglevel(int level) { pool_setdebuglevel($self, level); } @@ -1203,10 +1214,18 @@ typedef struct { } #endif - void free() { + ~Pool() { Pool_set_loadcallback($self, 0); pool_free($self); } + disown_helper free() { + Pool_set_loadcallback($self, 0); + pool_free($self); + return 0; + } + disown_helper disown() { + return 0; + } Id str2id(const char *str, bool create=1) { return pool_str2id($self, str, create); } -- cgit v1.2.3