geoff 2003/06/04 09:50:38
Modified: src/modules/perl modperl_module.c modperl_module.h
xs/Apache/Module Apache__Module.h
xs/tables/current/ModPerl FunctionTable.pm
Log:
renamed the private modperl_module_config_get_obj function to
modperl_module_config_create_obj, since the logic creates
the object but doesn't dig it out if it already exists. then,
moved logic from mpxs_Apache__Module_get_config into a new public
C function that reused the old name, modperl_module_config_get_obj.
while Apache::Module->get_config exists as a wrapper to return the
object to Perl space, now C/XS folks can also access the object
directly with the public function.
Submitted by: geoff
Reviewed by: stas
Revision Changes Path
1.15 +54 -12 modperl-2.0/src/modules/perl/modperl_module.c
Index: modperl_module.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_module.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- modperl_module.c 30 May 2003 12:55:14 -0000 1.14
+++ modperl_module.c 4 Jun 2003 16:50:37 -0000 1.15
@@ -246,14 +246,14 @@
sv_2mortal(modperl_ptr2obj(aTHX_ "Apache::CmdParms", (void *)parms))
static const char *
-modperl_module_config_get_obj(pTHX_
- apr_pool_t *p,
- PTR_TBL_t *table,
- modperl_module_cfg_t *cfg,
- modperl_module_cmd_data_t *info,
- modperl_mgv_t *method,
- cmd_parms *parms,
- SV **obj)
+modperl_module_config_create_obj(pTHX_
+ apr_pool_t *p,
+ PTR_TBL_t *table,
+ modperl_module_cfg_t *cfg,
+ modperl_module_cmd_data_t *info,
+ modperl_mgv_t *method,
+ cmd_parms *parms,
+ SV **obj)
{
const char *mname = info->modp->name;
modperl_module_info_t *minfo = MP_MODULE_INFO(info->modp);
@@ -385,9 +385,9 @@
}
- errmsg = modperl_module_config_get_obj(aTHX_ p, table, cfg, info,
- minfo->dir_create,
- parms, &obj);
+ errmsg = modperl_module_config_create_obj(aTHX_ p, table, cfg, info,
+ minfo->dir_create,
+ parms, &obj);
if (errmsg) {
return errmsg;
@@ -406,7 +406,7 @@
if (srv_cfg) {
SV *srv_obj;
- errmsg = modperl_module_config_get_obj(aTHX_ p, table, srv_cfg, info,
+ errmsg = modperl_module_config_create_obj(aTHX_ p, table, srv_cfg, info,
minfo->srv_create,
parms, &srv_obj);
if (errmsg) {
@@ -852,4 +852,46 @@
#endif
return NULL;
+}
+
+SV *modperl_module_config_get_obj(pTHX_ SV *pmodule, server_rec *s,
+ ap_conf_vector_t *v)
+{
+ MP_dSCFG(s);
+ module *modp;
+ const char *name;
+ void *ptr;
+ PTR_TBL_t *table;
+ SV *obj;
+
+ if (!v) {
+ v = s->module_config;
+ }
+
+ if (SvROK(pmodule)) {
+ name = SvCLASS(pmodule);
+ }
+ else {
+ STRLEN n_a;
+ name = SvPV(pmodule, n_a);
+ }
+
+ if (!(scfg->modules &&
+ (modp = apr_hash_get(scfg->modules, name, APR_HASH_KEY_STRING)))) {
+ return &PL_sv_undef;
+ }
+
+ if (!(ptr = ap_get_module_config(v, modp))) {
+ return &PL_sv_undef;
+ }
+
+ if (!(table = modperl_module_config_table_get(aTHX_ FALSE))) {
+ return &PL_sv_undef;
+ }
+
+ if (!(obj = modperl_svptr_table_fetch(aTHX_ table, ptr))) {
+ return &PL_sv_undef;
+ }
+
+ return obj;
}
1.2 +3 -0 modperl-2.0/src/modules/perl/modperl_module.h
Index: modperl_module.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_module.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- modperl_module.h 27 Aug 2002 04:21:20 -0000 1.1
+++ modperl_module.h 4 Jun 2003 16:50:37 -0000 1.2
@@ -8,4 +8,7 @@
const char *modperl_module_add(apr_pool_t *p, server_rec *s,
const char *name);
+SV *modperl_module_config_get_obj(pTHX_ SV *pmodule, server_rec *s,
+ ap_conf_vector_t *v);
+
#endif /* MODPERL_MODULE_H */
1.11 +1 -35 modperl-2.0/xs/Apache/Module/Apache__Module.h
Index: Apache__Module.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/Apache/Module/Apache__Module.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Apache__Module.h 30 May 2003 13:39:44 -0000 1.10
+++ Apache__Module.h 4 Jun 2003 16:50:37 -0000 1.11
@@ -44,41 +44,7 @@
server_rec *s,
ap_conf_vector_t *v)
{
- MP_dSCFG(s);
- module *modp;
- const char *name;
- void *ptr;
- PTR_TBL_t *table;
- SV *obj;
-
- if (!v) {
- v = s->module_config;
- }
-
- if (SvROK(pmodule)) {
- name = SvCLASS(pmodule);
- }
- else {
- STRLEN n_a;
- name = SvPV(pmodule, n_a);
- }
-
- if (!(scfg->modules &&
- (modp = apr_hash_get(scfg->modules, name, APR_HASH_KEY_STRING)))) {
- return &PL_sv_undef;
- }
-
- if (!(ptr = ap_get_module_config(v, modp))) {
- return &PL_sv_undef;
- }
-
- if (!(table = modperl_module_config_table_get(aTHX_ FALSE))) {
- return &PL_sv_undef;
- }
-
- if (!(obj = modperl_svptr_table_fetch(aTHX_ table, ptr))) {
- return &PL_sv_undef;
- }
+ SV *obj = modperl_module_config_get_obj(aTHX_ pmodule, s, v);
return SvREFCNT_inc(obj);
}
1.116 +22 -0 modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm
Index: FunctionTable.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- FunctionTable.pm 30 May 2003 12:55:15 -0000 1.115
+++ FunctionTable.pm 4 Jun 2003 16:50:38 -0000 1.116
@@ -3139,6 +3139,28 @@
]
},
{
+ 'return_type' => 'SV *',
+ 'name' => 'modperl_module_config_get_obj',
+ 'args' => [
+ {
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
+ {
+ 'type' => 'SV *',
+ 'name' => 'pmodule'
+ },
+ {
+ 'type' => 'server_rec *',
+ 'name' => 's'
+ },
+ {
+ 'type' => 'ap_conf_vector_t *',
+ 'name' => 'v'
+ }
+ ]
+ },
+ {
'return_type' => 'PTR_TBL_t *',
'name' => 'modperl_module_config_table_get',
'args' => [
|