os_result os_procDeleteThreadTaskVar( os_int32 taskid, char *executable_file, os_procContextData process_procContextData) { os_int32 status = os_resultSuccess; os_procGlobalVar procGlobalVar; os_int32 index=0; /* delete context variable for the task */ procGlobalVar = os_iterObject(process_procContextData->procGlobalVarList, index); index++; while (procGlobalVar!= NULL){ if (deleteTLSVar(taskid, (int *)procGlobalVar->procVarAddr) != OK) { OS_REPORT(OS_WARNING, "os_procDeleteTaskVar", 1, "os_procDeleteTaskVar user failed with error %d (%s, %s)", os_getErrno(), executable_file, process_procContextData->procName); status = os_resultInvalid; os_procSetExitStatus(process_procContextData, -1); } procGlobalVar = os_iterObject(process_procContextData->procGlobalVarList, index); index++; } if (deleteTLSVar(taskid, (int *)&procContextData) != OK) { OS_REPORT(OS_WARNING, "os_procDeleteTaskVar", 1, "os_procDeleteTaskVar failed with error %d (%s, %s)", os_getErrno(), executable_file, process_procContextData->procName); status = os_resultInvalid; os_procSetExitStatus(process_procContextData, -1); } return(status); }
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 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; }
/* Generate string in the format "<old>:<new>;<old>:<new>". */ static os_char * idl_packageRedirects ( void) { idl_packageRedirect redirect; os_uint32 count, total; os_size_t length; os_char *macro, *module, *package, *buffer; total = os_iterLength (idl_genJavaHelperPackageRedirects); length = 0; macro = NULL; for (count = 0; count < total; count++) { redirect = idl_packageRedirect(os_iterObject ( idl_genJavaHelperPackageRedirects, count)); assert (redirect != NULL); module = redirect->module; package = redirect->package; assert (package != NULL); if (module == NULL) { module = ""; } length += strlen (module) + strlen (package) + 3; /* ';' + ':' + '\0' */ buffer = os_malloc (length); memset (buffer, '\0', length); if (macro != NULL) { (void)snprintf (buffer, length, "%s;%s:%s",macro, module, package); os_free (macro); } else { (void)snprintf (buffer, length, "%s:%s", module, package); } macro = buffer; } if (macro == NULL) { macro = os_strdup ("null"); } else { length = strlen (macro) + 3; /* '"' + '"' */ buffer = os_malloc (length); (void)snprintf (buffer, length, "\"%s\"", macro); os_free (macro); macro = buffer; } return macro; }
/* Build a textual presentation of the provided scope stack taking the * Java keyword identifier translation into account. Further the function * equals "idl_scopeStack". */ c_char * idl_scopeStackJava ( idl_scope scope, const char *scopeSepp, const char *name) { c_long si; c_long sz; c_char *scopeStack = NULL; c_char *Id; os_char *substitute; os_char *module, *package; os_uint32 cnt, rlen; idl_packageRedirect redirect; assert (scopeSepp != NULL); scopeStack = os_strdup (""); for (si = 0, sz = idl_scopeStackSize(scope); si < sz; si++) { size_t slen; /* Translate the scope name to a C identifier */ Id = idl_javaId(idl_scopeJavaElementName(idl_scopeIndexed(scope, si))); /* allocate space for the current scope stack + the separator *and the next scope name */ /* QAC EXPECT 5007; will not use wrapper */ slen = strlen (scopeStack) + strlen (scopeSepp) + strlen (Id); scopeStack = os_realloc(scopeStack, slen + 1); /* Concatenate the separator */ /* QAC EXPECT 5007; will not use wrapper */ if (strlen(scopeStack)) { os_strcat(scopeStack, scopeSepp); } /* Concatenate the scope name */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat (scopeStack, Id); } /* idl_genJavaHelperPackageRedirects must be sorted */ substitute = scopeStack; rlen = os_iterLength (idl_genJavaHelperPackageRedirects); for (cnt = 0; cnt < rlen && substitute == scopeStack; cnt++) { redirect = idl_packageRedirect ( os_iterObject (idl_genJavaHelperPackageRedirects, cnt)); assert (redirect != NULL); package = os_str_replace (redirect->package, ".", scopeSepp, 0); if (package != NULL) { if (redirect->module != NULL) { module = os_str_replace (redirect->module, ".", scopeSepp, 0); if (module == NULL) { substitute = NULL; } else { substitute = os_str_word_replace ( scopeStack, scopeSepp, module, package, 1); if (module != redirect->module) { os_free (module); } } } else { substitute = os_malloc ( strlen (package) + strlen (scopeSepp) + strlen (scopeStack) + 1 /* '\0' */); if (substitute != NULL) { (void)strcpy (substitute, package); if (strlen (scopeStack)) { (void)os_strcat (substitute, scopeSepp); (void)os_strcat (substitute, scopeStack); } } } if (package != redirect->package) { os_free (package); } } } if (substitute != scopeStack) { os_free (scopeStack); scopeStack = substitute; } if (name) { /* A user identifier is specified */ /* Translate the user identifier to a Java identifier */ Id = idl_javaId(name); /* allocate space for the current scope stack + the separator * and the user identifier */ /* QAC EXPECT 5007; will not use wrapper */ scopeStack = os_realloc(scopeStack, strlen(scopeStack)+strlen(scopeSepp)+strlen(Id)+1); /* Concatenate the separator */ /* QAC EXPECT 5007; will not use wrapper */ if (strlen(scopeStack)) { os_strcat(scopeStack, scopeSepp); } /* Concatenate the user identifier */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat (scopeStack, Id); } /* return the scope stack representation */ return scopeStack; }
/** @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 * * @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) { char *labelImage; long nrElements, i; /* store type-name and field-name in iterator (append) */ idl_mapAdd(map, idl_javaId(name), typeSpec); /* Obtain name of first label and total number of labels. */ nrElements = os_iterLength(labelIter); labelImage = os_iterObject(labelIter, 0); /* Save the 1st case label for usage with the default constructor. */ if (!union1stCaseValue) { union1stCaseValue = os_iterObject(labelIter, 0); } idl_fileOutPrintf( idl_fileCur(), " private %s __%s;\n\n", idl_unionCaseTypeFromTypeSpec(typeSpec), idl_javaId(name)); idl_fileOutPrintf( idl_fileCur(), " public %s %s ()\n", idl_unionCaseTypeFromTypeSpec (typeSpec), idl_javaId(name)); idl_fileOutPrintf(idl_fileCur(), " {\n"); if (caseIsDefault == FALSE) { idl_fileOutPrintf(idl_fileCur(), " if (_d != %s", labelImage); for (i = 1; i < nrElements; i++) { labelImage = os_iterObject(labelIter, i); idl_fileOutPrintf(idl_fileCur(), " &&\n _d != %s", labelImage); } idl_fileOutPrintf(idl_fileCur(), ") {\n"); idl_fileOutPrintf(idl_fileCur(), " throw Utilities.createException(Utilities.EXCEPTION_TYPE_BAD_OPERATION, null);\n"); idl_fileOutPrintf(idl_fileCur(), " }\n"); } else { if(os_iterLength(labelsUsedIter)) { labelImage = os_iterObject(labelsUsedIter, 0); idl_fileOutPrintf(idl_fileCur(), " if (_d == %s", labelImage); nrElements = os_iterLength(labelsUsedIter); for (i = 1; i < nrElements; i++) { labelImage = os_iterObject(labelsUsedIter, i); idl_fileOutPrintf(idl_fileCur(), " ||\n _d == %s", labelImage); } idl_fileOutPrintf(idl_fileCur(), ") {\n"); idl_fileOutPrintf(idl_fileCur(), " throw Utilities.createException(Utilities.EXCEPTION_TYPE_BAD_OPERATION, null);\n"); idl_fileOutPrintf(idl_fileCur(), " }\n"); } } idl_fileOutPrintf(idl_fileCur(), " return __%s;\n", idl_javaId(name)); idl_fileOutPrintf(idl_fileCur(), " }\n\n"); idl_fileOutPrintf( idl_fileCur(), " public void %s (%s val)\n", idl_javaId(name), idl_unionCaseTypeFromTypeSpec(typeSpec)); idl_fileOutPrintf(idl_fileCur(), " {\n"); idl_fileOutPrintf(idl_fileCur(), " __%s = val;\n", idl_javaId(name)); labelImage = os_iterObject(labelIter, 0); if (labelImage) { idl_fileOutPrintf(idl_fileCur(), " _d = (%s)%s;\n", unionSwitchType, labelImage); } else { /* Theoretically this branch should never be reached: also the code underneath doesn't make any sense. That's why an assert has now been substituted. labelImage = os_iterObject(labelsUsedIter, 0); idl_fileOutPrintf(idl_fileCur(), " _d = (%s)%s;\n", unionSwitchType, labelImage); */ assert(FALSE); } idl_fileOutPrintf(idl_fileCur(), " }\n\n"); idl_fileOutPrintf( idl_fileCur(), " public void %s (%s d, %s val)\n", idl_javaId(name), unionSwitchType, idl_unionCaseTypeFromTypeSpec (typeSpec)); idl_fileOutPrintf(idl_fileCur(), " {\n"); if (caseIsDefault == FALSE) { labelImage = os_iterTakeFirst(labelIter); idl_fileOutPrintf(idl_fileCur(), " if (d != (%s)%s", unionSwitchType, labelImage); labelImage = os_iterTakeFirst(labelIter); while (labelImage) { idl_fileOutPrintf(idl_fileCur(), " &&\n d != (%s)%s", unionSwitchType, labelImage); labelImage = os_iterTakeFirst (labelIter); } idl_fileOutPrintf(idl_fileCur(), ") {\n"); idl_fileOutPrintf(idl_fileCur(), " throw Utilities.createException(Utilities.EXCEPTION_TYPE_BAD_OPERATION, null);\n"); idl_fileOutPrintf(idl_fileCur(), " }\n"); } else { if(os_iterLength(labelsUsedIter)) { labelImage = os_iterTakeFirst(labelsUsedIter); idl_fileOutPrintf(idl_fileCur(), " if (d == (%s)%s", unionSwitchType, labelImage); labelImage = os_iterTakeFirst(labelsUsedIter); while (labelImage) { idl_fileOutPrintf(idl_fileCur(), " ||\n d == (%s)%s", unionSwitchType, labelImage); labelImage = os_iterTakeFirst(labelsUsedIter); } idl_fileOutPrintf(idl_fileCur(), ") {\n"); idl_fileOutPrintf(idl_fileCur(), " throw Utilities.createException(Utilities.EXCEPTION_TYPE_BAD_OPERATION, null);\n"); idl_fileOutPrintf(idl_fileCur(), " }\n"); } } idl_fileOutPrintf(idl_fileCur(), " __%s = val;\n", idl_javaId(name)); idl_fileOutPrintf(idl_fileCur(), " _d = d;\n"); idl_fileOutPrintf(idl_fileCur(), " }\n\n"); }