当前位置: 首页>>代码示例>>C++>>正文


C++ AST_Decl::narrow方法代码示例

本文整理汇总了C++中AST_Decl::narrow方法的典型用法代码示例。如果您正苦于以下问题:C++ AST_Decl::narrow方法的具体用法?C++ AST_Decl::narrow怎么用?C++ AST_Decl::narrow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AST_Decl的用法示例。


在下文中一共展示了AST_Decl::narrow方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

void
be_CodeGenerator::Generate(be_ClientImplementation& source)
{
   UTL_ScopeActiveIterator* i;
   AST_Decl * d;
   UTL_Scope * s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id);

   if (s)
   {
      i = new UTL_ScopeActiveIterator(s, UTL_Scope::IK_decls);

      while (!(i->is_done()))
      {
         be_CodeGenerator * cg;

         d = i->item();

         if (!d->imported() &&
             (cg = (be_CodeGenerator*)d->narrow((long) & be_CodeGenerator::type_id)))
         {
            cg->Generate(source);
         }

         i->next();
      }

      delete i;
   }
   else
   {
      assert(pbfalse);
   }
}
开发者ID:xrl,项目名称:opensplice_dds,代码行数:33,代码来源:xbe_codegen.cpp

示例2: GenerateAssignmentOperator

void be_exception::GenerateAssignmentOperator (be_ClientImplementation& source)
{
   ostream & os = source.Stream ();
   DDS_StdString that ("");
   be_Type * btype;

   if (nmembers ())
   {
      that = " that";
   }

   os << ScopedName () << " & "
      << ScopedName () << "::operator = (const "
      << LocalName () << " &" << that << ")" << nl;
   os << "{" << nl;

   UTL_Scope * s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id);
   assert (s);

   UTL_ScopeActiveIterator *it;

   // Iterate through decls

   for 
   (
      it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls);
      ! it->is_done ();
      it->next ()
   )
   {
      AST_Decl * adecl = it->item ();
      assert (adecl);

      be_field *bfield = (be_field *) adecl->narrow ((long) & be_field::type_id);

      if (bfield)
      {
         btype = bfield->get_be_type ();
         if (btype && btype->IsArrayType ())
         {
            // Need to copy array elements

            os << "   "
               << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->StructMemberTypeName ())
               << "_copy (" << bfield->get_local_name () 
               << ", that." << bfield->get_local_name () << ");" << nl;
         }
         else
         {
            os << "   " << bfield->get_local_name () << " = that."
               << bfield->get_local_name() << ";" << nl;
         }
      }
   }

   delete it;

   os << "   return *this;" << nl;
   os << "}" << nl << nl;
}
开发者ID:diorahman,项目名称:opensplice,代码行数:60,代码来源:xbe_exception.cpp

示例3: GenerateGlobalDecls

void be_root::GenerateGlobalDecls (be_ClientHeader & source)
{
   UTL_ScopeActiveIterator * i;
   be_CodeGenerator * cg;
   AST_Decl * d;
   UTL_Scope * s = (UTL_Scope*) narrow ((long) & UTL_Scope::type_id);

   if (s)
   {
      // Iterate through decls

      i = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls);

      while (!(i->is_done ()))
      {
         d = i->item ();

         if (!d->imported ())
         {
            cg = (be_CodeGenerator*) d->narrow
               ((long) & be_CodeGenerator::type_id);

            if (cg)
            {
               cg->Generate (source);
            }
         }

         i->next ();
      }

      delete i;
   }
}
开发者ID:osrf,项目名称:opensplice,代码行数:34,代码来源:xbe_root.cpp

示例4: GenerateGlobalTypes

void be_root::GenerateGlobalTypes (be_ClientHeader& source)
{
   UTL_ScopeActiveIterator * i;
   be_CodeGenerator * cg;
   AST_Decl * d;
   be_Type * bt;
   DDS_StdString scope;
   UTL_Scope * s = (UTL_Scope*) narrow ((long) & UTL_Scope::type_id);

   if (s)
   {
      // Iterate through types

      i = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_localtypes);

      while (! i->is_done ())
      {
         d = i->item ();

         if (! d->imported ())
         {
            cg = (be_CodeGenerator*) d->narrow
               ((long) & be_CodeGenerator::type_id);
            if (cg)
            {
               bt = (be_Type*) d->narrow ((long) & be_Type::type_id);

               scope = bt->EnclosingScope ();
               if (! bt->HasTypeDef () && scope == NULL)
               {
                  cg->Generate (source);
               }
            }
         }

         i->next ();
      }

      delete i;
   }
}
开发者ID:osrf,项目名称:opensplice,代码行数:41,代码来源:xbe_root.cpp

示例5: Generate

