Add Solvable.Dataiterator constructor, add missing SEARCH_ definitions, add Datamatch...
authorMichael Schroeder <mls@suse.de>
Mon, 5 Nov 2012 11:01:30 +0000 (12:01 +0100)
committerMichael Schroeder <mls@suse.de>
Mon, 5 Nov 2012 11:01:30 +0000 (12:01 +0100)
Also autostringfy if SEARCH_FILES is used and there is no matcher.

bindings/solv.i
src/repodata.c

index 04bb30a..c4202b2 100644 (file)
@@ -522,6 +522,10 @@ typedef struct {
   Id const id;
 } Dep;
 
+# put before pool/repo so we can access the constructor
+%nodefaultdtor Dataiterator;
+typedef struct {} Dataiterator;
+
 typedef struct {
   Pool* const pool;
   Id const id;
@@ -543,9 +547,6 @@ typedef struct {
   Id const id;
 } XRepodata;
 
-# put before pool/repo so we can access the constructor
-%nodefaultdtor Dataiterator;
-typedef struct {} Dataiterator;
 typedef struct {} Pool_solvable_iterator;
 typedef struct {} Pool_repo_iterator;
 typedef struct {} Repo_solvable_iterator;
@@ -1446,6 +1447,8 @@ typedef struct {
 
 %extend Dataiterator {
   static const int SEARCH_STRING = SEARCH_STRING;
+  static const int SEARCH_STRINGSTART = SEARCH_STRINGSTART;
+  static const int SEARCH_STRINGEND = SEARCH_STRINGEND;
   static const int SEARCH_SUBSTRING = SEARCH_SUBSTRING;
   static const int SEARCH_GLOB = SEARCH_GLOB;
   static const int SEARCH_REGEX = SEARCH_REGEX;
@@ -1629,6 +1632,14 @@ typedef struct {
   void setpos_parent() {
     dataiterator_setpos_parent($self);
   }
+#if defined(SWIGPERL)
+  %rename("str") __str__;
+#endif
+  const char *__str__() {
+    if (!repodata_stringify($self->pool, $self->data, $self->key, &$self->kv, $self->flags))
+      return "";
+    return $self->kv.str;
+  }
 }
 
 %extend Pool_solvable_iterator {
@@ -1901,6 +1912,10 @@ typedef struct {
   const char *lookup_location(unsigned int *OUTPUT) {
     return solvable_lookup_location($self->pool->solvables + $self->id, OUTPUT);
   }
+  %newobject Dataiterator;
+  Dataiterator *Dataiterator(Id key, const char *match, int flags) {
+    return new_Dataiterator($self->pool, 0, $self->id, key, match, flags);
+  }
 #ifdef SWIGRUBY
   %rename("installable?") installable;
 #endif
index d64a00b..520984c 100644 (file)
@@ -1593,6 +1593,11 @@ dataiterator_step(Dataiterator *di)
          if (!datamatcher_match(&di->matcher, di->kv.str))
            continue;
        }
+      else
+       {
+         if (di->keyname == SOLVABLE_FILELIST && di->key->type == REPOKEY_TYPE_DIRSTRARRAY && (di->flags & SEARCH_FILES) != 0)
+           repodata_stringify(di->pool, di->data, di->key, &di->kv, di->flags);
+       }
       /* found something! */
       return 1;
     }