Beispiel #1
0
be_typedef::be_typedef (AST_Type *bt, UTL_ScopedName *n, const UTL_Pragmas &p)
:
   AST_Decl (AST_Decl::NT_typedef, n, p),
   AST_Typedef (bt, n, p),
   m_generateBase (FALSE),
   m_generated (FALSE),
   m_baseBeType (0)
{
   AST_Type* astType = base_type();
   be_array* ba;
   be_sequence* bs;

   localName = local_name()->get_string();
   enclosingScope = be_Type::EnclosingScopeString(this);
   m_baseBeType = get_base_be_type();

   //
   // make sure the base type has a name (if anonymous)
   //

   bs = (be_sequence*)astType->narrow((long) & be_sequence::type_id);
   if (bs)
   {
      m_generateBase = bs->SetName(enclosingScope, localName);
   }
   else if ((ba = (be_array*)astType->narrow((long) & be_array::type_id)))
   {
      m_generateBase = ba->SetName(enclosingScope, localName);
   }

   //
   // now initialize the base's type and typemap
   //
   m_baseBeType->Initialize();

   m_baseBeType->HasTypeDef (pbtrue);

   InitializeTypeMap (this);

   m_typecode = m_baseBeType->m_typecode;
   m_typecode->id = get_decl_pragmas().get_repositoryID()->get_string();
   m_typecode->name_of_type = localName;

   DDS_StdString scopedname = NoColons(enclosingScope + "_" + localName);

   TypeCodeTypeName(BE_Globals::TCPrefix + localName);

   MetaTypeTypeName(BE_Globals::MTPrefix + scopedname);

   TypeCodeRepName(BE_Globals::TCRepPrefix + scopedname);

   TypeCodeBaseName(BE_Globals::TCBasePrefix + scopedname);
}
Beispiel #2
0
be_argument::be_argument
(
   AST_Argument::Direction d,
   AST_Type *ft,
   UTL_ScopedName *n,
   const UTL_Pragmas &p
)
:
   AST_Decl (AST_Decl::NT_argument, n, p),
   AST_Field (AST_Decl::NT_argument, ft, n, p),
   AST_Argument (d, ft, n, p),
   m_beType (0),
   m_direction (d)
{
   AST_Type * at = field_type();
   be_Type * bt;

   if (at && (bt = (be_Type*)at->narrow((long) & be_Type::type_id)))
   {
      const char * typeName = bt->TypeName ();
      if (typeName && strcmp (typeName, "DDS::Any") == 0)
      {
         BE_Globals::inc_any = pbtrue;
      }
   }
}
Beispiel #3
0
void be_argument::Initialize ()
{
   AST_Type * at = field_type();
   be_Type * bt;

   if (at && (bt = (be_Type*)at->narrow((long) & be_Type::type_id)))
   {
      bt->Initialize ();
   }
}
Beispiel #4
0
be_Type*
be_argument::BeType() const
{
   be_Type * ret = 0;
   AST_Type* atype = ((be_argument*)this)->field_type();

   if (atype)
   {
      ret = (be_Type*)atype->narrow((long) & be_Type::type_id);
      assert(ret);
   }

   return ret;
}
Beispiel #5
0
DDS_StdString
be_typedef::Initializer(const DDS_StdString& var, VarType vt) const
{
   AST_Type * basetype = ((be_typedef*)this)->base_type();
   be_enum * basetype_enum = 0;
   be_Type * type;
   DDS_StdString ret;

   assert(basetype && basetype->narrow((long)&be_Type::type_id));

   // This conditional statement here is kludgy.  See comment

   basetype_enum = (be_enum*)basetype->narrow((long) & be_enum::type_id);
   if (basetype_enum)
   {
      ret = var + " = (" + typeName + ")0;";
   }
   else if ((basetype && (type = (be_Type*)basetype->narrow((long) & be_Type::type_id))))
   {
      ret = type->Initializer(var, vt);
   }

   return ret;
}
Beispiel #6
0
AST_Type *
be_typedef::_astBase(AST_Type * ttype)
{
   AST_Type * ret = ttype;

   if (ret)
   {
      AST_Typedef * atd;

      while ((atd = (AST_Typedef*)ret->narrow((long) & AST_Typedef::type_id)))
      {
         ret = atd->base_type();
      }
   }

   return ret;
}
Beispiel #7
0
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);
}