void be_structure::Generate (be_ClientImplementation & source)
{
   UTL_ScopeActiveIterator * i;
   AST_Decl * d;
   UTL_Scope * s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id);

   if (BE_Globals::ignore_interfaces && IsInterfaceDependant ())
   {
      return;
   }

   if (s)
   {
      i = new UTL_ScopeActiveIterator(s, UTL_Scope::IK_localtypes);

      while (!(i->is_done()))
      {
         be_CodeGenerator * cg;

         d = i->item();

         if (!d->imported() &&
               (cg = (be_CodeGenerator*)d->narrow((long) & be_CodeGenerator::type_id)))
         {
            cg->Generate (source);
         }

         i->next();
      }

      delete i;
   }
   else
   {
      assert(pbfalse);
   }
}
开发者ID:xrl,项目名称:opensplice_dds,代码行数:37,代码来源:xbe_structure.cpp

示例6: iter

void
be_CodeGenerator::Generate(be_ClientHeader& source)
{
   UTL_Scope* s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id);
   assert(s);

   // ITERATE THROUGH DECLS
   UTL_ScopeActiveIterator iter(s, UTL_Scope::IK_both);

   while (!(iter.is_done()))
   {
      be_CodeGenerator* cg;

      AST_Decl* d = iter.item();

      if (!d->imported() &&
          (cg = (be_CodeGenerator*)d->narrow((long) & be_CodeGenerator::type_id)))
      {
         cg->Generate(source);
      }

      iter.next();
   }
}
开发者ID:xrl,项目名称:opensplice_dds,代码行数:24,代码来源:xbe_codegen.cpp

示例7: tab

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);
   }
}
开发者ID:osrf,项目名称:opensplice,代码行数:73,代码来源:xbe_enum.cpp

示例8: GenerateConvenienceConstructor

