コード例 #1
0
ファイル: cppunitgen.py プロジェクト: kevwan/cppgen
    def run(self):
        hopt, header = self.__getOptArg__(("-h", "--header"))
        if not header:
            raise GetoptError("no header file specified")
        elif len(self.__args__) > 1:
            raise GetoptError("too many arguments")
    
        cppUnitFile = None
        if len(self.__args__) == 1:
            cppUnitFile = self.__args__[0]
        else:
            root, filename = path.split(header)
            name, ext = path.splitext(filename)
            cppSuffix = XmlConfig().getCppSuffix()
            cppUnitFile = "%sTest%s" % (name, cppSuffix)
            cppUnitFile = path.join(XmlConfig().getUnitTestDir(), cppUnitFile)

        self.__checkAndMakeUnitTestDir()
        self.__checkAndGenerateUnitTestMakefile()
        self.__checkAndGenerateUnitTestMain()
        dieOnExists(cppUnitFile)
        FileDepot().add(cppUnitFile)
        parser = TemplateParser("template.cpp", cppUnitFile)
        parser.parse()
        with open(cppUnitFile, "a+") as output:
            headerParser = CppHeaderParser(header)
            cppUnitGenImpl = CppUnitGenImpl(header, output)
            cppUnitGenImpl.setParser(headerParser)
            headerParser.addObserver(cppUnitGenImpl)
            headerParser.parse()
        print "\t" + cppUnitFile + "\t\t\t\t[OK]"
コード例 #2
0
ファイル: cppgen.py プロジェクト: kevwan/cppgen
 def __generateCppContentFromHeader(self, cppFile, header):
     with open(cppFile, "a+") as output:
         headerParser = CppHeaderParser(header)
         cppGenImpl = CppGenImpl(header, output)
         cppGenImpl.setParser(headerParser)
         headerParser.addObserver(cppGenImpl)
         headerParser.parse()
コード例 #3
0
ファイル: docgen.py プロジェクト: kevwan/cppgen
    def run(self):
        header = self.__getOptArg__(("-h", "--header"))[1]
        if not header:
            raise GetoptError("no header file specified")
        elif len(self.__args__) > 1:
            raise GetoptError("too many arguments")

        self.__target = header
        headerParser = CppHeaderParser(header)
        self.setParser(headerParser)
        headerParser.addObserver(self)
        headerParser.parse()
        self.__printToDocs()
        print "\t" + self.__target + "\t\t\t\t[OK]"