You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Gerald Richter <ri...@ecos.de> on 2001/09/25 12:12:25 UTC

ParseSource etc.

Hi,

some time ago we discussed to make ParseSource and the other XS generation
modules more generic. My goal is to also use them outside of mod_perl. At
the moment I like to create a perl wrapper for mod_dav 1.x and don't like to
code anything by hand. I also expect using this method will make porting to
mod_dav/_perl 2.0 much more easier.

I have started by dividing Apache/ParseSource.pm into two modules. A
ExtUtils::XSBuilder::ParseSource and the Apache::ParseSource which inherits
from the first. The Apache::ParseSource only need to override some methods
to supply any needed informations, like include dirs, prefixes etc.

I append what I written so far. perldoc ParseSource.pm gives a list of
overrideable methods. I just written this down, without any testing, so
don't expect it to work out of the box. Before I continue to work on that, I
want to have a feedback, if you think this is the right way to go.

If yes, Doug, how should we handle the changes. Should I send my changes to
the list and you review and commit them or should I directly commit them (of
course I only commit after testing and made sure it doesn't break anything
as far as I can see)

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------


Re: ParseSource etc.

Posted by Gerald Richter <ri...@ecos.de>.
>
> > These two things would need a extention of the xxx_types.map files. I
would
> > suggest simply append two addtional (optional) parameters for each line.
The
> > first holds the name used in the typemap file (%typemap) and the second
the
> > alias for the sv_convert.h file (%convert)
>
> all sounds good to me, do you want to work on the patch?
>

Yes, I do that. It will come together with the separation of the mod_perl
specific part and the generic part. (Will give a real huge patch, but the XS
generation stuff is really great and worth not only using it for mod_perl
:-)

Gerald





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Doug MacEachern <do...@covalent.net>.
On Sun, 7 Oct 2001, Gerald Richter wrote:
 
> I think we could easily remove this line and put the package name for these
> three functions in the map file. That would make much more sense to me. If
> you agree to that, I will do it and you don't have to take care about it.

already taken care of :)

> These two things would need a extention of the xxx_types.map files. I would
> suggest simply append two addtional (optional) parameters for each line. The
> first holds the name used in the typemap file (%typemap) and the second the
> alias for the sv_convert.h file (%convert)

all sounds good to me, do you want to work on the patch?



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Gerald Richter <ri...@ecos.de>.
>
> putting some trace statements in there, there's only 3 places where
> return_type is actually used:
> using Apache::Filter for ap_add_input_filter
> using Apache::RequestRec for ap_read_request
> using APR::IpSubnet for apr_ipsubnet_create
>
> i suppose we could probably get by without it, i'll work on getting rid of
> that line.
>

I think we could easily remove this line and put the package name for these
three functions in the map file. That would make much more sense to me. If
you agree to that, I will do it and you don't have to take care about it.
There is another thing that should going into the map files:

* TypeMap.pm:

#anything needed that mod_perl.h does not already include
#XXX: .maps should INCLUDE= these
my @includes = qw{
apr_uuid.h
apr_sha1.h
apr_md5.h
apr_base64.h
apr_getopt.h
apr_hash.h
apr_lib.h
apr_general.h
apr_signal.h
util_script.h
};

Your comment suggest it already...

* TypeMap.pm:

my %convert_alias = (
    Apache__RequestRec => 'r',
    Apache__Server => 'server',
    Apache__Connection => 'connection',
    APR__Table => 'table',
    APR__UUID => 'uuid',
    apr_status_t => 'status',
);


* WrapXS.pm

my %typemap = (
    'Apache::RequestRec' => 'T_APACHEOBJ',
    'apr_time_t' => 'T_APR_TIME',
    'APR::Table' => 'T_HASHOBJ',
);

These two things would need a extention of the xxx_types.map files. I would
suggest simply append two addtional (optional) parameters for each line. The
first holds the name used in the typemap file (%typemap) and the second the
alias for the sv_convert.h file (%convert)

What do you think ?

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Doug MacEachern <do...@covalent.net>.
On Sun, 7 Oct 2001, Gerald Richter wrote:
 
