def bitflags(*args):
    """Take a sequence of bool values and return an integer with those bits set."""
    cur, val = 1, 0
    for arg in args:
        if arg:
            val |= cur
        cur <<= 1
    return val
