Remove trailing whitespace and add modelines info

svn path=/trunk/; revision=53751
This commit is contained in:
Alexis La Goutte 2013-12-03 13:38:15 +00:00
parent ede151cbba
commit 225161b1be
1 changed files with 46 additions and 44 deletions

View File

@ -33,12 +33,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Description:
#
#
# Omniidl Back-end which parses an IDL data structure provided by the frontend
# and generates packet-idl-xxx.[ch] for compiling as a dissector in
# Wireshark IP protocol anlayser.
#
#
#
#
#
# Strategy.
@ -72,7 +72,7 @@ from wireshark_gen import wireshark_gen_C
class WiresharkVisitor:
DEBUG = 0 # debug flag
def __init__(self, st):
self.st = st
self.oplist = [] # list of operation nodes
@ -81,11 +81,11 @@ class WiresharkVisitor:
self.stlist = [] # list of struct nodes
self.unlist = [] # list of union nodes
def visitAST(self, node):
if self.DEBUG:
print "XXX visitAST() node = ", node
for n in node.declarations():
if isinstance(n, idlast.Module):
self.visitModule(n)
@ -103,22 +103,22 @@ class WiresharkVisitor:
self.visitUnion(n)
# Check for Typedef structs and unions
if isinstance(n, idlast.Typedef):
self.visitTypedef(n) # who are you ?
def visitModule(self, node):
if self.DEBUG:
print "XXX visitModule() node = ", node
for n in node.definitions():
if isinstance(n, idlast.Module):
self.visitModule(n)
self.visitModule(n)
if isinstance(n, idlast.Interface):
self.visitInterface(n)
self.visitInterface(n)
if isinstance(n, idlast.Operation):
self.visitOperation(n)
self.visitOperation(n)
if isinstance(n, idlast.Attribute):
self.visitAttribute(n)
if isinstance(n, idlast.Enum):
@ -129,38 +129,36 @@ class WiresharkVisitor:
self.visitUnion(n)
# Check for Typedef structs and unions
if isinstance(n, idlast.Typedef):
self.visitTypedef(n) # who are you ?
def visitInterface(self, node):
if self.DEBUG:
print "XXX visitInterface() node = ", node
for c in node.callables():
if isinstance(c, idlast.Operation):
self.visitOperation(c)
if isinstance(c, idlast.Attribute):
self.visitAttribute(c)
for d in node.contents():
if isinstance(d, idlast.Enum):
self.visitEnum(d)
if isinstance(d, idlast.Struct):
self.visitStruct(d)
if isinstance(d, idlast.Union):
self.visitUnion(d)
# Check for Typedef structs and unions
if isinstance(d, idlast.Typedef):
self.visitTypedef(d) # who are you ?
#
# visitOperation
@ -168,7 +166,7 @@ class WiresharkVisitor:
# populates the operations node list "oplist"
#
#
def visitOperation(self,opnode):
if not opnode in self.oplist:
self.oplist.append(opnode) # store operation node
@ -179,7 +177,7 @@ class WiresharkVisitor:
# populates the attribute node list "atlist"
#
#
def visitAttribute(self,atnode):
if not atnode in self.atlist:
self.atlist.append(atnode) # store attribute node
@ -191,7 +189,7 @@ class WiresharkVisitor:
# populates the Enum node list "enlist"
#
#
def visitEnum(self,enode):
if not enode in self.enlist:
self.enlist.append(enode) # store enum node if unique
@ -203,12 +201,12 @@ class WiresharkVisitor:
#
# eg: typdef enum colors {red, green, blue } mycolors;
#
def visitTypedef(self,td):
d = td.aliasType() # get Type, possibly Declared
if isinstance(d,idltype.Declared):
self.visitDeclared(d)
#
# visitDeclared
@ -216,13 +214,13 @@ class WiresharkVisitor:
# Search to see if its a struct, union, or enum
#
#
def visitDeclared(self,d):
if isinstance(d,idltype.Declared):
sue = d.decl() # grab the struct or union or enum
if isinstance(sue, idlast.Struct):
self.visitStruct(sue)
self.visitStruct(sue)
if isinstance(sue, idlast.Union):
self.visitUnion(sue)
if isinstance(sue, idlast.Enum):
@ -238,9 +236,9 @@ class WiresharkVisitor:
# and checks its members also
#
#
def visitStruct(self,stnode):
if not stnode in self.stlist:
if not stnode in self.stlist:
self.stlist.append(stnode) # store struct node if unique and avoid recursive loops
# if we come across recursive structs
@ -250,7 +248,6 @@ class WiresharkVisitor:
self.visitDeclared(mt) # if declared, then check it out
#
# visitUnion
#
@ -258,7 +255,7 @@ class WiresharkVisitor:
# and checks its members also
#
#
def visitUnion(self,unnode):
if not unnode in self.unlist:
self.unlist.append(unnode) # store union node if unique
@ -271,23 +268,21 @@ class WiresharkVisitor:
ct = c.caseType()
if isinstance(ct,idltype.Declared):
self.visitDeclared(ct) # if declared, then check it out
def run(tree, args):
st = output.Stream(sys.stdout, 4) # set indent for stream
ev = WiresharkVisitor(st) # create visitor object
ev.visitAST(tree) # go find some operations
#
# Grab name of main IDL file being compiled.
#
# Assumption: Name is of the form abcdefg.xyz (eg: CosNaming.idl)
#
fname = path.basename(tree.file()) # grab basename only, dont care about path
nl = string.split(fname,".")[0] # split name of main IDL file using "." as separator
# and grab first field (eg: CosNaming)
@ -298,21 +293,28 @@ def run(tree, args):
for i in ev.atlist:
print "XXX - Attribute node ", i, " identifiers() = ", i.identifiers()
for i in ev.enlist:
print "XXX - Enum node ", i, " repoId() = ", i.repoId()
print "XXX - Enum node ", i, " repoId() = ", i.repoId()
for i in ev.stlist:
print "XXX - Struct node ", i, " repoId() = ", i.repoId()
print "XXX - Struct node ", i, " repoId() = ", i.repoId()
for i in ev.unlist:
print "XXX - Union node ", i, " repoId() = ", i.repoId()
# create a C generator object
# and generate some C code
eg = wireshark_gen_C(ev.st, string.upper(nl), string.lower(nl), string.capitalize(nl) + " Dissector Using GIOP API")
eg.genCode(ev.oplist, ev.atlist, ev.enlist, ev.stlist, ev.unlist) # pass them onto the C generator
#
# Editor modelines - http://www.wireshark.org/tools/modelines.html
#
# Local variables:
# c-basic-offset: 4
# indent-tabs-mode: nil
# End:
#
# vi: set shiftwidth=4 expandtab:
# :indentSize=4:noTabs=true:
#