def BuildInterfaceInfo(iid):
    assert not have_shutdown, "Can't build interface info after a shutdown"
    ret = interface_cache.get(iid, None)
    if ret is None:
        # Build the data for the cache.
        method_code_blocks = []
        getters = {}
        setters = {}
        method_infos = {}

        interface = xpt.Interface(iid)
        for m in interface.methods:
            flags = m.flags
            if flags & FLAGS_TO_IGNORE == 0:
                if flags & XPT_MD_SETTER:
                    param_flags = map(
                        lambda x: (x.param_flags, ) + xpt.MakeReprForInvoke(x),
                        m.params)
                    setters[m.name] = m.method_index, param_flags
                elif flags & XPT_MD_GETTER:
                    param_flags = map(
                        lambda x: (x.param_flags, ) + xpt.MakeReprForInvoke(x),
                        m.params)
                    getters[m.name] = m.method_index, param_flags
                else:
                    method_infos[m.name] = m

        # Build the constants.
        constants = {}
        for c in interface.constants:
            constants[c.name] = c.value
        ret = method_infos, getters, setters, constants
        interface_cache[iid] = ret
    return ret
def _MakeMethodCode(method):
    # Build a declaration
    param_no = 0
    param_decls = []
    param_flags = []
    param_names = []
    used_default = 0
    for param in method.params:
        param_no = param_no + 1
        param_name = "Param%d" % (param_no, )
        param_default = ""
        if not param.hidden_indicator and param.IsIn(
        ) and not param.IsDipper():
            if param.IsOut(
            ) or used_default:  # If the param is "inout", provide a useful default for the "in" direction.
                param_default = " = None"
                used_default = 1  # Once we have used one once, we must for the rest!
            param_decls.append(param_name + param_default)
            param_names.append(param_name)

        type_repr = xpt.MakeReprForInvoke(param)
        param_flags.append((param.param_flags, ) + type_repr)
    sep = ", "
    param_decls = sep.join(param_decls)
    if len(param_names) == 1:  # Damn tuple reprs.
        param_names = param_names[0] + ","
    else:
        param_names = sep.join(param_names)
    # A couple of extra newlines make them easier to read for debugging :-)
    return method_template % (method.name, param_decls, method.method_index,
                              tuple(param_flags), param_names)
# The contents of this file are subject to the Mozilla Public License Version