/* Find the key list related to the specified typename in the specified scope */ c_char * idl_keyResolve ( idl_keyDef keyDef, idl_scope scope, const char *typeName) { c_long li; c_long si; idl_keyMap keyMap; c_metaObject typeScope; li = 0; /* check all key definition list elements */ while (li < c_iterLength (keyDef->keyList)) { keyMap = c_iterObject (keyDef->keyList, li); if (strcmp(typeName, keyMap->typeName) == 0) { /* if the typename equals, check if the scope compares */ if ((idl_scopeStackSize(scope) == 0) && (keyMap->scope->definedIn == NULL)) { /* Global scope */ return keyMap->keyList; } si = idl_scopeStackSize (scope)-1; typeScope = keyMap->scope; while (si >= 0) { /* for each scope element */ if (idl_scopeElementType(idl_scopeIndexed (scope, si)) == idl_tModule && strcmp (typeScope->name, idl_scopeElementName(idl_scopeIndexed (scope, si))) == 0) { /* the scope is a module and the scope name compares */ si--; if (typeScope) { typeScope = typeScope->definedIn; } if (si == -1) { /* bottom of the stack is reached */ if (typeScope == NULL || typeScope->name == NULL) { /* the typeScope has reached the bottom too, thus the scopes are equal */ return keyMap->keyList; } } } else { si = -1; } } } li++; } return NULL; }
/* Build a textual representation of the provided scope stack taking the C++ keyword identifier translation into account. Further the function equals "idl_scopeStack". */ c_char * idl_scopeStackISOCxx2( idl_scope scope, const char *scopeSepp, const char *name) { c_long si; c_long sz; c_char *scopeStack; c_char *Id; si = 0; sz = idl_scopeStackSize(scope); if (si < sz) { /* The scope stack is not empty */ /* Copy the first scope element name */ scopeStack = os_strdup(scopeSepp);/* start with the seperator */ Id = idl_ISOCxx2Id(idl_scopeElementName(idl_scopeIndexed(scope, si))); scopeStack = os_realloc(scopeStack, strlen(scopeStack)+strlen(scopeSepp)+strlen(Id)+1); os_strcat(scopeStack, Id); os_free(Id); si++; while (si < sz) { /* Translate the scope name to a C++ identifier */ Id = idl_ISOCxx2Id(idl_scopeElementName(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 */ scopeStack = os_realloc(scopeStack, strlen(scopeStack)+strlen(scopeSepp)+strlen(Id)+1); /* Concatenate the separator */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat(scopeStack, scopeSepp); /* Concatenate the scope name */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat(scopeStack, Id); os_free(Id); si++; } if (name) { /* A user identifier is specified */ /* Translate the user identifier to a C++ identifier */ Id = idl_ISOCxx2Id(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 */ os_strcat(scopeStack, scopeSepp); /* Concatenate the user identifier */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat(scopeStack, Id); os_free(Id); } } else { /* The stack is empty */ if (name) { /* A user identifier is specified */ scopeStack = idl_ISOCxx2Id(name); } else { /* make the stack represenation empty */ scopeStack = os_strdup(""); } } /* return the scope stack representation */ return scopeStack; }
/* Build a textual presenation 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; c_char *Id; if(orgLastSubstituted) { os_free(orgLastSubstituted); orgLastSubstituted = NULL; } if(tarLastSubstituted) { os_free(tarLastSubstituted); tarLastSubstituted = NULL; } si = 0; sz = idl_scopeStackSize(scope); if (si < sz) { /* The scope stack is not empty */ /* Copy the first scope element name */ scopeStack = os_strdup(idl_javaId(idl_scopeJavaElementName(idl_scopeIndexed(scope, si)))); si++; while (si < sz) { /* 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 */ scopeStack = os_realloc(scopeStack, (size_t)( (int)strlen(scopeStack)+ (int)strlen(scopeSepp)+ (int)strlen(Id)+1)); /* Concatenate the separator */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat(scopeStack, scopeSepp); /* Concatenate the scope name */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat (scopeStack, Id); si++; } if(strlen(scopeStack) > 0) { os_char* ptr; os_char* ptr2; os_char* ptr3; /* es, dds1540: The following code is not pretty, but time limitations * required it's implementation. To ensure * proper substitution of for example package name 'Chat' with * 'org.opensplice.Chat' without substitution class names like * 'ChatMessage' to 'org.opensplice.ChatMessage' we need to take some * special arrangements. We need to allow the user to state he wants to * replace 'Chat.' with ''org.opensplice.Chat.', as this would resolve * the previously stated problem. * However this function for getting the scope stack is called in a * special way if only the package names are required (without the * specific class at the end). In these cases package Chat would become * in string format 'Chat' instead of 'Chat.'. And this would cause * problems when doing the substitution for the directory names and * package directives. So to ensure substitution always goes correctly * we added the scopeSepp to the end of the scopeStack and input that * into the substitution algorithm. After the algorithm we remove the * added scopeSepp again. * So not that nicely solved, but lack of time to do it more nicely * (which would be to support regular expression type things) --> No. */ ptr = os_malloc(strlen(scopeStack)+ strlen(scopeSepp) + 1); os_strcpy(ptr, scopeStack); os_strncat(ptr, scopeSepp, strlen(scopeSepp)); ptr2 = idl_genJavaHelperApplyPackageSubstitute(ptr, scopeSepp); memset(ptr, 0, strlen(ptr)); os_free(ptr); ptr3 = strrchr(ptr2, *scopeSepp); if(ptr3) { *ptr3 = '\0'; } ptr = os_strdup(ptr2); memset(ptr2, 0, strlen(ptr2)); os_free(ptr2); memset(scopeStack, 0, strlen(scopeStack)); os_free(scopeStack); scopeStack = ptr; } 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, (size_t)( (int)strlen(scopeStack)+ (int)strlen(scopeSepp)+ (int)strlen(Id)+1)); /* Concatenate the separator */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat(scopeStack, scopeSepp); /* Concatenate the user identifier */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat (scopeStack, Id); } } else { /* The stack is empty */ if (name) { /* A user identifier is specified */ scopeStack = os_strdup(idl_javaId(name)); } else { /* make the stack represenation empty */ scopeStack = os_strdup(""); } } /* return the scope stack representation */ return scopeStack; }
/* Find the stac list related to the specified typename in the specified scope */ os_boolean idl_stacListItemIsDefined ( idl_stacDef stacDef, idl_scope scope, const char *typeName, const char* itemName) { c_ulong li; c_long si; idl_stacMap stacMap; c_metaObject typeScope; os_boolean isDefined = OS_FALSE; if(stacDef) { li = 0; /* check all stac definition list elements */ while (li < c_iterLength (stacDef->stacList) && !isDefined) { stacMap = c_iterObject (stacDef->stacList, li); if (strcmp(typeName, stacMap->typeName) == 0) { /* if the typename equals, check if the scope compares */ if ((idl_scopeStackSize(scope) == 0) && (stacMap->scope->definedIn == NULL)) { /* We're in the global scope */ /* If no members were defined for this type, then we will * interprete this as a request for all bounded string * members to be converted to a char array internally. */ if(strlen(stacMap->stacList) == 0) { isDefined = OS_TRUE; } else if(idl_stacDefOnlyExclusionsDefined(stacMap->stacList)) { if(idl_stacDefIsFieldExcluded(stacMap->stacList, itemName)) { isDefined = OS_FALSE; } else { isDefined = OS_TRUE; } } else { isDefined = idl_stacListItemIsMemberLocated(stacMap->stacList, itemName); } } if(!isDefined) { si = idl_scopeStackSize (scope)-1; typeScope = stacMap->scope; while (si >= 0) { /* for each scope element */ if (idl_scopeElementType(idl_scopeIndexed (scope, si)) == idl_tModule && strcmp (typeScope->name, idl_scopeElementName(idl_scopeIndexed (scope, si))) == 0) { /* the scope is a module and the scope name compares */ si--; if (typeScope) { typeScope = typeScope->definedIn; } if (si == -1) { /* bottom of the stack is reached */ if (typeScope == NULL || typeScope->name == NULL) { /* the typeScope has reached the bottom too, * thus the scopes are equal */ /* If no members were defined for this type, then we will * interprete this as a request for all bounded string * members to be converted to a char array internally. */ if(strlen(stacMap->stacList) == 0) { isDefined = OS_TRUE; } else if(idl_stacDefOnlyExclusionsDefined(stacMap->stacList)) { if(idl_stacDefIsFieldExcluded(stacMap->stacList, itemName)) { isDefined = OS_FALSE; } else { isDefined = OS_TRUE; } } else { isDefined = idl_stacListItemIsMemberLocated(stacMap->stacList, itemName); } } } } else { si = -1; } } } } li++; } } return isDefined; }
/* 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; }