Example #1
0
/* 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;
}
Example #2
0
/** @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;
}
Example #3
0
/** @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;
}
Example #4
0
/** @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)
{
    int nameLen = strlen(idl_javaId(name)) + strlen("Holder") + 1;
    char *holderName;

    holderName = os_malloc(nameLen);
    snprintf(holderName, nameLen, "%sHolder", idl_javaId(name));

    /* Open file for used scope, if needed create the directories */
    idl_openJavaPackage(scope, holderName);
    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");
    }
    idl_fileOutPrintf(idl_fileCur(), "public final class %s\n{\n\n", holderName);
    idl_fileOutPrintf(
        idl_fileCur(),
        "    public %s value = null;\n\n",
        idl_scopeStackJava(scope, ".", idl_javaId(name)));
    idl_fileOutPrintf(idl_fileCur(), "    public %s () { }\n\n", holderName);

    idl_fileOutPrintf(
        idl_fileCur(),
        "    public %s (%s initialValue)\n",
        holderName,
        idl_scopeStackJava(scope, ".", idl_javaId(name)));
    idl_fileOutPrintf(idl_fileCur(), "    {\n");
    idl_fileOutPrintf(idl_fileCur(), "        value = initialValue;\n");
    idl_fileOutPrintf(idl_fileCur(), "    }\n\n");
    idl_fileOutPrintf(idl_fileCur(), "}\n");
    /* close file */
    idl_closeJavaPackage();

    /* return idl_abort to indicate that the rest of the structure does not need to be processed */
    return idl_abort;
}
Example #5
0
/** @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
 *
 * @param scope Current scope
 * @param name Name of the union
 * @param unionSpec Specifies the number of union cases and the union switch type
 */
static idl_action
idl_unionOpen(
    idl_scope scope,
    const char *name,
    idl_typeUnion unionSpec,
    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;
    }
    unionSwitchType = idl_corbaJavaTypeFromTypeSpec(idl_typeUnionSwitchKind(unionSpec));

    /* setup iterator to hold case 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");
    }
    idl_fileOutPrintf(idl_fileCur(), "import org.opensplice.dds.dcps.Utilities;\n\n");
    /* public final class <struct-name> { */
    idl_fileOutPrintf(idl_fileCur(), "public final class %s {\n\n", idl_javaId(name));
    idl_fileOutPrintf(idl_fileCur(), "    private %s _d;\n\n", unionSwitchType);
    if(idl_unionHasCase((c_union)idl_typeSpecDef((idl_typeSpec)unionSpec), "discriminator")) {
        idl_fileOutPrintf(idl_fileCur(), "    public %s _discriminator ()\n", unionSwitchType);
    }else {
        idl_fileOutPrintf(idl_fileCur(), "    public %s discriminator ()\n", unionSwitchType);
    }
    idl_fileOutPrintf(idl_fileCur(), "    {\n");
    idl_fileOutPrintf(idl_fileCur(), "        return _d;\n");
    idl_fileOutPrintf(idl_fileCur(), "    }\n\n");

    labelsUsedIter = os_iterNew(NULL);
    /* return idl_explore to indicate that the rest of the enumeration needs to be processed */
    return idl_explore;
}
Example #6
0
/** @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;
}
Example #7
0
/** @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
 *
 * @param scope Current scope
 * @param name Name of the enumeration
 * @param enumSpec Specifies the number of elements in the enumeration
 */
static idl_action
idl_enumerationOpen(
    idl_scope scope,
    const char *name,
    idl_typeEnum enumSpec,
    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;
    }
    /* 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(), "import org.opensplice.dds.dcps.Utilities;\n\n");
    /* public final class <enumeration-name> { */
    idl_fileOutPrintf(idl_fileCur(), "public class %s {\n\n", idl_javaId(name));
    idl_fileOutPrintf(idl_fileCur(), "    private int __value;\n");
    idl_fileOutPrintf(
        idl_fileCur(),
        "    private static int __size = %d;\n",
        idl_typeEnumNoElements (enumSpec));
    enum_def = idl_scopeStackJava(scope, ".", name);
    idl_fileOutPrintf(
        idl_fileCur(),
        "    private static %s[] __array = new %s[__size];\n\n",
        enum_def,
        enum_def);
    enum_element = 0;
    /* return idl_explore to indicate that the rest of the structure needs to be processed */
    return idl_explore;
}
Example #8
0
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");
}
Example #9
0
/** @brief callback function called on definition of a named type in the IDL input file.
 *
 * Generate code for the following IDL construct:
 * @verbatim
   =>   typedef <type-name> <name>;
   @endverbatim
 *
 * @param scope Current scope
 * @param name Specifies the name of the type
 * @param defSpec Specifies the type of the named type
 */
