PyForTool
Python-fortran-tool
Loading...
Searching...
No Matches
Public Member Functions | List of all members
pyfortool.cpp.Cpp Class Reference
Inheritance diagram for pyfortool.cpp.Cpp:
Inheritance graph
[legend]

Public Member Functions

 applyCPPifdef (self, keys)
 

Detailed Description

C preprocessor directive handling methods.

Provides utilities for evaluating and manipulating C preprocessor
(#ifdef, #ifndef, #else, #endif) directives in FORTRAN code.

Definition at line 10 of file cpp.py.

Member Function Documentation

◆ applyCPPifdef()

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.

Here is the call graph for this function:

The documentation for this class was generated from the following file: