- fix compilation with older python versions
[platform/upstream/libsolv.git] / bindings / solv.i
index 43da77f..a5b9552 100644 (file)
   int size, i;
   VALUE *o;
   queue_init(&$1);
-  size = RARRAY($input)->len;
+  size = RARRAY_LEN($input);
   i = 0;
-  o = RARRAY($input)->ptr;
+  o = RARRAY_PTR($input);
   for (i = 0; i < size; i++, o++) {
     int v;
     int e = SWIG_AsVal_int(*o, &v);
@@ -362,8 +362,22 @@ typedef VALUE AppObjectPtr;
 #include "repo_susetags.h"
 #include "repo_content.h"
 #endif
+#ifdef ENABLE_MDKREPO
+#include "repo_mdk.h"
+#endif
+#ifdef ENABLE_ARCHREPO
+#include "repo_arch.h"
+#endif
 #include "solv_xfopen.h"
 
+/* for old ruby versions */
+#ifndef RARRAY_PTR
+#define RARRAY_PTR(ary) (RARRAY(ary)->ptr)
+#endif
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(ary) (RARRAY(ary)->len)
+#endif
+
 #define true 1
 #define false 1
 
@@ -542,7 +556,7 @@ typedef struct {
 
 %nodefaultctor Repo;
 %nodefaultdtor Repo;
-typedef struct _Repo {
+typedef struct {
   Pool * const pool;
   const char * const name;
   int priority;
@@ -557,7 +571,7 @@ typedef struct {
   Pool * const pool;
 } Solver;
 
-typedef struct chksum {
+typedef struct {
 } Chksum;
 
 %rename(xfopen) solv_xfopen;
@@ -829,7 +843,8 @@ typedef struct {
   %}
   void set_loadcallback(PyObject *callable) {
     if ($self->loadcallback == loadcallback) {
-      Py_DECREF($self->loadcallbackdata);
+      PyObject *obj = $self->loadcallbackdata;
+      Py_DECREF(obj);
     }
     if (callable) {
       Py_INCREF(callable);
@@ -1072,7 +1087,7 @@ typedef struct {
   static const int REPO_USE_LOADING = REPO_USE_LOADING;
   static const int REPO_EXTEND_SOLVABLES = REPO_EXTEND_SOLVABLES;
   static const int SOLV_ADD_NO_STUBS = SOLV_ADD_NO_STUBS;       /* repo_solv */
-#ifdef ENABLE_SUSETAGS
+#ifdef ENABLE_SUSEREPO
   static const int SUSETAGS_RECORD_SHARES = SUSETAGS_RECORD_SHARES;     /* repo_susetags */
 #endif
 
@@ -1156,6 +1171,25 @@ typedef struct {
     return 1;
   }
 #endif
+#ifdef ENABLE_MDKREPO
+  bool add_mdk(FILE *fp, int flags = 0) {
+    repo_add_mdk($self, fp, flags);
+    return 1;
+  }
+  bool add_mdk_info(FILE *fp, int flags = 0) {
+    repo_add_mdk($self, fp, flags);
+    return 1;
+  }
+#endif
+#ifdef ENABLE_ARCHREPO
+  bool add_arch_repo(FILE *fp, int flags = 0) {
+    repo_add_arch_repo($self, fp, flags);
+    return 1;
+  }
+  Id add_arch_pkg(const char *name, int flags = 0) {
+    return repo_add_arch_pkg($self, name, flags);
+  }
+#endif
   void internalize() {
     repo_internalize($self);
   }
@@ -1536,7 +1570,7 @@ typedef struct {
   void each() {
     Repo *n;
     while ((n = Pool_repo_iterator___next__($self)) != 0) {
-      rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p__Repo, SWIG_POINTER_OWN | 0));
+      rb_yield(SWIG_NewPointerObj(SWIG_as_voidptr(n), SWIGTYPE_p_Repo, SWIG_POINTER_OWN | 0));
     }
   }
 #endif