Skip to content

Commit

Permalink
Deploying to gh-pages from @ 2a17b27 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Oct 6, 2023
1 parent bd3e717 commit 16ebaeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions cxxheaderparser/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ class PreprocessorError(Exception):


class _CustomPreprocessor(Preprocessor):
def __init__(self, encoding: typing.Optional[str]):
def __init__(
self,
encoding: typing.Optional[str],
passthru_includes: typing.Optional["re.Pattern"],
):
Preprocessor.__init__(self)
self.errors: typing.List[str] = []
self.assume_encoding = encoding
self.passthru_includes = passthru_includes

def on_error(self, file, line, msg):
self.errors.append(f"{file}:{line} error: {msg}")
Expand Down Expand Up @@ -58,12 +63,15 @@ def make_pcpp_preprocessor(
include_paths: typing.List[str] = [],
retain_all_content: bool = False,
encoding: typing.Optional[str] = None,
passthru_includes: typing.Optional["re.Pattern"] = None,
) -> PreprocessorFunction:
"""
Creates a preprocessor function that uses pcpp (which must be installed
separately) to preprocess the input text.
:param encoding: If specified any include files are opened with this encoding
:param passthru_includes: If specified any #include directives that match the
compiled regex pattern will be part of the output.
.. code-block:: python
Expand All @@ -75,7 +83,7 @@ def make_pcpp_preprocessor(
"""

def _preprocess_file(filename: str, content: str) -> str:
pp = _CustomPreprocessor(encoding)
pp = _CustomPreprocessor(encoding, passthru_includes)
if include_paths:
for p in include_paths:
pp.add_path(p)
Expand Down
2 changes: 1 addition & 1 deletion cxxheaderparser/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.0-3-g26da918'
__version__ = '1.0.0-5-g2a17b27'

0 comments on commit 16ebaeb

Please sign in to comment.