コード例 #1
0
char *
idl_genXMLmeta (
    c_type type)
{
    sd_serializer metaSer;
    sd_serializedData serData;
    char *metaDescription = NULL;
    c_iter replaceInfo;
    c_iter replaceInfoStac;

    replaceInfo = idl_catsDefConvertAll(idl_catsDefDefGet());
    replaceInfoStac = idl_stacDefConvertAll(idl_stacDefDefGet());
    metaSer = sd_serializerXMLTypeinfoNew (c_getBase(c_object(type)), TRUE);
    if (metaSer)
    {
        serData = sd_serializerSerialize (metaSer, c_object(type));
        if (serData)
        {
	    metaDescription = sd_serializerToString (metaSer, serData);
	}
        sd_serializerFree (metaSer);
    }
    idl_catsDefRestoreAll(idl_catsDefDefGet(), replaceInfo);
    idl_stacDefRestoreAll(idl_stacDefDefGet(), replaceInfoStac);
    return metaDescription;
}
コード例 #2
0
ファイル: d_topicInfo.c プロジェクト: xrl/opensplice_dds
static c_type
cloneType(
    c_base src,
    c_base dst,
    c_type object)
{
    sd_serializer serializer, deserializer;
    sd_serializedData data;
    c_char* xmlData;
    c_type result;

    result = NULL;
    serializer = sd_serializerXMLTypeinfoNew(src, FALSE);
    deserializer = sd_serializerXMLTypeinfoNew(dst, FALSE);

    if(serializer && deserializer){
        data = sd_serializerSerialize(serializer, object);

        if(data){
            xmlData = sd_serializerToString(serializer, data);
            sd_serializedDataFree(data);

            if(xmlData){
                data = sd_serializerFromString(deserializer, xmlData);

                if(data){
                    result = c_type(sd_serializerDeserializeValidated(
                            deserializer, data));
                    sd_serializedDataFree(data);
                }
                os_free(xmlData);
            }
        }
        sd_serializerFree(serializer);
        sd_serializerFree(deserializer);
    }
    return result;
}
コード例 #3
0
ファイル: idl_registerType.c プロジェクト: xrl/opensplice_dds
void
idl_registerType (
    c_base base,
    const char *basename,
    c_iter typeNames
    )
{
    sd_serializer metaSer;
    sd_serializedData serData;
    char *metaDescription = NULL;
    char *typeName;
    c_char *fname;
    c_metaObject type;
    int i;

    fname = os_malloc((size_t)((int)strlen(basename)+20));
    snprintf (fname, (size_t)((int)strlen(basename)+20), "%s_register.h", basename);
    idl_fileSetCur (idl_fileOutNew (fname, "w"));
    if (idl_fileCur () == NULL) {
        idl_reportOpenError (fname);
    }
    idl_registerHeaderFile (basename);
    idl_fileOutFree (idl_fileCur());


    snprintf (fname, (size_t)((int)strlen(basename)+20), "%s_register.c", basename);
    idl_fileSetCur (idl_fileOutNew (fname, "w"));
    if (idl_fileCur () == NULL) {
        idl_reportOpenError (fname);
    }
    idl_registerBodyHeader (basename);
    for (i = 0; i < c_iterLength(typeNames); i++) {
	typeName = c_iterObject(typeNames, i);
        type = c_metaResolve ((c_metaObject)base, (const char *)typeName);
        if (type) {
            metaSer = sd_serializerXMLTypeinfoNew (base, TRUE);
            if (metaSer) {
                serData = sd_serializerSerialize (metaSer, c_object(type));
                if (serData) {
                    metaDescription = sd_serializerToString (metaSer, serData);
                    if (metaDescription) {
                        idl_registerBody (typeName, metaDescription);
                        os_free (metaDescription);
                    }
                }
                sd_serializerFree (metaSer);
            }
        } else {
	    printf ("Specified type %s not found\n", typeName);
        }
    }
    idl_fileOutPrintf (idl_fileCur(), "\n");
    idl_fileOutPrintf (idl_fileCur(), "void\n");
    idl_fileOutPrintf (idl_fileCur(), "%s__register_types (c_base base)\n", basename);
    idl_fileOutPrintf (idl_fileCur(), "{\n");
    for (i = 0; i < c_iterLength(typeNames); i++) {
	typeName = c_iterObject(typeNames, i);
	idl_fileOutPrintf (idl_fileCur(), "    %s__register_type (base);\n", idl_cScopedTypeName(typeName));
    }
    idl_fileOutPrintf (idl_fileCur(), "}\n");
    idl_fileOutFree (idl_fileCur());
    os_free (fname);
}