forked from Perl/perl5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ParseXS: don't use fake INPUT line for ANSI param
Initially, XSUBs were declared using a K&R-like syntax, where the parameters' types were specified later in INPUT lines: int foo(x, y) int x int y Then about 25 years ago, ANSI-style signatures were allowed: int foo(int x, int y) but the implementation was *horrible*. Basically the signature parser just injected a fake INPUT section later on into the src code input stream, containing lines like 'int x' etc. As well as being ugly, it made the code hard to understand, and caused all sorts of potential problems, since some syntax was specific to ANSI params, like '=foo' default values, while other syntax was specific to INPUT lines, like '= typemap_override($arg)'. And in particular, the pseudo-parameter 'length(foo)' made *everything* more complicated. The commits leading to this one have been gradually splitting parameter processing code into separate parsing, checking and code-emitting functions. We can now make use of this separation so that, instead of the signature-parsing code pushing a series of strings like 'int x' into an array, to be injected back into INPUT_handler() later, we can instead push a series of hashes along the lines of { name => 'x', type => 'int, ...} Then when this list of hashes is processed, it can pass the hash directly to the checking and code-generating methods, bypassing INPUT_handler() completely.
- Loading branch information
Showing
1 changed file
with
87 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters