]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Remove appdata_link again
authorMichael Schroeder <mls@suse.de>
Fri, 28 Aug 2015 09:48:54 +0000 (11:48 +0200)
committerMichael Schroeder <mls@suse.de>
Fri, 28 Aug 2015 09:48:54 +0000 (11:48 +0200)
As it turned out that you can only link to global variables, you
might as well just store the name of the variable with the normal
appdata mechanism.

bindings/solv.i
doc/libsolv-bindings.3
doc/libsolv-bindings.txt

index 589a81ab49108f0599603626c5929346df25e28c..21d39d1b9b6b5b06c3a48c03ebf4fb142c8dfba6 100644 (file)
@@ -823,8 +823,6 @@ typedef int disown_helper;
 struct myappdata {
   void *appdata;
   int disowned;
-  void *link;
-  void *linkitem;
 };
 
 
@@ -890,7 +888,7 @@ SWIGINTERN void appdata_clr_helper(void **appdatap) {
     myappdata->appdata = 0;
   }
   myappdata->disowned = 0;
-  if (!myappdata->appdata && !myappdata->link) {
+  if (!myappdata->appdata) {
     solv_free(myappdata);
     *appdatap = 0;
   }
@@ -924,89 +922,6 @@ SWIGINTERN void *appdata_get_helper(void *appdata) {
 #endif
 
 
-#if defined(SWIGTCL)
-%{
-SWIGINTERN void appdata_link_clr_helper(void **appdatap) {
-  char linkname[64];
-  Tcl_Interp *interp;
-  struct myappdata *myappdata = *(struct myappdata **)appdatap;
-  if (!myappdata || !myappdata->link)
-    return;
-  interp = myappdata->link;
-  if (interp) {
-    SWIG_PackData(linkname + 20, &myappdata->linkitem, sizeof(void *));
-    Tcl_UpVar(interp, "#0", "::solv::appdatalink_gone", linkname, TCL_GLOBAL_ONLY);
-    myappdata->link = 0;
-    myappdata->linkitem = 0;
-    if (!myappdata->appdata && !myappdata->link)
-      *appdatap = solv_free(myappdata);
-  }
-}
-
-SWIGINTERN int appdata_link_helper(void **appdatap, void *item, Tcl_Interp *interp, const char *cmd, const char *varname) {
-  struct myappdata *myappdata = *(struct myappdata **)appdatap;
-  char linkname[64];
-  int res;
-  strcpy(linkname, "::solv::appdatalink_");
-  SWIG_PackData(linkname + 20, &item, sizeof(void *));
-  if (!strcmp(cmd, "set")) {
-    if (!varname) {
-      SWIG_Tcl_SetErrorMsg(interp, "RuntimeError", "appdata_link set: needs an argument");
-      return TCL_ERROR;
-    }
-    if (myappdata && myappdata->link) {
-      Tcl_UpVar(myappdata->link, "#0", "::solv::appdatalink_gone", linkname, TCL_GLOBAL_ONLY);
-      myappdata->link = 0;
-      myappdata->linkitem = 0;
-    }
-    res = Tcl_UpVar(interp, "0", varname, linkname, TCL_GLOBAL_ONLY);
-    if (res != TCL_OK)
-      return res;
-    if (!myappdata)
-      myappdata = *appdatap = solv_calloc(sizeof(struct myappdata), 1);
-    myappdata->link = interp;
-    myappdata->linkitem = item;
-    return TCL_OK;
-  } else if (!strcmp(cmd, "get")) {
-    if (!varname) {
-      SWIG_Tcl_SetErrorMsg(interp, "RuntimeError", "appdata_link get: needs an argument");
-      return TCL_ERROR;
-    }
-    if (!myappdata || !myappdata->link) {
-      SWIG_Tcl_SetErrorMsg(interp, "RuntimeError", "appdata_link get: no link is set");
-      return TCL_ERROR;
-    }
-    return Tcl_UpVar(interp, "#0", linkname, varname, 0);
-  } else if (!strcmp(cmd, "del") && !varname) {
-    if (varname) {
-      SWIG_Tcl_SetErrorMsg(interp, "RuntimeError", "appdata_link del: needs no argument");
-      return TCL_ERROR;
-    }
-    if (!myappdata || !myappdata->link)
-      return TCL_OK;
-    res = Tcl_UpVar(interp, "#0", "::solv::appdatalink_gone", linkname, TCL_GLOBAL_ONLY);
-    if (res != TCL_OK)
-      return res;
-    myappdata->link = 0;
-    myappdata->linkitem = 0;
-    if (!myappdata->appdata && !myappdata->link) {
-      myappdata = *appdatap = solv_free(myappdata);
-    }
-    return TCL_OK;
-  }
-  SWIG_Tcl_SetErrorMsg(interp, "RuntimeError", "usage: appdata_link set|get|del varName");
-  return TCL_ERROR;
-}
-%}
-#else
-
-%{
-SWIGINTERN void appdata_link_clr_helper(void **appdatap) {
-}
-
-%}
-#endif
-
 /**
  ** the SWIG declarations defining the API
  **/
@@ -1710,7 +1625,6 @@ typedef struct {
     FOR_REPOS(repoid, repo)
       appdata_clr_helper(&repo->appdata);
     Pool_clr_loadcallback(pool);
-    appdata_link_clr_helper(&pool->appdata);
     appdata_clr_helper(&pool->appdata);
     pool_free(pool);
   }
@@ -1721,7 +1635,6 @@ typedef struct {
     FOR_REPOS(repoid, repo)
       appdata_clr_helper(&repo->appdata);
     Pool_clr_loadcallback(pool);
-    appdata_link_clr_helper(&pool->appdata);
     appdata_clr_helper(&pool->appdata);
     pool_free(pool);
     return 0;
@@ -1741,12 +1654,6 @@ typedef struct {
   void appdata_disown() {
     appdata_disown_helper(&$self->appdata);
   }
-#if defined(SWIGTCL)
-  %apply int Tcl_Result { int appdata_link };
-  int appdata_link(Tcl_Interp *interp, const char *cmd, const char *varname = 0) {
-    return appdata_link_helper(&$self->appdata, $self, interp, cmd, varname);
-  }
-#endif
 
   Id str2id(const char *str, bool create=1) {
     return pool_str2id($self, str, create);
@@ -2018,7 +1925,6 @@ rb_eval_string(
 #endif
 
   void free(bool reuseids = 0) {
-    appdata_link_clr_helper(&$self->appdata);
     appdata_clr_helper(&$self->appdata);
     repo_free($self, reuseids);
   }
@@ -2041,12 +1947,6 @@ rb_eval_string(
     return appdata_get_helper(repo->appdata);
   }
   %}
-#if defined(SWIGTCL)
-  %apply int Tcl_Result { int appdata_link };
-  int appdata_link(Tcl_Interp *interp, const char *cmd, const char *varname = 0) {
-    return appdata_link_helper(&$self->appdata, $self, interp, cmd, varname);
-  }
-#endif
 
   bool add_solv(const char *name, int flags = 0) {
     FILE *fp = fopen(name, "r");
index a0a9eace7422dd7ac40c762e60ecb86847bad20e..b2d8d4cd228cfbfeb101431c2614e5e7f9d0ca27 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: Libsolv-Bindings
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.78.0 <http://docbook.sf.net/>
-.\"      Date: 08/26/2015
+.\"      Date: 08/28/2015
 .\"    Manual: LIBSOLV
 .\"    Source: libsolv
 .\"  Language: English
 .\"
-.TH "LIBSOLV\-BINDINGS" "3" "08/26/2015" "libsolv" "LIBSOLV"
+.TH "LIBSOLV\-BINDINGS" "3" "08/28/2015" "libsolv" "LIBSOLV"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1009,6 +1009,21 @@ Get/Set fixed jobs stored in the pool\&. Those jobs are automatically appended t
 .\}
 .sp
 Set the callback function called when repository metadata needs to be loaded on demand\&. To make use of this feature, you need to create repodata stubs that tell the library which data is available but not loaded\&. If later on the data needs to be accessed, the callback function is called with a repodata argument\&. You can then load the data (maybe fetching it first from an remote server)\&. The callback should return true if the data has been made available\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+/* bindings only */
+\fI$pool\fR\fB\->appdata_disown()\fR
+\fIpool\fR\fB\&.appdata_disown()\fR
+\fIpool\fR\fB\&.appdata_disown()\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Decrement the reference count of the appdata object\&. This can be used to break circular references (e\&.g\&. if the pool\(cqs appdata value points to some meta data structure that contains a pool handle)\&. If used incorrectly, this method can lead to application crashes, so beware\&. (This method is a no\-op for ruby and tcl\&.)
 .SS "DATA RETRIEVAL METHODS"
 .sp
 In the following functions, the \fIkeyname\fR argument describes what to retrieve\&. For the standard cases you can use the available Id constants\&. For example,
index aa40cf87aa171d944eaadd9e585e8fdf4a80f828..f1834ff7f1003d22644757cd496426d421455f3b 100644 (file)
@@ -578,6 +578,16 @@ needs to be accessed, the callback function is called with a repodata argument.
 You can then load the data (maybe fetching it first from an remote server).
 The callback should return true if the data has been made available.
 
+       /* bindings only */
+       $pool->appdata_disown()
+       pool.appdata_disown()
+       pool.appdata_disown()
+
+Decrement the reference count of the appdata object. This can be used to break
+circular references (e.g. if the pool's appdata value points to some meta data
+structure that contains a pool handle). If used incorrectly, this method can
+lead to application crashes, so beware. (This method is a no-op for ruby and tcl.)
+
 === DATA RETRIEVAL METHODS ===
 
 In the following functions, the _keyname_ argument describes what to retrieve.