static void
idl_typedefOpenClose(
    idl_scope scope,
    const char *name,
    idl_typeDef defSpec,
    void *userData)
{
    int nameLen = strlen(idl_javaId(name)) + strlen("Holder") + 1;
    char *holderName;


    if (idl_typeSpecType(idl_typeDefRefered (defSpec)) == idl_tseq) {
        holderName = os_malloc(nameLen);
        snprintf(holderName, nameLen, "%sHolder", idl_javaId(name));
        /* Open file for used scope, if needed create the directories */
        idl_openJavaPackage(scope, holderName);
        if (idl_fileCur() == NULL) {
            return;
        }
        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 final class %s\n{\n\n", holderName);
        idl_fileOutPrintf(
            idl_fileCur(),
            "    public %s%s value = null;\n\n",
            idl_corbaJavaTypeFromTypeSpec(idl_typeSeqActual(idl_typeSeq(idl_typeDefRefered(defSpec)))),
            idl_sequenceIndexString (idl_typeSeq (idl_typeDefRefered (defSpec))));
        idl_fileOutPrintf(idl_fileCur(), "    public %s () { }\n\n", holderName);
        idl_fileOutPrintf(
            idl_fileCur(),
            "    public %s (%s%s initialValue)\n",
            holderName,
            idl_corbaJavaTypeFromTypeSpec(idl_typeSeqActual(idl_typeSeq(idl_typeDefRefered(defSpec)))),
            idl_sequenceIndexString(idl_typeSeq (idl_typeDefRefered (defSpec))));
        idl_fileOutPrintf(idl_fileCur(), "    {\n");
        idl_fileOutPrintf(idl_fileCur(), "        value = initialValue;\n");
        idl_fileOutPrintf(idl_fileCur(), "    }\n\n");
        idl_fileOutPrintf(idl_fileCur(), "}\n");
        /* close file */
        idl_closeJavaPackage();
    } else if (idl_typeSpecType(idl_typeDefRefered (defSpec)) == idl_tarray) {
        holderName = os_malloc(nameLen);
        snprintf(holderName, nameLen, "%sHolder", idl_javaId(name));
        /* Open file for used scope, if needed create the directories */
        idl_openJavaPackage(scope, holderName);
        if (idl_fileCur() == NULL) {
            return;
        }
        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 final class %s\n{\n\n", holderName);
        idl_fileOutPrintf(
            idl_fileCur(),
            "    public %s%s value = null;\n\n",
            idl_corbaJavaTypeFromTypeSpec(idl_typeArrayActual(idl_typeArray(idl_typeDefRefered(defSpec)))),
            idl_arrayJavaIndexString (idl_typeArray (idl_typeDefRefered (defSpec))));
        idl_fileOutPrintf(idl_fileCur(), "    public %s () { }\n\n", holderName);
        idl_fileOutPrintf(
            idl_fileCur(),
            "    public %s (%s%s initialValue)\n",
            holderName,
            idl_corbaJavaTypeFromTypeSpec(idl_typeArrayActual(idl_typeArray(idl_typeDefRefered(defSpec)))),
            idl_arrayJavaIndexString(idl_typeArray (idl_typeDefRefered (defSpec))));
        idl_fileOutPrintf(idl_fileCur(), "    {\n");
        idl_fileOutPrintf(idl_fileCur(), "        value = initialValue;\n");
        idl_fileOutPrintf(idl_fileCur(), "    }\n\n");
        idl_fileOutPrintf(idl_fileCur(), "}\n");
        /* close file */
        idl_closeJavaPackage();
    }
}
Example #10
0
static int
idl_genMeta (
    idl_meta meta)
{
    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(meta->name)));
    idl_macroSetAdd(idlpp_macroSet, idl_macroNew("actual-type-name", meta->actual_name));
    idl_macroSetAdd(
        idlpp_macroSet,
        idl_macroNew("scoped-type-name", idl_scopeStackJava(meta->scope, ".", meta->name)));
    idl_macroSetAdd(
        idlpp_macroSet,
        idl_macroNew("scoped-actual-type-name",idl_scopeStackJava(meta->scope, ".", meta->actual_name)));
    idl_macroSetAdd(
        idlpp_macroSet,
        idl_macroNew("meta-descriptor", idl_genSajXMLMeta(meta->type)));

    snprintf(pname, sizeof (pname), "%sMetaHolder", idl_javaId(meta->name));
    idl_openJavaPackage(meta->scope, pname);
    if (idl_fileCur() == NULL) {
        return -1;
    }
    if (idl_scopeStackSize(meta->scope) > 0) {
        idl_fileOutPrintf(idl_fileCur(), "package %s;\n", idl_scopeStackJava (meta->scope, ".", NULL));
        idl_fileOutPrintf(idl_fileCur(), "\n");
    }
    /* Prepare typeSupport class */
    snprintf(tmplFileName, (size_t)sizeof(tmplFileName), "%s%c%s%ctmplMetaHolder.java", tmplPath, OS_FILESEPCHAR, orbPath, OS_FILESEPCHAR);
    /* 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();

    return 0;
}
Example #11
0
/* 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;
}
Example #12
0
/* 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;
}
Example #13
0
/* 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;
}
Example #14
0
/** @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
 *
 * This function generates prototypes for the helper functions to
 * load the structures metadata, to determine the structures keys
 * and the scoped name of the struct if the struct 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>_<structure-name>__keys
   @endverbatim
 * The name of the name query function is:
 * @verbatim
        __<scope-elements>_<structure-name>__name
   @endverbatim
 * If the struct is defined within another struct or within a
 * union, no key nor its name can be queried. Such a structure
 * can not be communicated via Splice as a separate entity.
 * IDL structs are mapped onto C structs for Splice, therefor
 * a struct definition is opened:
 * @verbatim
        struct <scope-elements>_<name> {
   @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
 * @return Next action for this structure (idl_explore)
 */
static idl_action
idl_structureOpen(
    idl_scope scope,
    const char *name,
    idl_typeStruct structSpec,
    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 structure name */
        idl_fileOutPrintf(idl_fileCur(), "extern const char * __%s__name (void);\n",
	        idl_scopeStack(scope, "_", name));
        if(!test_mode)
        {
            /* define the prototype of the function for performing copyIn/copyOut. This needs to be
             * exported as well to ensure it can be access by other (ussually also OpenSplice
             * generated) packages
             */
            idl_fileOutPrintf(
                idl_fileCur(),
                "struct _%s ;\n",
                idl_scopeStack(scope, "_", name));

            if(useVoidPtrs)
            {
                idl_fileOutPrintf(
                    idl_fileCur(),
                    "extern %s c_bool __%s__copyIn(c_base base, void *from, void *to);\n",
                    idl_dllGetMacro(),
                    idl_scopeStack(scope, "_", name));
            } else
            {
                idl_fileOutPrintf(
                    idl_fileCur(),
                    "extern %s c_bool __%s__copyIn(c_base base, struct %s *from, struct _%s *to);\n",
                    idl_dllGetMacro(),
                    idl_scopeStack(scope, "_", name),
                    idl_scopeStack(scope, "::", name),
                    idl_scopeStack(scope, "_", name));
            }
            idl_fileOutPrintf(
                idl_fileCur(),
                "extern %s void __%s__copyOut(void *_from, void *_to);\n",
                idl_dllGetMacro(),
                idl_scopeStack(scope, "_", name));
        }

    }
    idl_printIndent(indent_level);
    idl_fileOutPrintf(
        idl_fileCur(),
        "struct _%s {\n",
        idl_scopeStack(scope, "_", name));
    indent_level++;

    /* return idl_explore to indicate that the rest of the structure needs to be processed */
    return idl_explore;
}
Example #15
0
/** @brief callback function called on definition of a named type in the IDL input file.
 *
 * Generate code for the following IDL construct:
 * @verbatim
   =>   typedef <type-name> <name>;
   @endverbatim
 *
 * This function generates a prototype for the helper function to
 * load the typedef metadata if the typedef is defined
 * within the global scope or the scope of a module.
 * The name of the metadata load function is:
 * @verbatim
        __<scope-elements>_<name>__load
   @endverbatim
 * If the type specification is idl_tbasic a standard mapping will be applied:
 * @verbatim
	typedef <basic-type-mapping> <scope-elements>_<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>;     => typedef enum <scope-elements>_<typedef-name> <scope-elements>_<name>;
	<enum-name> <name>;        => typedef enum <scope-elements>_<enum-name> <scope-elements>_<name>;
	<struct-name> <name>;      => typedef struct <scope-elements>_<structure-name> <scope-elements>_<name>;
	<union-name> <name>;       => typedef struct <scope-elements>_<union-name> <scope-elements>_<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]; =>
            typedef <scope-elements>_<other-usertype-name> <scope-elements>_<name>[n1]..[nn];
        <basic-type> <name>[n1]..[nn];          =>
            typedef <basic-type-mapping> <scope-elements>_<name>[n1]..[nn];
        sequence<spec> <name>[n1]..[nn];        =>
            typedef c_array <scope-elements>_<name>[n1]..[nn];
        sequence<spec,length> <name>[n1]..[nn]; =>
            typedef c_array <scope-elements>_<name>[n1]..[nn];
   @endverbatim
 * If the type specification is idl_tseq then generate a mapping on c_sequence:
 * @verbatim
        sequence<spec> <name>;        => typedef c_sequence <scope-elements>_<name>;
        sequence<spec,length> <name>; => typedef c_sequence <scope-elements>_<name>;
   @endverbatim
 *
 * @param scope Current scope
 * @param name Specifies the name of the type
 * @param defSpec Specifies the type of the named type
 */
