6,566
edits
(→All subsystems: Updated the output to match the newest script.) |
(→Script: Newest version of the script.) |
||
Line 57: | Line 57: | ||
# Add some problematic non-parsable classes. | # Add some problematic non-parsable classes. | ||
if self.category_subsystems: | if self.category_subsystems: | ||
self.subsystems[1].append(Subsystem("FGAISim", base_class=Subsystem("FGInterface", base_class=Subsystem("SGSubsystem")), declaration_file="src/FDM/SP/AISim.hpp", root_path=self.root_path("src/FDM/SP/AISim.hpp"), xml=self.output_xml)) | self.subsystems[1].append(Subsystem("FGAISim", base_class=Subsystem("FGInterface", base_class=Subsystem("SGSubsystem")), declaration_file="src/FDM/SP/AISim.hpp", root_path=self.root_path("src/FDM/SP/AISim.hpp"), full_path=self.output_full_path, xml=self.output_xml)) | ||
# Find all SGSubsystem and SGSubsystemGroup derived classes. | # Find all SGSubsystem and SGSubsystemGroup derived classes. | ||
Line 123: | Line 123: | ||
for subsystem in self.subsystems[0] + self.subsystems[1] + self.subsystems[2] + self.subsystems[3] + self.groups[0] + self.groups[1] + self.groups[2] + self.groups[3]: | for subsystem in self.subsystems[0] + self.subsystems[1] + self.subsystems[2] + self.subsystems[3] + self.groups[0] + self.groups[1] + self.groups[2] + self.groups[3]: | ||
# The repository location. | # The repository location. | ||
if self.is_simgear(subsystem. | if self.is_simgear(subsystem.declaration_file): | ||
path = SIMGEAR_PATH | path = SIMGEAR_PATH | ||
else: | else: | ||
Line 222: | Line 222: | ||
if class_name in skip: | if class_name in skip: | ||
continue | continue | ||
primary.append(Subsystem(class_name, base_class=base, declaration_file=file_name, root_path=self.root_path(file_name), xml=self.output_xml)) | primary.append(Subsystem(class_name, base_class=base, declaration_file=file_name, root_path=self.root_path(file_name), full_path=self.output_full_path, xml=self.output_xml)) | ||
# Sort the subsystems by name. | # Sort the subsystems by name. | ||
Line 246: | Line 246: | ||
# Loop over all primary subsystems. | # Loop over all primary subsystems. | ||
for subsystem in primary: | for subsystem in primary: | ||
for file_name, derived_class in self.grep(path=path, base_name=subsystem.name, simgear=self.is_simgear(subsystem. | for file_name, derived_class in self.grep(path=path, base_name=subsystem.name, simgear=self.is_simgear(subsystem.declaration_file)): | ||
secondary.append(Subsystem(derived_class, base_class=subsystem, declaration_file=file_name, root_path=self.root_path(file_name), xml=self.output_xml)) | secondary.append(Subsystem(derived_class, base_class=subsystem, declaration_file=file_name, root_path=self.root_path(file_name), full_path=self.output_full_path, xml=self.output_xml)) | ||
# Sort the subsystems by name. | # Sort the subsystems by name. | ||
Line 271: | Line 271: | ||
# Loop over all secondary subsystems. | # Loop over all secondary subsystems. | ||
for subsystem in secondary: | for subsystem in secondary: | ||
for file_name, derived_class in self.grep(path=path, base_name=subsystem.name, simgear=self.is_simgear(subsystem. | for file_name, derived_class in self.grep(path=path, base_name=subsystem.name, simgear=self.is_simgear(subsystem.declaration_file)): | ||
tertiary.append(Subsystem(derived_class, base_class=subsystem, declaration_file=file_name, root_path=self.root_path(file_name), xml=self.output_xml)) | tertiary.append(Subsystem(derived_class, base_class=subsystem, declaration_file=file_name, root_path=self.root_path(file_name), full_path=self.output_full_path, xml=self.output_xml)) | ||
# Sort all subsystems by name. | # Sort all subsystems by name. | ||
Line 296: | Line 296: | ||
# Loop over all tertiary subsystems. | # Loop over all tertiary subsystems. | ||
for subsystem in tertiary: | for subsystem in tertiary: | ||
for file_name, derived_class in self.grep(path=path, base_name=subsystem.name, simgear=self.is_simgear(subsystem. | for file_name, derived_class in self.grep(path=path, base_name=subsystem.name, simgear=self.is_simgear(subsystem.declaration_file)): | ||
quaternary.append(Subsystem(derived_class, base_class=subsystem, declaration_file=file_name, root_path=self.root_path(file_name), xml=self.output_xml)) | quaternary.append(Subsystem(derived_class, base_class=subsystem, declaration_file=file_name, root_path=self.root_path(file_name), full_path=self.output_full_path, xml=self.output_xml)) | ||
# Sort all subsystems by name. | # Sort all subsystems by name. | ||
Line 445: | Line 445: | ||
@type file_name: str | @type file_name: str | ||
@return: The root path. | @return: The root path. | ||
@rtype: | @rtype: str | ||
""" | """ | ||
# The relative or absolute path. | # The relative or absolute path. | ||
if self.is_simgear(file_name): | |||
return SIMGEAR_PATH | |||
else: | |||
return FLIGHTGEAR_PATH | |||
Line 471: | Line 466: | ||
for subsystem in self.subsystems[0] + self.subsystems[1] + self.subsystems[2] + self.subsystems[3] + self.groups[0] + self.groups[1] + self.groups[2] + self.groups[3]: | for subsystem in self.subsystems[0] + self.subsystems[1] + self.subsystems[2] + self.subsystems[3] + self.groups[0] + self.groups[1] + self.groups[2] + self.groups[3]: | ||
# The repository location. | # The repository location. | ||
if self.is_simgear(subsystem. | if self.is_simgear(subsystem.declaration_file): | ||
path = SIMGEAR_PATH | path = SIMGEAR_PATH | ||
else: | else: | ||
Line 485: | Line 480: | ||
# Loop over each file. | # Loop over each file. | ||
for file_name in files: | for file_name in files: | ||
# Extract the contents. | # Extract the contents. | ||
Line 513: | Line 507: | ||
for subsystem in subsystem_list: | for subsystem in subsystem_list: | ||
# Code base selections. | # Code base selections. | ||
if self.is_simgear(subsystem. | if self.is_simgear(subsystem.declaration_file) and not self.output_simgear: | ||
continue | continue | ||
if not self.is_simgear(subsystem. | if not self.is_simgear(subsystem.declaration_file) and not self.output_flightgear: | ||
continue | continue | ||
Line 577: | Line 571: | ||
subsystem_groups_flightgear = 0 | subsystem_groups_flightgear = 0 | ||
for subsystem in self.subsystems[0] + self.subsystems[1] + self.subsystems[2] + self.subsystems[3]: | for subsystem in self.subsystems[0] + self.subsystems[1] + self.subsystems[2] + self.subsystems[3]: | ||
if self.is_simgear(subsystem. | if self.is_simgear(subsystem.declaration_file): | ||
subsystem_classes_simgear += 1 | subsystem_classes_simgear += 1 | ||
else: | else: | ||
subsystem_classes_flightgear += 1 | subsystem_classes_flightgear += 1 | ||
for group in self.groups[0] + self.groups[1] + self.groups[2] + self.groups[3]: | for group in self.groups[0] + self.groups[1] + self.groups[2] + self.groups[3]: | ||
if self.is_simgear(group. | if self.is_simgear(group.declaration_file): | ||
subsystem_groups_simgear += 1 | subsystem_groups_simgear += 1 | ||
else: | else: | ||
Line 631: | Line 625: | ||
"""Object for storing the information for a specific subsystem.""" | """Object for storing the information for a specific subsystem.""" | ||
def __init__(self, name, base_class=None, declaration_file=None, implementation_file=None, root_path=None, xml=False): | def __init__(self, name, base_class=None, declaration_file=None, implementation_file=None, root_path=None, full_path=False, xml=False): | ||
"""Set up the object. | """Set up the object. | ||
Line 644: | Line 638: | ||
@keyword root_path: The root path to the files. | @keyword root_path: The root path to the files. | ||
@type root_path: str | @type root_path: str | ||
@keyword full_path: A flag which if True will cause the full paths to be shown. | |||
@type full_path: bool | |||
@keyword xml: Produce a valid XML representation of the object. | @keyword xml: Produce a valid XML representation of the object. | ||
@type xml: bool | @type xml: bool | ||
""" | """ | ||
# Initialisation. | |||
self.staticSubsystemClassId = None | |||
# Store the data. | # Store the data. | ||
self.name = name | self.name = name | ||
self.base_class = base_class | self.base_class = base_class | ||
self.implementation_file = implementation_file | self.implementation_file = implementation_file | ||
self.declaration_file = declaration_file | |||
self.root_path = root_path | self.root_path = root_path | ||
self.full_path = full_path | |||
self.xml = xml | self.xml = xml | ||
# Data extraction. | |||
self.info_extraction() | |||
Line 689: | Line 686: | ||
# The subsystem name and inheritance chain. | # The subsystem name and inheritance chain. | ||
string = "<%s : %s" % (self.name, inheritance) | string = "<%s : %s" % (self.name, inheritance) | ||
# Add the static class ID. | |||
if self.staticSubsystemClassId: | |||
string += " staticSubsystemClassId is \"%s\"" % self.staticSubsystemClassId | |||
# Add the declaration file name. | # Add the declaration file name. | ||
string += " declared in \"%s\"" % | file = self.declaration_file | ||
if self.full_path: | |||
file = self.root_path + sep + self.declaration_file | |||
string += " declared in \"%s\"" % file | |||
# Add the implementation file name. | # Add the implementation file name. | ||
if self.implementation_file: | if self.implementation_file: | ||
string += ", implemented in \"%s\"" % | file = self.implementation_file | ||
if self.full_path: | |||
file = self.root_path + sep + self.implementation_file | |||
string += ", implemented in \"%s\"" % file | |||
# Closure. | # Closure. | ||
Line 718: | Line 725: | ||
# The inheritance chain. | # The inheritance chain. | ||
string += " <inheritance>%s</inheritance>\n" % inheritance | string += " <inheritance>%s</inheritance>\n" % inheritance | ||
# Add the static class ID. | |||
if self.staticSubsystemClassId: | |||
string += " <staticSubsystemClassId>%s</staticSubsystemClassId>\n" % self.staticSubsystemClassId | |||
# Add the declaration file name. | # Add the declaration file name. | ||
string += " <declaration>%s</declaration>\n" % | file = self.declaration_file | ||
if self.full_path: | |||
file = self.root_path + sep + self.declaration_file | |||
string += " <declaration>%s</declaration>\n" % file | |||
# Add the implementation file name. | # Add the implementation file name. | ||
if self.implementation_file: | if self.implementation_file: | ||
string += " <implementation>%s</implementation>\n" % | file = self.implementation_file | ||
if self.full_path: | |||
file = self.root_path + sep + self.implementation_file | |||
string += " <implementation>%s</implementation>\n" % file | |||
# End. | # End. | ||
Line 742: | Line 759: | ||
# Store the file. | # Store the file. | ||
self.implementation_file = implementation_file | self.implementation_file = implementation_file | ||
def info_extraction(self): | |||
"""Extract subsystem information from the source files.""" | |||
# No declaration. | |||
if not self.declaration_file: | |||
return | |||
# Open the declaration file. | |||
file = open(self.root_path + sep + self.declaration_file) | |||
lines = file.readlines() | |||
file.close() | |||
# Loop over the file contents. | |||
for i in range(len(lines)): | |||
# The static subsystem class ID. | |||
if search("static const char\* staticSubsystemClassId()", lines[i]): | |||
id = lines[i].split("return \"")[1] | |||
id = id.split("\"")[0] | |||
self.staticSubsystemClassId = id | |||