Beispiel #1
0
 def dispatchEvent(self, groupID, dispatchObject):
     self.m_bInLoop = True
     if self.m_groupID2DispatchDic.ContainsKey(groupID):
         self.m_groupID2DispatchDic[groupID].dispatchEvent(dispatchObject)
     else:
         AppSysBase.instance().m_logSys.log("Event Dispatch Group not exist")
     self.m_bInLoop = False;
Beispiel #2
0
 def traverseOneDirs(directoryName, filesInDirectory, handleDisp):
     AppSysBase.instance().getLoggerPtr().info(directoryName)
     for fname in filesInDirectory:
         fpath = os.path.join(directoryName, fname)
         if not os.path.isdir(fpath):
             if handleDisp is not None:
                 handleDisp(fname, fpath)
Beispiel #3
0
    def clearAllEventHandle(self):
        if not self.m_bInLoop:
            for dispatch in self.m_groupID2DispatchDic.Values():
                dispatch.clearEventHandle()

            self.m_groupID2DispatchDic.Clear()
        else:
            AppSysBase.instance().m_logSys.log("looping cannot delete element");
Beispiel #4
0
 def __init__(self, fullPath):
     '''
     Constructor
     '''
     super(ProtoFile, self).__init__(eFileType.eFile, fullPath)
     self.m_fullPath = AppSysBase.instance().getClsUtils().normalPath(self.m_fullPath)
     self.m_fileNameNoExt = AppSysBase.instance().getClsUtils().getFileNameNoExt(self.m_fullPath)
     self.m_protoElemList = []
Beispiel #5
0
 def addEventHandle(self, handle, paramList):
     funcObject = EventDispatchFunctionObject();
     funcObject.m_handle = handle;
     funcObject.m_paramList = paramList
     if None != handle:
         self.addObject(funcObject);
     else:
         AppSysBase.instance().m_logSys.log("Event Handle is null");
Beispiel #6
0
 def removeEventHandle(self, handle):
     for idx in range(0, self.m_handleList.Count(), 1):
         if self.m_handleList[idx].m_handle is handle:
             break
     if idx < self.m_handleList.Count():
         self.delObject(self.m_handleList[idx])
     else:
         AppSysBase.instance().m_logSys.log("Event Handle not exist");
Beispiel #7
0
 def clearGroupEventHandle(self, groupID):
     if not self.m_bInLoop:
         if self.m_groupID2DispatchDic.ContainsKey(groupID):
             self.m_groupID2DispatchDic[groupID].clearEventHandle()
             self.m_groupID2DispatchDic.Remove(groupID)
         else:
             AppSysBase.instance().m_logSys.log("Event Dispatch Group not exist");
     else:
         AppSysBase.instance().m_logSys.log("looping cannot delete element");
Beispiel #8
0
 def traversalOneDir(directoryName, filesInDirectory):
     AppSysBase.instance().m_logSys.info(directoryName)
     for fname in filesInDirectory:
         fpath = os.path.join(directoryName, fname)
         if not os.path.isdir(fpath):
             UtilFile.m_dirName = directoryName
             UtilFile.m_fileName = fname
             UtilFile.m_fileFullPath = fpath
             UtilFile.m_sEventDispatch.dispatchEvent(None)
Beispiel #9
0
 def onBtnClkExportCs(self):
     # 子进程实现
     #if not AppSysBase.instance().getCsExportProcess().isRuning():
     #    AppSysBase.instance().getCsExportProcess().start()
     #else:
     #    AppSysBase.instance().getLogSysPtr().info('CS Export Is Runing, Please Wait End')
     
     # 子线程实现
     if not AppSysBase.instance().getCsExportThread().isRuning():
         AppSysBase.instance().getCsExportThread().start()
     else:
         AppSysBase.instance().getLogSysPtr().info('CS Export Is Runing, Please Wait End')
Beispiel #10
0
 def exportMessage(fHandle, message):
     # 写入类的名字
     CppExportMessage.exportClsDeclStart(fHandle, message)
     # 写入类的成员
     CppExportMessage.exportMemDecl(fHandle, message)
     # 与后面分割一个空格
     AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
     # 写入构造函数
     CppExportMessage.exportConstruct(fHandle, message)
     # 写入类的右括号
     CppExportMessage.exportClsDeclEnd(fHandle, message)
     # 输入一个空行,以便隔开
     AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
