subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bre...@apache.org
Subject svn commit: r1443811 - in /subversion/trunk/subversion/bindings/swig: include/svn_types.swg perl/libsvn_swig_perl/swigutil_pl.c perl/libsvn_swig_perl/swigutil_pl.h
Date Fri, 08 Feb 2013 00:36:05 GMT
Author: breser
Date: Fri Feb  8 00:36:05 2013
New Revision: 1443811

URL: http://svn.apache.org/r1443811
Log:
Replace inline typemap with a function.

* subversion/bindings/swig/include/svn_types.swg:
  The bulky input typemap for svn_opt_revision_t is inlined by Swig for each
  use in the generated Perl bindings.  Move its body ...

* subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c
  (svn_swig_pl_set_revision): ... to a new function here.  Also improve the
    error output when passing an invalid revision value.

* subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.h:
  Add function prototype.

Patch by: Roderich Schupp <roderich.schupp{_AT_}gmail.com>
(Tweaked by me.)

Modified:
    subversion/trunk/subversion/bindings/swig/include/svn_types.swg
    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/include/svn_types.swg
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/include/svn_types.swg?rev=1443811&r1=1443810&r2=1443811&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/include/svn_types.swg (original)
+++ subversion/trunk/subversion/bindings/swig/include/svn_types.swg Fri Feb  8 00:36:05 2013
@@ -1170,52 +1170,7 @@ svn_ ## TYPE ## _swig_rb_closed(VALUE se
 #ifdef SWIGPERL
 %typemap(in) svn_opt_revision_t * (svn_opt_revision_t rev) {
     $1 = &rev;
-    if ($input == NULL || $input == &PL_sv_undef || !SvOK($input)) {
-        rev.kind = svn_opt_revision_unspecified;
-    }
-    else if (sv_isobject($input) && sv_derived_from($input, "_p_svn_opt_revision_t"))
{
-        SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, 0);
-    }
-    else if (looks_like_number($input)) {
-        rev.kind = svn_opt_revision_number;
-        rev.value.number = SvIV($input);
-    }
-    else if (SvPOK($input)) {
-        char *input = SvPV_nolen($input);
-        if (svn_cstring_casecmp(input, "BASE") == 0)
-            rev.kind = svn_opt_revision_base;
-        else if (svn_cstring_casecmp(input, "HEAD") == 0)
-            rev.kind = svn_opt_revision_head;
-        else if (svn_cstring_casecmp(input, "WORKING") == 0)
-            rev.kind = svn_opt_revision_working;
-        else if (svn_cstring_casecmp(input, "COMMITTED") == 0)
-            rev.kind = svn_opt_revision_committed;
-        else if (svn_cstring_casecmp(input, "PREV") == 0)
-            rev.kind = svn_opt_revision_previous;
-        else if (*input == '{') {
-            svn_boolean_t matched;
-            apr_time_t tm;
-            svn_error_t *err;
-
-            char *end = strchr(input,'}');
-            if (!end)
-                SWIG_croak("unknown opt_revision_t type");
-            *end = '\0';
-            err = svn_parse_date (&matched, &tm, input + 1, apr_time_now(),
-                                  svn_swig_pl_make_pool ((SV *)NULL));
-            if (err) {
-                svn_error_clear (err);
-                SWIG_croak("unknown opt_revision_t type");
-            }
-            if (!matched)
-                SWIG_croak("unknown opt_revision_t type");
-
-            rev.kind = svn_opt_revision_date;
-            rev.value.date = tm;
-        } else
-            SWIG_croak("unknown opt_revision_t type");
-    } else
-        SWIG_croak("unknown opt_revision_t type");
+    svn_swig_pl_set_revision(&rev, $input);
 }
 #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=1443811&r1=1443810&r2=1443811&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 Fri Feb
 8 00:36:05 2013
@@ -36,6 +36,7 @@
 
 #include "svn_pools.h"
 #include "svn_opt.h"
