Esempio n. 1
0
void
c_cloneIn (
    c_type type,
    c_voidp data,
    c_voidp *dest)
{
    c_long size,subSize;
    c_type t;

    if (data == NULL) {
        *dest = NULL;
        return;
    }

    t = c_typeActualType(type);
    if (c_baseObject(t)->kind == M_COLLECTION) {
        switch(c_collectionType(t)->kind) {
        case C_STRING:
            *dest = c_stringNew(c_getBase(t), data);
            break;
        case C_LIST:
        case C_BAG:
        case C_SET:
        case C_MAP:
        case C_DICTIONARY:
            OS_REPORT(OS_WARNING,"Database misc",0,
                      "c_cloneIn: ODL collections unsupported");
        break;
        case C_ARRAY:
            subSize = c_collectionType(t)->subType->size;
            size = c_collectionType(t)->maxSize;
            if (size == 0) {
            	size = c_arraySize(data);
                *dest = c_newArray(c_collectionType(t), size);
            }
            if (size > 0) {
                memcpy(*dest, data, size * subSize);
                /* Find indirections */
                c__cloneReferences(t, data, dest);
            }
            break;
        case C_SEQUENCE:
            subSize = c_collectionType(t)->subType->size;
            size = c_sequenceSize(data);
            if (size > 0) {
                *dest = c_newSequence(c_collectionType(t), size);
                memcpy(*dest, data, size * subSize);
                /* Find indirections */
                c__cloneReferences(t, data, dest);
            }
            break;
        break;
        default:
            OS_REPORT_1(OS_ERROR,"Database misc",0,
                        "c_cloneIn: unknown collection kind (%d)",
                        c_collectionType(t)->kind);
            assert(FALSE);
        break;
        }
    } else if (c_typeIsRef(t)) {
        *dest = c_new(t);
        memcpy(*dest, data, t->size);
        /* Find indirections */
        c__cloneReferences(t, data, *dest);
    } else {
        memcpy(*dest, data, t->size);
        /* Find indirections */
        c__cloneReferences(t, data, *dest);
    }
}
Esempio n. 2
0
v_messageQos
v_messageQos_from_wqos_new(
    v_writerQos wqos,
    c_type msgQosType,
    v_presentationKind access_scope,
    c_bool coherent_access,
    c_bool ordered_access)
{
    v_messageQos _this;
    c_base base;
    v_duration tdur;
    c_ulong offset    = 6, /* byte0 + byte1 + transport_priority */
    strength_offset   = 0,
    latency_offset    = 0,
    deadline_offset   = 0,
    liveliness_offset = 0,
    lifespan_offset   = 0;

    c_octet byte0, byte1;

    c_octet *dst, *src;

    assert(C_TYPECHECK(wqos,v_writerQos));

    base = c_getBase(wqos);

    if (msgQosType == NULL) {
        msgQosType = c_metaArrayTypeNew(c_metaObject(base),
                                  "C_ARRAY<c_octet>",
                                  c_octet_t(base),
                                  0);
    }
    byte0 = (c_octet) (_LSHIFT_(wqos->reliability.v.kind, MQ_BYTE0_RELIABILITY_OFFSET) |
                       _LSHIFT_(wqos->ownership.v.kind, MQ_BYTE0_OWNERSHIP_OFFSET) |
                       _LSHIFT_(wqos->orderby.v.kind, MQ_BYTE0_ORDERBY_OFFSET) |
                       _LSHIFT_(wqos->lifecycle.v.autodispose_unregistered_instances, MQ_BYTE0_AUTODISPOSE_OFFSET));
    byte1 = (c_octet) (_LSHIFT_(wqos->durability.v.kind, MQ_BYTE1_DURABILITY_OFFSET) |
                       _LSHIFT_(wqos->liveliness.v.kind, MQ_BYTE1_LIVELINESS_OFFSET) |
                       /* writer->resend._d contains the access_scope of the publisher-QoS */
                       _LSHIFT_(access_scope, MQ_BYTE1_PRESENTATION_OFFSET) |
                       _LSHIFT_(coherent_access, MQ_BYTE1_COHERENT_ACCESS_OFFSET) |
                       _LSHIFT_(ordered_access, MQ_BYTE1_ORDERED_ACCESS_OFFSET));

    if (wqos->ownership.v.kind == V_OWNERSHIP_EXCLUSIVE) {
        strength_offset = offset;
        offset += (c_ulong) sizeof(wqos->strength.v.value);
    }
    if (OS_DURATION_ISZERO(wqos->latency.v.duration)) {
        byte0 = (c_octet) (byte0 | _LSHIFT_(1,MQ_BYTE0_LATENCY_OFFSET));
    } else {
        latency_offset = offset;
        offset += (c_ulong) sizeof(wqos->latency.v.duration);
    }
    if (OS_DURATION_ISINFINITE(wqos->deadline.v.period)) {
        byte0 = (c_octet) (byte0 | _LSHIFT_(1,MQ_BYTE0_DEADLINE_OFFSET));
    } else {
        deadline_offset = offset;
        offset += (c_ulong) sizeof(wqos->deadline.v.period);
    }
    if (OS_DURATION_ISINFINITE(wqos->liveliness.v.lease_duration)) {
        byte0 = (c_octet) (byte0 | _LSHIFT_(1,MQ_BYTE0_LIVELINESS_OFFSET));
    } else {
        liveliness_offset = offset;
        offset += (c_ulong) sizeof(wqos->liveliness.v.lease_duration);
    }
    if (OS_DURATION_ISINFINITE(wqos->lifespan.v.duration)) {
        byte0 = (c_octet) (byte0 | _LSHIFT_(1,MQ_BYTE0_LIFESPAN_OFFSET));
    } else {
        lifespan_offset = offset;
        offset += (c_ulong) sizeof(wqos->lifespan.v.duration);
    }

    _this = c_newArray((c_collectionType)msgQosType,offset);

    if (_this) {
        ((c_octet *)_this)[0] = byte0;
        ((c_octet *)_this)[1] = byte1;
        src = (c_octet *)&wqos->transport.v.value;
        dst = (c_octet *)&((c_octet *)_this)[2];
        _COPY4_(dst,src);

        if (strength_offset) {
            src = (c_octet *)&wqos->strength.v.value;
            dst = (c_octet *)&((c_octet *)_this)[strength_offset];
            _COPY4_(dst,src);
        }
        if (latency_offset) {
            tdur = v_durationFromOsDuration(wqos->latency.v.duration);
            src = (c_octet *)&tdur;
            dst = (c_octet *)&((c_octet *)_this)[latency_offset];
            _COPY8_(dst,src);
        }
        if (deadline_offset) {
            tdur = v_durationFromOsDuration(wqos->deadline.v.period);
            src = (c_octet *)&tdur;
            dst = (c_octet *)&((c_octet *)_this)[deadline_offset];
            _COPY8_(dst,src);
        }
        if (liveliness_offset) {
            tdur = v_durationFromOsDuration(wqos->liveliness.v.lease_duration);
            src = (c_octet *)&tdur;
            dst = (c_octet *)&((c_octet *)_this)[liveliness_offset];
            _COPY8_(dst,src);
        }
        if (lifespan_offset) {
            tdur = v_durationFromOsDuration(wqos->lifespan.v.duration);
            src = (c_octet *)&tdur;
            dst = (c_octet *)&((c_octet *)_this)[lifespan_offset];
            _COPY8_(dst,src);
        }
    } else {
        OS_REPORT(OS_CRITICAL,
                  "v_messageQos_new",V_RESULT_INTERNAL_ERROR,
                  "Failed to allocate messageQos.");
        assert(FALSE);
    }
    return _this;
}
Esempio n. 3
0
void
c_copyIn (
    c_type type,
    c_voidp data,
    c_voidp *dest)
{
    c_long size, subSize, i;
    c_type t, refType;

    if (data == NULL) {
        *dest = NULL;
        return;
    }
    t = c_typeActualType(type);
    if (c_baseObject(t)->kind == M_COLLECTION) {
        switch(c_collectionType(t)->kind) {
        case C_STRING:
            *dest = c_stringNew(c_getBase(t),data);
            return;
        case C_LIST:
        case C_BAG:
        case C_SET:
        case C_MAP:
        case C_DICTIONARY:
            OS_REPORT(OS_WARNING,"Database misc",0,
                      "c_copyIn: ODL collections unsupported");
        break;
        case C_ARRAY:
            refType = c_typeActualType(c_collectionType(type)->subType);
            subSize = refType->size;
            size = c_collectionType(t)->maxSize;
            if (size == 0) {
                size = c_arraySize(data);
                *dest = c_newArray(c_collectionType(t), size);
            }
            if (size > 0) {
                c_array ar = c_array(data);
                c_array destar = c_array(*dest);
                if (c_typeIsRef(refType)) {
                    for (i = 0; i < size; i++) {
                        copyReferences(refType, destar[i], ar[i]);
                    }
                } else {
                    memcpy(*dest, data, size * subSize);
                    /* Find indirections */
                    for (i = 0; i < size; i++) {
                        copyReferences(refType, C_DISPLACE(destar, (i*subSize)), C_DISPLACE(ar, (i*subSize)));
                    }
                }
            }
        break;
        case C_SEQUENCE:
            refType = c_typeActualType(c_collectionType(type)->subType);
            subSize = refType->size;
            size = c_sequenceSize(data);
            if (size > 0) {
                *dest = c_newSequence(c_collectionType(t), size);
                if (c_typeIsRef(refType)) {
                    c_sequence seq = c_sequence(data);
                    c_sequence destseq = c_sequence(*dest);
                    for (i = 0; i < size; i++) {
                        copyReferences(refType, destseq[i], seq[i]);
                    }
                } else {
                    memcpy(*dest, data, size * subSize);
                    /* Find indirections */
                    for (i = 0; i < size; i++) {
                        copyReferences(refType, C_DISPLACE(*dest, (i*subSize)), C_DISPLACE(data, (i*subSize)));
                    }
                }
            }
        break;
        default:
            OS_REPORT_1(OS_ERROR,"Database misc",0,
                        "c_copyIn: unknown collection kind (%d)",
                        c_collectionType(t)->kind);
            assert(FALSE);
        break;
        }
    } else if (c_typeIsRef(t)) {
        *dest = c_new(t);
        memcpy(*dest, data, t->size);
        copyReferences(t, *dest, data);
    } else {
        memcpy(*dest, data, t->size);
        copyReferences(t, *dest, data);
    }
}