Beispiel #11
0
 def parse(self):
     tokenParseBuffer = TokenParseBuffer()
     tokenParseBuffer.openFile(self.m_fullPath)
     while not tokenParseBuffer.isEOF():
         tokenKey = tokenParseBuffer.getTokenAndNoRemove()       # 获取一个符号,检查具体类型
         
         if tokenKey == ProtoKeyWord.eMessage:
             msg = ProtoMessage()
             self.m_protoElemList.append(msg)
             msg.parse(tokenParseBuffer)
         elif tokenKey == ProtoKeyWord.ePackage:
             package = ProtoPackage()
             self.m_protoElemList.append(package)
             package.parse(tokenParseBuffer)
         elif tokenKey == ProtoKeyWord.eEnum:
             enum_ = ProtoEnum()
             self.m_protoElemList.append(enum_)
             enum_.parse(tokenParseBuffer)
         elif tokenKey == ProtoKeyWord.eHeader:
             header_ = ProtoHeader()
             self.m_protoElemList.append(header_)
             header_.parse(tokenParseBuffer)
         elif tokenKey == ProtoKeyWord.eImport:
             import_ = ProtoImport()
             self.m_protoElemList.append(import_)
             import_.parse(tokenParseBuffer)
         elif tokenKey == ProtoKeyWord.ePragma:
             pragma_ = ProtoPragma()
             self.m_protoElemList.append(pragma_)
             pragma_.parse(tokenParseBuffer)
         else:   # 只处理注释
             if AppSysBase.instance().getClsUtils().tokenIsComment(tokenKey):       # 如果当前符号是注释
                 comment = ProtoComment()
                 self.m_protoElemList.append(comment)
                 comment.parse(tokenParseBuffer)
Beispiel #12
0
 def export(self):
     for file in AppSysBase.instance().getConfigPtr().getProtoFilesList().getFilesListPtr():
         if file.getFileType() == eFileType.eFile:  # 如果是文件,直接解析
             self.exportOneFile(file)
         elif file.getFileType() == eFileType.eDir:  # 如果是文件,直接解析
             for dirFile in file.getFilesList():
                 self.exportOneFile(dirFile)
Beispiel #13
0
 def exportUsing(fHandle, file):
     # 输出导入的命名空间
     #importUsing = "using SDK.Lib;"
     #fHandle.write(importUsing)
     
     # 输出导入的命名空间
     bFirst = True
     for protoElem in file.getProtoElemList():   # 遍历整个文件列表
         if protoElem.getElemType() == eProtoElemType.eImport:
             for importNS in protoElem.getHeaderList():
                 if not bFirst:
                     AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
                 
                 nsStr = "using {0};".format(importNS)
                 fHandle.write(nsStr)
                 
                 bFirst = False
Beispiel #14
0
 def exportMessage(fHandle, message):
     # 写入类的名字
     LuaExportMessage.exportClsDeclStart(fHandle, message)
     # 写入类的成员
     LuaExportMessage.exportMemDecl(fHandle, message)
     # 与后面分割一个空格
     AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
     # 写入构造函数
     LuaExportMessage.exportConstruct(fHandle, message)
     # 写入序列化函数
     LuaExportMessage.exportSerialize(fHandle, message)
     # 写入反序列化函数
     LuaExportMessage.exportDerialize(fHandle, message)
     # 写入类的右括号
     LuaExportMessage.exportClsDeclEnd(fHandle, message)
     # 输入一个空行,以便隔开
     AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
Beispiel #15
0
 def onBtnClkConv(self):
     #直接启动线程
     if AppSysBase.instance().getLoggerPtr().getConvOver():
         AppSysBase.instance().setConvThread(ConvThread("ConvThread"));
         AppSysBase.instance().getConvThread().start()
     else:
         AppSysBase.instance().getLoggerPtr().info('Convthread is runing')
Beispiel #16
0
 def exportInclude(fHandle, file):
     # 输出导入的命名空间
     #importUsing = "using SDK.Lib;"
     #fHandle.write(importUsing)
     
     # 输出导入的命名空间
     bFirst = True
     for protoElem in file.getProtoElemList():   # 遍历整个文件列表
         if protoElem.getElemType() == eProtoElemType.eHeader:
             for headerInclude in protoElem.getHeaderList():
                 if bFirst:          # 添加一个间隔空行
                     AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
                 
                 # 下一行写入
                 AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
                 includeStr = "#include {0}".format(headerInclude)
                 fHandle.write(includeStr)
                 
                 bFirst = False
