void
__std_msgs_msg_dds__UInt64MultiArray___copyOut(
    void *_from,
    void *_to)
{
    struct _std_msgs_msg_dds__UInt64MultiArray_ *from = (struct _std_msgs_msg_dds__UInt64MultiArray_ *)_from;
    struct ::std_msgs::msg::dds_::UInt64MultiArray_ *to = (struct ::std_msgs::msg::dds_::UInt64MultiArray_ *)_to;
    {
        extern void __std_msgs_msg_dds__MultiArrayLayout___copyOut(void *, void *);
        __std_msgs_msg_dds__MultiArrayLayout___copyOut((void *)&from->layout_, (void *)&to->layout_);
    }
    {
        long size0;
        c_ulonglong *src0 = (c_ulonglong *)from->data_;
        ::std_msgs::msg::dds_::UInt64MultiArray_::_data__seq *dst = &to->data_;

        size0 = c_arraySize(c_sequence(from->data_));
        to->data_.length(size0);
        {
            c_ulonglong *buf0;
            buf0 = (c_ulonglong *)(*dst).get_buffer();
            memcpy (buf0,src0,size0* sizeof(*buf0));
        }
    }
}
void
__sensor_msgs_msg_dds__CompressedImage___copyOut(
    void *_from,
    void *_to)
{
    struct _sensor_msgs_msg_dds__CompressedImage_ *from = (struct _sensor_msgs_msg_dds__CompressedImage_ *)_from;
    struct ::sensor_msgs::msg::dds_::CompressedImage_ *to = (struct ::sensor_msgs::msg::dds_::CompressedImage_ *)_to;
    {
        extern void __std_msgs_msg_dds__Header___copyOut(void *, void *);
        __std_msgs_msg_dds__Header___copyOut((void *)&from->header_, (void *)&to->header_);
    }
    to->format_ = DDS::string_dup(from->format_ ? from->format_ : "");
    {
        long size0;
        c_octet *src0 = (c_octet *)from->data_;
        ::sensor_msgs::msg::dds_::CompressedImage_::_data__seq *dst = &to->data_;

        size0 = c_arraySize(c_sequence(from->data_));
        to->data_.length(size0);
        {
            c_octet *buf0;
            buf0 = (c_octet *)(*dst).get_buffer();
            memcpy (buf0,src0,size0* sizeof(*buf0));
        }
    }
}
예제 #3
0
void
in_messageDeserializerReadStructure(
    in_messageDeserializer _this,
    c_type type,
    c_voidp data)
{
    c_structure structure = c_structure(type);
    c_member member;
    c_type memberType;
    os_uint32 size;
    os_uint32 i;
    c_voidp o;

    assert(_this);
    assert(in_messageDeserializerIsValid(_this));
    assert(type);
    assert(data);

    size = c_arraySize(structure->members);
    for (i = 0; i < size; i++)
    {
        member = structure->members[i];
        assert(member);
        o = C_DISPLACE(data, (c_address)member->offset);
        memberType = c_typeActualType(c_specifierType(member));
        in_messageDeserializerReadType(_this, memberType, o);
    }
}
예제 #4
0
static c_char *
createInstanceKeyExpr (
    c_base base,
    v_topic topic)
{
    c_char fieldName[16];
    c_char *keyExpr;
    c_long i,nrOfKeys,totalSize;
    c_array keyList;

    assert(C_TYPECHECK(topic,v_topic));
    keyList = v_topicMessageKeyList(topic);
    nrOfKeys = c_arraySize(keyList);
    if (nrOfKeys>0) {
        totalSize = nrOfKeys * strlen("key.field0,");
        if (nrOfKeys > 9) {
            totalSize += (nrOfKeys-9);
            if (nrOfKeys > 99) {
                totalSize += (nrOfKeys-99);
            }
        }
        keyExpr = c_stringMalloc(base, totalSize);
        keyExpr[0] = 0;
        for (i=0;i<nrOfKeys;i++) {
            os_sprintf(fieldName,"key.field%d",i);
            os_strcat(keyExpr,fieldName);
            if (i<(nrOfKeys-1)) { os_strcat(keyExpr,","); }
        }
    } else {
        keyExpr = NULL;
    }
    return keyExpr;
}
예제 #5
0
v_result
v_deliveryWaitListIgnore (
    v_deliveryWaitList _this,
    v_gid readerGID)
{
    c_ulong size, i, count;
    v_gid *list;

    assert(C_TYPECHECK(_this,v_deliveryWaitList));

    count = 0;
    size = c_arraySize(_this->readerGID);
    list = (v_gid *)_this->readerGID;
    for (i=0; i<size; i++) {
        if (v_gidEqual(list[i],readerGID)) {
            /* Set the found reader gid to zero,
             * iThe waitlist can be unblocked when
             * all expected systemIds are zero.
             * In that case count will be 0.
             */
            v_gidSetNil(list[i]);
        }
        count += v_gidSystemId(list[i]);
    }
    if (count == 0) {
        c_free(_this->readerGID);
        _this->readerGID = NULL;
        c_mutexLock(&_this->mutex);
        c_condSignal(&_this->cv);
        c_mutexUnlock(&_this->mutex);
    }
    return V_RESULT_OK;
}
예제 #6
0
static v_result
copy_IncompatibleQosStatus(
    c_voidp info,
    c_voidp arg)
{
    unsigned long i;
    unsigned long len;
    v_result result = V_RESULT_PRECONDITION_NOT_MET;
    struct v_incompatibleQosInfo *from;
    gapi_offeredIncompatibleQosStatus *to;

    from = (struct v_incompatibleQosInfo *)info;
    to = (gapi_offeredIncompatibleQosStatus *)arg;

    to->total_count = from->totalCount;
    to->total_count_change = from->totalChanged;
    to->last_policy_id = from->lastPolicyId;

    len = c_arraySize(from->policyCount);
    if ( to->policies._buffer && (len <= to->policies._maximum) ) {
        to->policies._length = len;
        for ( i = 0; i < len; i++ ) {
            to->policies._buffer[i].policy_id = i;
            to->policies._buffer[i].count = ((c_long *)from->policyCount)[i];
        }
        result = V_RESULT_OK;
    }

    return result;
}
예제 #7
0
static void
userDataQosPolicyCopyout (
    const struct v_userDataPolicy *src,
    gapi_userDataQosPolicy        *dst)
{
    unsigned long len = c_arraySize(src->value);

    if ( dst->value._maximum > 0 ) {
        if ( len != dst->value._maximum ) {
            if ( dst->value._release ) {
                gapi_free(dst->value._buffer);
            }
            dst->value._maximum = 0;
            dst->value._length  = 0;
            dst->value._buffer  = NULL;
        }
    }

    if ( len > 0 ) {
        if ( dst->value._length == 0 ) {
            if ( dst->value._maximum == 0 ) {
                dst->value._buffer  = gapi_octetSeq_allocbuf(len) ;
                dst->value._maximum = len;
                dst->value._length  = 0;
                dst->value._release = TRUE;
            }

            if ( dst->value._maximum >= len ) {
                memcpy(dst->value._buffer, src->value, len);
            }
        }
    }

    dst->value._length = len;
}
예제 #8
0
static c_type
createKeyType(
    const c_char *name,
    c_array keyList)
{
    c_base base;
    c_type foundType;
    c_char *typeName;
    c_char keyName[16];
    c_long i, length, sres;
    c_array members;
    c_metaObject o;
    c_field field;

    if (keyList == NULL) {
        return NULL;
    }
    base = c_getBase(keyList);
    length = c_arraySize(keyList);
    if (length == 0) {
        return NULL;
    }
    o = c_metaDefine(c_metaObject(base),M_STRUCTURE);
    members = c_arrayNew(c_member_t(base),length);

    for (i=0;i<length;i++) {
        field = keyList[i];
        assert(field != NULL);
        members[i] = (c_voidp)c_metaDefine(c_metaObject(base),M_MEMBER);
            sprintf(keyName,"field%d",i);
            c_specifier(members[i])->name = c_stringNew(base,keyName);
            c_specifier(members[i])->type = c_keep(c_fieldType(field));
    }
    c_structure(o)->members = members;
    c_metaObject(o)->definedIn = c_metaObject(base);
    c_metaFinalize(o);
#define KEY_NAME   "<Key>"
#define KEY_FORMAT "%s<Key>"

    if (name != NULL) {
        length = sizeof(KEY_NAME) + strlen(name);
        typeName = os_malloc(length);
        sres = snprintf(typeName,length,KEY_FORMAT,name);
        assert(sres == (length-1));
    } else {
        assert(FALSE);
        length = 100;
        typeName = os_malloc(length);
        os_sprintf(typeName,PA_ADDRFMT KEY_NAME,(c_address)o);
    }
#undef KEY_NAME
#undef KEY_FORMAT
    foundType = c_type(c_metaBind(c_metaObject(base),typeName,o));

    c_free(o);
    os_free(typeName);

    return foundType;

}
예제 #9
0
static d_instance
d_instanceNew(
    d_groupInfo groupInfo,
    const v_groupAction action)
{
    d_instance instance;
    c_type type;
    c_long nrOfKeys, i;
    c_array messageKeyList, instanceKeyList;

    instanceKeyList = c_tableKeyList(groupInfo->instances);
    type = c_subType(groupInfo->instances);
    instance = d_instance(c_new(type));
    c_free(type);

    if(instance){
        /*
         * copy the key value of the message into the newly created instance.
         */
        messageKeyList = v_topicMessageKeyList(v_groupTopic(action->group));
        nrOfKeys = c_arraySize(messageKeyList);
        assert(nrOfKeys == c_arraySize(instanceKeyList));

        for (i=0;i<nrOfKeys;i++) {
            c_fieldCopy(messageKeyList[i],action->message,
                        instanceKeyList[i], instance);
        }
        c_free(instanceKeyList);

        d_instanceSetHead(instance, NULL);
        d_instanceSetTail(instance, NULL);

        instance->messageCount = 0;
        instance->count = 0;
        instance->state = 0;

        v_stateSet(instance->state, L_EMPTY);
    } else {
        OS_REPORT(OS_ERROR,
                  "d_instanceNew",0,
                  "Failed to allocate instance.");
        assert(FALSE);
    }
    return instance;
}
예제 #10
0
void
c_fieldFreeRef (
    c_field field,
    c_object o)
{
    c_long i,n;
    c_voidp p = o;
    c_array refs;

    if (field->refs) {
        refs = field->refs;
        n = c_arraySize(refs)-1;
        for(i=0;i<n;i++) {
            p = *(c_voidp *)C_DISPLACE(p,refs[i]);
        }
        p = C_DISPLACE(p,refs[n]);
    } else {
        p = C_DISPLACE(p,field->offset);
    }

    switch(field->kind) {
    case V_ADDRESS:   break;
    case V_BOOLEAN:   break;
    case V_SHORT:     break;
    case V_LONG:      break;
    case V_LONGLONG:  break;
    case V_OCTET:     break;
    case V_USHORT:    break;
    case V_ULONG:     break;
    case V_ULONGLONG: break;
    case V_CHAR:      break;
    case V_WCHAR:     break;
    case V_STRING:
        c_free((c_object)(*(c_string *)p));
        (*(c_string *)p) = NULL;
    break;
    case V_WSTRING:
        c_free((c_object)(*(c_wstring *)p));
        (*(c_wstring *)p) = NULL;
    break;
    case V_FLOAT:     break;
    case V_DOUBLE:    break;
    case V_OBJECT:
        c_free(*(c_object *)p);
        (*(c_object *)p) = NULL;
    break;
    case V_VOIDP:     break;
    case V_FIXED:
    case V_UNDEFINED:
    case V_COUNT:
        OS_REPORT_1(OS_ERROR,"c_fieldFreeRef failed",0,
                    "illegal field value kind (%d)", field->kind);
        assert(FALSE);
    break;
    }
}
예제 #11
0
void
jni_getTopicKeyExpression(
    v_entity entity,
    c_voidp args)
{
    v_kernel vk;
    c_iter vtopics;
    c_array keyList;
    c_char* keyExpr;
    c_long nrOfKeys, totalSize, i;
    c_string fieldName, actualFieldName;
    struct jni_topicArg *arg;
    
    arg = (struct jni_topicArg *)args;
    vk = v_objectKernel(entity);
    
    if(vk != NULL){
        vtopics = v_resolveTopics(vk, arg->topicName);
            
        if(c_iterLength(vtopics) == 0){
            c_iterFree(vtopics);
        }
        else{
            keyList = v_topicMessageKeyList(c_iterTakeFirst(vtopics));
            c_iterFree(vtopics);                
            nrOfKeys = c_arraySize(keyList);

            if (nrOfKeys>0) {
                totalSize = 0;
                
                for (i=0;i<nrOfKeys;i++) {
                    fieldName = c_fieldName(keyList[i]);
                    totalSize += (strlen(fieldName)+1-9/*skip 'userdata.'*/);
                }
                keyExpr = (c_char *)os_malloc((size_t)(totalSize+1));
                keyExpr[0] = 0;
                
                for (i=0;i<nrOfKeys;i++) {
                    fieldName = c_fieldName(keyList[i]);
                    actualFieldName = c_skipUntil(fieldName, ".");
                    actualFieldName++; /*skip '.' */
                    os_strcat(keyExpr,actualFieldName);
                    
                    if (i<(nrOfKeys-1)) { 
                        os_strcat(keyExpr,","); 
                    }
                }
                arg->keyExpr = keyExpr;
            } else{
                /*No keys, do nothing.*/
            }
            arg->result = U_RESULT_OK;
        }
    }
}
예제 #12
0
void
c_fieldClone(
    c_field srcfield,
    c_object src,
    c_field dstfield,
    c_object dst)
{
    c_long i,n;
    c_array refs;
    c_voidp srcp = src;
    c_voidp dstp = dst;

    if (srcfield->refs) {
        refs = srcfield->refs;
        n = c_arraySize(refs)-1;
        for(i=0;i<n;i++) {
            srcp = *(c_voidp *)C_DISPLACE(srcp,refs[i]);
        }
        srcp = C_DISPLACE(srcp,refs[n]);
    } else {
        srcp = C_DISPLACE(srcp,srcfield->offset);
    }

    if (dstfield->refs) {
        refs = dstfield->refs;
        n = c_arraySize(refs)-1;
        for(i=0;i<n;i++) {
            dstp = *(c_voidp *)C_DISPLACE(dstp,refs[i]);
        }
        dstp = C_DISPLACE(dstp,refs[n]);
    } else {
        dstp = C_DISPLACE(dstp,dstfield->offset);
    }
    if ((dstfield->kind == V_STRING) ||
        (dstfield->kind == V_WSTRING) ||
        (dstfield->kind == V_FIXED)) {
    	dstp = c_stringNew(c_getBase(dstfield), srcp);
    } else {
        memcpy(dstp,srcp,dstfield->type->size);
    }
}
예제 #13
0
u_waitsetEvent
u_waitsetHistoryRequestEventNew(
    u_entity e,
    c_ulong k,
    v_handle source,
    c_char* filter,
    c_array filterParams,
    struct v_resourcePolicy resourceLimits,
    c_time minSourceTimestamp,
    c_time maxSourceTimestamp)
{
    u_waitsetEvent event;
    u_waitsetHistoryRequestEvent hrEvent;
    c_long i;

    event = (u_waitsetEvent)os_malloc(C_SIZEOF(u_waitsetHistoryRequestEvent));

    if (event) {
        hrEvent                     = u_waitsetHistoryRequestEvent(event);
        event->entity               = e;
        event->events               = k;
        event->kind                 = U_WAITSET_EVENT_HISTORY_REQUEST;

        if(filter){
            hrEvent->filter         = os_strdup(filter);
        } else {
            hrEvent->filter         = NULL;
        }
        hrEvent->source.server      = source.server;
        hrEvent->source.index       = source.index;
        hrEvent->source.serial      = source.serial;
        hrEvent->resourceLimits     = resourceLimits;
        hrEvent->minSourceTimestamp = minSourceTimestamp;
        hrEvent->maxSourceTimestamp = maxSourceTimestamp;
        hrEvent->filterParamsCount  = c_arraySize(filterParams);

        if(hrEvent->filterParamsCount > 0){
            hrEvent->filterParams = (c_char**)(os_malloc(
                                hrEvent->filterParamsCount*sizeof(c_char*)));

            for(i=0; i<hrEvent->filterParamsCount; i++){
                hrEvent->filterParams[i] = os_strdup(filterParams[i]);
            }
        } else {
            hrEvent->filterParams = NULL;
        }
    }
    return event;
}
예제 #14
0
/** \brief Function for selecting the correct case label for a given switch
 *         value
 */
