static void idl_moduleClose( void *userData) { idlpp_indent_level--; idl_printIndent(idlpp_indent_level); idl_fileOutPrintf(idl_fileCur(), "}\n"); idl_fileOutPrintf(idl_fileCur(), "\n"); }
static idl_action idl_moduleOpen ( idl_scope scope, const char *name, void *userData) { /* Test whether the module contains a component within the pragma keylist. * If it does not, then the module should not be generated since it will * contain no items (which is itself illegal idl syntax). * * Note that we are comparing against only the keys existing within this idl * file (idl_idlScopeKeyList). We do not use the result of idl_keyDefDefGet() * since this is a list of keys resulting from the preprocessed idl (which * will include keys from other idl files that this may include). */ if (os_iterLength (idl_idlScopeKeyList) == 0) { return idl_abort; } else { c_long li = 0; c_bool scopesMatch = FALSE; idl_scope moduleScope; idl_scopeElement newElement; /* the idl_scope parameter to this function does not yet include the scoping * for this module itself, so create a duplicate and add this scoping to it, * before testing whether this module contains one of the keys in this file. */ moduleScope = idl_scopeDup(scope); newElement = idl_scopeElementNew (name, idl_tModule); idl_scopePush (moduleScope, newElement); /* Loop through the list of keys applying to this idl file and test whether * this particular module contains one of these keys. If it does, generate * code for the module in the Dcps.idl file. */ while (li < os_iterLength (idl_idlScopeKeyList)) { idl_scope keyscope = os_iterObject (idl_idlScopeKeyList, li); scopesMatch = idl_scopeSub (moduleScope, keyscope); if (scopesMatch) { break; } li++; } if (scopesMatch == FALSE) { return idl_abort; } } idl_printIndent(idlpp_indent_level); idl_fileOutPrintf(idl_fileCur(), "module %s {\n", idl_cxxId(name)); idl_fileOutPrintf(idl_fileCur(), "\n"); idlpp_indent_level++; return idl_explore; }
static idl_action idl_moduleOpen ( idl_scope scope, const char *name, void *userData) { c_ulong streamsIndex, streamsCount; idl_action result; OS_UNUSED_ARG(userData); OS_UNUSED_ARG(userData); /* Test whether the module contains a component within the pragma streams. * If it does not, then the module should not be generated since it will * contain no items (which is itself illegal idl syntax). * * Note that we are comparing against only the streams existing within this idl * file (idl_idlScopeStreamsList). We do not use the result of idl_keyDefDefGet() * since this is a list of streams resulting from the preprocessed idl (which * will include streams from other idl files that this may include). */ result = idl_abort; streamsCount = os_iterLength(idl_idlScopeStreamsList); if (streamsCount != 0) { idl_scope moduleScope; idl_scopeElement newElement; /* the idl_scope parameter to this function does not yet include the scoping * for this module itself, so create a duplicate and add this scoping to it, * before testing whether this module contains one of the streams in this file. */ moduleScope = idl_scopeDup(scope); newElement = idl_scopeElementNew(name, idl_tModule); idl_scopePush(moduleScope, newElement); /* Loop through the list of keys applying to this idl file and test whether * this particular module contains one of these keys. If it does, generate * code for the module. */ for (streamsIndex = 0; (streamsIndex < streamsCount) && (result == idl_abort); streamsIndex++) { idl_scope streamsScope = os_iterObject(idl_idlScopeStreamsList, streamsIndex); if (idl_scopeSub(moduleScope, streamsScope)) { /* Scopes match */ result = idl_explore; } } } if (result == idl_explore) { idl_printIndent(idlpp_indent_level); idl_fileOutPrintf(idl_fileCur(), "module %s {\n", idl_cxxId(name)); idl_fileOutPrintf(idl_fileCur(), "\n"); idlpp_indent_level++; } return result; }
static void idl_registerBodyHeader ( const char *basename ) { idl_fileOutPrintf (idl_fileCur(), "#include <c_metabase.h>\n"); idl_fileOutPrintf (idl_fileCur(), "#include <sd_serializerXMLTypeinfo.h>\n"); idl_fileOutPrintf (idl_fileCur(), "\n"); idl_fileOutPrintf (idl_fileCur(), "#include \"%s_register.h\"\n", basename); }
static idl_action idl_moduleOpen( idl_scope scope, const char *name, void *userData) { idl_printIndent(idlpp_indent_level); idl_fileOutPrintf(idl_fileCur(), "namespace %s {\n", idl_cxxId(name)); idl_fileOutPrintf(idl_fileCur(), "\n"); idlpp_indent_level++; return idl_explore; }
/** @brief callback function called on closure of a union in the IDL input file. * * Generate code for the following IDL construct: * @verbatim union <union-name> switch(<switch-type>) { case label1.1; .. case label1.n; <union-case-1>; case label2.1; .. case label2.n; ... ... case labeln.1; .. case labeln.n; <union-case-n>; default: <union-case-m>; => }; @endverbatim * * The union is closed: * @verbatim } _u; }; @endverbatim * @param name Name of the union */ static void idl_unionClose ( const char *name, void *userData) { indent_level--; idl_printIndent(indent_level); idl_fileOutPrintf(idl_fileCur(), "} _u;\n"); indent_level--; idl_printIndent(indent_level); idl_fileOutPrintf(idl_fileCur(), "};\n\n"); }
static void idl_moduleClose( void *userData) { OS_UNUSED_ARG(userData); /* this is only executed if idl_moduleOpen returns 'idl_explore' */ OS_UNUSED_ARG(userData); idlpp_indent_level--; idl_printIndent(idlpp_indent_level); idl_fileOutPrintf(idl_fileCur(), "};\n"); idl_fileOutPrintf(idl_fileCur(), "\n"); }
/** @brief callback function called on module definition in the IDL input file. * * Generate code for the following IDL construct: * @verbatim => module <module-name> { <module-contents> }; @endverbatim * * This fuction generates the prototype of the function that * is responsible for loading the metadata into the database. * The name of the function is: * @verbatim __<scope-basename>_<scope-elements>_<module-name>__load @endverbatim * For the Splice types, no further actions are required. * * @param scope Current scope (and scope of the module definition) * @param name Name of the defined module * @return Next action for this module (idl_explore) */ static idl_action idl_moduleOpen( idl_scope scope, const char *name, void *userData) { idl_fileOutPrintf(idl_fileCur(), "extern c_metaObject __%s_%s__load (c_base base);\n", idl_scopeBasename(scope), idl_scopeStack(scope, "_", name)); idl_fileOutPrintf(idl_fileCur(), "\n"); /* return idl_explore to indicate that the rest of the module needs to be processed */ return idl_explore; }
/* @brief generate dimension of an array or a sequence * * java_arrayDimensions is a local support function to generate * the dimensions of a java Array representing an IDL sequence or * array. Since Sequences will always be initialized to 0 elements, * its dimensions will always be assigned 0. Arrays will be assigned * their IDL dimensions. * * @param typeSeq Specifies the type of the sequence */ static void java_arrayDimensions( idl_typeSpec typeSpec) { while (idl_typeSpecType(typeSpec) == idl_ttypedef) { typeSpec = idl_typeDefRefered(idl_typeDef(typeSpec)); } if (idl_typeSpecType(typeSpec) == idl_tarray) { idl_typeArray typeArray = idl_typeArray(typeSpec); idl_fileOutPrintf (idl_fileCur(), "[%d]", idl_typeArraySize(typeArray)); java_arrayDimensions(idl_typeArrayType(typeArray)); } else if (idl_typeSpecType(typeSpec) == idl_tseq) { idl_fileOutPrintf(idl_fileCur(), "[0]"); java_arrayDimensions(idl_typeSeqType(idl_typeSeq(typeSpec))); } }
static idl_action idl_structureOpen( idl_scope scope, const char *name, idl_typeStruct structSpec, void *userData) { c_char spaces[20]; idl_tmplExp te; CxxTypeUserData *cxxUserData = (CxxTypeUserData *)userData; /* QAC EXPECT 3416; No side effects here */ if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { /* keylist defined for this struct */ te = idl_tmplExpNew(idlpp_macroSet); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("namescope", idl_cxxId(idl_scopeElementName(idl_scopeCur(scope))))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("cnamescope", idl_scopeStack(scope, "_", ""))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name))); snprintf(spaces, sizeof(spaces), "%d", idlpp_indent_level*4); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("spaces", spaces)); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); /* Store data-type in iterator for future generation of type descriptor. */ idl_metaCxxAddType(scope, name, idl_typeSpec(structSpec), &cxxUserData->idlpp_metaList); } return idl_abort; }
static idl_action idl_unionOpen ( idl_scope scope, const char *name, idl_typeUnion unionSpec, void *userData) { c_char spaces[20]; idl_tmplExp te; /* QAC EXPECT 3416; No unexpected side effects here */ if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { /* keylist defined for this union */ idl_sequenceObjManagDef(scope, name, idl_typeSpec(unionSpec)); te = idl_tmplExpNew(idlpp_macroSet); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("type_name", idl_scopeStack(scope, "_", name))); snprintf(spaces, (size_t)sizeof(spaces), "%d", idlpp_indent_level*4); idl_macroSetAdd(idlpp_macroSet, idl_macroNew ("spaces", spaces)); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); } return idl_abort; }
/* @brief callback function called on closing the IDL input file. * * Generate standard file footer consisting of: * - mutiple inclusion prevention closure */ static void idl_fileClose( void *userData) { /* Generate closure of multiple inclusion prevention code */ idl_fileOutPrintf(idl_fileCur(), "#endif\n"); }
static void idl_typedefOpenClose( idl_scope scope, const char *name, idl_typeDef defSpec, void *userData) { c_char spaces[20]; idl_tmplExp te; /* QAC EXPECT 3416; No unexpected side effects here */ if ((idl_typeSpecType(idl_typeDefRefered(defSpec)) == idl_tstruct || idl_typeSpecType(idl_typeDefRefered(defSpec)) == idl_tunion) && idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { /* keylist defined for this typedef of struct or union */ te = idl_tmplExpNew(idlpp_macroSet); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("type_name", idl_scopeStack(scope, "_", name))); snprintf(spaces, (size_t)sizeof(spaces), "%d", idlpp_indent_level*4); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("spaces", spaces)); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); } }
static idl_action idl_structureOpen( idl_scope scope, const char *name, idl_typeStruct structSpec, void *userData) { c_char spaces[20]; idl_tmplExp te; /* QAC EXPECT 3416; No side effects here */ if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { /* keylist defined for this struct */ te = idl_tmplExpNew(idlpp_macroSet); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("namescope", idl_cxxId(idl_scopeElementName(idl_scopeCur(scope))))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name))); snprintf(spaces, (size_t)sizeof(spaces), "%d", idlpp_indent_level*4); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("spaces", spaces)); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); } return idl_abort; }
static idl_action idl_unionOpen( idl_scope scope, const char *name, idl_typeUnion unionSpec, void *userData) { c_char spaces[20]; idl_tmplExp te; OS_UNUSED_ARG(unionSpec); OS_UNUSED_ARG(userData); /* QAC EXPECT 3416; No side effects here */ if (idl_streamsResolve(idl_streamsDefDefGet(), scope, name)) { /* keylist defined for this union */ te = idl_tmplExpNew(idlpp_macroSet); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("namescope", idl_cxxId(idl_scopeElementName(idl_scopeCur(scope))))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scopedtypename", idl_scopeStack(scope, "::", name))); snprintf(spaces, sizeof(spaces), "%d", idlpp_indent_level*4); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("spaces", spaces)); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); } return idl_abort; }
static void idl_typedefOpenClose( idl_scope scope, const char *name, idl_typeDef defSpec, void *userData) { c_char spaces[20]; idl_tmplExp te; OS_UNUSED_ARG(userData); if ((idl_typeSpecType(idl_typeDefRefered(defSpec)) == idl_tstruct || (idl_typeSpecType(idl_typeDefRefered(defSpec)) == idl_tunion)) && (idl_streamsResolve(idl_streamsDefDefGet(), scope, name))) { /* keylist defined for this typedef of struct or union */ te = idl_tmplExpNew(idlpp_macroSet); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("namescope", idl_cxxId(idl_scopeElementName(idl_scopeCur(scope))))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scopedtypename", idl_scopeStack(scope, "::", name))); snprintf(spaces, sizeof(spaces), "%d", idlpp_indent_level*4); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("spaces", spaces)); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); } }
static void idl_fileClose( void *userData) { OS_UNUSED_ARG(userData); idl_fileOutPrintf(idl_fileCur(), "#endif\n"); }
/** @brief callback function called on structure definition in the IDL input file. * * Generate code for the following IDL construct: * @verbatim => struct <structure-name> { <structure-member-1>; ... ... <structure-member-n>; }; @endverbatim * * @param scope Current scope (and scope of the structure definition) * @param name Name of the structure * @param structSpec Specification of the struct holding the amount of members */ static idl_action idl_structureOpen( idl_scope scope, const char *name, idl_typeStruct structSpec, void *userData) { /* Open file for used scope, if needed create the directories */ idl_openJavaPackage(scope, idl_javaId(name)); if (idl_fileCur() == NULL) { return idl_abort; } /* setup iterator to hold field names and correcsponding type names */ map = idl_mapNew(NULL, 1, 1); /* Write package name */ #if 0 idl_fileOutPrintf (idl_fileCur(), "/*\n"); idl_fileOutPrintf (idl_fileCur(), " * Generated by OpenSpliceDDS "OSPL_VERSION_STR"\n"); idl_fileOutPrintf (idl_fileCur(), " */\n\n"); #endif if (idl_scopeStackSize(scope) > 0) { idl_fileOutPrintf(idl_fileCur(), "package %s;\n", idl_scopeStackJava (scope, ".", NULL)); idl_fileOutPrintf(idl_fileCur(), "\n"); } /* public final class <struct-name> { */ idl_fileOutPrintf(idl_fileCur(), "public final class %s {\n\n", idl_javaId(name)); /* return idl_explore to indicate that the rest of the structure needs to be processed */ return idl_explore; }
/* @brief callback function called on opening the IDL input file. * * Generate standard file header consisting of: * - mutiple inclusion prevention * - inclusion of Splice type definition files * - inclusion of application specific include files related to other IDL files * * @param scope Current scope (not used) * @param name Name of the IDL input file */ static idl_action idl_fileOpen( idl_scope scope, const char *name, void *userData) { struct idl_genSACPPData *arg = (struct idl_genSACPPData *)userData; /* First initialize userData */ arg->indent_level = 0; /* Generate inclusion of type definition file */ idl_fileOutPrintf(idl_fileCur(), "#include \"%s.h\"\n", name); idl_fileOutPrintf(idl_fileCur(), "\n"); /* return idl_explore to indicate that the rest of the file needs to be processed */ return idl_explore; }
/* @brief generate dimension of an array slice * * arraySliceDimensions is a local support function to generate * the array dimensions of an array slice * * @param typeArray Specifies the type of the array */ static void idl_arraySliceDimensions( idl_typeArray typeArray) { idl_fileOutPrintf(idl_fileCur(), "[%d]", idl_typeArraySize(typeArray)); if (idl_typeSpecType(idl_typeArrayType(typeArray)) == idl_tarray && idl_typeSpecType(idl_typeArrayType(idl_typeArray(idl_typeArrayType(typeArray)))) == idl_tarray) { idl_arraySliceDimensions(idl_typeArray(idl_typeArrayType(typeArray))); } }
/** @brief callback function called on definition of an enumeration. * * Generate code for the following IDL construct: * @verbatim => enum <enum-name> { <enum-element-1>; ... ... <enum-element-n>; }; @endverbatim * * This function generates a prototype for the helper function to * load the enumerations metadata if the enumeration is defined * within the global scope or the scope of a module. * The name of the metadata load function is: * @verbatim __<scope-elements>_<enum-name>__load @endverbatim * The enum definition is opened: * @verbatim enum <scope-elements>_<enum-name> { @endverbatim * @param scope Current scope * @param name Name of the enumeration * @param enumSpec Specifies the number of elements in the enumeration * @return Next action for this enumeration (idl_explore) */ static idl_action idl_enumerationOpen( idl_scope scope, const char *name, idl_typeEnum enumSpec, void *userData) { if (idl_scopeStackSize(scope) == 0 || idl_scopeElementType (idl_scopeCur(scope)) == idl_tModule) { idl_fileOutPrintf(idl_fileCur(), "extern c_metaObject __%s__load (c_base base);\n", idl_scopeStack(scope, "_", name)); } idl_printIndent(indent_level); idl_fileOutPrintf(idl_fileCur(), "enum _%s {\n", idl_scopeStack (scope, "_", name)); enum_element = idl_typeEnumNoElements(enumSpec); indent_level++; /* return idl_explore to indicate that the rest of the enumeration needs to be processed */ return idl_explore; }
/** @brief callback function called on definition of an enumeration element in the IDL input file. * * Generate code for the following IDL construct: * @verbatim enum <enum-name> { => <enum-element-1>, => ... ... => <enum-element-n> }; @endverbatim * * For the last element generate: * @verbatim <element-name> @endverbatim * For any but the last element generate: * @verbatim <element-name>, @endverbatim * * @param scope Current scope * @param name Name of the enumeration element */ static void idl_enumerationElementOpenClose( idl_scope scope, const char *name, void *userData) { enum_element--; if (enum_element == 0) { idl_printIndent(indent_level); idl_fileOutPrintf(idl_fileCur(), "_%s\n", idl_scopeStack(scope, "_", name)); } else { idl_printIndent(indent_level); idl_fileOutPrintf( idl_fileCur(), "_%s,\n", idl_scopeStack (scope, "_", name)); } }
/* Print the specified indentation the the default output file, the indent is specified in units of 4 space characters */ void idl_printIndent ( c_long indent) { c_long i; for (i = 0; i < indent; i++) { idl_fileOutPrintf (idl_fileCur(), " "); } }
/** @brief callback function called on definition of an enumeration element in the IDL input file. * * Generate code for the following IDL construct: * @verbatim enum <enum-name> { => <enum-element-1>, => ... ... => <enum-element-n> }; @endverbatim * * For the last element generate: * @verbatim <element-name> @endverbatim * For any but the last element generate: * @verbatim <element-name>, @endverbatim * * @param scope Current scope * @param name Name of the enumeration element */ static void idl_enumerationElementOpenClose ( idl_scope scope, const char *name, void *userData) { idl_fileOutPrintf( idl_fileCur(), " public static final int _%s = %d;\n", idl_javaId(name), enum_element); idl_fileOutPrintf( idl_fileCur(), " public static final %s %s = new %s(_%s);\n\n", enum_def, idl_javaId(name), enum_def, idl_javaId(name)); enum_element++; }
static void idl_registerHeaderFile ( const char *basename ) { idl_fileOutPrintf (idl_fileCur(), "#ifndef %s\n", idl_macroFromBasename(basename,"__REGISTER_H")); idl_fileOutPrintf (idl_fileCur(), "#define %s\n", idl_macroFromBasename(basename,"__REGISTER_H")); idl_fileOutPrintf (idl_fileCur(), "\n"); idl_fileOutPrintf (idl_fileCur(), "#include <c_base.h>\n"); idl_fileOutPrintf (idl_fileCur(), "\n"); idl_fileOutPrintf (idl_fileCur(), "void %s__register_types (c_base base);\n", basename); idl_fileOutPrintf (idl_fileCur(), "\n"); idl_fileOutPrintf (idl_fileCur(), "#endif\n"); }
/** @brief callback function called on definition of a union in the IDL input file. * * Generate code for the following IDL construct: * @verbatim => union <union-name> switch(<switch-type>) { case label1.1; .. case label1.n; <union-case-1>; case label2.1; .. case label2.n; ... ... case labeln.1; .. case labeln.n; <union-case-n>; default: <union-case-m>; }; @endverbatim * * This function generates prototypes for the helper functions to * load the unions metadata, to determine the unions keys and the * scoped name of the union if the union is defined in the global * scope or within a module. * The name of the metadata load function is: * @verbatim __<scope-elements>_<structure-name>__load @endverbatim * The name of the key query function is: * @verbatim __<scope-elements>_<union-name>__keys @endverbatim * The name of the name query function is: * @verbatim __<scope-elements>_<union-name>__name @endverbatim * If the union is defined within another union or within a * struct, no key nor its name can be queried. Such a union * can not be communicated via Splice as a separate entity. * IDL unions are mapped onto C structs for Splice in the * following manner: * @verbatim struct <union-name> { <switch-type> _d; union { <union-case-1>; ... ... <union-case-m>; } _u; }; @endverbatim * The union definition is opened: * @verbatim struct <scope-elements>_<name> { @endverbatim * Then depending on the type of the switch (integral type is required) any of the following: * @verbatim enum <enum-type> _d; // for an enumeration <scope-elements>_<typedef-name> _d; // for an typedeffed enum or basic type <basic-type-mapping> _d; // for an integral basic type @endverbatim * Then open the union part: * @verbatim union { @endverbatim * * @param scope Current scope * @param name Name of the union * @param unionSpec Specifies the number of union cases and the union switch type * @return Next action for this union (idl_explore) */ static idl_action idl_unionOpen( idl_scope scope, const char *name, idl_typeUnion unionSpec, void *userData) { if (idl_scopeStackSize(scope) == 0 || idl_scopeElementType (idl_scopeCur(scope)) == idl_tModule) { /* define the prototype of the function for metadata load */ idl_fileOutPrintf(idl_fileCur(), "extern c_metaObject __%s__load (c_base base);\n", idl_scopeStack(scope, "_", name)); /* define the prototype of the function for querying the keys */ idl_fileOutPrintf(idl_fileCur(), "extern const char * __%s__keys (void);\n", idl_scopeStack(scope, "_", name)); /* define the prototype of the function for querying scoped union name */ idl_fileOutPrintf(idl_fileCur(), "extern const char * __%s__name (void);\n", idl_scopeStack(scope, "_", name)); } /* open the struct */ idl_printIndent(indent_level); idl_fileOutPrintf(idl_fileCur(), "struct _%s {\n", idl_scopeStack(scope, "_", name)); indent_level++; /* generate code for the switch */ if (idl_typeSpecType(idl_typeUnionSwitchKind(unionSpec)) == idl_tbasic) { idl_printIndent(indent_level); idl_fileOutPrintf (idl_fileCur(), "%s _d;\n", idl_scopedTypeName(idl_typeUnionSwitchKind(unionSpec))); } else if (idl_typeSpecType(idl_typeUnionSwitchKind(unionSpec)) == idl_tenum) { idl_printIndent(indent_level); idl_fileOutPrintf(idl_fileCur(), "%s _d;\n", idl_scopedSplTypeName(idl_typeUnionSwitchKind(unionSpec))); } else if (idl_typeSpecType(idl_typeUnionSwitchKind(unionSpec)) == idl_ttypedef) { switch (idl_typeSpecType(idl_typeDefActual(idl_typeDef(idl_typeUnionSwitchKind(unionSpec))))) { case idl_tbasic: case idl_tenum: idl_printIndent(indent_level); idl_fileOutPrintf (idl_fileCur(), "%s _d;\n", idl_scopedSplTypeName(idl_typeUnionSwitchKind(unionSpec))); break; default: printf ("idl_unionOpen: Unsupported switchkind\n"); } } else { printf ("idl_unionOpen: Unsupported switchkind\n"); } /* open the union */ idl_printIndent(indent_level); idl_fileOutPrintf(idl_fileCur(), "union {\n"); indent_level++; /* return idl_explore to indicate that the rest of the union needs to be processed */ return idl_explore; }
/** @brief callback function called on definition of a union case in the IDL input file. * * Generate code for the following IDL construct: * @verbatim union <union-name> switch(<switch-type>) { case label1.1; .. case label1.n; => <union-case-1>; case label2.1; .. case label2.n; => ... ... case labeln.1; .. case labeln.n; => <union-case-n>; default: => <union-case-m>; }; @endverbatim * * If the type specification is idl_tbasic a standard mapping can be generated: * @verbatim string <name>; => c_string <name>; string <name,length>; => c_string <name>; char <name>; => c_char <name>; octet <name>; => c_octet <name>; short <name>; => c_short <name>; unsigned short <name>; => c_ushort <name>; long <name>; => c_long <name>; unsigned long <name>; => c_ulong <name>; long long <name>; => c_longlong <name>; unsigned long long <name>; => c_ulonglong <name>; float <name>; => c_float <name>; double <name>; => c_double <name>; boolean <name>; => c_bool <name>; @endverbatim * If the type specification is a user defined idl_ttypedef, idl_tenum, * idl_tstruct or idl_tunion a scoped name mapping will be generated. * @verbatim <typedef-name> <name>; => enum <scope-elements>_<typedef-name> <name>; <enum-name> <name>; => enum <scope-elements>_<enum-name> <name>; <struct-name> <name>; => struct <scope-elements>_<structure-name> <name>; <union-name> <name>; => struct <scope-elements>_<union-name> <name>; @endverbatim * If the type specification is idl_tarray then generate a scoped name * with the array specifiers: * @verbatim <other-usertype-name> <name>[n1]..[nn]; => <scope-elements>_<other-usertype-name> <name>[n1]..[nn]; <basic-type> <name>[n1]..[nn]; => <basic-type-mapping> <name>[n1]..[nn]; sequence<spec> <name>[n1]..[nn]; => c_array <name>[n1]..[nn]; sequence<spec,length> <name>[n1]..[nn]; => c_array <name>[n1]..[nn]; @endverbatim * If the type specification is idl_tseq then generate a mapping on c_sequence: * @verbatim sequence<spec> <name>; => c_sequence <name>; sequence<spec,length> <name>; => c_sequence <name>; @endverbatim * * @param scope Current scope (the union the union case is defined in) * @param name Name of the union case * @param typeSpec Specifies the type of the union case */ static void idl_unionCaseOpenClose( idl_scope scope, const char *name, idl_typeSpec typeSpec, void *userData) { if (idl_typeSpecType(typeSpec) == idl_ttypedef || idl_typeSpecType(typeSpec) == idl_tenum || idl_typeSpecType(typeSpec) == idl_tstruct || idl_typeSpecType(typeSpec) == idl_tunion || idl_typeSpecType(typeSpec) == idl_tbasic) { /* generate code for a standard mapping or a typedef, enum, struct or union user-type mapping */ idl_printIndent(indent_level); idl_fileOutPrintf( idl_fileCur(), "%s %s;\n", idl_scopedSplTypeIdent(typeSpec), idl_languageId(name)); } else if (idl_typeSpecType(typeSpec) == idl_tarray) { /* generate code for an array mapping */ idl_printIndent(indent_level); if (idl_typeSpecType(idl_typeArrayActual (idl_typeArray(typeSpec))) != idl_tseq) { idl_fileOutPrintf( idl_fileCur(), "%s %s", idl_scopedSplTypeIdent(idl_typeArrayActual (idl_typeArray(typeSpec))), idl_languageId (name)); } else { idl_fileOutPrintf( idl_fileCur(), "c_array %s", idl_languageId(name)); } idl_arrayDimensions(idl_typeArray(typeSpec), OS_FALSE); idl_fileOutPrintf(idl_fileCur(), ";\n"); } else if (idl_typeSpecType(typeSpec) == idl_tseq) { /* generate code for a sequence mapping */ idl_printIndent(indent_level); if (idl_typeSeqMaxSize (idl_typeSeq(typeSpec)) == 0) { /* unbounded sequence */ idl_fileOutPrintf(idl_fileCur(), "c_sequence %s", idl_languageId (name)); } else { /* bounded sequence */ idl_fileOutPrintf(idl_fileCur(), "c_sequence %s", idl_languageId (name)); } idl_fileOutPrintf(idl_fileCur(), ";\n"); } else { printf("idl_unionCaseOpenClose: Unsupported union case type (case name = %s, type = %s)\n", name, idl_scopedTypeName(typeSpec)); } }
static void idl_fileClose( void *userData) { idl_macro macro; os_char* tmpName; size_t i; (void) userData; if (idl_getIsISOCpp()) { macro = idl_macroSetGet (idlpp_macroSet, "basename"); if (macro) { tmpName = os_strdup(idl_macroValue(macro)); for(i = 0; i < strlen(tmpName); i++) { tmpName[i] = toupper (tmpName[i]); } idl_fileOutPrintf(idl_fileCur(), "#define %s_DCPS_TYPESUPPORT_DEFINED\n", tmpName); os_free(tmpName); } } idl_fileOutPrintf(idl_fileCur(), "#endif\n"); }
/* @brief generate dimension of an array * * arrayDimensions is a local support function to generate * the array dimensions of an array * * @param typeArray Specifies the type of the array */ static void idl_arrayDimensions ( idl_typeArray typeArray, os_boolean resolveTypedefs) { idl_typeSpec subType; idl_fileOutPrintf(idl_fileCur(), "[%d]", idl_typeArraySize(typeArray)); subType = idl_typeArrayType(typeArray); while(resolveTypedefs && idl_typeSpecType(subType) == idl_ttypedef) { subType = idl_typeDefResolveFully(subType); } if (idl_typeSpecType(subType) == idl_tarray) { idl_arrayDimensions (idl_typeArray(subType), resolveTypedefs); } }
static void idl_constantOpenClose( idl_scope scope, idl_constSpec constantSpec, void *userData) { /* Open file for used scope, if needed create the directories */ idl_openJavaPackage(scope, idl_javaId(idl_constSpecName(constantSpec))); /* Write package name */ #if 0 idl_fileOutPrintf(idl_fileCur(), "/*\n"); idl_fileOutPrintf(idl_fileCur(), " * Generated by OpenSpliceDDS "OSPL_VERSION_STR"\n"); idl_fileOutPrintf(idl_fileCur(), " */\n\n"); #endif if (idl_scopeStackSize(scope) > 0) { idl_fileOutPrintf(idl_fileCur(), "package %s;\n", idl_scopeStackJava(scope, ".", NULL)); idl_fileOutPrintf(idl_fileCur(), "\n"); } idl_fileOutPrintf(idl_fileCur(), "public interface %s {\n", idl_constSpecName(constantSpec)); if (idl_typeSpecType(idl_constSpecTypeGet(constantSpec)) == idl_tbasic && idl_typeBasicType(idl_typeBasic(idl_constSpecTypeGet(constantSpec))) == idl_string) { idl_fileOutPrintf( idl_fileCur(), " public static final %s value = %s;\n", idl_corbaJavaTypeFromTypeSpec(idl_constSpecTypeGet(constantSpec)), idl_constSpecImage (constantSpec)); } else { idl_fileOutPrintf( idl_fileCur(), " public static final %s value = (%s)(%s);\n", idl_corbaJavaTypeFromTypeSpec(idl_constSpecTypeGet(constantSpec)), idl_corbaJavaTypeFromTypeSpec(idl_constSpecTypeGet(constantSpec)), idl_constSpecImage(constantSpec)); } idl_fileOutPrintf(idl_fileCur(), "}\n"); }