Beispiel #17
0
    def copyFile(srcfilename, destfilename):
        if os.path.isfile(srcfilename):
            try:
                shutil.copyfile(srcfilename, destfilename)
                AppSysBase.instance().getLoggerPtr().info("copy file success: " + srcfilename)
            except:
                # 错误输出
                AppSysBase.instance().getLoggerPtr().info("copy file error: " + srcfilename)
                typeerr, value, tb = sys.exc_info()
                errstr = traceback.format_exception(typeerr, value, tb)
                AppSysBase.instance().getLoggerPtr().info(''.join(errstr))

        else:
            AppSysBase.instance().getLoggerPtr().info("cannot find file: " + srcfilename)
Beispiel #18
0
 def run(self):
     AppSysBase.instance().getLogSysPtr().info('CS Export Start Run')
     ThreadWrap.run(self)
     #super(CsExportProcess, self).run()
     AppSysBase.instance().getExportCSharpFile().export()
     AppSysBase.instance().getLogSysPtr().info('CS Export End Run')
     self.endRun()
Beispiel #19
0
    def exportNSStart(fHandle, file):
        # 输出命名空间
        AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
        AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)

        # nsStr = "namespace Game.Msg"
        # fHandle.write(nsStr)

        for protoElem in file.getProtoElemList():  # 遍历整个文件列表
            if protoElem.getElemType() == eProtoElemType.ePackage:
                nsStr = "namespace {0}".format(protoElem.getTypeName())
                fHandle.write(nsStr)
                break

        AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
        AppSysBase.instance().getClsUtils().writeLBrace2File(fHandle)
Beispiel #20
0
    def exportMemDecl(fHandle, message):
        # 写入类的成员
        for member in message.getMemberList():
            AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
            AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
            AppSysBase.instance().getClsUtils().writeTab2File(fHandle)

            # 写入变量名字
            if member.getPropertyType() == PropertyType.eInt8Array:  # char aaa[] 类型的特殊,直接转换成 string aaa
                memberStr = "public {0} {1};".format(
                    CSharpPropertyType2PropertyData.m_sType2PropertyData[
                        member.getPropertyType()
                    ].m_propertyTypeKeyWord,
                    member.getVarName(),
                )
            elif (
                member.getPropertyType() == PropertyType.eUint8
                or member.getPropertyType() == PropertyType.eInt16
                or member.getPropertyType() == PropertyType.eUInt16
                or member.getPropertyType() == PropertyType.eInt32
                or member.getPropertyType() == PropertyType.eUInt32
            ):
                memberStr = "public {0} {1};".format(
                    CSharpPropertyType2PropertyData.m_sType2PropertyData[
                        member.getPropertyType()
                    ].m_propertyTypeKeyWord,
                    member.getVarName(),
                )
            else:  # 数组处理
                memberStr = "public {0} {1};".format(
                    CSharpPropertyType2PropertyData.m_sType2PropertyData[
                        member.getPropertyType()
                    ].m_propertyTypeKeyWord,
                    member.getVarNameAndArray(),
                )

            fHandle.write(memberStr)
            # 写入注释
            if not AppSysBase.instance().getClsUtils().isNullOrEmpty(member.getCommentStr()):  # 如果字符串不为空
                AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
                fHandle.write(member.getCommentStr())
Beispiel #21
0
 def exportMemDecl(fHandle, message):
     # 写入类的成员
     for member in message.getMemberList():
         AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
         AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
         AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
         
         # 写入变量名字
         if member.isBasicType():
             memberStr = "{0} {1};".format(CppPropertyType2PropertyData.m_sType2PropertyData[member.getPropertyType()].m_propertyTypeKeyWord, member.getVarName())
         elif member.isCharArrayType():     # char aaa[] 类型的特殊,直接转换成 string aaa
             memberStr = "{0} {1};".format(CppPropertyType2PropertyData.m_sType2PropertyData[member.getPropertyType()].m_propertyTypeKeyWord, member.getVarName())
         elif member.isUserType():
             memberStr = "{0} {1};".format(member.getTypeName(), member.getVarName())
         elif member.isUserArrayType():
             memberStr = "{0} {1}[{2}];".format(member.getTypeName(), member.getVarName(), member.getArrLenAfterDot())
         else:       # 数组处理
             memberStr = "{0} {1}[{2}];".format(CppPropertyType2PropertyData.m_sType2PropertyData[member.getPropertyType()].m_propertyTypeKeyWord, member.getVarName(), member.getArrLenAfterDot())
         
         fHandle.write(memberStr)
         #写入注释
         if not AppSysBase.instance().getClsUtils().isNullOrEmpty(member.getCommentStr()):   # 如果字符串不为空
             AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
             fHandle.write(member.getCommentStr())
