コード例 #1
0
ファイル: main.py プロジェクト: lucyge/FBThrift
    def generate(self, program, languages):
        'Oooohh, recursively generate program, hot!!'

        from thrift_compiler.frontend import t_program
        assert isinstance(program, t_program)
        assert isinstance(languages, dict)

        # Generate code

        self.pverbose("Program: {0}\n".format(program.path))

        if self.dump_docs:
            frontend.dump_docstrings(program)

        for language, flags in languages.iteritems():
            for flag in flags:
                if flag not in generator_registry.generator_factory_map[ \
                        language].supported_flags:
                    self.pwarning(1, "Language {0} doesn't recognize flag {1}"\
                            .format(language, flag))
            g = generator_registry.get_generator(program, language, flags)
            if g is None:
                self.pwarning(1, "Unable to get a generator for " \
                    "{0}:{1}".format(language, ','.join(flags)))
            # do it!
            g.generate_program()
コード例 #2
0
ファイル: main.py プロジェクト: Hsin/fbthrift
    def generate(self, program, languages):
        'Oooohh, recursively generate program, hot!!'

        from thrift_compiler.frontend import t_program
        assert isinstance(program, t_program)
        assert isinstance(languages, dict)

        if self.recurse:
            for inc in program.includes:
                # Propagate output path from parent to child programs
                inc.out_path = program.out_path
                self.generate(inc, languages)

        # Generate code

        self.pverbose("Program: {0}\n".format(program.path))

        if self.dump_docs:
            frontend.dump_docstrings(program)

        for language, flags in languages.iteritems():
            for flag in flags:
                if flag not in generator_registry.generator_factory_map[ \
                        language].supported_flags:
                    self.pwarning(1, "Language {0} doesn't recognize flag {1}"\
                            .format(language, flag))
            g = generator_registry.get_generator(program, language, flags)
            if g is None:
                self.pwarning(1, "Unable to get a generator for " \
                    "{0}:{1}".format(language, ','.join(flags)))
            # do it!
            g.generate_program()