def _amiName(self, scopedName, kind): ident = scopedName[-1] scope = scopedName[:-1] prefix = "" while 1: candidate = "AMI_%s%s%s" % (prefix, ident, kind) try: idlast.findDecl(scope + [candidate]) except idlast.DeclNotFound: return candidate prefix = prefix + "AMI_"
def visitEnum(self, node): scoped_name = node.scopedName()[:-1] if len(scoped_name) and isinstance(idlast.findDecl(scoped_name), idlast.Interface): value = 0 for enum in node.enumerators(): name = enum.identifier() self._idl.out("const unsigned long @name@ = @value@;", name=name, value=str(value)) value = value + 1
def visitConst(self, node): scoped_name = node.scopedName()[:-1] if len(scoped_name) and isinstance(idlast.findDecl(scoped_name), idlast.Interface): name = node.identifier() ti = typeinfo.GetTypeInformation(node.constType().unalias()) cleaned_value = str(node.value()) if cleaned_value[-1] == 'L': cleaned_value = cleaned_value[0:-1] self._idl.out("const @type@ @name@ = @value@;", type=ti.type_xpidl, name=name, value=cleaned_value)
def relativeScope(fromScope, destScope): """relativeScope variant that handles invented fromScopes""" rs = idlutil.relativeScope(fromScope, destScope) if rs[0] is None: try: rd = idlast.findDecl(destScope) except idlast.DeclNotFound: return rs new_rs = rs while new_rs[0] is None and len(fromScope) > 1: fromScope = fromScope[:-1] new_rs = idlutil.relativeScope(fromScope, destScope) if new_rs[0] is not None: return new_rs return rs