develooper Front page | perl.perl5.porters | Postings from January 2012

Comment semantics in typemap files

Thread Next
From:
Steffen Mueller
Date:
January 17, 2012 09:44
Subject:
Comment semantics in typemap files
Message ID:
20120117174437.25558.qmail@lists-nntp.develooper.com
Dear all,

as I am re-reading the code than actually implements typemap handling 
(sigh), I keep stumbling across things that seem accidental behaviour. 
The most significant so far is the following:

Comments (lines matching /^\s*#/) are ignored in the TYPEMAP section of 
the file, but NOT in INPUT or OUTPUT sections.

Now, not ignoring comments on the same line as content (ie. not 
stripping s/#.*$//) is a safe choice, but I keep wondering whether not 
accepting comments in INPUT/OUTPUT is a bug/oversight or on purpose.

Consider

INPUT
T_FOO  code
        code
T_BAR  othercode
        othercode

Unless I misread the parser, a new input typemap is considered to start 
with the first line that has \S in the first column. So

INPUT
T_FOO  code
        code
#comment
T_BAR  othercode
        othercode

will probably break on trying to treat #comment as a new XS type identifier.

INPUT
T_FOO  code
        code
        #comment
T_BAR  othercode
        othercode

will include "#comment" verbatim in the T_FOO inputmap code.

Now, in theory, we could be looking at people trying to use the C 
pre-processor directive here. Is that a valid thing to do in a typemap? 
I'm on the fence. If not, I'd enable stripping of comments in 
INPUT/OUTPUT as well.

Cheers,
Steffen

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About