Ejemplo n.º 1
0
    def processMarkupFiles(self, sourceRoot):
        self.readHashConstants()

        logmessage("Searching for module.markup files in %s" % sourceRoot)
        # Find the module.markup files in the source tree
        for module in opera_module.modules(sourceRoot):
            filename = module.getModuleFile("markup")
            if util.fileTracker.addInput(filename):
                self.markup_files.append(filename)

        logmessage("  found %d files.\n" % len(self.markup_files))

        # Generate the files from the module.markup data
        try:
            self.error_value = 0

            self.parseMarkupNames()

            if self.checkHashing():
                self.error_value = 2

            if self.generateTables():
                self.error_value = 2

            if self.regenerateSVGpresentationAttrs() == 2:
                self.error_value = 2
        except MarkupParserError, mpe:
            logmessage("  FATAL: bad markup at line %d, column %d! %s." %
                       (mpe.line_num, mpe.col_num, mpe.error_msg))
            self.addError(util.Line(mpe.file_name, mpe.line_num),
                          "FATAL: bad markup!\n%s" % mpe.error_msg)
            self.error_value = 1
Ejemplo n.º 2
0
    def loadActions(self, sourceRoot):
        import opera_module
        self.setParseDefinition([
            module_parser.ModuleItemParseDefinition(
                type="ACTION",
                definitions=["depends on", "string"],
                create_item=self.createAction,
                parse_item_definition=self.parseActionDefinition)
        ])
        for module in opera_module.modules(sourceRoot):
            self.__module = module
            self.parseFile(module.getActionsFile())
            self.__module = None

        # validate the result:
        for action in self.actions():
            if not action.isDeprecated() and not action.string():
                self.addParserError(action.line(),
                                    "%s has no string set" % action.name())

        if self.printParserErrors():
            return False
        else:
            self.__actions.sort(key=Action.name)
            return True
Ejemplo n.º 3
0
    def parseComponents(self, sourceRoot):
        """
        Parses all module.components files in all modules that are found in the
        specified sourceRoot. The parsed ComponentType instances can be accessed
        by calling components().

        @return True if parsing was successful and False if there was a parsing
            error (which was printed to stderr).
        """
        if self.__parsed is None:
            # Prepare parser to parse all module.components files
            parser = module_parser.ModuleParser()
            parse_def = module_parser.ModuleItemParseDefinition(
                type="COMPONENT",
                definitions=["class", "include file", "depends on"],
                create_item=ComponentType,
                parse_item_definition=lambda f, c, w, v: c.setValue(w, v))
            parser.setParseDefinition([parse_def])

            # Collect all component definitions.
            components = []
            for module in list(opera_module.modules(sourceRoot)):
                if util.fileTracker.addInput(module.getComponentsFile()):
                    components.extend(parser.parseFile(module.getComponentsFile(),
                                                       allowed_types=set()))

            if parser.printErrors(): self.__parsed = False
            else:
                self.__parsed = True
                self.__components = components
        return self.__parsed
Ejemplo n.º 4
0
    def parseComponents(self, sourceRoot):
        """
        Parses all module.components files in all modules that are found in the
        specified sourceRoot. The parsed ComponentType instances can be accessed
        by calling components().

        @return True if parsing was successful and False if there was a parsing
            error (which was printed to stderr).
        """
        if self.__parsed is None:
            # Prepare parser to parse all module.components files
            parser = module_parser.ModuleParser()
            parse_def = module_parser.ModuleItemParseDefinition(
                type="COMPONENT",
                definitions=["class", "include file", "depends on"],
                create_item=ComponentType,
                parse_item_definition=lambda f, c, w, v: c.setValue(w, v))
            parser.setParseDefinition([parse_def])

            # Collect all component definitions.
            components = []
            for module in list(opera_module.modules(sourceRoot)):
                if util.fileTracker.addInput(module.getComponentsFile()):
                    components.extend(
                        parser.parseFile(module.getComponentsFile(),
                                         allowed_types=set()))

            if parser.printErrors(): self.__parsed = False
            else:
                self.__parsed = True
                self.__components = components
        return self.__parsed
Ejemplo n.º 5
0
    def processMarkupFiles(self, sourceRoot):
        self.readHashConstants()

        logmessage("Searching for module.markup files in %s" % sourceRoot)
        # Find the module.markup files in the source tree
        for module in opera_module.modules(sourceRoot):
            filename = module.getModuleFile("markup")
            if util.fileTracker.addInput(filename):
                self.markup_files.append(filename)

        logmessage("  found %d files.\n" % len(self.markup_files))

        # Generate the files from the module.markup data
        try:
            self.error_value = 0

            self.parseMarkupNames()

            if self.checkHashing():
                self.error_value = 2

            if self.generateTables():
                self.error_value = 2

            if self.regenerateSVGpresentationAttrs() == 2:
                self.error_value = 2
        except MarkupParserError, mpe:
            logmessage("  FATAL: bad markup at line %d, column %d! %s." % (mpe.line_num, mpe.col_num, mpe.error_msg))
            self.addError(util.Line(mpe.file_name, mpe.line_num), "FATAL: bad markup!\n%s" % mpe.error_msg)
            self.error_value = 1
