[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Permanent solution to pool problem

From: Daniel Berlin <dberlin_at_dberlin.org>
Date: 2002-09-01 22:05:37 CEST

As suggested by beazley, this basically works (a few const issues, but
these are our fault, not SWIG's). Suit to taste.

Index: svn_string.i
===================================================================
--- svn_string.i
+++ svn_string.i 2002-09-01 15:55:13.000000000 -0400
@@ -52,11 +52,9 @@
          PyErr_SetString(PyExc_TypeError, "not a string");
          return NULL;
      }
-%#error need pool argument from somewhere
      $1 = svn_stringbuf_ncreate(PyString_AS_STRING($input),
                                 PyString_GET_SIZE($input),
- /* ### gah... what pool to use? */
- pool);
+ _global_pool);
  }

  %typemap(python,out) svn_stringbuf_t * {
@@ -64,7 +62,7 @@
  }

  /* svn_stringbuf_t ** is always an output parameter */
-%typemap(ignore) svn_stringbuf_t ** (svn_stringbuf_t *temp) {
+%typemap(python) svn_stringbuf_t ** (svn_stringbuf_t *temp) {
      $1 = &temp;
  }
  %apply RET_STRING { svn_stringbuf_t ** };
@@ -92,8 +90,7 @@
  /* when storing an svn_string_t* into a structure, we must allocate the
     svn_string_t structure on the heap. */
  %typemap(python,memberin) const svn_string_t * {
-%#error need pool argument from somewhere
- $1 = svn_string_dup($input, pool);
+ $1 = svn_string_dup($input, _global_pool);
  }

  %typemap(python,out) svn_string_t * {
@@ -101,7 +98,7 @@
  }

  /* svn_string_t ** is always an output parameter */
-%typemap(ignore) svn_string_t ** (svn_string_t *temp) {
+%typemap(python) svn_string_t ** (svn_string_t *temp) {
      $1 = &temp;
  }
  %apply RET_STRING { svn_string_t ** };
@@ -113,7 +110,7 @@
  */

  /* ### note that SWIG drops the const in the arg decl, so we must cast
*/
-%typemap(ignore) const char **OUTPUT (const char *temp) {
+%typemap(python) const char **OUTPUT (const char *temp) {
      $1 = (char **)&temp;
  }
  %typemap(python,argout) const char **OUTPUT {
@@ -133,10 +130,14 @@
  /*
-----------------------------------------------------------------------
     define a general INPUT param of an array of svn_stringbuf_t* items.
   */
-
+%typemap(arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
+SWIG_ConvertPtr(PyObject_GetItem(args, PyInt_FromLong($argnum)), (void
**)&$1, SWIGTYPE_p_apr_pool_t, SWIG_POINTER_EXCEPTION | 0);
+_global_pool = $1;
+}
+%typemap (in) apr_pool_t *pool "";
  %typemap(python,in) const apr_array_header_t *STRINGLIST {
-%#error need pool argument from somewhere
- $1 = svn_swig_py_strings_to_array($input, NULL);
+
+ $1 = svn_swig_py_strings_to_array($input, _global_pool);
      if ($1 == NULL)
          return NULL;
  }
Index: svn_fs.i
===================================================================
--- svn_fs.i
+++ svn_fs.i 2002-09-01 15:58:17.000000000 -0400
@@ -69,7 +69,7 @@
     list_transaction's "apr_array_header_t **" is returning a list of
strings
  */

-%typemap(ignore) apr_array_header_t ** (apr_array_header_t *temp) {
+%typemap(python) apr_array_header_t ** (apr_array_header_t *temp) {
      $1 = &temp;
  }
  %typemap(python, argout) apr_array_header_t ** {
Index: svn_wc.i
===================================================================
--- svn_wc.i
+++ svn_wc.i 2002-09-01 16:00:00.000000000 -0400
@@ -24,12 +24,6 @@
  %import svn_string.i
  %import svn_delta.i

-/*
-----------------------------------------------------------------------
- ### these functions require a pool, which we don't have immediately
- ### handy. just eliminate these funcs for now.
-*/
-%ignore svn_wc_set_auth_file;
-
  /* ### ignore this structure because the accessors will need a pool */
  %ignore svn_wc_keywords_t;

Index: svn_client.i
===================================================================
--- svn_client.i
+++ svn_client.i 2002-09-01 16:00:44.000000000 -0400
@@ -29,11 +29,6 @@
  */
  %ignore svn_client_proplist_item_s;

-/* ### these take an 'apr_array_header_t *' which requires a pool,
which
- ### we don't have immediately handy. just eliminate these funcs for
now. */
-%ignore svn_client_commit;
-%ignore svn_client_log;
-%ignore svn_client_diff;

  /*
-----------------------------------------------------------------------
     all "targets" and "diff_options" arrays are constant inputs of
@@ -67,7 +62,7 @@
     handle the return value for svn_client_proplist()
  */

-%typemap(ignore) apr_array_header_t ** (apr_array_header_t *temp) {
+%typemap(python) apr_array_header_t ** (apr_array_header_t *temp) {
      $1 = &temp;
  }
  %typemap(python,argout) apr_array_header_t ** {
@@ -102,13 +97,13 @@
  /*
-----------------------------------------------------------------------
     handle the "statushash" OUTPUT param for svn_client_status()
  */
-%typemap(ignore) apr_hash_t **statushash = apr_hash_t **OUTPUT;
  %typemap(python,argout) apr_hash_t **statushash {
      $result = t_output_helper(
          $result,
          svn_swig_py_convert_hash(*$1, SWIGTYPE_p_svn_wc_status_t));
  }

+/*%typemap(python) apr_hash_t **statushash = apr_hash_t **OUTPUT;*/
  /*
-----------------------------------------------------------------------
     We use 'svn_wc_status_t *' in some custom code, but it isn't in the
     API anywhere. Thus, SWIG doesn't generate a typemap entry for it. by

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Sep 1 22:06:12 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.