static c_ulong idl_genArrayTotalDimension( idl_typeArray typeArray) { c_ulong result = 0; idl_typeSpec ptr; result = (c_ulong)idl_typeArraySize(typeArray); ptr = idl_typeArrayType(typeArray); while (idl_typeSpecType(ptr) == idl_tarray) { result = result * (c_ulong)idl_typeArraySize(idl_typeArray(ptr)); ptr = idl_typeArrayType(idl_typeArray(ptr)); } return result; }
/* @brief generate dimension of an array slice * * arraySliceDimensions is a local support function to generate * the array dimensions of an array slice * * @param typeArray Specifies the type of the array */ static void idl_arraySliceDimensions( idl_typeArray typeArray) { idl_fileOutPrintf(idl_fileCur(), "[%d]", idl_typeArraySize(typeArray)); if (idl_typeSpecType(idl_typeArrayType(typeArray)) == idl_tarray && idl_typeSpecType(idl_typeArrayType(idl_typeArray(idl_typeArrayType(typeArray)))) == idl_tarray) { idl_arraySliceDimensions(idl_typeArray(idl_typeArrayType(typeArray))); } }
/* @brief generate dimension of an array or a sequence * * java_arrayDimensions is a local support function to generate * the dimensions of a java Array representing an IDL sequence or * array. Since Sequences will always be initialized to 0 elements, * its dimensions will always be assigned 0. Arrays will be assigned * their IDL dimensions. * * @param typeSeq Specifies the type of the sequence */ static void java_arrayDimensions( idl_typeSpec typeSpec) { while (idl_typeSpecType(typeSpec) == idl_ttypedef) { typeSpec = idl_typeDefRefered(idl_typeDef(typeSpec)); } if (idl_typeSpecType(typeSpec) == idl_tarray) { idl_typeArray typeArray = idl_typeArray(typeSpec); idl_fileOutPrintf (idl_fileCur(), "[%d]", idl_typeArraySize(typeArray)); java_arrayDimensions(idl_typeArrayType(typeArray)); } else if (idl_typeSpecType(typeSpec) == idl_tseq) { idl_fileOutPrintf(idl_fileCur(), "[0]"); java_arrayDimensions(idl_typeSeqType(idl_typeSeq(typeSpec))); } }
/* @brief generate dimension of an array * * arrayDimensions is a local support function to generate * the array dimensions of an array * * @param typeArray Specifies the type of the array */ static void idl_arrayDimensions ( idl_typeArray typeArray, os_boolean resolveTypedefs) { idl_typeSpec subType; idl_fileOutPrintf(idl_fileCur(), "[%d]", idl_typeArraySize(typeArray)); subType = idl_typeArrayType(typeArray); while(resolveTypedefs && idl_typeSpecType(subType) == idl_ttypedef) { subType = idl_typeDefResolveFully(subType); } if (idl_typeSpecType(subType) == idl_tarray) { idl_arrayDimensions (idl_typeArray(subType), resolveTypedefs); } }
/* @brief generate initialization of array elements. * * idl_arrayElementInit generates for-loops that initialize * each attribute of an array explicitly. * * @param typeArray Specifies the type of the array */ static void idl_arrayElementInit( idl_typeSpec typeSpec, const char *elementName, int dimCount, int indent) { while (idl_typeSpecType(typeSpec) == idl_ttypedef) { typeSpec = idl_typeDefRefered(idl_typeDef(typeSpec)); } if (idl_typeSpecType(typeSpec) == idl_tarray) { idl_fileOutPrintf( idl_fileCur(), "%*sfor(int i%d = 0; i%d < %d; i%d++) {\n", indent, "", dimCount, dimCount, idl_typeArraySize(idl_typeArray(typeSpec)), dimCount); idl_arrayElementInit( idl_typeArrayType(idl_typeArray(typeSpec)), elementName, dimCount + 1, indent + 4); idl_fileOutPrintf( idl_fileCur(), "%*s}\n", indent, ""); } else { int j; idl_fileOutPrintf( idl_fileCur(), "%*s%s", indent, "", elementName); for (j = 1; j < dimCount; j++) { idl_fileOutPrintf(idl_fileCur(), "[i%d]", j); } if ( idl_typeSpecType(typeSpec) == idl_tbasic && idl_typeBasicType(idl_typeBasic(typeSpec)) == idl_string) { idl_fileOutPrintf( idl_fileCur(), " = \"\";\n"); } else if ( idl_typeSpecType(typeSpec) == idl_tunion || idl_typeSpecType(typeSpec) == idl_tstruct ) { idl_fileOutPrintf( idl_fileCur(), " = new %s();\n", idl_corbaJavaTypeFromTypeSpec(typeSpec)); } else if (idl_typeSpecType(typeSpec) == idl_tenum) { idl_fileOutPrintf( idl_fileCur(), " = %s.from_int(0);\n", idl_corbaJavaTypeFromTypeSpec(typeSpec)); } } }