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 side effects here */ if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { /* 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))); 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 void idl_typedefOpenClose( idl_scope scope, const char *name, idl_typeDef defSpec, void *userData) { c_char spaces[20]; idl_tmplExp te; 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("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); } }
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_structureOpen( idl_scope scope, const char *name, idl_typeStruct structSpec, 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 struct */ te = idl_tmplExpNew(idlpp_macroSet); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scope", idl_scopeStackCxx(scope, "::", NULL))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scopedtypename", idl_scopeStack(scope, "::", name))); //idl_macroSetAdd(idlpp_macroSet, idl_macroNew("uniquetypename", 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; }
/** * Not yet required * @return idl_explore - Apparently this means process the rest of the file. */ static idl_action idl_structureOpen( idl_scope scope, const char *name, idl_typeStruct structSpec, void *userData) { char* sampleType; (void) scope; (void) userData; if (idl_keyResolve(idl_keyDefDefGet(), idl_typeUserScope(idl_typeUser(structSpec)), name) != NULL) { sampleType = idl_corbaCxxTypeFromTypeSpec(idl_typeSpec(structSpec)); idl_fileOutPrintf(idl_fileCur(), "REGISTER_TOPIC_TRAITS(%s)\n", sampleType); /* Remove "StreamSample" for REGISTER_STREAM_TOPIC_TRAITS */ if(strlen(name) > 12 && strcmp(name+strlen(name)-12, "StreamSample")==0) { sampleType[strlen(sampleType)-12] = '\0'; idl_fileOutPrintf(idl_fileCur(), "REGISTER_STREAM_TOPIC_TRAITS(%s)\n", sampleType); } os_free(sampleType); } return idl_explore; }
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 union */ idl_sequenceObjManagDef(scope, name, idl_typeSpec(defSpec)); 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_unionOpen( idl_scope scope, const char *name, idl_typeUnion unionSpec, void *userData) { if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { newMeta(scope, name, idl_typeSpec(unionSpec)); } return idl_abort; }
static void idl_typedefOpenClose( idl_scope scope, const char *name, idl_typeDef defSpec, void *userData) { if ((idl_typeSpecType(idl_typeDefActual (defSpec)) == idl_tstruct) || (idl_typeSpecType(idl_typeDefActual (defSpec)) == idl_tunion)) { if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { newMeta(scope, name, idl_typeSpec(defSpec)); } } }
static idl_action idl_unionOpen( idl_scope scope, const char *name, idl_typeUnion unionSpec, void *userData) { if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { idl_genInterface(scope, name, "TypeSupport", idl_typeSpec(unionSpec), FALSE); idl_genInterface(scope, name, "DataReader", idl_typeSpec(unionSpec), TRUE); idl_genInterface(scope, name, "DataReaderView", idl_typeSpec(unionSpec), TRUE); idl_genInterface(scope, name, "DataWriter", idl_typeSpec(unionSpec), TRUE); idl_genTypeSeqHolder(scope, name, idl_typeSpec(unionSpec)); } return idl_abort; }
/* unionOpen callback A union is a type that can be communicated via the DCPS API. A union can have a key list defining all key fields (practically only the switch). For the union the following helper functions are defined: - a function to query the union scoped type name - a function to query the union key list The name of the functions are: __<scope-elements>_<union-name>__name and __<scope-elements>_<union-name>__keys respectively. return idl_abort to state that the rest of the union does not need to be processed */ static idl_action idl_unionOpen( idl_scope scope, const char *name, idl_typeUnion unionSpec, void *userData) { const c_char *key_list; OS_UNUSED_ARG(unionSpec); OS_UNUSED_ARG(userData); OS_UNUSED_ARG(unionSpec); OS_UNUSED_ARG(userData); idl_fileOutPrintf(idl_fileCur(), "const char *\n"); idl_fileOutPrintf(idl_fileCur(), "__%s__name(void)\n", idl_scopeStack(scope, "_", name)); idl_fileOutPrintf(idl_fileCur(), "{\n"); idl_fileOutPrintf( idl_fileCur(), " return (const char*)\"%s\";\n", idl_scopeStack(scope, "::", name)); idl_fileOutPrintf(idl_fileCur(), "}\n"); idl_fileOutPrintf(idl_fileCur(), "\n"); key_list = idl_keyResolve(idl_keyDefDefGet(), scope, name); idl_fileOutPrintf(idl_fileCur(), "const char *\n"); idl_fileOutPrintf( idl_fileCur(), "__%s__keys(void)\n", idl_scopeStack(scope, "_", name)); idl_fileOutPrintf(idl_fileCur(), "{\n"); if (key_list) { idl_fileOutPrintf( idl_fileCur(), " return (const char *)\"%s\";\n", key_list); } else { idl_fileOutPrintf(idl_fileCur(), " return (const char *)\"\";\n"); } idl_fileOutPrintf(idl_fileCur(), "}\n"); idl_fileOutPrintf(idl_fileCur(), "\n"); return idl_abort; }
static void idl_typedefOpenClose( idl_scope scope, const char *name, idl_typeDef defSpec, void *userData) { if ((idl_typeSpecType(idl_typeDefActual (defSpec)) == idl_tstruct) || (idl_typeSpecType (idl_typeDefActual (defSpec)) == idl_tunion)) { if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { idl_genInterface(scope, name, "TypeSupport", idl_typeSpec(defSpec), FALSE); idl_genInterface(scope, name, "DataReader", idl_typeSpec(defSpec), TRUE); idl_genInterface(scope, name, "DataReaderView", idl_typeSpec(defSpec), TRUE); idl_genInterface(scope, name, "DataWriter", idl_typeSpec(defSpec), TRUE); idl_genTypeSeqHolder(scope, name, idl_typeDefActual(defSpec)); } } }
static idl_action idl_unionOpen( idl_scope scope, const char *name, idl_typeUnion unionSpec, void *userData) { OS_UNUSED_ARG(userData); if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { idl_genInterface(scope, name, "TypeSupport", idl_typeSpec(unionSpec), FALSE); idl_genInterface(scope, name, "DataReader", idl_typeSpec(unionSpec), TRUE); idl_genInterface(scope, name, "DataReaderView", idl_typeSpec(unionSpec), TRUE); idl_genInterface(scope, name, "DataWriter", idl_typeSpec(unionSpec), TRUE); if (idl_getCorbaMode() == IDL_MODE_STANDALONE) { idl_genTypeSeqHolder(scope, name, idl_typeSpec(unionSpec)); } } return idl_abort; }
static void idl_typedefOpenClose( idl_scope scope, const char *name, idl_typeDef defSpec, void *userData) { idl_tmplExp te; 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("scope", idl_scopeStackCxx(scope, "::", NULL))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scopedtypename", idl_scopeStack(scope, "::", name))); 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_unionOpen( idl_scope scope, const char *name, idl_typeUnion unionSpec, void *userData) { idl_tmplExp te; /* QAC EXPECT 3416; No unexpected side effects here */ if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) { /* keylist defined for this union */ te = idl_tmplExpNew(idlpp_macroSet); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scope", idl_scopeStackCxx(scope, "::", NULL))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scopedtypename", idl_scopeStack(scope, "::", name))); 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; }
/* * Check if each usage of a char array as a key has a corresponding * "#pragma cats" declaration. */ static c_bool idl_checkCatsUsage( c_base base, const char* filename) { char errorBuffer [IDL_MAX_ERRORSIZE]; idl_keyDef keyDef = idl_keyDefDefGet(); c_long keyMapIdx; idl_keyMap keyMap; c_type type; c_structure structure; c_iter keysList; os_uint32 keysListSize; os_uint32 keyIdx; c_char* keyName; os_uint32 i; c_iter keyNameList; os_uint32 keyNameListSize; c_structure tmpStructure; c_specifier sp; c_type subType; c_string typeName; c_type spType; if (keyDef != NULL) { /* check all key definition list elements */ for (keyMapIdx = 0; keyMapIdx < c_iterLength(keyDef->keyList); keyMapIdx++) { keyMap = c_iterObject(keyDef->keyList, keyMapIdx); /* if a keylist is defined for the type */ if (keyMap->keyList && strlen(keyMap->keyList) > 0) { /* find meteobject for the type */ type = c_type(c_metaResolveType(keyMap->scope, keyMap->typeName)); if (!type) { snprintf(errorBuffer, IDL_MAX_ERRORSIZE-1, errorText[idl_UndeclaredIdentifier], keyMap->typeName); idl_printError(filename, errorBuffer); return OS_FALSE; } /* type can be a typedef. Determine the actual type. */ type = c_typeActualType(type); /* type should be a structure */ if (c_baseObject(type)->kind != M_STRUCTURE) { snprintf(errorBuffer, IDL_MAX_ERRORSIZE-1, errorText[idl_IllegalKeyFields]); idl_printError(filename, errorBuffer); return OS_FALSE; } structure = c_structure(type); /* for each key in keyList, check if type is a char array */ keysList = c_splitString(keyMap->keyList, ","); keysListSize = c_iterLength(keysList); for(keyIdx = 0; keyIdx < keysListSize; keyIdx++) { keyName = c_iterTakeFirst(keysList); /* We might be dealing with a field of a field definition in * the keylist, so let's split this up */ keyNameList = c_splitString(keyName, "."); keyNameListSize = c_iterLength(keyNameList); tmpStructure = structure; for(i = 0; i < keyNameListSize; i++) { keyName = c_iterTakeFirst(keyNameList); /* Now get the actual member defined by the name */ sp = c_specifier(c_metaFindByName( c_metaObject(tmpStructure), keyName, CQ_FIXEDSCOPE | CQ_MEMBER | CQ_CASEINSENSITIVE)); if(sp) { spType = c_typeActualType(sp->type); /* If the member is a structure, we need to * recurse deeper. */ if(c_baseObject(spType)->kind == M_STRUCTURE) { tmpStructure = c_structure(spType); } /* If the member is a collection then we need to * ensure it is not a character array, but if it * is we need to ensure a corresponding CATS pragma * can be located */ else if(c_baseObject(spType)->kind == M_COLLECTION && c_collectionType(spType)->kind == C_ARRAY) { subType = c_typeActualType(c_collectionType(spType)->subType); if(c_baseObject(subType)->kind == M_PRIMITIVE && c_primitive(subType)->kind == P_CHAR) { typeName = c_metaName(c_metaObject(tmpStructure)); /* check if there is corresponding catsDef */ if (!idl_isCatsDefFor(c_metaObject(tmpStructure)->definedIn, typeName, keyName)) { snprintf( errorBuffer, IDL_MAX_ERRORSIZE-1, errorText[idl_NoCorrespondingCats], c_metaObject(structure)->name, keyName); idl_printError(filename, errorBuffer); return OS_FALSE; } c_free(typeName); } } } } } } } } return OS_TRUE; }
static int idl_genInterface( idl_scope scope, const char *name, char *class_base, idl_typeSpec typeSpec, c_bool generateInterfaceClass) { idl_tmplExp te; c_char tmplFileName[1024]; c_char pname[1024]; c_char *tmplPath; c_char *orbPath; int tmplFile; struct os_stat_s tmplStat; unsigned int nRead; os_char *redirects; char *scopedMetaTypeName; const char *internalTypeName; const char *keyList; char *scopeStackJavaDot = idl_scopeStackJava(scope, ".", name); char *scopeStackJavaSlash = idl_scopeStackJava(scope, "/", name); char *typeSpecName = idl_typeSpecName(typeSpec); char *javaId = idl_javaId(name); int result = 0; tmplPath = os_getenv("OSPL_TMPL_PATH"); orbPath = os_getenv("OSPL_ORB_PATH"); if (tmplPath == NULL) { printf("OSPL_TMPL_PATH not defined\n"); result = -1; goto err_exit; } if (orbPath == NULL) { printf("OSPL_ORB_PATH not defined\n"); result = -1; goto err_exit; } idlpp_macroSet = idl_macroSetNew(); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("type-name", javaId)); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("actual-type-name", typeSpecName)); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scoped-type-name", scopeStackJavaDot)); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("java-class-name", scopeStackJavaSlash)); redirects = idl_packageRedirects (); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("java-package-redirects", redirects)); os_free(redirects); scopedMetaTypeName = idl_scopeStack(scope, "::", name); internalTypeName = idl_internalTypeNameForBuiltinTopic(scopedMetaTypeName); keyList = idl_keyResolve(idl_keyDefDefGet(), scope, name); if ((strlen(internalTypeName) != 0) && ((keyList == NULL) || (strcmp(keyList,"key") == 0))) { keyList = "key.localId,key.systemId"; } idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scoped-meta-type-name", scopedMetaTypeName)); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("internal-type-name", internalTypeName)); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scoped-actual-type-name", idl_corbaJavaTypeFromTypeSpec(typeSpec))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("key-list", keyList)); os_free(scopedMetaTypeName); /* Generate only in standalone mode */ if (idl_getCorbaMode() == IDL_MODE_STANDALONE) { snprintf(pname, sizeof (pname), "%s%s", javaId, class_base); idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { result = -1; goto err_exit; } /* Prepare Interface class */ if (generateInterfaceClass) { snprintf(tmplFileName, sizeof(tmplFileName), "%s%c%s%ctmpl%s.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf ("No template found or protection violation (%s)\n", tmplFileName); result = -1; goto err_exit; } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc(tmplStat.stat_size+1); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, tmplStat.stat_size); memset(&idlpp_template[nRead], 0, tmplStat.stat_size+1-nRead); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); os_free(idlpp_template); } idl_closeJavaPackage(); snprintf(pname, sizeof(pname), "%s%sHolder", javaId, class_base); idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { result = -1; goto err_exit; } /* Prepare typeSupportHolder class */ snprintf(tmplFileName, sizeof(tmplFileName), "%s%c%s%ctmpl%sHolder.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf ("No template found or protection violation (%s)\n", tmplFileName); result = -1; goto err_exit; } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc(tmplStat.stat_size+1); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, tmplStat.stat_size); memset(&idlpp_template[nRead], 0, tmplStat.stat_size+1-nRead); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); os_free(idlpp_template); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); idl_closeJavaPackage(); snprintf(pname, sizeof(pname), "%s%sHelper", javaId, class_base); idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { result = -1; goto err_exit; } /* Prepare typeSupportHelper class */ snprintf(tmplFileName, sizeof(tmplFileName), "%s%c%s%ctmpl%sHelper.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf ("No template found or protection violation (%s)\n", tmplFileName); result = -1; goto err_exit; } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc(tmplStat.stat_size+1); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, tmplStat.stat_size); memset(&idlpp_template[nRead], 0, tmplStat.stat_size+1-nRead); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); os_free(idlpp_template); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); idl_closeJavaPackage(); snprintf(pname, sizeof(pname), "%s%sOperations", javaId, class_base); idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { result = idl_abort; goto err_exit; } /* Prepare typeSupportOperations class */ snprintf(tmplFileName, sizeof(tmplFileName), "%s%c%s%ctmpl%sOperations.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf ("No template found or protection violation (%s)\n", tmplFileName); result = -1; goto err_exit; } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc(tmplStat.stat_size+1); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, tmplStat.stat_size); memset(&idlpp_template[nRead], 0, tmplStat.stat_size+1-nRead); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); os_free(idlpp_template); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); idl_closeJavaPackage(); } if (generateInterfaceClass) { /* Implementation with Impl extension */ snprintf(pname, sizeof(pname), "%s%sImpl", javaId, class_base); } else { /* Implementation without Impl extension */ snprintf(pname, sizeof(pname), "%s%s", javaId, class_base); } idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { result = -1; goto err_exit; } /* Prepare typeSupportStub class */ snprintf(tmplFileName, sizeof(tmplFileName), "%s%c%s%ctmpl%sImpl.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf("No template found or protection violation (%s)\n", tmplFileName); result = idl_abort; goto err_exit; } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc(tmplStat.stat_size+1); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, tmplStat.stat_size); memset(&idlpp_template[nRead], 0, tmplStat.stat_size+1-nRead); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); os_free(idlpp_template); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); idl_closeJavaPackage(); err_exit: os_free(javaId); os_free(scopeStackJavaDot); os_free(scopeStackJavaSlash); return result; }
static int idl_genInterface( idl_scope scope, const char *name, char *class_base, idl_typeSpec typeSpec, c_bool generateInterfaceClass) { idl_tmplExp te; c_char tmplFileName[1024]; c_char pname[1024]; c_char *tmplPath; c_char *orbPath; int tmplFile; struct os_stat tmplStat; unsigned int nRead; tmplPath = os_getenv("OSPL_TMPL_PATH"); orbPath = os_getenv("OSPL_ORB_PATH"); if (tmplPath == NULL) { printf("OSPL_TMPL_PATH not defined\n"); return -1; } if (orbPath == NULL) { printf("OSPL_ORB_PATH not defined\n"); return -1; } idlpp_macroSet = idl_macroSetNew(); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("type-name", idl_javaId(name))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("actual-type-name", idl_typeSpecName(typeSpec))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scoped-type-name", idl_scopeStackJava(scope, ".", name))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("java-class-name", idl_scopeStackJava(scope, "/", name))); if(idl_genJavaHelperGetOrgPName()) { idl_macroSetAdd(idlpp_macroSet, idl_macroNew("java-org-package-name", idl_genJavaHelperGetOrgPName())); } else { idl_macroSetAdd(idlpp_macroSet, idl_macroNew("java-org-package-name", "null")); } if(idl_genJavaHelperGetTgtPName()) { idl_macroSetAdd(idlpp_macroSet, idl_macroNew("java-tgt-package-name", idl_genJavaHelperGetTgtPName())); } else { idl_macroSetAdd(idlpp_macroSet, idl_macroNew("java-tgt-package-name", "null")); } idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scoped-meta-type-name", idl_scopeStack(scope, "::", name))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scoped-actual-type-name", idl_corbaJavaTypeFromTypeSpec(typeSpec))); idl_macroSetAdd(idlpp_macroSet, idl_macroNew("key-list", idl_keyResolve(idl_keyDefDefGet(), scope, name))); snprintf(pname, sizeof (pname), "%s%s", idl_javaId(name), class_base); idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { return -1; } if (idl_scopeStackSize(scope) > 0) { idl_fileOutPrintf(idl_fileCur(), "package %s;\n", idl_scopeStackJava (scope, ".", NULL)); idl_fileOutPrintf(idl_fileCur(), "\n"); } /* Prepare Interface class */ if (generateInterfaceClass) { snprintf(tmplFileName, (size_t)sizeof(tmplFileName), "%s%c%s%ctmpl%s.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf ("No template found or protection violation (%s)\n", tmplFileName); return -1; } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc((size_t)((int)tmplStat.stat_size+1)); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, (size_t)tmplStat.stat_size); memset(&idlpp_template[nRead], 0, (size_t)((int)tmplStat.stat_size+1-nRead)); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); } idl_closeJavaPackage(); snprintf(pname, sizeof(pname), "%s%sHolder", idl_javaId(name), class_base); idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { return -1; } if (idl_scopeStackSize(scope) > 0) { idl_fileOutPrintf(idl_fileCur(), "package %s;\n", idl_scopeStackJava(scope, ".", NULL)); idl_fileOutPrintf(idl_fileCur(), "\n"); } /* Prepare typeSupportHolder class */ snprintf(tmplFileName, (size_t)sizeof(tmplFileName), "%s%c%s%ctmpl%sHolder.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf ("No template found or protection violation (%s)\n", tmplFileName); return -1; } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc((size_t)((int)tmplStat.stat_size+1)); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, (size_t)tmplStat.stat_size); memset(&idlpp_template[nRead], 0, (size_t)((int)tmplStat.stat_size+1-nRead)); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); idl_closeJavaPackage(); snprintf(pname, sizeof(pname), "%s%sHelper", idl_javaId(name), class_base); idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { return -1; } if (idl_scopeStackSize(scope) > 0) { idl_fileOutPrintf(idl_fileCur(), "package %s;\n", idl_scopeStackJava(scope, ".", NULL)); idl_fileOutPrintf(idl_fileCur(), "\n"); } /* Prepare typeSupportHelper class */ snprintf(tmplFileName, (size_t)sizeof(tmplFileName), "%s%c%s%ctmpl%sHelper.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf ("No template found or protection violation (%s)\n", tmplFileName); return -1; } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc((size_t)((int)tmplStat.stat_size+1)); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, (size_t)tmplStat.stat_size); memset(&idlpp_template[nRead], 0, (size_t)((int)tmplStat.stat_size+1-nRead)); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); idl_closeJavaPackage(); snprintf(pname, sizeof(pname), "%s%sOperations", idl_javaId(name), class_base); idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { return (idl_abort); } if (idl_scopeStackSize(scope) > 0) { idl_fileOutPrintf(idl_fileCur(), "package %s;\n", idl_scopeStackJava(scope, ".", NULL)); idl_fileOutPrintf(idl_fileCur(), "\n"); } /* Prepare typeSupportOperations class */ snprintf(tmplFileName, (size_t)sizeof(tmplFileName), "%s%c%s%ctmpl%sOperations.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf ("No template found or protection violation (%s)\n", tmplFileName); return -1; } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc((size_t)((int)tmplStat.stat_size+1)); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, (size_t)tmplStat.stat_size); memset(&idlpp_template[nRead], 0, (size_t)((int)tmplStat.stat_size+1-nRead)); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); idl_closeJavaPackage(); if (generateInterfaceClass) { /* Implementation with Impl extension */ snprintf(pname, sizeof(pname), "%s%sImpl", idl_javaId(name), class_base); } else { /* Implementation without Impl extension */ snprintf(pname, sizeof(pname), "%s%s", idl_javaId(name), class_base); } idl_openJavaPackage(scope, pname); if (idl_fileCur() == NULL) { return -1; } if (idl_scopeStackSize(scope) > 0) { idl_fileOutPrintf(idl_fileCur(), "package %s;\n", idl_scopeStackJava(scope, ".", NULL)); idl_fileOutPrintf(idl_fileCur(), "\n"); } /* Prepare typeSupportStub class */ snprintf(tmplFileName, (size_t)sizeof(tmplFileName), "%s%c%s%ctmpl%sImpl.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR, class_base); /* QAC EXPECT 3416; No side effects here */ if ((os_stat(tmplFileName, &tmplStat) != os_resultSuccess) || (os_access(tmplFileName, OS_ROK) != os_resultSuccess)) { printf("No template found or protection violation (%s)\n", tmplFileName); return (idl_abort); } /* QAC EXPECT 5007; will not use wrapper */ idlpp_template = os_malloc((size_t)((int)tmplStat.stat_size+1)); tmplFile = open(tmplFileName, O_RDONLY); nRead = (unsigned int)read(tmplFile, idlpp_template, (size_t)tmplStat.stat_size); memset(&idlpp_template[nRead], 0, (size_t)((int)tmplStat.stat_size+1-nRead)); close(tmplFile); idlpp_macroAttrib = idl_macroAttribNew(IDL_TOKEN_START, IDL_TOKEN_OPEN, IDL_TOKEN_CLOSE); idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib); te = idl_tmplExpNew(idlpp_macroSet); idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur()); idl_streamInFree(idlpp_inStream); idl_tmplExpFree(te); idl_closeJavaPackage(); return 0; }