Author: kkaempf Date: Thu Dec 4 13:08:55 2008 New Revision: 11864 URL: http://svn.opensuse.org/viewcvs/zypp?rev=11864&view=rev Log: factorize Dataiterator constructor/destructor out so Repo::search can use it Modified: trunk/sat-solver/bindings/dataiterator.i trunk/sat-solver/bindings/satsolver.i Modified: trunk/sat-solver/bindings/dataiterator.i URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/dataiterator.i?rev=11864&r1=11863&r2=11864&view=diff ============================================================================== --- trunk/sat-solver/bindings/dataiterator.i (original) +++ trunk/sat-solver/bindings/dataiterator.i Thu Dec 4 13:08:55 2008 @@ -6,7 +6,6 @@ %rename(Dataiterator) _Dataiterator; typedef struct _Dataiterator {} Dataiterator; - %extend Dataiterator { %constant int SEARCH_STRINGMASK = SEARCH_STRINGMASK; %constant int SEARCH_STRING = SEARCH_STRING; @@ -33,21 +32,10 @@ Dataiterator(Pool *pool, Repo *repo, const char *match, int option, XSolvable *xs = 0, const char *keyname = 0) { - Dataiterator *di = calloc(1, sizeof( Dataiterator )); - Solvable *s = 0; - /* cope with pool or repo being NULL */ - if (!pool) { - if (!repo) { - /* raise exception (FIXME) */ - } - pool = repo->pool; - } - if (xs) s = xsolvable_solvable(xs); - dataiterator_init(di, pool, repo, s ? s - s->repo->pool->solvables : 0, keyname && pool ? str2id(pool, keyname, 0) : 0, match, option); - return di; + return swig_dataiterator_new(pool, repo, match, option, xs, keyname); } - ~Dataiterator() { dataiterator_free($self); free( $self ); } + ~Dataiterator() { swig_dataiterator_free($self); } XSolvable *solvable() { Modified: trunk/sat-solver/bindings/satsolver.i URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/satsolver.i?rev=11864&r1=11863&r2=11864&view=diff ============================================================================== --- trunk/sat-solver/bindings/satsolver.i (original) +++ trunk/sat-solver/bindings/satsolver.i Thu Dec 4 13:08:55 2008 @@ -16,6 +16,10 @@ %module satsolver %feature("autodoc","1"); +#if defined(SWIGRUBY) +%include <ruby.swg> +#endif + %{ /*=============================================================*/ @@ -144,6 +148,38 @@ } #endif +/* + * create Dataiterator + * (used by dataiterator.i and pool.search) + */ + +static Dataiterator * +swig_dataiterator_new(Pool *pool, Repo *repo, const char *match, int option, XSolvable *xs, const char *keyname) +{ + Dataiterator *di = calloc(1, sizeof( Dataiterator )); + Solvable *s = 0; + /* cope with pool or repo being NULL */ + if (!pool) { + if (!repo) { + /* raise exception (FIXME) */ + } + pool = repo->pool; + } + if (xs) s = xsolvable_solvable(xs); + dataiterator_init(di, pool, repo, s ? s - s->repo->pool->solvables : 0, keyname && pool ? str2id(pool, keyname, 0) : 0, match, option); + return di; +} + +/* + * destroy Dataiterator + */ +void +swig_dataiterator_free(Dataiterator *di) +{ + dataiterator_free(di); + free( di ); +} + /* convert Dataiterator to target value * if *more != 0 on return, value is incomplete */ @@ -253,6 +289,7 @@ /* types and typemaps */ #if defined(SWIGRUBY) + /* * FILE * to Ruby * (copied from /usr/share/swig/ruby/file.i) -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org