Skip to content

Commit

Permalink
[MERGE] ParseXS: refactor: add Node objects
Browse files Browse the repository at this point in the history
This branch heavily refactors the XSUB signature and INPUT parsing parts
of ExtUtils::ParseXS. Over about 50 commits, it adds a new file:

    dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm

and adds two  classes to it:

    ExtUtils::ParseXS::Node::Param
    ExtUtils::ParseXS::Node::Sig

It then changes the parsing and processing so that, instead of building
up a number of hashes indexed by var name to store the information about
a parameter, it instead stores all the information about a particular
parameter in a Node::Param object, then adds all those objects to an
array in a Node::Sig object.

Then the Node::Param->as_code() method will emit the C code associated
with the declaration and initialisation of one parameter.

This can be viewed as the first steps along the road to making
ExtUtils::ParseXS build an AST and emit code as a separate step. Its not
nearly there yet - most of the module still emits code as it goes along,
saving only the minimum state needed. And the C var declarations are
still emitted mostly after each INPUT line is processed rather than at
the end of all signature/INPUT processing, but at least an AST for just
the sig and parameter data is available for later in the processing.

Overall it makes the code much cleaner and reduces the amount of
special-casing, which was often distributed over many parts of the
module.

There is little visible change in functionality, although there are more
error messages now, for things that would have formerly just silently
emitted bad C which would likely fail to compile.

Lots of new tests have been added.
  • Loading branch information
iabyn committed Oct 18, 2024
2 parents 19a5403 + 0a291b5 commit 9621dfa
Show file tree
Hide file tree
Showing 15 changed files with 1,875 additions and 958 deletions.
2 changes: 1 addition & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -4166,6 +4166,7 @@ dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pod ExtUtils::ParseXS documentation
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm ExtUtils::ParseXS guts
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/CountLines.pm ExtUtils::ParseXS guts
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Eval.pm ExtUtils::ParseXS guts
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm ExtUtils::ParseXS guts - AST nodes
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm ExtUtils::ParseXS guts
dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm ExtUtils::Typemaps, a PXS helper
dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/Cmd.pm ExtUtils::Typemaps helper module
Expand All @@ -4187,7 +4188,6 @@ dist/ExtUtils-ParseXS/t/105-valid_proto_string.t ExtUtils::ParseXS tests
dist/ExtUtils-ParseXS/t/106-process_typemaps.t ExtUtils::ParseXS tests
dist/ExtUtils-ParseXS/t/108-map_type.t ExtUtils::ParseXS tests
dist/ExtUtils-ParseXS/t/109-standard_XS_defs.t ExtUtils::ParseXS tests
dist/ExtUtils-ParseXS/t/110-assign_func_args.t ExtUtils::ParseXS tests
dist/ExtUtils-ParseXS/t/111-analyze_preprocessor_statements.t ExtUtils::ParseXS tests
dist/ExtUtils-ParseXS/t/112-set_cond.t ExtUtils::ParseXS tests
dist/ExtUtils-ParseXS/t/113-check_cond_preproc_statements.t ExtUtils::ParseXS tests
Expand Down
Loading

0 comments on commit 9621dfa

Please sign in to comment.