printsize = False for opt,arg in opts: if (opt in ("-h","--help")): usage() sys.exit(0) elif (opt in ("-s","--size")): printsize = True elif (opt in ("-c","--cstruct")): printc = True elif (opt in ("-n","--names")): printname = True else: print "Unhandled option :"+opt sys.exit(1) headerfile = cheader.cheaderfile(args[:-1]) cstruct = headerfile.structs[args[-1].strip()] cs2p = c2py.cstruct2py() pattern = cs2p.get_pattern(cstruct) #Print C struct if (printc): print cstruct #Print pattern print "Python pattern = "+pattern #Print name if (printname): print cstruct.get_names()
elif (opt in ("-M", "--macros")): allMacros = True elif (opt in ("-m", "--macro")): macro = arg elif (opt in ("-E", "--enums")): allEnums = True elif (opt in ("-e", "--enum")): enum = arg elif (opt in ("-n", "--name-only")): nameOnly = True elif (opt in ("-P", "--print-no-comment")): printNoComment = True else: assert (False, "Unhandled option :" + opt) headerfile = cheader.cheaderfile(args) if (printNoComment): for line in headerfile.content: print line sys.exit(0) #Print all macros if (allMacros): for (macroname, value) in headerfile.macros.items(): if (nameOnly): print macroname else: print macroname + "\t=\t" + str(value) #Print specified macro if (macro != ""): try:
outputlavi=False else: print "Unhandled option:"+opt sys.exit(2) #Check for header file in NOX directory if not (os.path.isfile(args[0]+"/src/nox/coreapps/messenger/message.hh")): print "Messenger header file not found!" sys.exit(2) if (outputlavi): if not (os.path.isfile(args[0]+"/src/nox/netapps/lavi/lavi-message.hh")): print "LAVI message header file not found!" sys.exit(2) #Get headerfile and pythonizer msgheader = cheader.cheaderfile(args[0]+"/src/nox/coreapps/messenger/message.hh") mpynizer = lavi.pythonize.msgpythonizer(msgheader) if (outputlavi): laviheader = cheader.cheaderfile([args[0]+"/src/nox/coreapps/messenger/message.hh", args[0]+"/src/nox/netapps/lavi/lavi-message.hh"]) lpynizer = lavi.pythonize.lavipythonizer(laviheader) #Generate Python code for messenger fileRef = open(args[0]+"/src/nox/coreapps/messenger/messenger.py", "w") for x in mpynizer.pycode(templatefile): fileRef.write(x+"\n") fileRef.write("\n") fileRef.close() if (outputlavi): fileRef = open(args[0]+"/src/nox/netapps/lavi/lavi.py", "w")
outputlavi = False else: print "Unhandled option:" + opt sys.exit(2) #Check for header file in NOX directory if not (os.path.isfile(args[0] + "/src/nox/coreapps/messenger/message.hh")): print "Messenger header file not found!" sys.exit(2) if (outputlavi): if not (os.path.isfile(args[0] + "/src/nox/netapps/lavi/lavi-message.hh")): print "LAVI message header file not found!" sys.exit(2) #Get headerfile and pythonizer msgheader = cheader.cheaderfile(args[0] + "/src/nox/coreapps/messenger/message.hh") mpynizer = lavi.pythonize.msgpythonizer(msgheader) if (outputlavi): laviheader = cheader.cheaderfile([ args[0] + "/src/nox/coreapps/messenger/message.hh", args[0] + "/src/nox/netapps/lavi/lavi-message.hh" ]) lpynizer = lavi.pythonize.lavipythonizer(laviheader) #Generate Python code for messenger fileRef = open(args[0] + "/src/nox/coreapps/messenger/messenger.py", "w") for x in mpynizer.pycode(templatefile): fileRef.write(x + "\n") fileRef.write("\n") fileRef.close()
elif (opt in ("-M","--macros")): allMacros = True elif (opt in ("-m","--macro")): macro=arg elif (opt in ("-E","--enums")): allEnums = True elif (opt in ("-e","--enum")): enum = arg elif (opt in ("-n","--name-only")): nameOnly = True elif (opt in ("-P","--print-no-comment")): printNoComment = True else: assert (False,"Unhandled option :"+opt) headerfile = cheader.cheaderfile(args) if (printNoComment): for line in headerfile.content: print line sys.exit(0) #Print all macros if (allMacros): for (macroname, value) in headerfile.macros.items(): if (nameOnly): print macroname else: print macroname+"\t=\t"+str(value) #Print specified macro if (macro != ""): try: