コード例 #1
0
ファイル: xbe_string.cpp プロジェクト: diorahman/opensplice
be_string::be_string (AST_Expression *v, long wide)
:
   AST_Decl
   (
      AST_Decl::NT_string,
      (wide == 1)
         ? new UTL_ScopedName (new Identifier ("string", 1, 0, I_FALSE), NULL)
         : new UTL_ScopedName (new Identifier("wstring", 1, 0, I_FALSE), NULL)
   ),
   AST_String (v, wide),
   m_wide(wide)
{
   if (wide)
   {
      m_typecode->kind = DDS::tk_wstring;
      m_typecode->id = "DDS::WString";
      localName = "DDS::WString";
   }
   else
   {
      m_typecode->kind = DDS::tk_string;
      m_typecode->id = "DDS::String";
      localName = "DDS::String";
   }

   InitializeTypeMap (this);
}
コード例 #2
0
be_exception::be_exception (UTL_ScopedName *n, const UTL_Pragmas &p)
:
   AST_Decl (AST_Decl::NT_except, n, p),
   UTL_Scope (AST_Decl::NT_except, n, p),
   AST_Structure (AST_Decl::NT_except, n, p),
   m_isFixedLength (TRUE),
   m_elemAlignment (0),
   m_elemSize (0),
   m_marshalInCore (false)
{
   isAtModuleScope (pbfalse);
   const DDS_StdString userException = "DDS::UserException";
   DDS_StdString barScopedName = NameToString(name(), "_");

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

   m_tc_ctor_val = (DDS_StdString) barScopedName + "_ctor";
   m_tc_dtor_val = (DDS_StdString) barScopedName + "_dtor";
   m_tc_put_val = "(DDS::TypeCode::PutFunc) 0";
   m_tc_get_val = "(DDS::TypeCode::GetFunc) 0";
   m_tc_assign_val = (DDS_StdString) barScopedName +
      "_copy";

   SetScopedClassName(ScopedName());
   AddParent (new be_ClassParent (userException, userException, true, false));

   m_typecode->kind = DDS::tk_except;
   m_typecode->id = get_decl_pragmas().get_repositoryID()->get_string();
   m_typecode->name_of_type = localName;

   InitializeTypeMap(this);
}
コード例 #3
0
ファイル: xbe_typedef.cpp プロジェクト: S73417H/opensplice
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);
}
コード例 #4
0
ファイル: xbe_string.cpp プロジェクト: diorahman/opensplice
be_string::be_string (AST_Expression *v)
:
   AST_Decl
   (
      AST_Decl::NT_string,
      new UTL_ScopedName (new Identifier("string", 1, 0, I_FALSE), NULL)
   ),
   AST_String (v),
   m_wide(0)
{
   localName = "DDS::String";
   m_typecode->kind = DDS::tk_string;
   m_typecode->id = "DDS::String";
   m_any_op_id = m_typecode->id;
   InitializeTypeMap(this);
}
コード例 #5
0
ファイル: xbe_enum.cpp プロジェクト: osrf/opensplice
be_enum::be_enum (UTL_ScopedName *n, const UTL_Pragmas &p)
:
   AST_Decl (AST_Decl::NT_enum, n, p),
   UTL_Scope (AST_Decl::NT_enum, n, p),
   AST_Enum (n, p)
{
   isAtModuleScope(pbfalse);
   DDS_StdString barScopedName = NameToString(name(), "_");

   m_swapCall = "SWAP32";
   localName = local_name()->get_string();
   enclosingScope = be_Type::EnclosingScopeString(this);
   m_typecode->kind = DDS::tk_enum;
   m_typecode->id = get_decl_pragmas().get_repositoryID()->get_string();
   m_typecode->name_of_type = localName;
   m_tc_put_val = (DDS_StdString) "DDS_put_" + barScopedName + "_param";
   m_tc_get_val = (DDS_StdString) "DDS_get_" + barScopedName + "_param";
   m_any_op_id = barScopedName;
   InitializeTypeMap(this);
   be_root::AddTypeThatNeedsProtoTypeCodeFinished(*this);
}
コード例 #6
0
ファイル: xbe_sequence.cpp プロジェクト: cynron/opensplice
void
be_sequence::GenerateTypedefs(const DDS_StdString &scope,
                              const be_typedef& alias,
                              be_ClientHeader& source)
{
   ostream & os = source.Stream();
   be_Tab tab(source);
   DDS_StdString relTypeName = BE_Globals::RelativeScope(scope, typeName);

   os << tab << "typedef " << relTypeName << " "
   << alias.LocalName() << ";" << nl;
   os << tab << "typedef " << relTypeName << DDSVarExtension
   << " " << alias.LocalName() << DDSVarExtension << ";" << nl;
   os << tab << "typedef " << relTypeName << DDSOutExtension
   << " " << alias.LocalName() << DDSOutExtension << ";" << nl;

   if (anonymous)
   {
      localName = alias.LocalName ();
      anonymous = pbfalse;
      InitializeTypeMap (this);
   }
}
コード例 #7
0
ファイル: xbe_structure.cpp プロジェクト: xrl/opensplice_dds
be_structure::be_structure(UTL_ScopedName *n, const UTL_Pragmas &p)
   :
   AST_Decl (AST_Decl::NT_struct, n, p),
   UTL_Scope (AST_Decl::NT_struct, n, p),
   m_isFixedLength (pbtrue),
   m_elemAlignment (0),
   m_maxElemAlignment (1),
   m_elemSize (0),
   m_canOptimize (pbfalse),
   m_lastFieldSize (0),
   m_cppScope (g_feScopeStack.Top()),
   m_cppType (g_feScopeStack.Top(), *n),
   m_interface_dependant (pbfalse)
{
   DDS_StdString barScopedName = NameToString(name(), "_");
   isAtModuleScope(pbfalse);

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

   m_tc_ctor_val = (DDS_StdString) barScopedName + "_ctor";
   m_tc_dtor_val = (DDS_StdString) barScopedName + "_dtor";
   m_tc_put_val = (DDS_StdString) barScopedName + "_put";
   m_tc_get_val = (DDS_StdString) barScopedName + "_get";
   m_tc_assign_val = (DDS_StdString) barScopedName + "_copy";

   m_any_op_id = barScopedName;
   m_nullArg = (DDS_StdString)"*(new " + ScopedName() + ")";
   m_typecode->kind = DDS::tk_struct;
   m_typecode->id = get_decl_pragmas().get_repositoryID()->get_string();
   m_typecode->name_of_type = localName;
   m_marshalInCore = FALSE;

   InitializeTypeMap(this);

   be_CppFwdDecl::Add(be_CppFwdDecl::STRUCT, this, m_cppScope);
}
コード例 #8
0
ファイル: xbe_sequence.cpp プロジェクト: cynron/opensplice
void
be_sequence::init_type(const DDS_StdString& scope,
                       const DDS_StdString& name)
{
   enclosingScope = scope;
   localName = name;

   m_tc_ctor_val = NoColons((DDS_StdString) Scope(localName) + "_ctor");
   m_tc_dtor_val = NoColons((DDS_StdString) Scope(localName) + "_dtor");
   if (local() != I_TRUE)
   {
      m_tc_put_val = NoColons((DDS_StdString) Scope(localName) + "_put");
      m_tc_get_val = NoColons((DDS_StdString) Scope(localName) + "_get");
   }
   else
   {
      m_tc_put_val = (DDS_StdString)"0";
      m_tc_get_val = (DDS_StdString)"0";
   }
   m_tc_assign_val = NoColons((DDS_StdString)
                              Scope(localName) + "_copy");

   InitializeTypeMap(this);
}
コード例 #9
0
AST_Field *
be_exception::add_field(AST_Field *af)
{
   if (AST_Structure::add_field(af))
   {
      be_field * field = be_field::_narrow (af);

      if (field)
      {
         field->initialize();

         if (IsFixedLength() && !field->IsFixedLength())
         {
            is_fixed_length (false);
            InitializeTypeMap(this);
         }

         //
         // note the alignment of the first field
         //
         if (!m_fields.size())
         {
            m_elemAlignment = field->get_elem_alignment();
         }

         //
         // don't forget to add the padding!!!
         //
         DDS::ULong fieldPad = (field->get_elem_size()) ?
                                 m_elemSize % field->get_elem_size() :
                                 4;

         //
         // now update the element size
         //
         m_elemSize += fieldPad + field->get_elem_size();

         //
         // determine if marshaling should be done in the core
         //
         if (field->is_core_marshaled())
         {
            m_marshalInCore = TRUE;
         }

         //
         // add field to our list for marshaling
         //
         m_fields.push_back(field);
      }

      //
      // add to typecode
      //
      m_typecode->members.push_back(field->get_be_type()->m_typecode);

      m_typecode->member_names.push_back(field->get_local_name());

      return af;
   }

   return 0;
}
コード例 #10
0
ファイル: xbe_structure.cpp プロジェクト: xrl/opensplice_dds
AST_Field *
be_structure::add_field(AST_Field *af)
{
   if (AST_Structure::add_field(af))
   {
      be_field * field;

      if ((field = be_field::_narrow(af)))
      {
         field->initialize();

         //
         // re-initialize typemap
         //

         if (m_isFixedLength && !field->IsFixedLength())
         {
            is_fixed_length(FALSE);
            InitializeTypeMap(this);
         }

         //
         // determine if marshaling should be done in the core
         //
         if (field->is_core_marshaled())
         {
            m_marshalInCore = TRUE;
         }

         //
         // update type stats
         //
         if (!m_fields.size())
         {
            m_elemAlignment = field->get_elem_alignment();
         }

         //
         // don't forget to add the padding!!!
         //
         DDS::ULong alignment = field->get_elem_alignment();
         DDS::ULong osAlignment = field->get_OS_elem_alignment();
         if ((alignment == osAlignment) || ( m_elemSize % alignment == 0))
         {
            DDS::ULong fieldPad = (alignment) ?
               (alignment - m_elemSize % alignment) % alignment :
               4;
            DDS::ULong maxAlign = alignment;
            be_structure * structField;
            if ((structField = be_structure::_narrow( af->field_type() )))
            {
               maxAlign = structField->get_max_elem_alignment();
            }
            
            m_maxElemAlignment = ( m_maxElemAlignment > maxAlign ) 
               ? m_maxElemAlignment 
               : maxAlign;
            
            
            be_array * t_array = 0;
            
            be_Type* type = field->get_be_type();

            m_interface_dependant |= type->IsInterfaceDependant ();
            
            be_typedef* pTypedef;

            //
            // dealias typedefs
            //
            do
            {
               pTypedef = (be_typedef*) (type->narrow((long) & be_typedef::type_id));
               
               if (pTypedef != 0)
               {
                  type = pTypedef->get_base_be_type();
               }
            }
            while (pTypedef != 0);
            
            DDS::ULong fieldSize = field->get_elem_size();
            if (fieldSize == 0)
            {
               m_elemSize = 0;
            }
            else if (m_elemSize > 0 || (m_elemSize == 0 && !m_fields.size()))
            {
               m_elemSize += fieldPad;
               
               //  
               // check for array
               //
               if ((t_array = (be_array*)(type->narrow((long) & be_array::type_id))))
               {
                  m_elemSize += fieldSize * t_array->MatrixSize();
               }
               else
               {
                  m_elemSize += fieldSize;
               }
            }

            //
            // check to see if we can optimize streaming
            //
            if (!m_fields.size())
            {
               // first time through, set to true
               m_canOptimize = TRUE;
            }

            if (!type->IsOptimizable())
            {
               m_canOptimize = FALSE;
            }
         }
         else
         {
            m_elemSize = 0;
         }

         // set m_lastFieldSize to new value;
         m_lastFieldSize = field->get_elem_size();

         //
         // add to our own field list
         //
         m_fields.push_back(field);

         //
         // add to the TypeCode
         //
         m_typecode->members.push_back(field->get_be_type()->m_typecode);

         m_typecode->member_names.push_back(field->get_local_name());
      }

      return af;
   }

   return 0;
}