Example #1
0
    def EndParsing(self):
        super(StructureNode, self).EndParsing()

        # Now that we have attributes and children, instantiate the gatherers.
        gathertype = _GATHERERS[self.attrs['type']]

        self.gatherer = gathertype(self.attrs['file'], self.attrs['name'],
                                   self.attrs['encoding'])
        self.gatherer.SetGrdNode(self)
        self.gatherer.SetUberClique(self.UberClique())
        if hasattr(self.GetRoot(), 'defines'):
            self.gatherer.SetDefines(self.GetRoot().defines)
        self.gatherer.SetAttributes(self.attrs)

        # Parse local variables and instantiate the substituter.
        if self.attrs['variables']:
            variables = self.attrs['variables']
            self.substituter = util.Substituter()
            self.substituter.AddSubstitutions(self._ParseVariables(variables))

        self.skeletons = {}  # Maps expressions to skeleton gatherers
        for child in self.children:
            assert isinstance(child, variant.SkeletonNode)
            skel = gathertype(child.attrs['file'],
                              self.attrs['name'],
                              child.GetEncodingToUse(),
                              is_skeleton=True)
            skel.SetGrdNode(
                self)  # TODO(benrg): Or child? Only used for ToRealPath
            skel.SetUberClique(self.UberClique())
            self.skeletons[child.attrs['expr']] = skel
Example #2
0
 def GetSubstituter(self):
     if self.substituter is None:
         self.substituter = util.Substituter()
         self.substituter.AddMessages(self.GetSubstitutionMessages(),
                                      self.output_language)
         if self.output_language in _RTL_LANGS:
             direction = 'dir="RTL"'
         else:
             direction = 'dir="LTR"'
         self.substituter.AddSubstitutions({
             'GRITLANGCODE': self.output_language,
             'GRITDIR': direction,
         })
         from grit.format import rc  # avoid circular dep
         rc.RcSubstitutions(self.substituter, self.output_language)
     return self.substituter
Example #3
0
 def __init__(self):
     base.Node.__init__(self)
     self.output_language = ''
     self.defines = {}
     self.substituter = util.Substituter()