static void
idl_typedefOpenClose(
    idl_scope scope,
    const char *name,
    idl_typeDef defSpec,
    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));
        if (idl_typeSpecType(idl_typeDefActual(defSpec)) == idl_tstruct ||
            idl_typeSpecType(idl_typeDefActual(defSpec)) == idl_tunion) {
            /* If this is a typedef of a struct or union			*/
            /* 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 structure name */
            idl_fileOutPrintf(
                idl_fileCur(),
                "extern const char * __%s__name (void);\n",
                idl_scopeStack(scope, "_", name));
        }
    }
    if (idl_typeSpecType(idl_typeSpec(idl_typeDefRefered(defSpec))) == idl_ttypedef ||
        idl_typeSpecType(idl_typeSpec(idl_typeDefRefered(defSpec))) == idl_tenum ||
        idl_typeSpecType(idl_typeSpec(idl_typeDefRefered(defSpec))) == idl_tstruct ||
        idl_typeSpecType(idl_typeSpec(idl_typeDefRefered(defSpec))) == idl_tunion ||
        idl_typeSpecType(idl_typeSpec(idl_typeDefRefered(defSpec))) == 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(),
            "typedef %s _%s;\n\n",
            idl_scopedSplTypeIdent(idl_typeSpec(idl_typeDefRefered(defSpec))),
            idl_scopeStack (scope, "_", name));
    } else if (idl_typeSpecType(idl_typeSpec(idl_typeDefRefered(defSpec))) == idl_tarray) {
        /* generate code for an array mapping */
        idl_printIndent(indent_level);
        idl_fileOutPrintf(
            idl_fileCur(),
            "typedef %s _%s",
            idl_scopedSplTypeIdent(idl_typeArrayActual (idl_typeArray(idl_typeDefRefered(defSpec)))),
            idl_scopeStack(scope, "_", name));
        idl_arrayDimensions(idl_typeArray(idl_typeDefRefered(defSpec)), OS_FALSE);
	    idl_fileOutPrintf(idl_fileCur(), ";\n\n");
    } else if (idl_typeSpecType(idl_typeSpec(idl_typeDefRefered(defSpec))) == idl_tseq) {
        /* generate code for a sequence mapping */
        idl_printIndent(indent_level);
        if (idl_typeSeqMaxSize (idl_typeSeq(idl_typeDefRefered(defSpec))) == 0) {
	    /* unbounded sequence */
            idl_fileOutPrintf(
                idl_fileCur(),
                "typedef c_sequence _%s",
                idl_scopeStack (scope, "_", name));
        } else {
	    /* bounded sequence */
            idl_fileOutPrintf(
                idl_fileCur(),
                "typedef c_sequence _%s",
                idl_scopeStack(scope, "_", name));
        }
        idl_fileOutPrintf (idl_fileCur(), ";\n\n");
    } else {
        printf("idl_typedefOpenClose: Unsupported typedef type (typename = %s, type = %s)\n",
            name, idl_scopedTypeName(idl_typeSpec(defSpec)));
    }
}
Example #16
0
/* 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;
}
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;
}