idlast.py
来自「编译工具」· Python 代码 · 共 1,144 行 · 第 1/3 页
PY
1,144 行
self.__identifier = identifier #print line, "Parameter init:", identifier def accept(self, visitor): visitor.visitParameter(self) def direction(self): return self.__direction def is_in(self): return self.__is_in def is_out(self): return self.__is_out def paramType(self): return self.__paramType def identifier(self): return self.__identifierclass Operation (Decl, DeclRepoId): """Operation declaration (Decl, DeclRepoId)Functions: oneway() -- boolean: true if operation is one way. returnType() -- IdlType.Type object for return type. parameters() -- list of Parameter objects. raises() -- list of Exception objects. contexts() -- list of strings for context expressions.""" def __init__(self, file, line, mainFile, pragmas, comments, oneway, returnType, identifier, scopedName, repoId, parameters, raises, contexts): Decl.__init__(self, file, line, mainFile, pragmas, comments) DeclRepoId.__init__(self, identifier, scopedName, repoId) self.__oneway = oneway self.__returnType = returnType self.__parameters = parameters self.__raises = raises self.__contexts = contexts #print line, "Operation init:", identifier, raises, contexts def accept(self, visitor): visitor.visitOperation(self) def oneway(self): return self.__oneway def returnType(self): return self.__returnType def parameters(self): return self.__parameters def raises(self): return self.__raises def contexts(self): return self.__contextsclass Native (Decl, DeclRepoId): """Native declaration (Decl, DeclRepoId)Native should not be used in normal IDL.No non-inherited functions.""" def __init__(self, file, line, mainFile, pragmas, comments, identifier, scopedName, repoId): Decl.__init__(self, file, line, mainFile, pragmas, comments) DeclRepoId.__init__(self, identifier, scopedName, repoId) def accept(self, visitor): visitor.visitNative(self)class StateMember (Decl): """State member of a valuetype (Decl)Functions: memberAccess() -- integer: 0 == public, 1 == private. memberType() -- IdlType.Type object for member type. constrType() -- boolean: true if member type is declared within the StateMember. declarators() -- list of Declarator objects.""" def __init__(self, file, line, mainFile, pragmas, comments, memberAccess, memberType, constrType, declarators): Decl.__init__(self, file, line, mainFile, pragmas, comments) self.__memberAccess = memberAccess self.__memberType = memberType self.__constrType = constrType self.__declarators = declarators def accept(self, visitor): visitor.visitStateMember(self) # Access specifier: 0 for public, 1 for private def memberAccess(self): return self.__memberAccess def memberType(self): return self.__memberType def constrType(self): return self.__constrType def declarators(self): return self.__declarators class Factory (Decl): """Factory method of valuetype (Decl)Functions: identifier() -- string. parameters() -- list of Parameter objects.""" def __init__(self, file, line, mainFile, pragmas, comments, identifier, parameters): Decl.__init__(self, file, line, mainFile, pragmas, comments) self.__identifier = identifier self.__parameters = parameters def accept(self, visitor): visitor.visitFactory(self) def identifier(): return self.__identifier def parameters(): return self.__parametersclass ValueForward (Decl, DeclRepoId): """Forward declared valuetype (Decl, DeclRepoId)Function: abstract() -- boolean: true if declared abstract. fullDecl() -- Value or ValueAbs object corresponding to the full valuetype declaration or None if there is no full declaration.""" def __init__(self, file, line, mainFile, pragmas, comments, identifier, scopedName, repoId, abstract): Decl.__init__(self, file, line, mainFile, pragmas, comments) DeclRepoId.__init__(self, identifier, scopedName, repoId) self.__abstract = abstract self._fullDecl = None self._more = [] def accept(self, visitor): visitor.visitValueForward(self) def abstract(self): return self.__abstract def fullDecl(self): return self._fullDeclclass ValueBox (Decl, DeclRepoId): """ValueBox declaration (Decl, DeclRepoId)Functions: boxedType() -- IdlType.Type object for boxed type. constrType() -- boolean: true if boxed type is declared inside the ValueBox declaration.""" def __init__(self, file, line, mainFile, pragmas, comments, identifier, scopedName, repoId, boxedType, constrType): Decl.__init__(self, file, line, mainFile, pragmas, comments) DeclRepoId.__init__(self, identifier, scopedName, repoId) self.__boxedType = boxedType self.__constrType = constrType def accept(self, visitor): visitor.visitValueBox(self) def boxedType(self): return self.__boxedType def constrType(self): return self.__constrTypeclass ValueAbs (Decl, DeclRepoId): """Abstract valuetype declaration (Decl, DeclRepoId)Functions: inherits() -- list of ValueAbs objects from which this inherits. supports() -- list of Interface objects which this supports. contents() -- list of Decl objects for declarations within this valuetype. declarations() -- subset of contents() containing types, constants and exceptions. callables() -- subset of contents() containing Operations and Attributes.""" def __init__(self, file, line, mainFile, pragmas, comments, identifier, scopedName, repoId, inherits, supports): Decl.__init__(self, file, line, mainFile, pragmas, comments) DeclRepoId.__init__(self, identifier, scopedName, repoId) self.__inherits = inherits self.__supports = supports self.__contents = [] self.__declarations = [] self.__callables = [] def _setContents(self, contents): self.__contents = contents self.__declarations = filter(lambda c: not \ (isinstance(c, Attribute) or isinstance(c, Operation)), contents) self.__callables = filter(lambda c: \ (isinstance(c, Attribute) or isinstance(c, Operation)), contents) def accept(self, visitor): visitor.visitValueAbs(self) def inherits(self): return self.__inherits def supports(self): return self.__supports def contents(self): return self.__contents def declarations(self): return self.__declarations def callables(self): return self.__callablesclass Value (Decl, DeclRepoId): """valuetype declaration (Decl, DeclRepoId)Functions: custom() -- boolean: true if declared custom. inherits() -- list of valuetypes from which this inherits. The first may be a Value object or a ValueAbs object; any others will be ValueAbs objects. truncatable() -- boolean: true if the inherited Value is declared truncatable. supports() -- list of Interface objects which this supports. contents() -- list of Decl objects for all items declared within this valuetype. declarations() -- subset of contents() containing types, constants and exceptions. callables() -- subset of contents() containing Operations, Attributes, StateMembers and Factorys.""" def __init__(self, file, line, mainFile, pragmas, comments, identifier, scopedName, repoId, custom, inherits, truncatable, supports): Decl.__init__(self, file, line, mainFile, pragmas, comments) DeclRepoId.__init__(self, identifier, scopedName, repoId) self.__custom = custom self.__inherits = inherits self.__truncatable = truncatable self.__supports = supports self.__contents = [] self.__declarations = [] self.__callables = [] def _setContents(self, contents): self.__contents = contents self.__declarations = filter(lambda c: not \ (isinstance(c, Attribute) or isinstance(c, Operation) or isinstance(c, StateMember) or isinstance(c, Factory)), contents) self.__callables = filter(lambda c: \ (isinstance(c, Attribute) or isinstance(c, Operation) or isinstance(c, StateMember) or isinstance(c, Factory)), contents) def accept(self, visitor): visitor.visitValue(self) def custom(self): return self.__custom def inherits(self): return self.__inherits def truncatable(self): return self.__truncatable def supports(self): return self.__supports def contents(self): return self.__contents def declarations(self): return self.__declarations def callables(self): return self.__callables# Map of Decl objects, indexed by stringified scoped name, and# functions to access itdeclMap = {}def registerDecl(scopedName, decl): """Private function""" sname = idlutil.slashName(scopedName) if declMap.has_key(sname): rdecl = declMap[sname] isi = isinstance if (isi(decl, Interface) and isi(rdecl, Forward)) or \ (isi(decl, ValueAbs) and isi(rdecl, ValueForward)) or \ (isi(decl, Value) and isi(rdecl, ValueForward)) or \ (isi(decl, Struct) and isi(rdecl, StructForward)) or \ (isi(decl, Union) and isi(rdecl, UnionForward)): # resolving a forward declaration rdecl._fullDecl = decl for f in rdecl._more: f._fullDecl = decl declMap[sname] = decl elif (isi(decl, Forward) and isi(rdecl, Forward)) or \ (isi(decl, ValueForward) and isi(rdecl, ValueForward)) or \ (isi(decl, StructForward) and isi(rdecl, StructForward)) or \ (isi(decl, UnionForward) and isi(rdecl, UnionForward)): # repeat forward declaration rdecl._more.append(decl) elif (isi(decl, Forward) and isi(rdecl, Interface)) or \ (isi(decl, ValueForward) and isi(rdecl, ValueAbs)) or \ (isi(decl, ValueForward) and isi(rdecl, Value)) or \ (isi(decl, StructForward) and isi(rdecl, Struct)) or \ (isi(decl, UnionForward) and isi(rdecl, Union)): # forward declaration of full declaration decl._fullDecl = rdecl elif (isi(decl, Module) and isi(rdecl, Module)): # continued module rdecl._continuations.append(decl) else: print "***Warning: attempt to re-register", sname return declMap[sname] = declclass DeclNotFound: """Exception to indicate that findDecl() could not find the requested Decl object.""" def __init__(self, scopedName): self.__scopedName = scopedName def scopedName(self): return self.__scopedNamedef findDecl(scopedName): """findDecl(scopedName) -> DeclFind a Decl object given a fully scoped name represented as a list ofstrings. Raises DeclNotFound if the name is not recognised.""" sname = idlutil.slashName(scopedName) if not declMap.has_key(sname): raise DeclNotFound(scopedName) return declMap[sname]# Declarations of non-basic `built-in' typesCORBAObject = Interface("<built in>", 0, 0, [], [], "Object", ["CORBA", "Object"], "IDL:omg.org/CORBA/Object:1.0", 0, 0, [])CORBAObject._Decl__builtIn = 1registerDecl(["CORBA", "Object"], CORBAObject)CORBAValueBase = Value("<built in>", 0, 0, [], [], "ValueBase", ["CORBA", "ValueBase"], "IDL:omg.org/CORBA/ValueBase:1.0", 0, [], 0, [])CORBAValueBase._Decl__builtIn = 1registerDecl(["CORBA", "ValueBase"], CORBAValueBase)CORBAModule = Module("<built in>", 0, 0, [], [], "CORBA", ["CORBA"], "IDL:omg.org/CORBA:1.0", [CORBAObject, CORBAValueBase])registerDecl(["CORBA"], CORBAModule)def clear(): """Clear back-end structures ready for another run""" declMap.clear() registerDecl(["CORBA", "Object"], CORBAObject) registerDecl(["CORBA", "ValueBase"], CORBAValueBase) registerDecl(["CORBA"], CORBAModule)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?