示例#1
0
static void
idl_typedefOpenClose(
    idl_scope scope,
    const char *name,
    idl_typeDef defSpec,
    void *userData)
{
    c_char spaces[20];
    idl_tmplExp te;

    OS_UNUSED_ARG(userData);

    if ((idl_typeSpecType(idl_typeDefRefered(defSpec)) == idl_tstruct ||
        (idl_typeSpecType(idl_typeDefRefered(defSpec)) == idl_tunion)) &&
        (idl_streamsResolve(idl_streamsDefDefGet(), scope, name))) {
        /* keylist defined for this typedef of struct or union */
        te = idl_tmplExpNew(idlpp_macroSet);
        idl_macroSetAdd(idlpp_macroSet,
            idl_macroNew("namescope", idl_cxxId(idl_scopeElementName(idl_scopeCur(scope)))));
        idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name)));
        idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scopedtypename", idl_scopeStack(scope, "::", name)));
        snprintf(spaces, sizeof(spaces), "%d", idlpp_indent_level*4);
        idl_macroSetAdd(idlpp_macroSet, idl_macroNew("spaces", spaces));
        idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib);
        idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur());
        idl_streamInFree(idlpp_inStream);
        idl_tmplExpFree(te);
    }
}
static idl_action
idl_structureOpen(
    idl_scope scope,
    const char *name,
    idl_typeStruct structSpec,
    void *userData)
{
    c_char spaces[20];
    idl_tmplExp te;

    /* QAC EXPECT 3416; No side effects here */
    if (idl_keyResolve(idl_keyDefDefGet(), scope, name) != NULL) {
	/* keylist defined for this struct */
        te = idl_tmplExpNew(idlpp_macroSet);
        idl_macroSetAdd(idlpp_macroSet,
            idl_macroNew("namescope", idl_cxxId(idl_scopeElementName(idl_scopeCur(scope)))));
        idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name)));
        snprintf(spaces, (size_t)sizeof(spaces), "%d", idlpp_indent_level*4);
        idl_macroSetAdd(idlpp_macroSet, idl_macroNew("spaces", spaces));
        idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib);
        idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur());
        idl_streamInFree(idlpp_inStream);
        idl_tmplExpFree(te);
    }
    return idl_abort;
}
示例#3
0
static idl_action
idl_unionOpen(
    idl_scope scope,
    const char *name,
    idl_typeUnion unionSpec,
    void *userData)
{
    c_char spaces[20];
    idl_tmplExp te;

    OS_UNUSED_ARG(unionSpec);
    OS_UNUSED_ARG(userData);

    /* QAC EXPECT 3416; No side effects here */
    if (idl_streamsResolve(idl_streamsDefDefGet(), scope, name)) {
    /* keylist defined for this union */
        te = idl_tmplExpNew(idlpp_macroSet);
        idl_macroSetAdd(idlpp_macroSet,
            idl_macroNew("namescope", idl_cxxId(idl_scopeElementName(idl_scopeCur(scope)))));
        idl_macroSetAdd(idlpp_macroSet, idl_macroNew("typename", idl_cxxId(name)));
        idl_macroSetAdd(idlpp_macroSet, idl_macroNew("scopedtypename", idl_scopeStack(scope, "::", name)));
        snprintf(spaces, sizeof(spaces), "%d", idlpp_indent_level*4);
        idl_macroSetAdd(idlpp_macroSet, idl_macroNew("spaces", spaces));
        idlpp_inStream = idl_streamInNew(idlpp_template, idlpp_macroAttrib);
        idl_tmplExpProcessTmpl(te, idlpp_inStream, idl_fileCur());
        idl_streamInFree(idlpp_inStream);
        idl_tmplExpFree(te);
    }
    return idl_abort;
}
static 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;
}
示例#5
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;
}
示例#6
0
os_boolean
idl_stacDef_isStacDefined(
    idl_scope scope,
    const char *name,
    idl_typeSpec typeSpec,
    idl_typeSpec* baseStringTypeDereffered)
{
    os_boolean isStacDefined = OS_FALSE;
    idl_typeSpec typeDereffered;
    idl_typeSpec subType;
    idl_scope tmpScope;
    os_char* containingElement;
    idl_basicType basic;
    c_ulong maxlen;

    /* resolve any type defs */
    typeDereffered = idl_typeDefResolveFully(typeSpec);
    if(idl_typeSpecType(typeDereffered) == idl_tarray)
    {
        /* If this is an array, then get the sub type and recurse deeper into this
         * operation. Arrays of bounded strings are allowed for pragma stac
         */
        subType = idl_typeArrayActual(idl_typeArray(typeDereffered));
        isStacDefined = idl_stacDef_isStacDefined(scope, name, subType, baseStringTypeDereffered);
    } else if(idl_typeSpecType(typeDereffered) == idl_tbasic)
    {
        /* Get the basic type to see if it is a string */
        basic = idl_typeBasicType(idl_typeBasic(typeDereffered));
        if(basic == idl_string)
        {
            /* If this is indeed a string, then get the 'maxLen' attribute of the
             * string type. If it is not 0, then this is a bounded string
             */
            maxlen = idl_typeBasicMaxlen(idl_typeBasic(typeDereffered));
            if(maxlen != 0)
            {
                tmpScope = idl_scopeDup(scope);
                containingElement = idl_scopeElementName(idl_scopeCur (scope));
                idl_scopePop(tmpScope);
                isStacDefined = idl_stacListItemIsDefined (idl_stacDefDefGet(), tmpScope, containingElement, name);
                if(isStacDefined && baseStringTypeDereffered)
                {
                    *baseStringTypeDereffered = typeDereffered;
                }
            } /* else stac define status not relevant for this member */
        } /* else stac define status not relevant for this member */
    } /* else stac define status not relevant for this member */
    return isStacDefined;
}
示例#7
0
static c_char *
idl_scopeJavaElementName (
    idl_scopeElement scope)
{
    c_char *scopeName;
    c_char *scopeJavaName;

    scopeName = idl_scopeElementName(scope);
    if ((idl_scopeElementType(scope) == idl_tStruct) ||
	(idl_scopeElementType(scope) == idl_tUnion)) {
	scopeJavaName = os_malloc(strlen(scopeName) + 8);
	sprintf(scopeJavaName, "%sPackage", scopeName);
    } else {
	scopeJavaName = scopeName;
    }
    return scopeJavaName;
}
示例#8
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;
}
示例#9
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;
}