subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1506580 - in /subversion/trunk/subversion/bindings/swig: core.i perl/libsvn_swig_perl/swigutil_pl.c perl/libsvn_swig_perl/swigutil_pl.h
Date Wed, 24 Jul 2013 14:39:20 GMT
Author: rhuijben
Date: Wed Jul 24 14:39:20 2013
New Revision: 1506580

URL: http://svn.apache.org/r1506580
Log:
Following up on r1506554, cleanup more swig code with the assumption that
there is a shared library available for sharing state and that the individual
libraries shouldn't depend on each other.

Don't export functions from core.i with the risk of loading duplicated code,
but publish the core.i functions via the swig utils library.

* subversion/bindings/swig/core.i
  (svn_swig_pl_get_current_pool,
   svn_swig_pl_set_current_pool): Make static and rename to
  (core_get_current_pool,
   core_set_current_pool): To stop exporting this function from here.
  (init): Update caller.

* subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c
  (svn_swig_pl_get_current_pool,
   svn_swig_pl_set_current_pool): Rename to ...
  (get_current_pool_cb,
   set_current_pool_cb): To make the name show that they are file static.

  (svn_swig_pl_bind_current_pool_fns): Use our common pattern of hiding by
     renaming this function to...
  (svn_swig_pl__bind_current_pool_fns): ... this.
  (svn_swig_pl_get_current_pool): New function.
  (svn_swig_pl_set_current_pool): New function.

* subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.h
  (svn_swig_pl_get_current_pool_t,
   svn_swig_pl_set_current_pool_t): Rename to ...
     (svn_swig_pl_get_current_pool_func_t,
      svn_swig_pl_set_current_pool_func_t): this.

  (svn_swig_pl_bind_current_pool_fns): Rename to ...
  (svn_swig_pl__bind_current_pool_fns): ... this.

  (svn_swig_pl_get_current_pool,
   svn_swig_pl_set_current_pool): New function.

Modified:
    subversion/trunk/subversion/bindings/swig/core.i
    subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c
    subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.h

Modified: subversion/trunk/subversion/bindings/swig/core.i
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/core.i?rev=1506580&r1=1506579&r2=1506580&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/core.i (original)
+++ subversion/trunk/subversion/bindings/swig/core.i Wed Jul 24 14:39:20 2013
@@ -645,28 +645,20 @@ typedef int apr_status_t;
 #ifdef SWIGPERL
 apr_pool_t *current_pool;
 
-#if SWIG_VERSION <= 0x010324
-%{
-#define SVN_SWIGEXPORT(t) SWIGEXPORT(t)
-%}
-#else
-%{
-#define SVN_SWIGEXPORT(t) SWIGEXPORT t
-%}
-#endif
-
 %{
 
+/* ### Eventually this should go away. This is not thread safe and a very
+   ### good example on HOW NOT TO USE pools */
 static apr_pool_t *current_pool = 0;
 
-SVN_SWIGEXPORT(apr_pool_t *)
-svn_swig_pl_get_current_pool (void)
+static apr_pool_t *
+core_get_current_pool (void)
 {
   return current_pool;
 }
 
-SVN_SWIGEXPORT(void)
-svn_swig_pl_set_current_pool (apr_pool_t *pool)
+static void
+core_set_current_pool (apr_pool_t *pool)
 {
   current_pool = pool;
 }
@@ -870,8 +862,8 @@ static void svn_auth_set_gnome_keyring_u
 #include "svn_private_config.h"
 %}
 %init %{
-  svn_swig_pl_bind_current_pool_fns (&svn_swig_pl_get_current_pool,
-                                     &svn_swig_pl_set_current_pool);
+  svn_swig_pl__bind_current_pool_fns(&core_get_current_pool,
+                                     &core_set_current_pool);
 %}
 #endif
 

Modified: subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c?rev=1506580&r1=1506579&r2=1506580&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c (original)
+++ subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c Wed Jul
24 14:39:20 2013
@@ -1605,14 +1605,32 @@ svn_boolean_t svn_swig_pl_thunk_config_e
 
 /* default pool support */
 
-static svn_swig_pl_get_current_pool_t svn_swig_pl_get_current_pool = NULL;
-static svn_swig_pl_set_current_pool_t svn_swig_pl_set_current_pool = NULL;
+static svn_swig_pl_get_current_pool_func_t get_current_pool_cb = NULL;
+static svn_swig_pl_set_current_pool_func_t set_current_pool_cb = NULL;
 
-void svn_swig_pl_bind_current_pool_fns(svn_swig_pl_get_current_pool_t get,
-                                       svn_swig_pl_set_current_pool_t set)
+void
+svn_swig_pl__bind_current_pool_fns(svn_swig_pl_get_current_pool_func_t get,
+                                   svn_swig_pl_set_current_pool_func_t set)
 {
-  svn_swig_pl_get_current_pool = get;
-  svn_swig_pl_set_current_pool = set;
+  /* This function should only be called ONCE, otherwise there are two
+     global variables CURRENT_POOL */
+  SVN_ERR_ASSERT_NO_RETURN(get_current_pool_cb == NULL
+                           && set_current_pool_cb == NULL);
+
+  get_current_pool_cb = get;
+  set_current_pool_cb = set;
+}
+
+apr_pool_t * svn_swig_pl_get_current_pool()
+{
+  SVN_ERR_ASSERT_NO_RETURN(get_current_pool_cb != NULL);
+  return get_current_pool_cb();
+}
+
+void svn_swig_pl_set_current_pool(apr_pool_t *pool)
+{
+  SVN_ERR_ASSERT_NO_RETURN(set_current_pool_cb != NULL);
+  set_current_pool_cb(pool);
 }
 
 apr_pool_t *svn_swig_pl_make_pool(SV *obj)

Modified: subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.h?rev=1506580&r1=1506579&r2=1506580&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.h (original)
+++ subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.h Wed Jul
24 14:39:20 2013
@@ -59,11 +59,14 @@ extern "C" {
 #endif
 
 
-typedef apr_pool_t *(*svn_swig_pl_get_current_pool_t)(void);
-typedef void (*svn_swig_pl_set_current_pool_t)(apr_pool_t *pool);
+typedef apr_pool_t *(*svn_swig_pl_get_current_pool_func_t)(void);
+typedef void (*svn_swig_pl_set_current_pool_func_t)(apr_pool_t *pool);
 
-void svn_swig_pl_bind_current_pool_fns(svn_swig_pl_get_current_pool_t get,
-                                       svn_swig_pl_set_current_pool_t set);
+void svn_swig_pl__bind_current_pool_fns(svn_swig_pl_get_current_pool_func_t get,
+                                       svn_swig_pl_set_current_pool_func_t set);
+
+apr_pool_t * svn_swig_pl_get_current_pool();
+void svn_swig_pl_set_current_pool(apr_pool_t *pool);
 
 apr_pool_t *svn_swig_pl_make_pool(SV *obj);
 



Mime
View raw message