def createCodes(): #file = sys.argv[1] file = '' ostream = Outputer() #ostream.addHandler(sys.stdout) argv = sys.argv outdir = '.' pkgname = '' while argv: p = argv.pop(0) # if p =='-o': # p = argv.pop(0) # f = open(p,'w') # ostream.addHandler(f) if p == '-o': if argv: p = argv.pop(0) outdir = p if p == '-i': if argv: p = argv.pop(0) file = p if p == '-if': # 接口起始下标,如多个module文件并存,则同坐此参数区分开 if argv: ifcnt = int(argv.pop(0)) if p == '-pkg': if argv: pkgname = argv.pop(0) fp = open(file, 'r') content = fp.read() fp.close() # print outdir os.chdir(outdir) sw = StreamWriter() name = os.path.basename(file).split('.')[0] if not pkgname: pkgname = name # print pkgname sw.createPackage(pkgname) sw.pkg_enter(pkgname) # ostream.write(headtitles) unit = syntax_result(content) for idx, e in enumerate(unit.list): createCodeFrame(e, idx, sw) ostream.write(NEWLINE) sw.pkg_leave()
def createCodes(): #file = sys.argv[1] file = '' ostream = Outputer() #ostream.addHandler(sys.stdout) argv = sys.argv outdir ='.' pkgname = '' while argv: p = argv.pop(0) # if p =='-o': # p = argv.pop(0) # f = open(p,'w') # ostream.addHandler(f) if p == '-o': if argv: p = argv.pop(0) outdir = p if p =='-i': if argv: p = argv.pop(0) file = p if p =='-if': # 接口起始下标,如多个module文件并存,则同坐此参数区分开 if argv: ifcnt = int(argv.pop(0)) if p == '-pkg': if argv: pkgname = argv.pop(0) fp = open(file,'r') content = fp.read() fp.close() print outdir os.chdir( outdir ) sw = StreamWriter() name = os.path.basename(file).split('.')[0] if not pkgname: pkgname = name print pkgname sw.createPackage(pkgname) sw.pkg_enter(pkgname) # ostream.write(headtitles) unit = syntax_result(content) for idx,e in enumerate(unit.list): createCodeFrame(e,idx,sw) ostream.write(NEWLINE) sw.pkg_leave()
def createCodes(): #file = sys.argv[1] global interface_defs,ifcnt file = '' ostream = Outputer() #ostream.addHandler(sys.stdout) argv = sys.argv outdir ='./output' pkgname = '' outfile = '' filters='' while argv: p = argv.pop(0) # if p =='-o': # p = argv.pop(0) # f = open(p,'w') # ostream.addHandler(f) if p == '-o': if argv: p = argv.pop(0) outdir = p if p =='-i': if argv: p = argv.pop(0) file = p if p =='-if': # ??????????module?????????????? if argv: ifcnt = int(argv.pop(0)) # if p =='-filter': # if argv: # filters = argv.pop(0) if not os.path.exists(outdir): os.mkdir(outdir) idlfiles = file.strip().split(',') # fp = open(file,'r') # content = fp.read() # fp.close() # print outdir # os.chdir( outdir ) for file in idlfiles: print file idl_file = file lexparser.curr_idl_path = os.path.dirname(idl_file) parse_idlfile(idl_file) # name = os.path.basename(file).split('.')[0] # # outfile = outdir+'/%s.js'%name # sw = StreamWriter(ostream=open(outfile,'w')) # ostream.write(headtitles) unit = syntax_result() # filters = [ x for x in map(string.strip,filters.split(' ')) if x] # import tce_util # tce_util.filterInterface(unit,filters,ifcnt) for module in global_modules: name = module.name # print 'module:',name,module.ref_modules.keys() # print module.children f = open(os.path.join(outdir,name+'.js'),'w') ostream.clearHandler() ostream.addHandler(f) ostream.write(headtitles) sw = StreamWriter(ostream,Indent()) # for ref in module.ref_modules.keys(): # sw.writeln('import %s'%ref) sw.writeln('define("%s",["tce"],function(tce){'%module.name).wln() ifs = [] for idx,e in enumerate(module.list): createCodeFrame(module,e,idx,sw) ostream.write(NEWLINE) if isinstance(e,Interface): ifs.append(e.name) sw.writeln('return {').idt_inc() #?????????? for n in range(len(ifs)): ifx = ifs[n] if not tce_util.isExposeDelegateOfInterfaceWithName("%s.%s"%(module.name,ifx)): continue sw.writeln('%s : %s,'%(ifx,ifx)) sw.write('%sProxy : %sProxy'%(ifx,ifx)) if n <= len(ifs)-2: sw.write(',') sw.wln() sw.idt_dec().writeln('};') sw.wln().writeln("});")
def createCodes(): # file = sys.argv[1] global interface_defs, ifcnt file = "" ostream = Outputer() # ostream.addHandler(sys.stdout) argv = sys.argv outdir = "." outfile = "" filters = "" while argv: p = argv.pop(0) if p == "-o": p = argv.pop(0) outfile = p if p == "-i": if argv: p = argv.pop(0) file = p if p == "-if": # ??????????module?????????????? if argv: ifcnt = int(argv.pop(0)) # ?????????????? # ????????? # ???????? + - ???????????????? # "A+,B-,C-,D" # ??+ - ???+ if p == "-filter": if argv: filters = argv.pop(0) fp = open(file, "r") content = fp.read() fp.close() # ????idl???? if not outfile: outfile = file path = os.path.dirname(outfile) name = os.path.basename(outfile).split(".")[0] sw = StreamWriter() txt = """ #include <string> #include <functional> #include <map> #include <vector> #include <list> #include <algorithm> #include <boost/smart_ptr.hpp> #include <boost/enable_shared_from_this.hpp> #include <tce/tce.h> //#include "/root/workspace/tce/code/cpp/tce/tce.h" //#include "/Users/socketref/Documents/workspace/test2/src/tce2.h" """ sw.setIncludes("default", (txt,)) # print name,',' ,path sw.createPackage(name, path) sw.pkg_enter(name) # ostream.write(headtitles) unit = syntax_result(content) # filters = [ x for x in map(string.strip,filters.split(' ')) if x] # import tce_util # tce_util.filterInterface(unit,filters,ifcnt) for module in global_modules: name = module.name print "module:", name, module.ref_modules.keys() # print module.children for idx, e in enumerate(module.list): createCodeFrame(e, idx, sw) ostream.write(NEWLINE) # inline wroten sw.write(gbufwriter.ostream.d) sw.pkg_leave()
def createCodes(): #file = sys.argv[1] global interface_defs, ifcnt # global curr_idl_path file = 'idl/main.idl' idlfiles = '' ostream = Outputer() # ostream.addHandler(sys.stdout) outdir = './' argv = sys.argv while argv: p = argv.pop(0) if p == '-o': #???? p = argv.pop(0) outdir = p #f = open(p,'w') #ostream.addHandler(f) if p == '-i': if argv: p = argv.pop(0) file = p if p == '-if': # ??????????module?????????????? if argv: ifcnt = int(argv.pop(0)) if not os.path.exists(outdir): os.mkdir(outdir) idlfiles = file.strip().split(',') #??idl???? # fp = None # content = None for file in idlfiles: # try: # fp = open(file,'r') # content = fp.read() # fp.close() # except: # print 'access file: %s failed!'%file # sys.exit() # if content.find('\n\r') ==-1: # content.replace('\r','\n\r') print file idl_file = file lexparser.curr_idl_path = os.path.dirname(idl_file) parse_idlfile(idl_file) unit = syntax_result() # print global_modules_defs # for name, module in global_modules_defs.items(): #--??????module for module in global_modules: name = module.name # print 'module:',name,module.ref_modules.keys() # print module.children f = open(os.path.join(outdir, name + '.py'), 'w') ostream.clearHandler() ostream.addHandler(f) ostream.write(headtitles) sw = StreamWriter(ostream, Indent()) for ref in module.ref_modules.keys(): sw.writeln('import %s' % ref) for idx, e in enumerate(module.list): createCodeFrame(module, e, idx, ostream) ostream.write(NEWLINE)
def createCodes(): #file = sys.argv[1] global interface_defs,ifcnt # global curr_idl_path file = 'idl/main.idl' idlfiles = '' ostream = Outputer() # ostream.addHandler(sys.stdout) outdir = './' argv = sys.argv while argv: p = argv.pop(0) if p =='-o': #???? p = argv.pop(0) outdir = p #f = open(p,'w') #ostream.addHandler(f) if p =='-i': if argv: p = argv.pop(0) file = p if p =='-if': # ??????????module?????????????? if argv: ifcnt = int(argv.pop(0)) if not os.path.exists(outdir): os.mkdir(outdir) idlfiles = file.strip().split(',') #??idl???? # fp = None # content = None for file in idlfiles: # try: # fp = open(file,'r') # content = fp.read() # fp.close() # except: # print 'access file: %s failed!'%file # sys.exit() # if content.find('\n\r') ==-1: # content.replace('\r','\n\r') print file idl_file = file lexparser.curr_idl_path = os.path.dirname(idl_file) parse_idlfile(idl_file) unit = syntax_result() # print global_modules_defs # for name, module in global_modules_defs.items(): #--??????module for module in global_modules: name = module.name # print 'module:',name,module.ref_modules.keys() # print module.children f = open(os.path.join(outdir,name+'.py'),'w') ostream.clearHandler() ostream.addHandler(f) ostream.write(headtitles) sw = StreamWriter(ostream,Indent()) for ref in module.ref_modules.keys(): sw.writeln('import %s'%ref) for idx,e in enumerate(module.list): createCodeFrame(module,e,idx,ostream) ostream.write(NEWLINE)
def createCodes(): #file = sys.argv[1] global interface_defs,ifcnt file = 'idl/main.idl' ostream = Outputer() #ostream.addHandler(sys.stdout) argv = sys.argv outdir = './output' pkgname = '' filters='' while argv: p = argv.pop(0) # if p =='-o': # p = argv.pop(0) # f = open(p,'w') # ostream.addHandler(f) if p == '-o': if argv: p = argv.pop(0) outdir = p if p =='-i': if argv: p = argv.pop(0) file = p if p =='-if': # ??????????module?????????????? if argv: ifcnt = int(argv.pop(0)) # if p == '-p': # if argv: # pkgname = argv.pop(0) if p =='-filter': if argv: filters = argv.pop(0) fp = None content = None try: fp = open(file,'r') content = fp.read() fp.close() except: print 'access file: %s failed!'%file sys.exit() if content.find('\n\r') ==-1: content.replace('\r','\n\r') if not os.path.exists(outdir): os.mkdir(outdir) import tce_util tce_util.getInterfaceIndexWithName('') # print outdir sw = StreamWriter() # name = os.path.basename(file).split('.')[0] # if not pkgname: # pkgname = name # print pkgname print file idlfiles = file.strip().split(',') for file in idlfiles: lexparser.curr_idl_path = os.path.dirname(file) parse_idlfile(file) # ostream.write(headtitles) unit = syntax_result() print global_modules_defs os.chdir( outdir ) for module in global_modules: name = module.name print 'module:',name,module.ref_modules.keys() # print module.children sw = StreamWriter(ostream,Indent()) sw.createPackage(name) # sw.pkg_enter(name) for idx,e in enumerate(module.list): createCodeFrame(e,idx,sw) sw.pkg_leave()
def createCodes(): #file = sys.argv[1] global interface_defs,ifcnt file = '' ostream = Outputer() ostream.addHandler(sys.stdout) argv = sys.argv outdir ='./output' pkgname = '' filters='' while argv: p = argv.pop(0) # if p =='-ox': # p = argv.pop(0) # f = open(p,'w') # ostream.addHandler(f) if p == '-o': if argv: p = argv.pop(0) outdir = p if p =='-if': # ??????????module?????????????? ifcnt = int(argv.pop(0)) if p =='-i': if argv: p = argv.pop(0) file = p if p == '-p': pkgname = argv.pop(0) if p =='-filter': filters = argv.pop(0) fp = open(file,'r') content = fp.read() fp.close() if not os.path.exists(outdir): os.mkdir(outdir) idlfiles = file.strip().split(',') for file in idlfiles: lexparser.curr_idl_path = os.path.dirname(file) parse_idlfile(file) unit = syntax_result() os.chdir( outdir ) sw = StreamWriter() if not pkgname: pkgname = os.path.basename(file).split('.')[0] sw.createPackage(pkgname) sw.pkg_enter(pkgname) # ostream.write(headtitles) # unit = syntax_result(content) # filters = [ x for x in map(string.strip,filters.split(' ')) if x] sys.path.append(os.path.dirname(__file__)) import tce_util tce_util.filterInterface(unit, filters, ifcnt) print global_modules_defs for module in global_modules: for idx,e in enumerate(module.list): createCodeFrame(e,idx,sw) # ostream.write(NEWLINE) sw.pkg_leave()
def createCodes(): #file = sys.argv[1] global interface_defs, ifcnt file = '' ostream = Outputer() ostream.addHandler(sys.stdout) argv = sys.argv outdir = './output' pkgname = '' filters = '' while argv: p = argv.pop(0) # if p =='-ox': # p = argv.pop(0) # f = open(p,'w') # ostream.addHandler(f) if p == '-o': if argv: p = argv.pop(0) outdir = p if p == '-if': # ??????????module?????????????? ifcnt = int(argv.pop(0)) if p == '-i': if argv: p = argv.pop(0) file = p if p == '-p': pkgname = argv.pop(0) if p == '-filter': filters = argv.pop(0) fp = open(file, 'r') content = fp.read() fp.close() if not os.path.exists(outdir): os.mkdir(outdir) idlfiles = file.strip().split(',') for file in idlfiles: lexparser.curr_idl_path = os.path.dirname(file) parse_idlfile(file) unit = syntax_result() os.chdir(outdir) sw = StreamWriter() if not pkgname: pkgname = os.path.basename(file).split('.')[0] sw.createPackage(pkgname) sw.pkg_enter(pkgname) # ostream.write(headtitles) # unit = syntax_result(content) # filters = [ x for x in map(string.strip,filters.split(' ')) if x] sys.path.append(os.path.dirname(__file__)) import tce_util tce_util.filterInterface(unit, filters, ifcnt) print global_modules_defs for module in global_modules: for idx, e in enumerate(module.list): createCodeFrame(e, idx, sw) # ostream.write(NEWLINE) sw.pkg_leave()
def createCodes(): #file = sys.argv[1] global interface_defs,ifcnt file = '' ostream = Outputer() # ostream.addHandler(sys.stdout) argv = sys.argv outdir ='.' outfile ='' filters='' while argv: p = argv.pop(0) if p =='-o': p = argv.pop(0) outfile = p if p =='-i': if argv: p = argv.pop(0) file = p if p =='-if': # ??????????module?????????????? if argv: ifcnt = int(argv.pop(0)) #?????????????? # ????????? # ???????? + - ???????????????? # "A+,B-,C-,D" # ??+ - ???+ if p =='-filter': if argv: filters = argv.pop(0) fp = open(file,'r') content = fp.read() fp.close() #????idl???? if not outfile: outfile = file path = os.path.dirname(outfile) name = os.path.basename(outfile).split('.')[0] sw = StreamWriter() txt=''' #include <string> #include <functional> #include <map> #include <vector> #include <list> #include <algorithm> #include <boost/smart_ptr.hpp> #include <boost/enable_shared_from_this.hpp> #include <tce/tce.h> //#include "/root/workspace/tce/code/cpp/tce/tce.h" //#include "/Users/socketref/Documents/workspace/test2/src/tce2.h" ''' sw.setIncludes('default',(txt,)) # print name,',' ,path sw.createPackage(name,path) sw.pkg_enter(name) # ostream.write(headtitles) unit = syntax_result(content) # filters = [ x for x in map(string.strip,filters.split(' ')) if x] # import tce_util # tce_util.filterInterface(unit,filters,ifcnt) for module in global_modules: name = module.name print 'module:',name,module.ref_modules.keys() # print module.children for idx,e in enumerate(module.list): createCodeFrame(e,idx,sw) ostream.write(NEWLINE) #inline wroten sw.write(gbufwriter.ostream.d) sw.pkg_leave()
def createCodes(): global interface_defs,ifcnt file = 'idl/main.idl' ostream = Outputer() argv = sys.argv outdir = './output' pkgname = '' filters='' while argv: p = argv.pop(0) if p == '-o': if argv: p = argv.pop(0) outdir = p if p =='-i': if argv: p = argv.pop(0) file = p if p =='-if': # ??????????module?????????????? if argv: ifcnt = int(argv.pop(0)) if p == '-p': if argv: pkgname = argv.pop(0) if p =='-filter': if argv: filters = argv.pop(0) if not os.path.exists(outdir): os.mkdir(outdir) import tce_util tce_util.getInterfaceIndexWithName('') # print outdir idlfiles = file.strip().split(',') for file in idlfiles: lexparser.curr_idl_path = os.path.dirname(file) parse_idlfile(file) unit = syntax_result() print global_modules_defs os.chdir( outdir ) for module in global_modules: name = module.name print 'module:',name,module.ref_modules.keys() sw = StreamWriter(ostream,Indent()) sw.pkg_prefix = pkgname.strip() sw.createPackage(name) sw.pkg_enter(name) for idx,e in enumerate(module.list): createCodeFrame(e,idx,sw) #????module???? sw.pkg_leave()