+#include "svn_time.h"
 #include "svn_private_config.h"
 
 #include "swig_perl_external_runtime.swg"
@@ -313,6 +314,65 @@ SV *svn_swig_pl_revnums_to_list(const ap
                          NULL);
 } 
 
+/* perl -> c svn_opt_revision_t conversion */
+void svn_swig_pl_set_revision(svn_opt_revision_t *rev, SV *source)
+{
+    if (source == NULL || source == &PL_sv_undef || !SvOK(source)) {
+        rev->kind = svn_opt_revision_unspecified;
+    }
+    else if (sv_isobject(source) && sv_derived_from(source, "_p_svn_opt_revision_t"))
{
+        SWIG_ConvertPtr(source, (void **)&rev, _SWIG_TYPE("svn_opt_revision_t *"), 0);
+    }
+    else if (looks_like_number(source)) {
+        rev->kind = svn_opt_revision_number;
+        rev->value.number = SvIV(source);
+    }
+    else if (SvPOK(source)) {
+        char *input = SvPV_nolen(source);
+        if (svn_cstring_casecmp(input, "BASE") == 0)
+            rev->kind = svn_opt_revision_base;
+        else if (svn_cstring_casecmp(input, "HEAD") == 0)
+            rev->kind = svn_opt_revision_head;
+        else if (svn_cstring_casecmp(input, "WORKING") == 0)
+            rev->kind = svn_opt_revision_working;
+        else if (svn_cstring_casecmp(input, "COMMITTED") == 0)
+            rev->kind = svn_opt_revision_committed;
+        else if (svn_cstring_casecmp(input, "PREV") == 0)
+            rev->kind = svn_opt_revision_previous;
+        else if (*input == '{') {
+            svn_boolean_t matched;
+            apr_time_t tm;
+            svn_error_t *err;
+
+            char *end = strchr(input,'}');
+            if (!end)
+                croak("unknown opt_revision_t string \"%s\": "
+                      "missing closing brace for \"{DATE}\"", input);
+            *end = '\0';
+            err = svn_parse_date (&matched, &tm, input + 1, apr_time_now(),
+                                  svn_swig_pl_make_pool ((SV *)NULL));
+            if (err) {
+                svn_error_clear (err);
+                croak("unknown opt_revision_t string \"{%s}\": "
+                      "internal svn_parse_date error", input + 1);
+            }
+            if (!matched)
+                croak("unknown opt_revision_t string \"{%s}\": "
+                      "svn_parse_date failed to parse it", input + 1);
+
+            rev->kind = svn_opt_revision_date;
+            rev->value.date = tm;
+        } else
+            croak("unknown opt_revision_t string \"%s\": must be one of "
+                  "\"BASE\", \"HEAD\", \"WORKING\", \"COMMITTED\", "
+                  "\"PREV\" or a \"{DATE}\"", input);
+    } else
+        croak("unknown opt_revision_t type: must be undef, a number, "
+              "a string (one of \"BASE\", \"HEAD\", \"WORKING\", "
+              "\"COMMITTED\", \"PREV\" or a \"{DATE}\") "
+              "or a _p_svn_opt_revision_t object");
+}
+
 /* put the va_arg in stack and invoke caller_func with func.
    fmt:
    * O: perl object

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=1443811&r1=1443810&r2=1443811&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 Fri Feb
 8 00:36:05 2013
@@ -107,6 +107,8 @@ SV *svn_swig_pl_convert_array(const apr_
 
 SV *svn_swig_pl_revnums_to_list(const apr_array_header_t *array);
 
+void svn_swig_pl_set_revision(svn_opt_revision_t *rev, SV *source);
+
 /* thunked log receiver function.  */
 svn_error_t * svn_swig_pl_thunk_log_receiver(void *py_receiver,
                                              apr_hash_t *changed_paths,



Mime
View raw message