httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cvs commit: httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload Apache__Upload.h
Date Wed, 07 Jul 2004 06:41:17 GMT
joes        2004/07/06 23:41:17

  Modified:    glue/perl/t/response/TestApReq request.pm
               glue/perl/xsbuilder apreq_xs_postperl.h apreq_xs_tables.h
               glue/perl/xsbuilder/Apache/Cookie Apache__Cookie.h
               glue/perl/xsbuilder/Apache/Request Apache__Request.h
               glue/perl/xsbuilder/Apache/Upload Apache__Upload.h
  Log:
  Tests with fixes for $table->add, $table->set.  Prior to this fix, those APIs produced
segfaults.  The changes required uniform adoption of apreq_xs_find_obj throughout the table
macros, because we need to allow both the tiehash and object APIs to share the same XS.
  
  Revision  Changes    Path
  1.23      +7 -0      httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm
  
  Index: request.pm
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- request.pm	5 Jul 2004 17:39:50 -0000	1.22
  +++ request.pm	7 Jul 2004 06:41:16 -0000	1.23
  @@ -25,6 +25,13 @@
       my $method = $r->method;
   
       if ($test eq 'param') {
  +        my $table = $req->args();
  +        $table->add("new_arg" => "new");
  +        die "Can't find new_arg" unless $table->{new_arg} eq "new";
  +        $table->{new_arg} = "newer";
  +        die "Can't find newer arg" unless $table->get("new_arg") eq "newer";
  +        delete $table->{new_arg};
  +        die "New arg still exists after deletion" if exists $table->{new_arg};
           my $value = $req->param('value');
           $req->print($value);
       }
  
  
  
  1.37      +1 -1      httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_postperl.h
  
  Index: apreq_xs_postperl.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_postperl.h,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- apreq_xs_postperl.h	6 Jul 2004 18:26:48 -0000	1.36
  +++ apreq_xs_postperl.h	7 Jul 2004 06:41:16 -0000	1.37
  @@ -276,7 +276,7 @@
                                                                   \
       if (items != 1 || !SvROK(ST(0)))                            \
           Perl_croak(aTHX_ "Usage: $obj->pool()");                \
  -    env = apreq_xs_##attr##_sv2env(ST(0));                      \
  +    env = apreq_xs_##attr##_sv2env(SvRV(ST(0)));                \
       ST(0) = sv_2mortal(sv_setref_pv(newSV(0), "APR::Pool",      \
                                       apreq_env_pool(env)));      \
       XSRETURN(1);                                                \
  
  
  
  1.3       +29 -12    httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_tables.h
  
  Index: apreq_xs_tables.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_tables.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apreq_xs_tables.h	6 Jul 2004 18:34:35 -0000	1.2
  +++ apreq_xs_tables.h	7 Jul 2004 06:41:16 -0000	1.3
  @@ -25,6 +25,22 @@
    * don't bother supporting merge, overlap, compress
    */
   
  +#define apreq_xs_sv2table(sv)      ((apr_table_t *) SvIVX(SvRV(sv)))
  +/*
  +APR_INLINE
  +static apr_table_t * apreq_xs_sv2table(pTHX_ SV *sv)
  +{
  +    MAGIC *mg = mg_find(SvRV(sv), PERL_MAGIC_tied);
  +    if (mg == NULL || !SvROK(mg->mg_obj))
  +        Perl_croak(aTHX_ "Can't find tied table");
  +
  +    return (apr_table_t *) SvIVX(SvRV(mg->mg_obj));
  +}
  +*/
  +#define apreq_xs_table2sv(t,class,parent)                               \
  +                  apreq_xs_table_c2perl(aTHX_ t, env, class, parent)
  +
  +
   #define APREQ_XS_DEFINE_TABLE_MAKE(attr)                        \
   static XS(apreq_xs_table_##attr##_make)                         \
   {                                                               \
  @@ -55,14 +71,18 @@
       void *env;                                                                  \
       apr_table_t *t;                                                             \
       const char *key, *val;                                                      \
  +    SV *sv;                                                                     \
       STRLEN klen, vlen;                                                          \
       apreq_##attr##_t *obj;                                                      \
                                                                                   \
       if (items != 3 || !SvROK(ST(0)) || !SvPOK(ST(1)))                           \
           Perl_croak(aTHX_ "Usage: $table->" #method "($key, $val)");             \
                                                                                   \
  -    env = apreq_xs_sv2env(ST(0));                                               \
  -    t   = apreq_xs_sv2table(ST(0));                                             \
  +    sv  = apreq_xs_find_obj(aTHX_ ST(0), #attr);                                \
  +    if (sv == NULL)                                                             \
  +         Perl_croak(aTHX_ "Cannot find object");                                \
  +    env = apreq_xs_sv2env(sv);                                                  \
  +    t   = (apr_table_t *) SvIVX(sv);                                            \
       key = SvPV(ST(1), klen);                                                    \
                                                                                   \
       if (SvROK(ST(2))) {                                                         \
  @@ -88,8 +108,8 @@
   
   struct apreq_xs_do_arg {
       void            *env;
  -    PerlInterpreter *perl;
       SV              *parent;
  +    PerlInterpreter *perl;
   };
   
   static int apreq_xs_table_keys(void *data, const char *key,
  @@ -111,11 +131,6 @@
       return 1;
   }
   
  -#define apreq_xs_sv2table(sv)      ((apr_table_t *) SvIVX(SvRV(sv)))
  -
  -#define apreq_xs_table2sv(t,class,parent)                               \
  -                  apreq_xs_table_c2perl(aTHX_ t, env, class, parent)
  -
   #define apreq_xs_do(attr)          (items == 1 ? apreq_xs_table_keys    \
                                      : apreq_xs_##attr##_table_values)
   
  @@ -168,15 +183,17 @@
   {                                                                       \
       dXSARGS;                                                            \
       const char *key = NULL;                                             \
  -    struct apreq_xs_do_arg d = { NULL, aTHX, NULL };                    \
  +    struct apreq_xs_do_arg d = { NULL, NULL, aTHX };                    \
       void *env;                                                          \
  -    SV *sv = ST(0);                                                     \
  +    SV *sv;                                                             \
                                                                           \
       if (items == 0 || items > 2 || !SvROK(ST(0)))                       \
           Perl_croak(aTHX_ "Usage: $object->get($key)");                  \
                                                                           \
  -    env = apreq_xs_##attr##_sv2env(ST(0));                              \
  -    d.env = env; d.parent=sv;                                           \
  +    sv = apreq_xs_find_obj(aTHX_ ST(0), #attr);                         \
  +    env = apreq_xs_##attr##_sv2env(sv);                                 \
  +    d.env = env;                                                        \
  +    d.parent = sv;                                                      \
       if (items == 2)                                                     \
           key = SvPV_nolen(ST(1));                                        \
                                                                           \
  
  
  
  1.25      +5 -6      httpd-apreq-2/glue/perl/xsbuilder/Apache/Cookie/Apache__Cookie.h
  
  Index: Apache__Cookie.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Cookie/Apache__Cookie.h,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Apache__Cookie.h	6 Jul 2004 18:26:48 -0000	1.24
  +++ Apache__Cookie.h	7 Jul 2004 06:41:16 -0000	1.25
  @@ -40,7 +40,7 @@
           if (n == 1 && items == 2)                                       \
               break;                                                      \
       default:                                                            \
  -        s = apreq_xs_sv2(jar, sv)->status;                              \
  +        s = ((apreq_jar_t *)SvIVX(sv))->status;                         \
           if (s != APR_SUCCESS) {                                         \
               apreq_xs_croak(aTHX_ newHV(), s, "Apache::Cookie::Jar::get",\
                              "Apache::Cookie::Error");                    \
  @@ -56,16 +56,15 @@
   #define S2C(s)  apreq_value_to_cookie(apreq_strtoval(s))
   #define apreq_xs_jar_push(sv,d,key)   apreq_xs_push(jar,sv,d,key)
   #define apreq_xs_table_push(sv,d,key) apreq_xs_push(table,sv,d,key)
  -#define apreq_xs_jar_sv2table(sv) (apreq_xs_sv2(jar, sv)->cookies)
  -#define apreq_xs_table_sv2table(sv) apreq_xs_sv2table(sv)
  -#define apreq_xs_jar_sv2env(sv) apreq_xs_sv2(jar,sv)->env
  -#define apreq_xs_table_sv2env(sv) apreq_xs_sv2env(SvRV(sv))
  +#define apreq_xs_jar_sv2table(sv)     ((apreq_jar_t *)SvIVX(sv))->cookies
  +#define apreq_xs_table_sv2table(sv)   ((apr_table_t *)SvIVX(sv))
  +#define apreq_xs_jar_sv2env(sv)       ((apreq_jar_t *)SvIVX(sv))->env
  +#define apreq_xs_table_sv2env(sv)     apreq_xs_sv2env(sv)
   
   #define apreq_xs_jar_cookie(sv,k) \
                   S2C(apr_table_get(apreq_xs_jar_sv2table(sv),k))
   #define apreq_xs_table_cookie(sv,k) \
                   S2C(apr_table_get(apreq_xs_table_sv2table(sv),k))
  -
   
   #define TABLE_PKG   "Apache::Cookie::Table"
   #define COOKIE_PKG  "Apache::Cookie"
  
  
  
  1.41      +14 -14    httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h
  
  Index: Apache__Request.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- Apache__Request.h	6 Jul 2004 18:26:48 -0000	1.40
  +++ Apache__Request.h	7 Jul 2004 06:41:17 -0000	1.41
  @@ -30,7 +30,7 @@
           if (n == 1 && items == 2)                                       \
               break;                                                      \
       default:                                                            \
  -        req = apreq_xs_sv2(request, sv);                                \
  +        req = (apreq_request_t *)SvIVX(sv);                             \
           s = req->args_status;                                           \
           if (s == APR_SUCCESS && req->parser)                            \
               s = apreq_parse_request(req, NULL);                         \
  @@ -56,7 +56,7 @@
           if (n == 1 && items == 2)                                       \
               break;                                                      \
       default:                                                            \
  -        req = apreq_xs_sv2(request, sv);                                \
  +        req = (apreq_request_t *)SvIVX(sv);                             \
           s = req->args_status;                                           \
           if (s != APR_SUCCESS)                                           \
               apreq_xs_croak(aTHX_ newHV(), s, "Apache::Request::args",   \
  @@ -75,7 +75,7 @@
           if (n == 1 && items == 2)                                       \
               break;                                                      \
       default:                                                            \
  -        req = apreq_xs_sv2(request, sv);                                \
  +        req = (apreq_request_t *)SvIVX(sv);                             \
           if (req->parser == NULL)                                        \
              break;                                                       \
           switch (s = apreq_parse_request(req,NULL)) {                    \
  @@ -101,7 +101,7 @@
   
   #define S2P(s) (s ? apreq_value_to_param(apreq_strtoval(s)) : NULL)
   #define apreq_xs_request_push(sv,d,key) do {                            \
  -    apreq_request_t *req = apreq_xs_sv2(request,sv);                    \
  +    apreq_request_t *req = (apreq_request_t *)SvIVX(sv);                \
       apr_status_t s;                                                     \
       apr_table_do(apreq_xs_do(request), d, req->args, key, NULL);        \
       do s = apreq_env_read(req->env, APR_BLOCK_READ, READ_BLOCK_SIZE);   \
  @@ -114,22 +114,22 @@
   #define apreq_xs_table_push(sv,d,k) apreq_xs_push(table,sv,d,k)
   
   #define apreq_xs_request_sv2table(sv) apreq_params(apreq_env_pool(env), \
  -                                                   apreq_xs_sv2(request,sv))
  -#define apreq_xs_args_sv2table(sv) apreq_xs_sv2(request,sv)->args
  -#define apreq_xs_body_sv2table(sv) apreq_xs_sv2(request,sv)->body
  -#define apreq_xs_table_sv2table(sv) apreq_xs_sv2table(sv)
  -#define apreq_xs_request_sv2env(sv) apreq_xs_sv2(request,sv)->env
  -#define apreq_xs_args_sv2env(sv) apreq_xs_sv2(request,sv)->env
  -#define apreq_xs_body_sv2env(sv) apreq_xs_sv2(request,sv)->env
  -#define apreq_xs_table_sv2env(sv) apreq_xs_sv2env(SvRV(sv))
  +                                        (apreq_request_t *)SvIVX(sv))
  +#define apreq_xs_args_sv2table(sv)  ((apreq_request_t *)SvIVX(sv))->args
  +#define apreq_xs_body_sv2table(sv)  ((apreq_request_t *)SvIVX(sv))->body
  +#define apreq_xs_table_sv2table(sv) ((apr_table_t *)SvIVX(sv))
  +#define apreq_xs_request_sv2env(sv) ((apreq_request_t *)SvIVX(sv))->env
  +#define apreq_xs_args_sv2env(sv)    ((apreq_request_t *)SvIVX(sv))->env
  +#define apreq_xs_body_sv2env(sv)    ((apreq_request_t *)SvIVX(sv))->env
  +#define apreq_xs_table_sv2env(sv)   apreq_xs_sv2env(sv)
   
  -#define apreq_xs_request_param(sv,k) apreq_param(apreq_xs_sv2(request,sv),k)
  +#define apreq_xs_request_param(sv,k) apreq_param((apreq_request_t *)SvIVX(sv),k)
   #define apreq_xs_args_param(sv,k) \
                        S2P(apr_table_get(apreq_xs_args_sv2table(sv),k))
   #define apreq_xs_body_param(sv,k) \
                        S2P(apr_table_get(apreq_xs_body_sv2table(sv),k))
   #define apreq_xs_table_param(sv,k) \
  -                     S2P(apr_table_get(apreq_xs_sv2table(sv),k))
  +                     S2P(apr_table_get(apreq_xs_table_sv2table(sv),k))
   
   APREQ_XS_DEFINE_TABLE_GET(request, PARAM_TABLE, param, NULL, 1);
   APREQ_XS_DEFINE_TABLE_GET(args,    PARAM_TABLE, param, NULL, 1);
  
  
  
  1.17      +12 -10    httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload/Apache__Upload.h
  
  Index: Apache__Upload.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload/Apache__Upload.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Apache__Upload.h	6 Jul 2004 18:26:48 -0000	1.16
  +++ Apache__Upload.h	7 Jul 2004 06:41:17 -0000	1.17
  @@ -33,7 +33,7 @@
           if (n == 1 && items == 2)                                       \
               break;                                                      \
       default:                                                            \
  -        req = apreq_xs_sv2(request, sv);                                \
  +        req = (apreq_request_t *)SvIVX(sv);                             \
           if (req->parser == NULL)                                        \
              break;                                                       \
           switch (s = apreq_parse_request(req,NULL)) {                    \
  @@ -57,7 +57,7 @@
                                   : apreq_xs_upload_table_values)
   
   #define apreq_xs_upload_push(sv,d,key) do {                             \
  -    apreq_request_t *req = apreq_xs_sv2(request,sv);                    \
  +    apreq_request_t *req = (apreq_request_t *)SvIVX(sv);                \
       apr_status_t s;                                                     \
       do s = apreq_env_read(req->env, APR_BLOCK_READ, READ_BLOCK_SIZE);   \
       while (s == APR_INCOMPLETE);                                        \
  @@ -67,19 +67,19 @@
   
   #define apreq_xs_upload_table_push(sv,d,k) apreq_xs_push(upload_table,sv,d,k)
   #define apreq_xs_upload_sv2table(sv) apreq_uploads(apreq_env_pool(env), \
  -                                                   apreq_xs_sv2(request,sv))
  -#define apreq_xs_upload_table_sv2table(sv) apreq_xs_sv2table(sv)
  -#define apreq_xs_upload_sv2env(sv) apreq_xs_sv2(request,sv)->env
  -#define apreq_xs_upload_table_sv2env(sv) apreq_xs_sv2env(SvRV(sv))
  -#define apreq_xs_upload_param(sv,k) apreq_upload(apreq_xs_sv2(request,sv),k)
  +                                                (apreq_request_t *)SvIVX(sv))
  +#define apreq_xs_upload_table_sv2table(sv) ((apr_table_t *)SvIVX(sv))
  +#define apreq_xs_upload_sv2env(sv)         ((apreq_request_t *)SvIVX(sv))->env
  +#define apreq_xs_upload_table_sv2env(sv)   apreq_xs_sv2env(sv)
  +#define apreq_xs_upload_param(sv,k) apreq_upload((apreq_request_t *)SvIVX(sv),k)
   #define apreq_xs_upload_table_param(sv,k) \
  -                     S2P(apr_table_get(apreq_xs_sv2table(sv),k))
  +                        S2P(apr_table_get(apreq_xs_upload_table_sv2table(sv),k))
   
   
   /* uploads are represented by the full apreq_param_t in C */
   #define apreq_upload_t apreq_param_t
   #define apreq_xs_param2sv(ptr,class,parent)  apreq_xs_2sv(ptr,class,parent)
  -#define apreq_xs_sv2param(sv) ((apreq_upload_t *)SvIVX(SvRV(sv)))
  +#define apreq_xs_sv2param(sv) ((apreq_param_t *)SvIVX(SvRV(sv)))
   
   static int apreq_xs_upload_table_keys(void *data, const char *key,
                                         const char *val)
  @@ -105,8 +105,10 @@
   
   }
   
  +
   #define UPLOAD_TABLE  "Apache::Upload::Table"
   #define UPLOAD_PKG    "Apache::Upload"
  +
   APREQ_XS_DEFINE_TABLE_GET(upload, UPLOAD_TABLE, param, UPLOAD_PKG, RETVAL->bb);
   APREQ_XS_DEFINE_TABLE_GET(upload_table, UPLOAD_TABLE, param, UPLOAD_PKG, 1);
   APREQ_XS_DEFINE_ENV(upload);
  @@ -143,7 +145,7 @@
           apr_off_t len;
   
           s = apr_file_open(&f, name, APR_CREATE | APR_EXCL | APR_WRITE |
  -                          APR_READ | APR_BINARY | APR_BUFFERED,
  +                          APR_READ | APR_BINARY,
                             APR_OS_DEFAULT,
                             apreq_env_pool(env));
           if (s == APR_SUCCESS) {
  
  
  

Mime
View raw message