static c_unionCase
sd_unionDetermineLabel(
    c_union v_union,
    c_value switchValue)
{
    c_unionCase result = NULL;
    c_unionCase deflt;
    c_unionCase currentCase;
    c_literal label;
    int i,j, nLabels;

    /* Determine corresponding label */
    result = NULL;
    deflt = NULL;
    for (i=0; (i<c_arraySize(v_union->cases)) && !result; i++) {
        currentCase = c_unionCase(v_union->cases[i]);
        nLabels = c_arraySize(currentCase->labels);
        if (nLabels > 0) {
            for (j=0; (j<nLabels) && !result; j++) {
                label = c_literal(currentCase->labels[j]);

                if (c_valueCompare(switchValue, label->value) == C_EQ) {
                    result = currentCase;
                }
            }
        } else {
            deflt = currentCase;
        }
    }

    if (!result) {
        result = deflt;
    }

    return result;
}
예제 #15
0
void
__sensor_msgs_msg_dds__CameraInfo___copyOut(
    void *_from,
    void *_to)
{
    struct _sensor_msgs_msg_dds__CameraInfo_ *from = (struct _sensor_msgs_msg_dds__CameraInfo_ *)_from;
    struct ::sensor_msgs::msg::dds_::CameraInfo_ *to = (struct ::sensor_msgs::msg::dds_::CameraInfo_ *)_to;
    {
        extern void __std_msgs_msg_dds__Header___copyOut(void *, void *);
        __std_msgs_msg_dds__Header___copyOut((void *)&from->header_, (void *)&to->header_);
    }
    to->height_ = (::DDS::ULong)from->height_;
    to->width_ = (::DDS::ULong)from->width_;
    to->distortion_model_ = DDS::string_dup(from->distortion_model_ ? from->distortion_model_ : "");
    {
        long size0;
        c_double *src0 = (c_double *)from->d_;
        ::sensor_msgs::msg::dds_::CameraInfo_::_d__seq *dst = &to->d_;

        size0 = c_arraySize(c_sequence(from->d_));
        to->d_.length(size0);
        {
            c_double *buf0;
            buf0 = (c_double *)(*dst).get_buffer();
            memcpy (buf0,src0,size0* sizeof(*buf0));
        }
    }
    {
        extern void __sensor_msgs_msg_dds__sensor_msgs__CameraInfo__double_array_9__copyOut(void *, void *);
        __sensor_msgs_msg_dds__sensor_msgs__CameraInfo__double_array_9__copyOut((void *)&from->k_, (void *)&to->k_);
    }
    {
        extern void __sensor_msgs_msg_dds__sensor_msgs__CameraInfo__double_array_9__copyOut(void *, void *);
        __sensor_msgs_msg_dds__sensor_msgs__CameraInfo__double_array_9__copyOut((void *)&from->r_, (void *)&to->r_);
    }
    {
        extern void __sensor_msgs_msg_dds__sensor_msgs__CameraInfo__double_array_12__copyOut(void *, void *);
        __sensor_msgs_msg_dds__sensor_msgs__CameraInfo__double_array_12__copyOut((void *)&from->p_, (void *)&to->p_);
    }
    to->binning_x_ = (::DDS::ULong)from->binning_x_;
    to->binning_y_ = (::DDS::ULong)from->binning_y_;
    {
        extern void __sensor_msgs_msg_dds__RegionOfInterest___copyOut(void *, void *);
        __sensor_msgs_msg_dds__RegionOfInterest___copyOut((void *)&from->roi_, (void *)&to->roi_);
    }
}
예제 #16
0
static c_bool
idl_unionHasCase(c_union _union, char *name) {
    c_long caseCount, i;
    c_unionCase _case;
    c_bool result = FALSE;

    caseCount = c_arraySize(_union->cases);

    for(i=0; i<caseCount; i++) {
        _case = _union->cases[i];
        if(!strcmp(c_specifier(_case)->name, name)) {
            result = TRUE;
            break;
        }
    }

    return result;
}
예제 #17
0
static v_message
createUnregisterMessage(
    v_group group,
    v_message message)
{
    c_array            messageKeyList;
    c_long                i, nrOfKeys;
    v_message            unregisterMessage;

    assert(!v_stateTest(v_nodeState(message), L_UNREGISTER));

    /* Create new message objec */
    unregisterMessage = v_topicMessageNew
                                (group->topic);

    /* Copy keyvalues to unregistermessage */
    messageKeyList = v_topicMessageKeyList(v_groupTopic(group));
    nrOfKeys = c_arraySize(messageKeyList);
    for (i=0;i<nrOfKeys;i++) {
        c_fieldAssign (messageKeyList[i],
                unregisterMessage,
                c_fieldValue(messageKeyList[i],message));
    }

    /* Set instance & writer GID */
    unregisterMessage->writerGID =
            message->writerGID;
    unregisterMessage->writerInstanceGID =
            message->writerInstanceGID;

    /* Copy messageQos */
    c_keep (message->qos);
    unregisterMessage->qos = message->qos;

    /* Set nodestate to unregister */
    v_nodeState(unregisterMessage) = L_UNREGISTER;

    unregisterMessage->writeTime = v_timeGet();
#ifndef _NAT_
    unregisterMessage->allocTime = unregisterMessage->writeTime;
#endif

    return unregisterMessage;
}
예제 #18
0
static void
extractStructReferences(
    c_structure m,
    c_object o,
    void *data)
{
    c_long i,length;
    c_member member;
    c_type type;
    c_object *ref;

    if (m->references == NULL) return;
    length = c_arraySize(m->references);
    for (i=0;i<length;i++) {
        member = c_member(m->references[i]);
        type = c_typeActualType(c_specifier(member)->type);
        while (c_baseObject(type)->kind == M_TYPEDEF) {
            type = c_typeDef(type)->alias;
        }
        switch (c_baseObject(type)->kind) {
        case M_CLASS:
        case M_INTERFACE:
        case M_COLLECTION:
        case M_BASE:
            ref = C_DISPLACE(data,member->offset);
            *ref = NULL;
            c_copyOut(type,C_REFGET(o,member->offset),ref);
        break;
        case M_EXCEPTION:
        case M_STRUCTURE:
        case M_UNION:
            copyReferences(type,C_DISPLACE(o,member->offset),
                                C_DISPLACE(data,member->offset))
;
        break;
        default:
            assert(FALSE);
        break;
        }
    }
}
void
__rcl_interfaces_srv_dds__GetParameterTypes_Response___copyOut(
    void *_from,
    void *_to)
{
    struct _rcl_interfaces_srv_dds__GetParameterTypes_Response_ *from = (struct _rcl_interfaces_srv_dds__GetParameterTypes_Response_ *)_from;
    struct ::rcl_interfaces::srv::dds_::GetParameterTypes_Response_ *to = (struct ::rcl_interfaces::srv::dds_::GetParameterTypes_Response_ *)_to;
    {
        long size0;
        c_octet *src0 = (c_octet *)from->types_;
        ::rcl_interfaces::srv::dds_::GetParameterTypes_Response_::_types__seq *dst = &to->types_;

        size0 = c_arraySize(c_sequence(from->types_));
        to->types_.length(size0);
        {
            c_octet *buf0;
            buf0 = (c_octet *)(*dst).get_buffer();
            memcpy (buf0,src0,size0* sizeof(*buf0));
        }
    }
}
예제 #20
0
v_messageQos
v_messageQos_copy (
    v_messageQos src)
{
    v_messageQos _this;
    c_ulong size;
    c_type type = NULL;

    size = c_arraySize(src);
    type = c_getType(src);
    _this = c_newArray((c_collectionType)type,size);
    if (_this) {
        memcpy(_this,src,size);
    } else {
        OS_REPORT(OS_CRITICAL,
                  "v_messageQos_copy",V_RESULT_INTERNAL_ERROR,
                  "Failed to allocate messageQos.");
    }

    return _this;
}
예제 #21
0
os_int32
idl_stacDefFindMemberIndexByName(
    c_array members,
    const os_char* name)
{
    os_uint32 membersSize;
    os_int32 memberIndex = -1;
    c_member member;
    os_uint32 i;

    membersSize = c_arraySize(members);
    for(i = 0; i < membersSize && memberIndex == -1 ; i++)
    {
        member = c_member(members[i]);
        if(0 == strcmp(c_specifier(member)->name, name))
        {
            memberIndex = (os_int32) i;
        }
    }
    return memberIndex;
}
예제 #22
0
void
__sensor_msgs_msg_dds__LaserEcho___copyOut(
    void *_from,
    void *_to)
{
    struct _sensor_msgs_msg_dds__LaserEcho_ *from = (struct _sensor_msgs_msg_dds__LaserEcho_ *)_from;
    struct ::sensor_msgs::msg::dds_::LaserEcho_ *to = (struct ::sensor_msgs::msg::dds_::LaserEcho_ *)_to;
    {
        long size0;
        c_float *src0 = (c_float *)from->echoes_;
        ::sensor_msgs::msg::dds_::LaserEcho_::_echoes__seq *dst = &to->echoes_;

        size0 = c_arraySize(c_sequence(from->echoes_));
        to->echoes_.length(size0);
        {
            c_float *buf0;
            buf0 = (c_float *)(*dst).get_buffer();
            memcpy (buf0,src0,size0* sizeof(*buf0));
        }
    }
}
예제 #23
0
static void
checkTopicKeyList (
    v_entity e,
    c_voidp arg)
{
    c_array keyList = v_topicMessageKeyList(e);
    checkTopicKeyListArg *info  = (checkTopicKeyListArg *) arg;
    c_long i;
    gapi_char *name;
    c_long size;
    c_iter iter;
    gapi_boolean equal = TRUE;

    iter = c_splitString(info->keyList, " \t,");

    if ( iter ) {
        size = c_arraySize(keyList);

        for ( i = 0; equal && (i < size); i++ ) {
            name = (gapi_char *)c_iterResolve(iter,
                                              topicKeyCompare,
                                              keyNameFromField(keyList[i]));
            if ( !name ) {
                equal = FALSE;
                OS_REPORT_2(OS_API_INFO,
                            "gapi::kernelCheckTopicKeyList", 0,
                            "incompatible key <%s> found for topic <%s>",
                            keyNameFromField(keyList[i]),
                            v_entityName(e));
            }
        }
        name = c_iterTakeFirst(iter);
        while ( name ) {
            os_free(name);
            name = c_iterTakeFirst(iter);
        }
        c_iterFree(iter);
    }
    info->equal = equal;
}
예제 #24
0
v_result
v_deliveryWaitListNotify (
    v_deliveryWaitList _this,
    v_deliveryInfoTemplate msg)
{
    c_ulong size, i, count;
    v_gid *list;

    assert(C_TYPECHECK(_this,v_deliveryWaitList));
    assert(msg);

    list = (v_gid *)_this->readerGID;
    if(msg->userData.sequenceNumber == _this->sequenceNumber)
    {
        count = 0;
        
        size = c_arraySize(_this->readerGID);
        for (i=0; i<size; i++) {
            if (v_gidEqual(list[i],msg->userData.readerGID)) {
                /* Set the found readerGID to zero,
                 * iThe waitlist can be unblocked when
                 * all expected systemIds are zero.
                 * In that case count will be 0.
                 */
                v_gidSetNil(list[i]);
            }
            count += v_gidSystemId(list[i]);
        }
        if (count == 0) {
            c_free(_this->readerGID);
            _this->readerGID = NULL;
            c_mutexLock(&_this->mutex);
            c_condSignal(&_this->cv);
            c_mutexUnlock(&_this->mutex);
        }
    }
    return V_RESULT_OK;
}
예제 #25
0
static void
builtinPartitionQosPolicyCopyout (
    const struct v_builtinPartitionPolicy *src,
    gapi_partitionQosPolicy               *dst)
{
    unsigned long len = c_arraySize(src->name);

    if ( dst->name._maximum > 0 ) {
        if ( len != dst->name._maximum ) {
            if ( dst->name._release ) {
                gapi_free(dst->name._buffer);
            }
            dst->name._maximum = 0;
            dst->name._length  = 0;
            dst->name._buffer  = NULL;
        }
    }

    if ( len > 0 ) {
        if ( dst->name._length == 0 ) {
            if ( dst->name._maximum == 0 ) {
                dst->name._buffer  = gapi_stringSeq_allocbuf(len) ;
                dst->name._maximum = len;
                dst->name._length  = 0;
                dst->name._release = TRUE;
            }

            if ( dst->name._maximum >= len ) {
                unsigned long i;
                for ( i = 0; i < len; i++ ) {
                    dst->name._buffer[i] = gapi_string_dup(src->name[i]);
                }
            }
        }
    }

    dst->name._length = len;
}
예제 #26
0
static void
copyInterfaceReferences(
    c_interface m,
    c_voidp dest,
    c_voidp data)
{
    c_long i,length;
    c_property property;
    c_type type;
    c_object *ref;

    if (m->references == NULL) {
        return;
    }
    length = c_arraySize(m->references);
    for (i=0;i<length;i++) {
        property = c_property(m->references[i]);
        type = c_typeActualType(property->type);
        switch (c_baseObject(type)->kind) {
        case M_CLASS:
        case M_INTERFACE:
        case M_COLLECTION:
        case M_BASE:
            ref = C_DISPLACE(dest,property->offset);
            c_copyIn(type,C_REFGET(data,property->offset),ref);
        break;
        case M_EXCEPTION:
        case M_STRUCTURE:
        case M_UNION:
            copyReferences(type,C_DISPLACE(dest,property->offset),
                                C_DISPLACE(data,property->offset));
        break;
        default:
            assert(FALSE);
        break;
        }
    }
}
예제 #27
0
static void
topicGetKeys(
    v_entity e,
    c_voidp arg)
{
    c_array keyList = v_topicMessageKeyList(e);
    gapi_char     **keys  = (gapi_char **) arg;
    gapi_char      *ptr;
    c_ulong i;
    c_ulong size;
    c_ulong total = 0;
    c_ulong len = 0;

    size = c_arraySize(keyList);

    for ( i = 0; i < size; i++ ) {
        total += strlen(c_fieldName(keyList[i])) + 1;
    }

    if ( total > 0 ) {
        *keys = (gapi_char *)os_malloc(total);
        memset(*keys, 0, total);
    } else {
        *keys = (gapi_char *)os_malloc(1);
        **keys = '\0';
    }

    ptr = *keys;
    for ( i = 0; i < size; i++ ) {
        if ( i == 0 ) {
            len = os_sprintf(ptr, "%s", keyNameFromField(keyList[i]));
        } else {
            len = os_sprintf(ptr, ",%s", keyNameFromField(keyList[i]));
        }
        ptr = &(ptr[len]);
    }
}
예제 #28
0
파일: v_index.c 프로젝트: osrf/opensplice
static c_array
createKeyList(
    c_type instanceType,
    c_array keyList)
{
    c_ulong size, i;
    c_array newKeyList = NULL;

    assert(instanceType);

    if (keyList) {
        size = c_arraySize(keyList);

        newKeyList = c_arrayNew(c_field_t(c_getBase(instanceType)), size);

        if (newKeyList) {
            for(i = 0; i<size; i++){
                c_field f = c_fieldNew(instanceType, PREFIX);
                assert(f);
                if (f) {
                    newKeyList[i] = c_fieldConcat(f, keyList[i]);
                    c_free(f);
                } else {
                    OS_REPORT(OS_CRITICAL,
                                "createKeyList", V_RESULT_INTERNAL_ERROR,
                                "Could not create c_field");
                }
            }
        } else {
            OS_REPORT(OS_FATAL,
                        "createKeyList", V_RESULT_INTERNAL_ERROR,
                        "Could not create array");
        }
    }
    return newKeyList;
}
예제 #29
0
static d_instance
d_groupInfoLookupInstance (
    d_groupInfo _this,
    const v_groupAction action)
{
    c_long i, nrOfKeys;
    c_value keyValues[32];
    d_instance instance;
    c_array messageKeyList;

    assert(C_TYPECHECK(action->message,v_message));

    messageKeyList = v_topicMessageKeyList(action->group->topic);
    nrOfKeys = c_arraySize(messageKeyList);

    if (nrOfKeys > 32) {
        OS_REPORT_1(OS_ERROR,
                    "d_groupInfoGetInstance",0,
                    "too many keys %d exceeds limit of 32",
                    nrOfKeys);
        instance = NULL;
    } else {
        for (i=0;i<nrOfKeys;i++) {
            keyValues[i] = c_fieldValue(messageKeyList[i],action->message);
        }
        instance = c_tableFind(_this->instances, &keyValues[0]);
        c_keep(instance);



        for (i=0;i<nrOfKeys;i++) {
            c_valueFreeRef(keyValues[i]);
        }
    }
    return instance;
}
예제 #30
0
c_equality
c_fieldCompare (
    c_field field1,
    c_object src1,
    c_field field2,
    c_object src2)
{
    c_long i,n,r;
    c_array refs;
    c_voidp p1 = src1;
    c_voidp p2 = src2;
    c_equality result;

    result = C_NE;

    if (field1->refs) {
        refs = field1->refs;
        n = c_arraySize(refs)-1;
        for(i=0;i<n;i++) {
            p1 = *(c_voidp *)C_DISPLACE(p1,refs[i]);
        }
        p1 = C_DISPLACE(p1,refs[n]);
    } else {
        p1 = C_DISPLACE(p1,field1->offset);
    }

    if (field2->refs) {
        refs = field2->refs;
        n = c_arraySize(refs)-1;
        for(i=0;i<n;i++) {
            p2 = *(c_voidp *)C_DISPLACE(p2,refs[i]);
        }
        p2 = C_DISPLACE(p2,refs[n]);
    } else {
        p2 = C_DISPLACE(p2,field2->offset);
    }
#define _CMP_(t) ((*(t*)p1)<(*(t*)p2)?C_LT:((*(t*)p1)>(*(t*)p2)?C_GT:C_EQ))

    switch(field1->kind) {
    case V_ADDRESS:   result = _CMP_(c_address); break;
    case V_BOOLEAN:   result = _CMP_(c_bool); break;
    case V_SHORT:     result = _CMP_(c_short); break;
    case V_LONG:      result = _CMP_(c_long); break;
    case V_LONGLONG:  result = _CMP_(c_longlong); break;
    case V_OCTET:     result = _CMP_(c_octet); break;
    case V_USHORT:    result = _CMP_(c_ushort); break;
    case V_ULONG:     result = _CMP_(c_ulong); break;
    case V_ULONGLONG: result = _CMP_(c_ulonglong); break;
    case V_CHAR:      result = _CMP_(c_char); break;
    case V_WCHAR:     result = _CMP_(c_wchar); break;
    case V_FLOAT:     result = _CMP_(c_float); break;
    case V_DOUBLE:    result = _CMP_(c_double); break;
    case V_VOIDP:     result = _CMP_(c_voidp); break;
    case V_OBJECT:    result = _CMP_(c_object); break;
    case V_STRING:
    case V_WSTRING:
    case V_FIXED:     p1 = (p1?*(c_voidp*)p1:NULL);
                      p2 = (p2?*(c_voidp*)p2:NULL);
                      if (((c_address)p1) == ((c_address)p2)) {
                          result = C_EQ;
                      } else if (p1 == NULL) {
                          result = C_LT;
                      } else if (p2 == NULL) {
                          result = C_GT;
                      } else {
                          r = strcmp(p1,p2);
                          if (r>0) {
                              result = C_GT;
                          } else if (r<0) {
                              result = C_LT;
                          } else {
                              result = C_EQ;
                          }
                      }
    break;
    case V_UNDEFINED:
    case V_COUNT:
        OS_REPORT_1(OS_ERROR,"c_fieldCompare failed",0,
                    "illegal field value kind (%d)", field1->kind);
        assert(FALSE);
        result = C_NE;
    break;
    }
    return result;
#undef _CMP_
}