示例#1
0
    def extract_function(self, file, section_number, name_folder):
        sub_section_number = 1
        function, sub_section_number = self.next_function(
            file, section_number,
            sub_section_number)  # find first function entry

        while function is not None:  # iterate over function entries

            print " " * 4 + "* " + function.strip()

            if settings.SPEC_VERSION_INT == 138:
                subsubcaption = 'Detailed Actions'
                entry = str(section_number) + "." + str(sub_section_number)
                count = 2
                if ("_TPM_Init" in function) or ("TPM2_Startup" in function):
                    count = 4
                elif "TPM2_PP_Commands" in function:
                    count = 3
                file.seek(0)
                for i in range(0, count):
                    file.seek(file.find(entry) + len(entry))
                file.seek(file.find(subsubcaption) + len(subsubcaption))
            else:
                entry = self.next_entry(
                    file, function,
                    str(section_number) + "." + str(sub_section_number))
                file.seek(file.find(entry) + len(entry))

            f = self.extract_code_blocks(file, section_number)

            f.name = function.strip()
            f.short_name = f.name.replace(constants.TPM20_PREFIX_TPM2_, "")
            f.file_name = f.short_name + ".c"
            f.table_command = TableExtractor.extract_commands_table_command(
                file, f.short_name)
            f.table_response = TableExtractor.extract_commands_table_response(
                file, f.short_name)
            f.folder_name = name_folder

            self.functions.append(f)

            sub_section_number += 1
            function, sub_section_name = self.next_function(
                file, section_number,
                sub_section_number)  # find next function entry
    def extract_function(self, main_entry, name_section, name_folder):
        function = self.next_function(main_entry)  # find first function entry

        while function is not None:  # iterate over function entries

            print " " * 4 + "* " + function.get_text().strip()

            f = self.extract_tpm2_part3_command(function, None)

            f.name = function.get_text()
            f.short_name = f.name.replace(constants.TPM20_PREFIX_TPM2_, "")
            f.file_name = f.short_name + ".c"
            f.table_command = TableExtractor.extract_commands_table_command(
                function, f.short_name)
            f.table_response = TableExtractor.extract_commands_table_response(
                function, f.short_name)
            f.folder_name = name_folder
            f.section_name = name_section

            self.functions.append(f)
            function = self.next_function(function)  # find next function entry
    def extract(self, structures_file):
        # extract license text
        license_text = LicenseExtractor.extract_license(structures_file)
        FileHandling.set_license(license_text)

        # extract tables from document
        table_list = TableExtractor.extract_structure_tables(structures_file)

        # create TPM_Types.h (and BaseTypes.h)
        self.create_tpm_types_h_file(table_list)

        self.marshaller.handle_arrays()
        self.marshaller.write()
示例#4
0
    def extract(self, structures_file):
        # extract license text
        license_text = LicenseExtractor.extract_license(structures_file)
        FileHandling.set_license(license_text)

        # extract tables from document
        table_list = TableExtractor.extract_structure_tables(structures_file)

        # create TPM_Types.h (and BaseTypes.h)
        self.create_tpm_types_h_file(table_list)

        self.marshaller.handle_arrays()
        self.marshaller.write()
    def extract_function(self, file, section_number, name_folder):
        sub_section_number = 1
        function, sub_section_number = self.next_function(file, section_number, sub_section_number)  # find first function entry

        while function is not None:  # iterate over function entries

            print " "*4 + "* " + function.strip()

            entry = self.next_entry(file, function, str(section_number) + "." + str(sub_section_number))
            file.seek(file.find(entry) + len(entry))
            
            f = self.extract_code_blocks(file, section_number)

            f.name = function.strip()
            f.short_name = f.name.replace(constants.TPM20_PREFIX_TPM2_, "")
            f.file_name = f.short_name + ".c"
            f.table_command = TableExtractor.extract_commands_table_command(file, f.short_name)
            f.table_response = TableExtractor.extract_commands_table_response(file, f.short_name)
            f.folder_name = name_folder

            self.functions.append(f)

            sub_section_number += 1
            function, sub_section_name = self.next_function(file, section_number, sub_section_number)  # find next function entry