void be_exception::GenerateConvenienceConstructor (be_ClientImplementation & source)
{
   ostream & os = source.Stream ();
   const char * argPrefix = "_";
   pbbool first = pbtrue;
   be_Tab tab (source);
   be_Type * btype;

   os << ScopedName () << "::" << LocalName () << " (";

   UTL_Scope * s = (UTL_Scope*)narrow ((long) & UTL_Scope::type_id);
   assert (s);

   // Iterate through decls

   UTL_ScopeActiveIterator * it;

   for
   (
      it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls);
      !it->is_done ();
      it->next ()
   )
   {
      AST_Decl * adecl = it->item ();
      assert (adecl);

      be_field *bfield = (be_field *)adecl->narrow ((long) & be_field::type_id);

      if (bfield)
      {
         btype = bfield->get_be_type ();

         if (!first)
         {
            os << ", ";
         }

         first = pbfalse;

         if (btype && btype->IsStringType ())
         {
            // Strings are special case

            os << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->InTypeName ());
         }
         else
         {
            os << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->StructMemberTypeName ());
         }

         os << " " << argPrefix << (char*) bfield->get_local_name ();
      }
   }
   delete it;

   os << ")" << nl;

   // Iterate thru members initializing

   if (nmembers ())
   {
      source.Indent ();

      first = pbtrue;

      for
      (
         it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls);
         !it->is_done ();
         it->next ()
      )
      {
         AST_Decl * adecl = it->item ();
         assert (adecl);

         be_field *bfield = (be_field *)adecl->narrow ((long) & be_field::type_id);

         if (bfield)
         {
            btype = bfield->get_be_type ();

            // Array members are assigned in body of method

            if (btype && ! btype->IsArrayType ())
            {
               if (first)
               {
                  first = pbfalse;
                  os << "   : " << nl;
               }
               else
               {
                  os << "," << nl;
               }

               os << "   " << (char*) bfield->get_local_name () << "(" << argPrefix
               << (char*) bfield->get_local_name () << ")";
            }
         }
//.........这里部分代码省略.........
开发者ID:diorahman,项目名称:opensplice,代码行数:101,代码来源:xbe_exception.cpp

示例9: UTL_ScopeActiveIterator

DDS_StdString be_operation::DirectSignature
(
   OP_SignatureType sigType,
   const DDS_StdString & implclassname
)
{
   UTL_ScopeActiveIterator *i =
      new UTL_ScopeActiveIterator (this, IK_decls);
   ostringstream os;
   pbbool first = pbtrue;
   DDS_StdString ret;
   AST_Decl *d;

   // GENERATE RETURN TYPE

   if (sigType != OP_Invoke)
   {
      assert (returnType);
      os << returnType->MakeSignature (VT_Return, "") << " ";
   }

   if (sigType != OP_Declaration)
   {
      os << implclassname << "::";
   }

   // OP NAME
   os << LocalName ();

   // GENERATE PARAMETER LIST
   os << "(";

   for (; !(i->is_done ()); i->next ())
   {
      be_argument *arg;

      d = i->item ();

      arg = (be_argument *) d->narrow ((long) &be_argument::type_id);
      if (arg)
      {
         if (!first)
            os << ", ";

         first = pbfalse;

         if (sigType != OP_Invoke)
         {
            os << arg->Signature ("");
         }

         os << " " << *arg->local_name ();
      }
   }

   delete i;

#if defined(CONTEXT_SUPPORT)
   // ADD CONTEXT

   if (context ())
   {
      if (!first)
      {
         os << ", ";
      }

      first = pbfalse;

      if (sigType != OP_Invoke)
      {
         os << BE_Globals::CorbaScope ("Context_ptr");
      }

      os << " " << DDSCtxVar;
   }

#endif

   if (sigType == OP_Invoke)
   {
      if (!first)
      {
         os << XBE_Ev::arg (XBE_ENV_VARN);
      }
      else
      {
         os << XBE_Ev::arg (XBE_ENV_VAR1);
      }
   }
   else
   {
      if (!first)
      {
         os << XBE_Ev::arg (XBE_ENV_ARGN);
      }
      else
      {
         os << XBE_Ev::arg (XBE_ENV_ARG1);
      }
//.........这里部分代码省略.........
开发者ID:xrl,项目名称:opensplice_dds,代码行数:101,代码来源:xbe_operation.cpp

示例10: if

DDS_StdString
be_operation::ReplySignature
  (ExceptionStatus excStat, OP_SignatureType sigType)
{
  UTL_ScopeActiveIterator *i = new UTL_ScopeActiveIterator (this, IK_decls);
  ostringstream os;
  DDS_StdString ret = "";
  AST_Decl *d;
  DDS_StdString op_suffix = "";

  // VOID RETURN

  if (sigType == OP_Declaration || sigType == OP_Implementation)
    {
      os << "void ";
    }

  if (excStat == OP_NoException)
    {
      // no suffix
    }
  else if (excStat == OP_Exception)
    {
      op_suffix = "_exc";
    }
  else
    {
      op_suffix = "_retry";
    }

  // OP NAME
  os << "handle_" << LocalName () << op_suffix;

  // GENERATE PARAMETER LIST
  os << "(";

  os << "DDS::Codec::RequestId rid, ";

  os << "DDS::Stub_ptr stub";

  if (excStat == OP_NoException)
    {
      // GENERATE RETURN

      if (HasReturn ())
        {
          assert (returnType);
          os << ", ";

          if (returnType->IsFixedLength () && returnType->IsStructuredType ())
            {
              os << returnType->MakeSignature (VT_InOutParam, "");
            }
          else
            {
              os << returnType->MakeSignature (VT_Return, "");
            }
        }

      for (; !(i->is_done ()); i->next ())
        {
          be_argument *arg;

          d = i->item ();

          arg = (be_argument *) d->narrow ((long) &be_argument::type_id);
          if (arg)
            {
              if (arg->is_out_arg () || arg->is_inout_arg ())
                {
                  be_Type *argtype = be_Type::_narrow (arg->field_type ());

                  os << ", ";

                  if (sigType != OP_Invoke)
                    {
                      if (argtype->IsFixedLength ()
                          && argtype->IsStructuredType ())
                        {
                          os << argtype->MakeSignature (VT_InOutParam, "");
                        }
                      else
                        {
                          os << argtype->MakeSignature (VT_Return, "");
                        }
                    }

                  os << " " << *arg->local_name ();
                }
            }
        }

      delete i;
      os << ")" << ends;
    }
  else if (excStat == OP_Exception)
  {
     os << ", DDS::Exception & exception)" << ends;
  }
  else                          // (excStat == OP_Retry)
//.........这里部分代码省略.........
开发者ID:xrl,项目名称:opensplice_dds,代码行数:101,代码来源:xbe_operation.cpp

示例11: StubSignature

DDS_StdString be_operation::StubSignature (OP_SignatureType sigType)
{
   UTL_ScopeActiveIterator * i = new UTL_ScopeActiveIterator (this, IK_decls);
   ostringstream os;
   pbbool first = pbtrue;
   DDS_StdString ret;
   AST_Decl * d;

   // Generate return type

   assert (returnType);

   if (sigType == OP_Implementation)
   {
      os << returnType->MakeSignature (VT_Return, "") << " " << nl;
   }
   else
   {
      os << returnType->MakeSignature (VT_Return, iface->ScopedName ()) << " ";
   }

   // Op name

   if (sigType == OP_Implementation)
   {
      os << iface->Scope (iface->StubClassname ()) << "::" << LocalName ();
   }
   else
   {
      os << LocalName ();
   }

   // Generate parameter list

   os << " (";

   for (; !(i->is_done ()); i->next ())
   {
      be_argument * arg;

      d = i->item ();

      arg = (be_argument *) d->narrow ((long) &be_argument::type_id);
      if (arg)
      {
         if (!first)
         {
            os << ", ";
         }

         first = pbfalse;
         os << arg->Signature (iface->ScopedName ());
         os << " " << *arg->local_name ();
      }
   }

   delete i;

#if defined (CONTEXT_SUPPORT)

   // Add context

   if (context ())
   {
      if (!first)
      {
         os << ", ";
      }

      first = pbfalse;

      os << BE_Globals::CorbaScope ("Context_ptr");
      os << " " << DDSCtxVar;
   }

#endif

   if (!first)
   {
      os << XBE_Ev::arg (XBE_ENV_ARGN);
   }
   else
   {
      os << XBE_Ev::arg (XBE_ENV_ARG1);
   }

   os << ")" << ends;

   ret = os.str().c_str();
   return ret;
}
开发者ID:xrl,项目名称:opensplice_dds,代码行数:91,代码来源:xbe_operation.cpp

示例12: ScopedBaseRequestCall

DDS_StdString be_operation::ScopedBaseRequestCall ()
{
  UTL_ScopeActiveIterator *
    i = new UTL_ScopeActiveIterator (this, IK_decls);
  ostringstream
    os;
  pbbool
    first = pbtrue;
  DDS_StdString
    ret;
  AST_Decl *
    d;

  DDS_StdString
    ifaceBasename_nocolons = NoColons (iface->ScopedName ());

  if (ifaceBasename_nocolons.length ())
    {
      os << ifaceBasename_nocolons << "::" << LocalName ();
    }
  else
    {
      os << LocalName ();
    }

  // GENERATE PARAMETER LIST
  os << "(";

  for (; !(i->is_done ()); i->next ())
    {
      be_argument *
        arg;

      d = i->item ();

      arg = (be_argument *) d->narrow ((long) &be_argument::type_id);
      if (arg)
        {
          if (!first)
            {
              os << ", ";
            }
          first = pbfalse;

          os << " " << arg->LocalName ();
        }
    }

  delete
    i;

  // ADD CONTEXT

  if (context ())
    {
      if (!first)
        os << ", ";

      first = pbfalse;

      os << " " << DDSCtxVar;
    }

  // THIS IS FOR PROPERTIES
  if (!first)
    os << ", ";

  os << "0";

  first = pbfalse;

  os << ")" << ends;

  ret = os.str().c_str();
  return ret;
}
开发者ID:xrl,项目名称:opensplice_dds,代码行数:76,代码来源:xbe_operation.cpp

示例13: assert

DDS_StdString be_operation::BaseSignature 
   (const DDS_StdString & implclassname)
{
   UTL_ScopeActiveIterator *
      i = new UTL_ScopeActiveIterator (this, IK_decls);
   ostringstream os;
   pbbool first = pbtrue;
   DDS_StdString ret;
   AST_Decl * d;
   bool fullScope = (iface->BaseClassname () != implclassname);

   // GENERATE RETURN TYPE
   assert (returnType);

   if (fullScope)
   {
      os << returnType->MakeSignature (VT_Return, "") << " ";
   }
   else
   {
      os << returnType->MakeSignature (VT_Return,
                                       iface->ScopedName ()) << " ";
   }

   os << LocalName ();

   // GENERATE PARAMETER LIST
   os << " (";

   for (; !(i->is_done ()); i->next ())
   {
      be_argument *arg;

      d = i->item ();

      arg = (be_argument *) d->narrow ((long) &be_argument::type_id);
      if (arg)
      {
         if (!first)
            os << ", ";

         first = pbfalse;

         if (fullScope)
         {
            os << arg->Signature ("");
         }
         else
         {
            os << arg->Signature (iface->ScopedName ());
         }

         os << " " << *arg->local_name ();
      }
   }

   delete i;

#if defined(CONTEXT_SUPPORT)
   //
   // add context
   //

   if (context ())
   {
      if (!first)
      {
         os << ", ";
      }

      first = pbfalse;

      os << BE_Globals::CorbaScope ("Context_ptr");
      os << " " << DDSCtxVar;
   }

#endif

   if (!first)
   {
      os << XBE_Ev::arg (XBE_ENV_ARGN);
   }
   else
   {
      os << XBE_Ev::arg (XBE_ENV_ARG1);
   }

   os << ")" << ends;

   ret = os.str().c_str();
   return ret;
}
开发者ID:xrl,项目名称:opensplice_dds,代码行数:92,代码来源:xbe_operation.cpp


注:本文中的AST_Decl::narrow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。