Beispiel #22
0
 def parse(self, tokenParseBuffer):
     super(ProtoMessage, self).parse(tokenParseBuffer)
     
     self.m_typeKeyWord = tokenParseBuffer.getTokenAndRemove()  # "message"
     self.m_typeName = tokenParseBuffer.getTokenAndRemove() # "stTest"
     # 检查父类
     nextToken = tokenParseBuffer.getTokenAndNoRemove()
     if nextToken == ":":     # 说明有基类
         nextToken = tokenParseBuffer.getTokenAndRemove()    # 移除 ":"
         self.m_parentCls = tokenParseBuffer.getTokenAndRemove()
     
     
     tokenParseBuffer.getTokenAndRemove()        # 移除 "{"
     
     while True:
         linePrefix = tokenParseBuffer.getTokenAndNoRemove()
         if linePrefix == ProtoKeyWord.eRightBraceSemicolon:     # 如果取出来是 "};"
             break
         elif linePrefix == ProtoKeyWord.eRightBrace:            # 如果取出来是 "}"
             tokenParseBuffer.getTokenAndRemove()        # 移除 ";"
             break
         elif AppSysBase.instance().getClsUtils().tokenIsComment(linePrefix):       # 如果当前符号是注释
             memberComment = ProtoMemberComment()
             self.m_memberList.append(memberComment)
             memberComment.parse(memberComment)
         elif linePrefix == ProtoKeyWord.eBase:
             messageMember = MessageMember()
             self.m_baseMemberInitList.append(messageMember)
             messageMember.parse(tokenParseBuffer)
         else:
             messageMember = MessageMember()
             self.m_memberList.append(messageMember)
             messageMember.parse(tokenParseBuffer)
         
     
     tokenParseBuffer.getTokenAndRemove()        # 移除 "};"
Beispiel #23
0
    def parse(self, tokenParseBuffer):
        super(ProtoEnum, self).parse(tokenParseBuffer)

        self.m_typeKeyWord = tokenParseBuffer.getTokenAndRemove()  # "enum"
        self.m_typeName = tokenParseBuffer.getTokenAndRemove()  # "eTest"
        tokenParseBuffer.getTokenAndRemove()  # 移除 "{"

        while True:
            linePrefix = tokenParseBuffer.getTokenAndNoRemove()
            if linePrefix == ProtoKeyWord.eRightBraceSemicolon:  # 如果取出来是 "};"
                break
            elif linePrefix == ProtoKeyWord.eRightBrace:  # 如果取出来是 "}"
                tokenParseBuffer.getTokenAndRemove()  # 移除 ";"
                break
            elif AppSysBase.instance().getClsUtils().tokenIsComment(linePrefix):  # 如果当前符号是注释
                memberComment = ProtoMemberComment()
                self.m_memberList.append(memberComment)
                memberComment.parse(memberComment)
            else:
                enumMember = EnumMember()
                self.m_memberList.append(enumMember)
                enumMember.parse(tokenParseBuffer)

        tokenParseBuffer.getTokenAndRemove()  # 移除 "};"
Beispiel #24
0
    def exportOneFile(self, file):
        fileNameNoExt = file.getFileNameNoExt()
        fileOutPath = AppSysBase.instance().getConfigPtr().getCppOutPath()
        fullPath = "{0}/{1}.h".format(fileOutPath, fileNameNoExt)

        with open(fullPath, "w", encoding="utf8") as fHandle:
            AppSysBase.instance().getClsCppExportDefine().exportHeaderDefineStart(fHandle, fileNameNoExt)
            AppSysBase.instance().getClsCppExportInclude().exportInclude(fHandle, file)
            AppSysBase.instance().getClsCppExportPragma().exportPragmaBeforeNS(fHandle, file)
            AppSysBase.instance().getClsCppExportNS().exportNSStart(fHandle, file)

            for protoElem in file.getProtoElemList():  # 遍历整个文件列表
                if protoElem.getElemType() == eProtoElemType.eMessage:  # 如果是消息
                    AppSysBase.instance().getClsCppExportMessage().exportMessage(fHandle, protoElem)
                elif protoElem.getElemType() == eProtoElemType.eEnum:
                    AppSysBase.instance().getClsCppExportEnum().exportEnum(fHandle, protoElem)
                elif protoElem.getElemType() == eProtoElemType.eComment:
                    AppSysBase.instance().getClsCppExportComment().exportComment(fHandle, protoElem)

            AppSysBase.instance().getClsCSharpExportNS().exportNSEnd(fHandle)
            AppSysBase.instance().getClsCppExportPragma().exportPragmaAfterNS(fHandle, file)
            AppSysBase.instance().getClsCppExportDefine().exportHeaderDefineEnd(fHandle)

            fHandle.close()  # 关闭文件输入
