|
PyForTool
Python-fortran-tool
|

Public Member Functions | |
| applyCPPifdef (self, keys) | |
C preprocessor directive handling methods. Provides utilities for evaluating and manipulating C preprocessor (#ifdef, #ifndef, #else, #endif) directives in FORTRAN code.
| pyfortool.cpp.Cpp.applyCPPifdef | ( | self, | |
| keys | |||
| ) |
Evaluate and reduce #ifdef / #ifndef blocks based on specified keys.
Parameters
----------
keys : list of str
List of preprocessor keys to evaluate.
Keys preceded by '%' are treated as undefined (False).
Example: ['KEY1', '%KEY2'] means KEY1=True, KEY2=False.
Transformation Examples
----------------------
If 'K' is in keys (K=True):
#ifdef K
A
#else
B
#endif
becomes simply: A
If '%K' is in keys (K=False):
#ifdef K
A
#else
B
#endif
becomes simply: B
Notes
-----
- Only handles #ifdef and #ifndef (not "#if defined ...")
- Nested if/ifdef/ifndef are supported
- Code not matching any conditional is kept unchanged
Definition at line 22 of file cpp.py.
