be_sequence::be_sequence (AST_Expression *v, AST_Type *t) : AST_Decl ( AST_Decl::NT_sequence, new UTL_ScopedName (new Identifier ("sequence", 1, 0, I_FALSE), NULL) ), AST_Sequence(v, t), initialized (pbfalse), maxSize (0), anonymous (pbtrue), deferred (pbfalse), isPrimitiveSeq (pbfalse), isStringSeq (pbfalse), isInterfaceSeq (pbfalse), baseType (0) { // NOTE: BASE TYPE AND MAX SIZE ARE KNOWN assert(base_type()); assert(max_size()); static int sequence_count = 0; isAtModuleScope(pbfalse); idlType = this; if (base_type()) { baseType = be_Type::_narrow(base_type()); baseType = baseType->idlType; isStringSeq = baseType->IsStringType(); isInterfaceSeq = baseType->IsInterfaceType(); isValueSeq = baseType->IsValueType(); isPrimitiveSeq = (baseType->IsPrimitiveType() && baseType->IsFixedLength() // eliminates ANY, etc.. && !baseType->IsEnumeratedType()); // Sequence of Typecode mem leak fix eCPP896 be_predefined_type * pdt = be_predefined_type::_narrow(base_type()); if (pdt && (pdt->pt() == AST_PredefinedType::PT_typecode)) { isInterfaceSeq = TRUE; } } else { UTL_Error* oops = new UTL_Error; oops->error0(UTL_Error::EIDL_LOOKUP_ERROR); delete oops; } if (baseType->IsExceptionType()) { UTL_Error* oops = new UTL_Error; oops->error0(UTL_Error::EIDL_ILLEGAL_USE); delete oops; } maxSize = ExprToULong(max_size()); if (baseType) { be_Type * unaliasedBase = be_typedef::_beBase(base_type()); baseTypeName = baseType->SequenceMemberTypeName(); // // create type id (YO maybe should be the same as the equivalence id // localName = (DDS_StdString)"_s_" + baseType->TypeName() + "_"; localName += BE_Globals::int_to_string(MaxSize()); ColonToBar((char *)localName); // // create operational type equivalence id // m_any_op_id = (DDS_StdString)"_s_" + unaliasedBase->any_op_id() + "_"; m_any_op_id += BE_Globals::int_to_string(MaxSize()) + "_"; m_any_op_id += BE_Globals::int_to_string(sequence_count++); ColonToBar((char *)m_any_op_id); } // initialize typecode m_typecode->kind = DDS::tk_sequence; m_typecode->members.push_back(baseType->m_typecode); m_typecode->bounds = MaxSize(); m_typecode->length = 0; if (!IsBounded()) { m_typecode->bounds = 0; } if (isStringSeq) { m_typecode->id = "SEQ_DDS::String_" + BE_Globals::ulong_to_string(m_typecode->bounds); } init_type (enclosingScope, localName); }
void be_string::InitializeTypeMap (be_Type* t) { idlType = t; AST_Expression* maxsize = 0; be_string* t_string = 0; be_typedef* t_typedef = 0; DDS_StdString corbaString; DDS_StdString stringInOut; DDS_StdString stringOut; DDS_StdString structStringVar; if (m_typecode->kind == DDS::tk_string) { corbaString = BE_Globals::CorbaScope("String"); stringInOut = BE_Globals::CorbaScope("String&"); stringOut = BE_Globals::CorbaScope("String_out"); structStringVar = BE_Globals::CorbaScope ("String_mgr"); } else { corbaString = BE_Globals::CorbaScope ("WString"); stringInOut = BE_Globals::CorbaScope ("WString&"); stringOut = BE_Globals::CorbaScope ("WString_out"); structStringVar = BE_Globals::CorbaScope ("WString_var"); } char size[10]; os_sprintf (size, "%d", (int) ExprToULong(maxsize)); t_typedef = (be_typedef*)t->narrow((long) & be_typedef::type_id); if (t_typedef) { AST_Type * t_ast = (AST_Type*)t->narrow((long) & AST_Type::type_id); AST_Type * basetype; AST_String * realbasetype; (void) t_ast; assert (t_ast); basetype = be_typedef::_astBase(((AST_Typedef*)t->narrow((long) & AST_Typedef::type_id))->base_type()); assert(basetype); realbasetype = (AST_String*)basetype->narrow((long) & AST_String::type_id); assert(realbasetype); maxsize = realbasetype->max_size(); corbaString = t->Scope(t->LocalName()); stringInOut = corbaString + "&"; stringOut = corbaString + DDSOutExtension; t->TypeCodeTypeName(BE_Globals::TCPrefix + t->LocalName()); // t->MetaTypeTypeName(BE_Globals::MTPrefix + NameToString(t_ast->name(),"_")); t->MetaTypeTypeName("xps_mt_DDS::String"); } else { t_string = (be_string*)t->narrow((long) & be_string::type_id); assert(t_string); maxsize = t_string->max_size(); // YO JFG 2/14/99 modified this // t->TypeCodeTypeName((DDS_StdString)"DDSTypeCodeFactory::createTypeCode(DDS::tk_string," + size + ")"); if (m_typecode->kind == DDS::tk_string) { t->TypeCodeTypeName ("DDS::_tc_string"); } else { t->TypeCodeTypeName ("DDS::_tc_wstring"); } } t->TypeName(corbaString); if (m_typecode->kind == DDS::tk_string) { t->InTypeName ((DDS_StdString)"const char *"); // NOTE: != const corbaString; } else { t->InTypeName ((DDS_StdString)"const WChar *"); // NOTE: != const corbaString; } t->InOutTypeName (stringInOut); t->OutTypeName (stringOut); t->ReturnTypeName (stringOut); t->DMFAdtMemberTypeName (corbaString); t->StructMemberTypeName (structStringVar); t->UnionMemberTypeName (corbaString); t->SequenceMemberTypeName (corbaString); if (m_typecode->kind == DDS::tk_string) { t->VarSignature(VT_InParam, "DDS::Char", VT_Const, VT_Pointer, VT_NonReference); } else { t->VarSignature(VT_InParam, "DDS::WChar", VT_Const, VT_Pointer, VT_NonReference); } t->VarSignature (VT_InOutParam, stringInOut, VT_NonConst, VT_Var, VT_NonReference); t->VarSignature (VT_OutParam, stringOut, VT_NonConst, VT_Var, VT_NonReference); t->VarSignature (VT_Return, t->TypeName(), VT_NonConst, VT_Var, VT_NonReference); }