Exemple #1
0
DDS_StdString
be_Type::EnclosingScopeString(AST_Decl * decl)
{
   DDS_StdString ret;

   assert(decl);

   if (decl)
   {
      UTL_Scope * enclosingScope = decl->defined_in();
      AST_Decl * enclosingDecl;

      if (enclosingScope)
      {
         if ((enclosingDecl = (AST_Decl*)enclosingScope->narrow((long) & AST_Decl::type_id)))
         {
            ret = NameToString(enclosingDecl->name(), 0);
         }
         else
         {
            DDSError((DDS_StdString)"Can't narrow enclosing scope for " + NameToString(decl->name(), 0));
         }
      }
   }

   return ret;
}
Exemple #2
0
be_operation::be_operation 
(
   AST_Type * rt,
   AST_Operation::Flags fl,
   UTL_ScopedName * n,
   const UTL_Pragmas & p
)
:
   AST_Decl (AST_Decl::NT_op, n, p),
   UTL_Scope (AST_Decl::NT_op, n, p),
   AST_Operation (rt, fl, n, p),
   returnType (0),
   n_InArgs (0),
   n_OutArgs (0),
   n_InOutArgs (0),
   n_Args (0)
{
   assert (return_type ());

   isAtModuleScope (pbfalse);

   if (return_type ())
   {
      returnType = (be_DispatchableType *) return_type ()->
         narrow ((long) &be_DispatchableType::type_id);

      const char * typeName = returnType->TypeName ();

      if (typeName && strcmp (typeName, "DDS::Any") == 0)
      {
         BE_Globals::inc_any = pbtrue;
      }
   }
   else
   {
      DDSError ((DDS_StdString) "unknown return type for operation " +
                LocalName ());
   }

   enclosingScope = be_Type::EnclosingScopeString (this);
   stubClassname = enclosingScope + DDSStubExtension;
   opKey = NameToString (name (), "_");
}
Exemple #3
0
be_attribute::be_attribute
(
   idl_bool ro,
   AST_Type *ft,
   UTL_ScopedName *n,
   const UTL_Pragmas &p
)
:
   AST_Decl (AST_Decl::NT_attr, n, p),
   AST_Field (AST_Decl::NT_attr, ft, n, p),
   AST_Attribute (ro, ft, n, p),
   fieldType (0),
   m_getDispatchDone (FALSE),
   m_setDispatchDone (FALSE)
{
   assert(field_type());

   isAtModuleScope(pbfalse);

   if (field_type())
   {
      fieldType =
         (be_DispatchableType*)field_type()->narrow((long) & be_Type::type_id);
      assert(fieldType);
      const char * typeName = fieldType->TypeName ();
      if (typeName && strcmp (typeName, "DDS::Any") == 0)
      {
         BE_Globals::inc_any = pbtrue;
      }
   }
   else
   {
      DDSError((DDS_StdString)"unknown field type for attribute " + LocalName());
   }

   enclosingScope = be_Type::EnclosingScopeString(this);
   setOpKey = (DDS_StdString) "_set_" + LocalName();
   getOpKey = (DDS_StdString) "_get_" + LocalName();
}
Exemple #4
0
void
be_enum::Generate(be_ClientHeader& source)
{
   if (!Generated())
   {
      UTL_ScopeActiveIterator* i = new UTL_ScopeActiveIterator(this, IK_decls);
      ostream & os = source.Stream();
      unsigned long expectedValue = 0;
      be_Tab tab(source);
      AST_Decl * d;

      Generated(pbtrue);

      os << tab << "enum " << *local_name() << nl;
      os << tab << "{" << nl;
      tab.indent();

      while (!(i->is_done()))
      {
         d = i->item ();
         if (d)
         {
            be_enum_val * ev = (be_enum_val*) d->narrow ((long) & be_enum_val::type_id);

            if (ev)
            {
               os << tab << *ev->local_name();

               if (ev->Value() != expectedValue)
               {
                  expectedValue = ev->Value();
                  os << " = " << expectedValue;
               }

               expectedValue++;

               i->next();

               if (!(i->is_done()))
               {
                  os << ",";
               }

               os << nl;
            }
            else
            {
               DDSError(NameToString(name()) + " contains non-enum val");
               assert(pbfalse);
            }
         }
         else
         {
            DDSError(NameToString(name()) + " declaration is corrupted");
            assert(pbfalse);
         }
      }

      //os << tab << "DDS_DCPS_FORCE_ENUM32(__" << *local_name() << ")" << nl;

      tab.outdent();
      os << tab << "};" << nl;

      delete i;

      // GENERATE STREAMING OPERATORS
      be_root::AddAnyOps(*this);
      be_root::AddPutGetOps(*this);
      be_root::AddStreamOps(*this);
      be_root::AddTypedef(*this);
      be_root::AddTypecode(*this);
   }
}