Changeset e5d07e1 in rtems-central


Ignore:
Timestamp:
May 10, 2020, 6:15:30 PM (5 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
3276ce2
Parents:
bfae00f
git-author:
Sebastian Huber <sebastian.huber@…> (05/10/20 18:15:30)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/28/20 08:38:22)
Message:

interface: Add item to HeaderFile?

Make HeaderFile? an internal class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsqual/interface.py

    rbfae00f re5d07e1  
    172172class Node:
    173173    """ Nodes of a header file. """
    174     def __init__(self, header_file: "HeaderFile", item: Item,
     174    def __init__(self, header_file: "_HeaderFile", item: Item,
    175175                 ingroups: ItemMap):
    176176        self.header_file = header_file
     
    390390
    391391
    392 class HeaderFile:
     392class _HeaderFile:
    393393    """ A header file. """
    394     def __init__(self, enabled_by_defined: Dict[str, str]):
     394    def __init__(self, item: Item, enabled_by_defined: Dict[str, str]):
     395        self._item = item
    395396        self._content = CContent()
    396397        self._ingroups = {}  # type: ItemMap
     
    429430            self.add_potential_edge(node, ingroup)
    430431
    431     def generate_nodes(self, item: Item) -> None:
     432    def generate_nodes(self) -> None:
    432433        """ Generates all nodes of this header file. """
    433         for link in item.links_to_children():
     434        for link in self._item.links_to_children():
    434435            if link["role"] == "interface-placement":
    435436                self._add_child(link.item)
     
    472473        return nodes_in_dependency_order
    473474
    474     def finalize(self, item: Item) -> None:
     475    def finalize(self) -> None:
    475476        """ Finalizes the header file. """
    476477        self._content.add_spdx_license_identifier()
     
    478479            self._content.add_ingroup(_ingroups_to_designators(self._ingroups))
    479480        self._content.add_copyrights_and_licenses()
    480         with self._content.header_guard(item["interface-path"]):
     481        with self._content.header_guard(self._item["interface-path"]):
    481482            self._content.add_includes([
    482                 inc["interface-path"] for inc in self._includes if inc != item
     483                inc["interface-path"] for inc in self._includes
     484                if inc != self._item
    483485            ])
    484486            with self._content.extern_c():
     
    486488                    self._content.add(node.content)
    487489
    488     def write(self, filename: str) -> None:
     490    def write(self, domain_path: str) -> None:
    489491        """ Writes the header file. """
    490         self._content.write(filename)
     492        self._content.write(
     493            os.path.join(domain_path, self._item["interface-prefix"],
     494                         self._item["interface-path"]))
    491495
    492496
     
    496500    if domain_path is None:
    497501        return
    498     header_file = HeaderFile(enabled_by_defined)
    499     header_file.generate_nodes(item)
    500     header_file.finalize(item)
    501     header_file.write(
    502         os.path.join(domain_path, item["interface-prefix"],
    503                      item["interface-path"]))
     502    header_file = _HeaderFile(item, enabled_by_defined)
     503    header_file.generate_nodes()
     504    header_file.finalize()
     505    header_file.write(domain_path)
    504506
    505507
Note: See TracChangeset for help on using the changeset viewer.