> I do that anyway, because the first_class method contains other Apache
> specific things (like checking for pool). I have done this in many places to
> spearate generic code from mod_perl specific. The difference here is, that I
> don't understand under which circumstances it makes sense to take the return
> type instead of the first argument for guessing the target package of the
> function. At the moment I can't imagine a situation where this makes sense,
> so I failed to understand the reason why you did it. Because of that I can't
> decide how to handle this for the generic situation (mod_dav was only an
> example), because the generic code should of course behave in a way to
> catches most cases and we override for the specfic ones (of course). If you
> have a example function where this takeing of return type makes sense, it
> would help me very much.

putting some trace statements in there, there's only 3 places where
return_type is actually used:
using Apache::Filter for ap_add_input_filter
using Apache::RequestRec for ap_read_request
using APR::IpSubnet for apr_ipsubnet_create

i suppose we could probably get by without it, i'll work on getting rid of
that line.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Gerald Richter <ri...@ecos.de>.
>
> > sub first_class {
>
> couldn't you just override this method to make it do what works best for
> dav?
>

I do that anyway, because the first_class method contains other Apache
specific things (like checking for pool). I have done this in many places to
spearate generic code from mod_perl specific. The difference here is, that I
don't understand under which circumstances it makes sense to take the return
type instead of the first argument for guessing the target package of the
function. At the moment I can't imagine a situation where this makes sense,
so I failed to understand the reason why you did it. Because of that I can't
decide how to handle this for the generic situation (mod_dav was only an
example), because the generic code should of course behave in a way to
catches most cases and we override for the specfic ones (of course). If you
have a example function where this takeing of return type makes sense, it
would help me very much.

Thanks

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Doug MacEachern <do...@covalent.net>.
On Sat, 6 Oct 2001, Gerald Richter wrote:

> sub first_class {

couldn't you just override this method to make it do what works best for
dav?



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Gerald Richter <ri...@ecos.de>.
>
> if it makes things easier to run through cpp first, by all means do.

I will rethink what's the best solution....

Another question. I have gotten very far in separting the mod_perl specific
code and the generic code. So I tried to run what I have so far over mod_dav
1.x and the result is really nice (also still a lot of work until I can use
it), but I found that when I don't specify the package where to put
functions in, WrapXS makes really strange guesses. It mostly takes the
return type, which doesn't make much sense to me. (For example function in
mod_dav often return a dav_error struct, so all these functions will go into
the Apache::DAV::Error package). The source is the function
*::TypeMap::first_class:

sub first_class {
    my($self, $func) = @_;

    return $func->{return_type} if $func->{return_type} =~ /::/;

    for my $e (@{ $func->{args} }) {
        next unless $e->{type} =~ /::/;
        #there are alot of util functions that take an APR::Pool
        #that do not belong in the APR::Pool class
        next if $e->{type} eq 'APR::Pool' and $func->{name} !~ /^apr_pool/;
        return $e->{type};
    }

    return $func->{name} =~ /^apr_/ ? 'APR' : 'Apache';
}

which returns the return_type if it is an object. From my point of view the
return ... if in line 4 should be removed, but I guess it is/was good for
something ?

Gerald



-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 5 Oct 2001, Gerald Richter wrote:
 
> I've done so, but it's hard work to get all the details right, so it's still
> under construction, also the results already comes very close to the tables
> in the CVS.

great!!
 
> There is one issue I like to get some feedback before continuing. C::Scan
> has used the C preprocessor, thatway it didn't had to care about C-macro
> definitions. For example there is a macro called AP_DECLARE_HOOK, which
> declares a ap_hook_foo and a ap_run_foo. My current aproach is to only use
> Parse::RecDescent and not the C preprocessor, that makes it independend of
> installed compilers etc., but I have to find out all these macros and
> reimplement them in my RecDescent grammer, to get the correct result. Also
> there are some parts inside of #if and the current aproach ignores #if at
> all. As far as I see the second point isn't so important, but the first
> maybe, because any change in these macros inside the  Apache sources must
> also be reflected in the RecDescent grammer.

if it makes things easier to run through cpp first, by all means do.
we will still ship a copy of the generated tables with the distribution,
running source_scan will be optional.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Gerald Richter <ri...@ecos.de>.
>
> I have played along this line a few hours, taken the grammer from
Inline::C
> and Inline::Struct and now have a nearly working replacement for C::Scan.
I
> think this is the right way to go, since the RecDecent parser grammer is
> much easier to extent and modify (and it works on all platforms, also it
> will be slower than C::Scan).
>
> I continue to work on this during the next days and try to integrate it
into
> Apache::ParseSource, by making a abstract base class and
Apache::ParseSource
> will contain only Apache spcific things.
>

I've done so, but it's hard work to get all the details right, so it's still
under construction, also the results already comes very close to the tables
in the CVS.

There is one issue I like to get some feedback before continuing. C::Scan
has used the C preprocessor, thatway it didn't had to care about C-macro
definitions. For example there is a macro called AP_DECLARE_HOOK, which
declares a ap_hook_foo and a ap_run_foo. My current aproach is to only use
Parse::RecDescent and not the C preprocessor, that makes it independend of
installed compilers etc., but I have to find out all these macros and
reimplement them in my RecDescent grammer, to get the correct result. Also
there are some parts inside of #if and the current aproach ignores #if at
all. As far as I see the second point isn't so important, but the first
maybe, because any change in these macros inside the  Apache sources must
also be reflected in the RecDescent grammer.

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 27 Sep 2001, Gerald Richter wrote:
 
> I have played along this line a few hours, taken the grammer from Inline::C
> and Inline::Struct and now have a nearly working replacement for C::Scan. I
> think this is the right way to go, since the RecDecent parser grammer is
> much easier to extent and modify (and it works on all platforms, also it
> will be slower than C::Scan).

fantastic news gerald!!  not worried if it is slower than C::Scan.
 
> I continue to work on this during the next days and try to integrate it into
> Apache::ParseSource, by making a abstract base class and Apache::ParseSource
> will contain only Apache spcific things.

sounds good.
 
> I come back to the list when it is working and we can see how the best way
> is to get this into the current modperl developement.

looking forward to it!



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Gerald Richter <ri...@ecos.de>.
Doug,

> gerald, i would be happy to see the source parser usable outside of
> modperl.  first i would like to solve the C::Scan problem.  it just isn't
> usable on every system.

Agreed

>  i think one option would be to ditch C::Scan and
> see if Parse::RecDecent can be used in place of it.  i looked at
> Inline.pm, they have an Inline::C::grammar that should be a good
> start.  looks like it should be usable for generating the
> Function/Structure tables in the same format they are currently in.
> we would not depend on Inline.pm, but rather borrow C::grammar.pm and turn
> it into what we need.
> anybody interested in taking a shot at this?
>

I have played along this line a few hours, taken the grammer from Inline::C
and Inline::Struct and now have a nearly working replacement for C::Scan. I
think this is the right way to go, since the RecDecent parser grammer is
much easier to extent and modify (and it works on all platforms, also it
will be slower than C::Scan).

I continue to work on this during the next days and try to integrate it into
Apache::ParseSource, by making a abstract base class and Apache::ParseSource
will contain only Apache spcific things.

I come back to the list when it is working and we can see how the best way
is to get this into the current modperl developement.

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by brian moseley <bc...@maz.org>.
you gotta figure that *::gramar.pm are generally useful
(think of lxr) and deserve their own namespace and
packaging.

On Wed, 26 Sep 2001, Doug MacEachern wrote:

> gerald, i would be happy to see the source parser usable outside of
> modperl.  first i would like to solve the C::Scan problem.  it just isn't
> usable on every system.  i think one option would be to ditch C::Scan and
> see if Parse::RecDecent can be used in place of it.  i looked at
> Inline.pm, they have an Inline::C::grammar that should be a good
> start.  looks like it should be usable for generating the
> Function/Structure tables in the same format they are currently in.
> we would not depend on Inline.pm, but rather borrow C::grammar.pm and turn
> it into what we need.
> anybody interested in taking a shot at this?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
> For additional commands, e-mail: dev-help@perl.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: ParseSource etc.

Posted by Doug MacEachern <do...@covalent.net>.
gerald, i would be happy to see the source parser usable outside of
modperl.  first i would like to solve the C::Scan problem.  it just isn't
usable on every system.  i think one option would be to ditch C::Scan and
see if Parse::RecDecent can be used in place of it.  i looked at
Inline.pm, they have an Inline::C::grammar that should be a good
start.  looks like it should be usable for generating the 
Function/Structure tables in the same format they are currently in.
we would not depend on Inline.pm, but rather borrow C::grammar.pm and turn
it into what we need.
anybody interested in taking a shot at this?




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org