httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r170303 - in /httpd/apreq/trunk/glue/perl/xsbuilder: APR/Request/APR__Request.h APR/Request/Param/APR__Request__Param.h APR/Request/Request.xs apreq_xs_postperl.h
Date Mon, 16 May 2005 04:42:03 GMT
Author: joes
Date: Sun May 15 21:42:01 2005
New Revision: 170303

URL: http://svn.apache.org/viewcvs?rev=170303&view=rev
Log:
Dump silly APREQ_XS_THROW_ERROR macro, and upgrade apreq_xs_croak.

Modified:
    httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/APR__Request.h
    httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
    httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs
    httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h

Modified: httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/APR__Request.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/APR__Request.h?rev=170303&r1=170302&r2=170303&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/APR__Request.h (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/APR__Request.h Sun May 15 21:42:01 2005
@@ -4,15 +4,14 @@
 {
     dXSARGS;
     apreq_handle_t *req;
-    SV *sv, *obj;
+    SV *obj;
     IV iv;
 
     if (items == 0 || items > 2 || !SvROK(ST(0))
         || !sv_derived_from(ST(0), "APR::Request"))
         Perl_croak(aTHX_ "Usage: APR::Request::jar($req [,$name])");
 
-    sv = ST(0);
-    obj = apreq_xs_sv2object(aTHX_ sv, HANDLE_CLASS, 'r');
+    obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
     iv = SvIVX(obj);
     req = INT2PTR(apreq_handle_t *, iv);
 
@@ -28,8 +27,10 @@
             apr_status_t s;
 
             s = apreq_jar(req, &t);
-            if (apreq_module_status_is_error(s))
-                APREQ_XS_THROW_ERROR(r, s, "APR::Request::jar", ERROR_CLASS);
+            if (apreq_module_status_is_error(s) 
+                && !sv_derived_from(ST(0), ERROR_CLASS))
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::jar", ERROR_CLASS);
 
             XSRETURN_UNDEF;
         }
@@ -41,8 +42,10 @@
 
         s = apreq_jar(req, &t);
 
-        if (apreq_module_status_is_error(s))
-            APREQ_XS_THROW_ERROR(r, s, "APR::Request::jar", ERROR_CLASS);
+        if (apreq_module_status_is_error(s)
+            && !sv_derived_from(ST(0), ERROR_CLASS))
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::jar", ERROR_CLASS);
 
         if (t == NULL)
             XSRETURN_EMPTY;
@@ -80,15 +83,14 @@
 {
     dXSARGS;
     apreq_handle_t *req;
-    SV *sv, *obj;
+    SV *obj;
     IV iv;
 
     if (items == 0 || items > 2 || !SvROK(ST(0))
         || !sv_derived_from(ST(0), HANDLE_CLASS))
         Perl_croak(aTHX_ "Usage: APR::Request::args($req [,$name])");
 
-    sv = ST(0);
-    obj = apreq_xs_sv2object(aTHX_ sv, HANDLE_CLASS, 'r');
+    obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
     iv = SvIVX(obj);
     req = INT2PTR(apreq_handle_t *, iv);
 
@@ -106,8 +108,10 @@
             apr_status_t s;
             s = apreq_args(req, &t);
 
-            if (apreq_module_status_is_error(s))
-                APREQ_XS_THROW_ERROR(r, s, "APR::Request::args", ERROR_CLASS);
+            if (apreq_module_status_is_error(s) &&
+                !sv_derived_from(ST(0), ERROR_CLASS))
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::args", ERROR_CLASS);
 
             XSRETURN_UNDEF;
         }
@@ -119,8 +123,10 @@
 
         s = apreq_args(req, &t);
 
-        if (apreq_module_status_is_error(s))
-            APREQ_XS_THROW_ERROR(r, s, "APR::Request::args", ERROR_CLASS);
+        if (apreq_module_status_is_error(s) &&
+            !sv_derived_from(ST(0), ERROR_CLASS))
+            apreq_xs_croak(aTHX_ newHV(), obj, s,
+                           "APR::Request::args", ERROR_CLASS);
 
         if (t == NULL)
             XSRETURN_EMPTY;
@@ -157,15 +163,14 @@
 {
     dXSARGS;
     apreq_handle_t *req;
-    SV *sv, *obj;
+    SV *obj;
     IV iv;
 
     if (items == 0 || items > 2 || !SvROK(ST(0))
         || !sv_derived_from(ST(0),HANDLE_CLASS))
         Perl_croak(aTHX_ "Usage: APR::Request::body($req [,$name])");
 
-    sv = ST(0);
-    obj = apreq_xs_sv2object(aTHX_ sv, HANDLE_CLASS, 'r');
+    obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
     iv = SvIVX(obj);
     req = INT2PTR(apreq_handle_t *, iv);
 
@@ -183,8 +188,10 @@
             apr_status_t s;
             s = apreq_body(req, &t);
 
-            if (apreq_module_status_is_error(s))
-                APREQ_XS_THROW_ERROR(r, s, "APR::Request::body", ERROR_CLASS);
+            if (apreq_module_status_is_error(s) &&
+                !sv_derived_from(ST(0), ERROR_CLASS))
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::body", ERROR_CLASS);
 
             XSRETURN_UNDEF;
         }
@@ -196,8 +203,10 @@
 
         s = apreq_body(req, &t);
 
-        if (apreq_module_status_is_error(s))
-            APREQ_XS_THROW_ERROR(r, s, "APR::Request::body", ERROR_CLASS);
+        if (apreq_module_status_is_error(s) &&
+            !sv_derived_from(ST(0), ERROR_CLASS))
+            apreq_xs_croak(aTHX_ newHV(), obj, s,
+                           "APR::Request::body", ERROR_CLASS);
 
         if (t == NULL)
             XSRETURN_EMPTY;
@@ -235,15 +244,14 @@
 {
     dXSARGS;
     apreq_handle_t *req;
-    SV *sv, *obj;
+    SV *obj;
     IV iv;
 
     if (items == 0 || items > 2 || !SvROK(ST(0))
         || !sv_derived_from(ST(0), "APR::Request"))
         Perl_croak(aTHX_ "Usage: APR::Request::param($req [,$name])");
 
-    sv = ST(0);
-    obj = apreq_xs_sv2object(aTHX_ sv, HANDLE_CLASS, 'r');
+    obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
     iv = SvIVX(obj);
     req = INT2PTR(apreq_handle_t *, iv);
 

Modified: httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h?rev=170303&r1=170302&r2=170303&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h Sun May
15 21:42:01 2005
@@ -279,7 +279,7 @@
         e = APR_BRIGADE_FIRST(bb);
         s = apr_bucket_read(e, &data, &dlen, APR_BLOCK_READ);
         if (s != APR_SUCCESS)
-            apreq_xs_croak(aTHX_ newHV(), s, 
+            apreq_xs_croak(aTHX_ newHV(), Nullsv, s, 
                            "APR::Request::Brigade::READ", 
                            "APR::Error");
         want = dlen;
@@ -292,7 +292,7 @@
         case APR_INCOMPLETE:
             s = apr_brigade_length(bb, 1, &len);
             if (s != APR_SUCCESS)
-                apreq_xs_croak(aTHX_ newHV(), s, 
+                apreq_xs_croak(aTHX_ newHV(), Nullsv, s, 
                                "APR::Request::Brigade::READ",
                                "APR::Error");
             want = len;
@@ -301,7 +301,7 @@
             break;
 
         default:
-            apreq_xs_croak(aTHX_ newHV(), s, 
+            apreq_xs_croak(aTHX_ newHV(), Nullsv, s, 
                            "APR::Request::Brigade::READ",
                            "APR::Error");
         }
@@ -318,8 +318,9 @@
         apr_size_t dlen;
         s = apr_bucket_read(e, &data, &dlen, APR_BLOCK_READ);
         if (s != APR_SUCCESS)
-            apreq_xs_croak(aTHX_ newHV(), s, 
-                           "APR::Request::Brigade::READ", "APR::Error");
+            apreq_xs_croak(aTHX_ newHV(), Nullsv, s, 
+                           "APR::Request::Brigade::READ",
+                           "APR::Error");
         memcpy(buf, data, dlen);
         buf += dlen;
         apr_bucket_delete(e);
@@ -369,7 +370,7 @@
         e = APR_BRIGADE_FIRST(bb);
         s = apr_bucket_read(e, &data, &dlen, APR_BLOCK_READ);
         if (s != APR_SUCCESS)
-            apreq_xs_croak(aTHX_ newHV(), s, 
+            apreq_xs_croak(aTHX_ newHV(), Nullsv, s, 
                            "APR::Request::Brigade::READLINE",
                            "APR::Error");
 

Modified: httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs?rev=170303&r1=170302&r2=170303&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Request.xs Sun May 15 21:42:01 2005
@@ -43,10 +43,13 @@
         apr_uint64_t bytes;
         s = apreq_read_limit_get(req, &bytes);     
         if (s != APR_SUCCESS) {
-            SV *sv = ST(0), *obj = ST(0);
-            APREQ_XS_THROW_ERROR(r, s, 
-                   "APR::Request::read_limit", "APR::Request::Error");
-            RETVAL = &PL_sv_undef;
+            if (!sv_derived_from(ST(0), ERROR_CLASS)) {
+                SV *obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::read_limit", ERROR_CLASS);
+            }
+            else
+                RETVAL = &PL_sv_undef;
         }
         else {
             RETVAL = newSVuv(bytes);
@@ -55,12 +58,13 @@
     else {
         apr_status_t s = apreq_read_limit_set(req, SvUV(val));
         if (s != APR_SUCCESS) {
-            if (GIMME_V == G_VOID) {
-                SV *sv = ST(0), *obj = ST(0);
-                APREQ_XS_THROW_ERROR(r, s, 
-                    "APR::Request::read_limit", "APR::Request::Error");
+            if (GIMME_V == G_VOID && !sv_derived_from(ST(0), ERROR_CLASS)) {
+                SV *obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::read_limit", ERROR_CLASS);
             }
-            RETVAL = &PL_sv_no;
+            else
+                RETVAL = &PL_sv_no;
         }
         else {
             RETVAL = &PL_sv_yes;
@@ -82,10 +86,13 @@
         apr_size_t bytes;
         s = apreq_brigade_limit_get(req, &bytes);     
         if (s != APR_SUCCESS) {
-            SV *sv = ST(0), *obj = ST(0);
-            APREQ_XS_THROW_ERROR(r, s, 
-                   "APR::Request::brigade_limit", "APR::Request::Error");
-            RETVAL = &PL_sv_undef;
+            if (!sv_derived_from(ST(0), ERROR_CLASS)) {
+                SV *obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::brigade_limit", ERROR_CLASS);
+            }
+            else
+                RETVAL = &PL_sv_undef;
         }
         else {
             RETVAL = newSVuv(bytes);
@@ -94,12 +101,13 @@
     else {
         apr_status_t s = apreq_brigade_limit_set(req, SvUV(val));
         if (s != APR_SUCCESS) {
-            if (GIMME_V == G_VOID) {
-                SV *sv = ST(0), *obj = ST(0);
-                APREQ_XS_THROW_ERROR(r, s, 
-                    "APR::Request::brigade_limit", "APR::Request::Error");
+            if (GIMME_V == G_VOID && !sv_derived_from(ST(0), ERROR_CLASS)) {
+                SV *obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::brigade_limit", ERROR_CLASS);
             }
-            RETVAL = &PL_sv_no;
+            else
+                RETVAL = &PL_sv_no;
         }
         else {
             RETVAL = &PL_sv_yes;
@@ -122,10 +130,13 @@
         const char *path;
         s = apreq_temp_dir_get(req, &path);     
         if (s != APR_SUCCESS) {
-            SV *sv = ST(0), *obj = ST(0);
-            APREQ_XS_THROW_ERROR(r, s, 
-                   "APR::Request::temp_dir", "APR::Request::Error");
-            RETVAL = &PL_sv_undef;
+            if (!sv_derived_from(ST(0), ERROR_CLASS)) {
+                SV *obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::temp_dir", ERROR_CLASS);
+            }
+            else
+                RETVAL = &PL_sv_undef;
         }
         else {
             RETVAL = (path == NULL) ? &PL_sv_undef : newSVpv(path, 0);
@@ -134,12 +145,13 @@
     else {
         apr_status_t s = apreq_temp_dir_set(req, SvPV_nolen(val));
         if (s != APR_SUCCESS) {
-            if (GIMME_V == G_VOID) {
-                SV *sv = ST(0), *obj = ST(0);
-                APREQ_XS_THROW_ERROR(r, s, 
-                    "APR::Request::temp_dir", "APR::Request::Error");
+            if (GIMME_V == G_VOID && !sv_derived_from(ST(0), ERROR_CLASS)) {
+                SV *obj = apreq_xs_sv2object(aTHX_ ST(0), HANDLE_CLASS, 'r');
+                apreq_xs_croak(aTHX_ newHV(), obj, s,
+                               "APR::Request::temp_dir", ERROR_CLASS);
             }
-            RETVAL = &PL_sv_no;
+            else
+                RETVAL = &PL_sv_no;
         }
         else {
             RETVAL = &PL_sv_yes;

Modified: httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h?rev=170303&r1=170302&r2=170303&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h Sun May 15 21:42:01 2005
@@ -236,28 +236,28 @@
 }
 
 static APR_INLINE
-void apreq_xs_croak(pTHX_ HV *data, apr_status_t rc, const char *func, 
-                   const char *class)
+void apreq_xs_croak(pTHX_ HV *data, SV *obj, apr_status_t rc,
+                    const char *func, const char *class)
 {
-    HV *stash = gv_stashpvn(class, strlen(class), FALSE);
+    HV *stash;
 
-    sv_setsv(ERRSV, sv_2mortal(sv_bless(newRV_noinc((SV*)data), stash)));
+    stash = gv_stashpv(ERROR_CLASS, FALSE);
+    if (stash == NULL) {
+        SV *pkg_name = sv_2mortal(newSVpv(class, 0));
+        Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, pkg_name, Nullsv);
+        stash = gv_stashpv(class, TRUE);
+    }
+
+    if (obj != Nullsv)
+        sv_setsv(*hv_fetch(data, "_r",   2, 1), sv_2mortal(newRV_inc(obj)));
     sv_setiv(*hv_fetch(data, "rc",   2, 1), rc);
     sv_setpv(*hv_fetch(data, "file", 4, 1), CopFILE(PL_curcop));
     sv_setiv(*hv_fetch(data, "line", 4, 1), CopLINE(PL_curcop));
     sv_setpv(*hv_fetch(data, "func", 4, 1), func);
+
+    sv_setsv(ERRSV, sv_2mortal(sv_bless(newRV_noinc((SV*)data), stash)));
     Perl_croak(aTHX_ Nullch);
 }
-
-#define APREQ_XS_THROW_ERROR(attr, status, func, errpkg)  do {          \
-    if (!sv_derived_from(sv, errpkg)) {                                 \
-        HV *hv = newHV();                                               \
-        SV *rv = newRV_inc(obj);                                        \
-        sv_setsv(*hv_fetch(hv, "_" #attr, 2, 1), sv_2mortal(rv));       \
-        apreq_xs_croak(aTHX_ hv, status, func, errpkg);                 \
-    }                                                                   \
-} while (0)
-
 
 static APR_INLINE
 const char *apreq_xs_helper_class(pTHX_ SV **SP, SV *sv, const char *method)



Mime
View raw message