Skip to content

Refactor output_templates #25

@erlend-aasland

Description

@erlend-aasland

Fairly early in output_templates(), we've got this comment:

        # we have to set these things before we're done:
        #    
        # docstring_prototype
        # docstring_definition
        # impl_prototype
        # methoddef_define
        # parser_prototype
        # parser_definition
        # impl_definition
        # cpp_if
        # cpp_endif
        # methoddef_ifndef

Post this comment, there are a few large blocks of code where most of these "fields" are set; these blocks depend on the type of call:

  1. no args -- METH_NOARGS
  2. one positional arg -- METH_O
  3. optional groups
  4. positional only args
  5. methods/funcs with keyword args

Post these cases, most of the "fields" are set and there follows some fairly complex "post-processing" code (produce deprecation warnings, process some of the templates, and there's also some special handling for new/init methods.

We should try to refactor the five major cases in some kind of way. Perhaps a "builder class" that holds the required fields is the best approach. Perhaps "builder class" helpers for rendering Limited API fields and Internal API fields would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions