Cpp

Provides various utilities for interfacing with the platform installaion of cpp. This includes using cpp as a sub-process to extract macros. This also provides some standard cpp like options used by both cpp.py and CPIPMain.py

Created on 24 Jan 2015

@author: paulross

cpip.util.Cpp.addStandardArguments(parser)

This adds standard command line arguments to an argparse argument parser.

Parameters:parser (argparse.ArgumentParser) – <insert documentation for argument>
Returns:NoneType
cpip.util.Cpp.invokeCppForPlatformMacros(*args)

Invoke the pre-processor as a sub-process with *args and return a list of macro definition strings.

By default the preprocessor is cpp but this is overridden if $CPP is set in the environment.

May raise subprocess.CalledProcessError on failure.

cpip.util.Cpp.macroDefinitionDict(cmdLineArgS)

Given a list of command line arguments of the form n<=d> where n is the macro name and d the optional definition this returns an ordered dict of {n : d, ...}.

cpip.util.Cpp.macroDefinitionString(cmdLineArgS)

Given a list of command line arguments of the form n<=d> where n is the macro name and d the optional definition this returns a same ordered multi-line string where each line is of the form #define n d or #define n if d is not present.

Parameters:cmdLineArgS (list([])) – Comman line arguments as strings.
Returns:str – Multi line string of macro definitions.
cpip.util.Cpp.predefinedFileObjects(args)

Returns a list of file like objects to be pre-processed before the ITU. This does in this order:

  1. Platform specific macros
  2. Any command line defines
  3. Any pre-included files
Parameters:args (argparse.Namespace) – Parsed arguments.
Returns:list([_io.StringIO]) – List of file like objects.
cpip.util.Cpp.stdPredefinedMacros(args)

Returns a dict of standard predefined macros specified on the command line. See ISO/IEC 9899:1999 (E) 6.10.8 Predefined macro names.