Synopsis - Synopsis/SourceFile.py

File: Synopsis/SourceFile.py

     1#
     2# Copyright (C) 2006 Stefan Seefeld
     3# All rights reserved.
     4# Licensed to the public under the terms of the GNU LGPL (>= 2),
     5# see the file COPYING for details.
     6#
     7
     8class Include:
     9    """Information about an include directive in a SourceFile.
    10    If the include directive required a macro expansion to get the filename,
    11    the is_macro will return true. If the include directive was actually an
    12    include_next, then is_next will return true.
    13    """
    14
    15    def __init__(self, target, name, is_macro, is_next):
    16
    17        self.target = target
    18        """The target SourceFile object being referenced."""
    19        self.name = name
    20        """The name by which the target is referenced."""
    21        self.is_macro = is_macro
    22        """True if the directive uses a macro."""
    23        self.is_next = is_next
    24        """True if this is using #include_next (GNU extension)."""
    25
    26
    27class MacroCall:
    28    """A class to support mapping from positions in a preprocessed file
    29    back to positions in the original file."""
    30
    31    def __init__(self, name, start, end, expanded_start, expanded_end):
    32
    33        self.name = name
    34        "The name of the macro being called."
    35        self.start = start
    36        "(line, column) pair indicating the start of the call."
    37        self.end = end
    38        "(line, column) pair indicating the end of the call."
    39        self.expanded_start = expanded_start
    40        "(line, column) pair indicating the start of the expansion in the preprocessed file."
    41        self.expanded_end = expanded_end
    42        "(line, column) pair indicating the end of the expansion in the preprocessed file."
    43
    44class SourceFile:
    45    """The information about a file that the ASG was generated from.
    46    Contains filename, all declarations from this file (even nested ones) and
    47    includes (aka imports) from this file."""
    48
    49    def __init__(self, name, abs_name, language, primary = False):
    50        """Constructor"""
    51
    52        self.name = name
    53        """The filename."""
    54        self.abs_name = abs_name
    55        """The absolute filename."""
    56        self.annotations = {'language':language, 'primary':primary}
    57        """Dictionary with file annotations."""
    58        self.includes = []
    59        """List of includes this file contains."""
    60        self.declarations = []
    61        """List of declarations this file contains."""
    62        self.macro_calls = []
    63        """List of macro calls this file contains."""
    64
    65

Generated on Thu Apr 16 16:27:12 2009 by
synopsis (version devel)