Beispiel #25
0
 def delObject(self, delayObject):
     if self.bInDepth():
         super(EventDispatch, self).delObject(delayObject);
     else:
         if not self.m_handleList.Remove(delayObject):
             AppSysBase.instance().m_logSys.log("Event Handle not exist");
Beispiel #26
0
 def run(self):
     AppSysBase.instance().getLogSysPtr().info('CPP Export Start Run')
     super(CppExportProcess, self).run()
     AppSysBase.instance().getExportCppFile().export()
Beispiel #27
0
 def start(self):
     AppSysBase.instance().getConfigPtr().getProtoFilesList().parse()
     super(CppExportProcess, self).start()
Beispiel #28
0
 def run(self):
     AppSysBase.instance().getLogSysPtr().info('CPP Export Start Run')
     super(CppExportThread, self).run()
     AppSysBase.instance().getExportCppFile().export()
     AppSysBase.instance().getLogSysPtr().info('CPP Export End Run')
     self.endRun()
Beispiel #29
0
 def start(self):
     AppSysBase.instance().getLogSysPtr().info('Start Cpp Export Run')
     AppSysBase.instance().getConfigPtr().getProtoFilesList().parse()
     super(CppExportThread, self).start()
Beispiel #30
0
 def exportConstruct(fHandle, message):
     # 写入构造函数
     AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
     AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
     AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
     constructFuncStr = "public {0}()".format(message.getTypeName())
     fHandle.write(constructFuncStr)
     
     # 写入构造函数左括号
     AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
     AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
     AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
     AppSysBase.instance().getClsUtils().writeLBrace2File(fHandle)
     
     # 写入构造函数内容
     # 写入父类构造函数内容
     for baseMemberInit in message.getBaseMemberInitList():
         AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
         AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
         AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
         AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
         
         # 写入变量名字
         memberStr = "{0} = {1};".format(baseMemberInit.getVarName(), baseMemberInit.getDefaultValueAfterDot())
         
         fHandle.write(memberStr)
         #写入注释
         if not AppSysBase.instance().getClsUtils().isNullOrEmpty(baseMemberInit.getCommentStr()):   # 如果字符串不为空
             AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
             fHandle.write(baseMemberInit.getCommentStr())
             
     # 写入自己的数据成员
     for selfMember in message.getMemberList():
         if not selfMember.hasDefaultValue():        # 如果没有默认值
             continue
         AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
         AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
         AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
         AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
         if selfMember.isBasicType():
             # 写入变量名字
             memberStr = "{0} = {1};".format(selfMember.getVarName(), selfMember.getDefaultValueAfterDot())
         elif selfMember.isCharArrayType():
             memberStr = "{0} = {1};".format(selfMember.getVarName(), selfMember.getDefaultValueAfterDot())
         else:   # 其它的数组
             memberStr = "{0} = {1};".format(selfMember.getVarName(), selfMember.getDefaultValueAfterDot())
             
         fHandle.write(memberStr)
         # 这个注释就不用写了,因为成员的注释已经在成员声明区域输出了
         #if not AppSysBase.instance().getClsUtils().isNullOrEmpty(selfMember.getCommentStr()):   # 如果字符串不为空
         #    AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
         #    fHandle.write(selfMember.getCommentStr())
         
     
     # 写入构造函数右括号
     AppSysBase.instance().getClsUtils().writeNewLine2File(fHandle)
     AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
     AppSysBase.instance().getClsUtils().writeTab2File(fHandle)
     AppSysBase.instance().getClsUtils().writeRBrace2File(fHandle)