def declaredType(decl, scopedName, kind, local): sname = idlutil.slashName(scopedName) if declaredTypeMap.has_key(sname): dt = declaredTypeMap[sname] if dt.kind() == kind: return dt dt = Declared(decl, scopedName, kind, local) declaredTypeMap[sname] = dt return dt
def findDecl(scopedName): """findDecl(scopedName) -> Decl Find a Decl object given a fully scoped name represented as a list of strings. Raises DeclNotFound if the name is not recognised.""" sname = idlutil.slashName(scopedName) if not declMap.has_key(sname): raise DeclNotFound(scopedName) return declMap[sname]
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 for cc in rdecl._continuations: cc._continuations.append(decl) rdecl._continuations.append(decl) else: print "Warning: attempt to re-register", sname return declMap[sname] = decl