Ejemplo n.º 6
0
 def getTemplateActionHandler(self, sourceRoot):
     """
     Returns an instance of OperaHTemplateAction which can be used to handle
     opera_template.h, opera_template.inc and capabilities_template.h.
     If an instance is created it is stored as a member and can be re-used
     for the processing the next template file.
     """
     if self.__template_action is None:
         self.__template_action = OperaHTemplateAction(list(opera_module.modules(sourceRoot)))
         hardcoreDir = os.path.join(sourceRoot, 'modules', 'hardcore')
         operaDir = os.path.join(hardcoreDir, 'opera')
         self.__template_action.readModules(os.path.join(operaDir, "modules.txt"),
                                            os.path.join(operaDir, "blacklist.txt"))
     return self.__template_action
Ejemplo n.º 7
0
 def getTemplateActionHandler(self, sourceRoot):
     """
     Returns an instance of OperaHTemplateAction which can be used to handle
     opera_template.h, opera_template.inc and capabilities_template.h.
     If an instance is created it is stored as a member and can be re-used
     for the processing the next template file.
     """
     if self.__template_action is None:
         self.__template_action = OperaHTemplateAction(
             list(opera_module.modules(sourceRoot)))
         hardcoreDir = os.path.join(sourceRoot, 'modules', 'hardcore')
         operaDir = os.path.join(hardcoreDir, 'opera')
         self.__template_action.readModules(
             os.path.join(operaDir, "modules.txt"),
             os.path.join(operaDir, "blacklist.txt"))
     return self.__template_action
Ejemplo n.º 8
0
    def loadKeys(self, sourceRoot):
        self.__keys = []
        self.__keysBySymbol = {}
        self.__keysByName = {}
        self.__next_offset = 0
        errors = []

        for module in opera_module.modules(sourceRoot):
            errors.extend(
                self.parseKeys(
                    os.path.join(sourceRoot, module.relativePath(),
                                 "module.keys"), module))

        if errors:
            for error in sorted(errors):
                print >> sys.stderr, error

            return False
        else:
            return True
Ejemplo n.º 9
0
    def loadMessages(self, sourceRoot):
        """
        Parses the 'module.messages' files for all modules relative to
        the specifed sourceRoot.
        @param sourceRoot is the root directory of the source tree
          that will be parsed.
        """

        def parseMessageDefinitions(line, current_item, what, value):
            """
            This method is called by ModuleParser.parseFile() if a
            "depends on" line was found.
            @param line is the current message_parser.Line
            @param current_item is the current Message instance
            @param what is expected to be "depends on"
            @param value is the condition on which the message depends.
            """
            assert what == "depends on"
            current_item.addDependsOnString(value)

        self.setParseDefinition([
                module_parser.ModuleItemParseDefinition(
                    type="message",
                    definitions=["depends on"],
                    create_item=self.createMessage,
                    parse_item_definition=parseMessageDefinitions)
                ])
        for module in list(opera_module.modules(sourceRoot)):
            self.__current_module = module
            self.parseFile(module.getMessagesFile())
            self.__current_module = None

        if self.printParserErrors():
            return False
        else:
            self.featureDefinition().setMessagesLoaded()
            self.__messages.sort()
            return True
Ejemplo n.º 10
0
    def loadActions(self, sourceRoot):
        import opera_module
        self.setParseDefinition([
                module_parser.ModuleItemParseDefinition(
                    type="ACTION",
                    definitions=["depends on", "string"],
                    create_item=self.createAction,
                    parse_item_definition=self.parseActionDefinition)
                ])
        for module in opera_module.modules(sourceRoot):
            self.__module = module
            self.parseFile(module.getActionsFile())
            self.__module = None

        # validate the result:
        for action in self.actions():
            if not action.isDeprecated() and not action.string():
                self.addParserError(action.line(), "%s has no string set" % action.name())

        if self.printParserErrors():
            return False
        else:
            self.__actions.sort(key=Action.name)
            return True
Ejemplo n.º 11
0
 def loadProbes(self, sourceRoot, quiet=True):
     if not quiet:
         print "Reading module.probes files from all modules:"
     for module in opera_module.modules(sourceRoot):
         self.parseProbefile(module, quiet)
     return True
Ejemplo n.º 12
0
 def loadProbes(self, sourceRoot, quiet=True):
     if not quiet:
         print "Reading module.probes files from all modules:"
     for module in opera_module.modules(sourceRoot):
         self.parseProbefile(module, quiet)
     return True