Exemple #1
0
def getCompactDescriptor(d):
    seen = {}
    ind = []
    r = r_getCompactDescriptor(d, seen, ind)

    # Fix up indirections:
    for i in ind:
        try:
            if (type(i[0]) is types.StringType):
                i[0] = seen[i[0]]
            else:
                i[0] = seen[id(i[0])]
        except KeyError:
            raise CORBA.BAD_TYPECODE(BAD_TYPECODE_InvalidIndirection,
                                     CORBA.COMPLETED_NO)

    return r
Exemple #2
0
def createTypeCode(d, parent=None):
    try:
        r = basicTypeCodes.get(d)
        if r is not None:
            return r
    except TypeError:
        # Happens if d contains a mutable object
        pass

    if type(d) is not types.TupleType:
        raise CORBA.INTERNAL()

    k = d[0]

    if k == tv_string: return TypeCode_string(d)
    elif k == tv_wstring: return TypeCode_wstring(d)
    elif k == tv_fixed: return TypeCode_fixed(d)

    elif k in [tv_objref, tv_abstract_interface, tv_local_interface]:
        tc = typeCodeMapping.get(d[1])
        if tc is None:
            tc = TypeCode_objref(d)
        return tc

    elif k == tv_struct:
        tc = typeCodeMapping.get(d[2])
        if tc is None:
            tc = TypeCode_struct(d, parent)
        return tc

    elif k == tv_union:
        tc = typeCodeMapping.get(d[2])
        if tc is None:
            tc = TypeCode_union(d, parent)
        return tc

    elif k == tv_enum:
        tc = typeCodeMapping.get(d[1])
        if tc is None:
            tc = TypeCode_enum(d)
        return tc

    elif k == tv_sequence:
        return TypeCode_sequence(d, parent)
    elif k == tv_array:
        return TypeCode_array(d, parent)

    elif k == tv_alias:
        tc = typeCodeMapping.get(d[1])
        if tc is None:
            tc = TypeCode_alias(d, parent)
        return tc

    elif k == tv_except:
        tc = typeCodeMapping.get(d[2])
        if tc is None:
            tc = TypeCode_except(d, parent)
        return tc

    elif k == tv_value:
        tc = typeCodeMapping.get(d[2])
        if tc is None:
            tc = TypeCode_value(d, parent)
        return tc

    elif k == tv_value_box:
        tc = typeCodeMapping.get(d[2])
        if tc is None:
            tc = TypeCode_value_box(d, parent)
        return tc

    elif k == tv__indirect:
        if type(d[1][0]) == types.StringType:
            nd = omniORB.findType(d[1][0])
            if nd is None:
                raise CORBA.BAD_TYPECODE(
                    omniORB.BAD_TYPECODE_InvalidIndirection,
                    CORBA.COMPLETED_NO)
            d[1][0] = nd
        return createTypeCode(d[1][0], parent)

    raise CORBA.INTERNAL()