fe_init.cpp

来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 639 行 · 第 1/2 页

CPP
639
字号
                          );
  m->fe_add_predefined_type (pdt);

  Identifier raises_id ("raises");
  UTL_ScopedName raises_name (&raises_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &raises_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier readonly_id ("readonly");
  UTL_ScopedName readonly_name (&readonly_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &readonly_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier sequence_id ("sequence");
  UTL_ScopedName sequence_name (&sequence_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &sequence_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier string_id ("string");
  UTL_ScopedName string_name (&string_id, 0);
  pdt =
      idl_global->gen ()->create_predefined_type (
                              AST_PredefinedType::PT_pseudo,
                              &string_name
                            );
  m->fe_add_predefined_type (pdt);

  Identifier wstring_id ("wstring");
  UTL_ScopedName wstring_name (&wstring_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &wstring_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier struct_id ("struct");
  UTL_ScopedName struct_name (&struct_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &struct_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier switch_id ("switch");
  UTL_ScopedName switch_name (&switch_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &switch_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier typedef_id ("typedef");
  UTL_ScopedName typedef_name (&typedef_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &typedef_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier union_id ("union");
  UTL_ScopedName union_name (&union_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &union_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier unsigned_id ("unsigned");
  UTL_ScopedName unsigned_name (&unsigned_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &unsigned_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier TRUE_id ("TRUE");
  UTL_ScopedName TRUE_name (&TRUE_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &TRUE_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier FALSE_id ("FALSE");
  UTL_ScopedName FALSE_name (&FALSE_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &FALSE_name
                         );
  m->fe_add_predefined_type (pdt);

  Identifier abstract_id ("abstract");
  UTL_ScopedName abstract_name (&abstract_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &abstract_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier custom_id ("custom");
  UTL_ScopedName custom_name (&custom_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &custom_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier private_id ("private");
  UTL_ScopedName private_name (&private_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &private_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier public_id ("public");
  UTL_ScopedName public_name (&public_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &public_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier supports_id ("supports");
  UTL_ScopedName supports_name (&supports_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &supports_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier truncatable_id ("truncatable");
  UTL_ScopedName truncatable_name (&truncatable_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &truncatable_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier valuetype_id ("valuetype");
  UTL_ScopedName valuetype_name (&valuetype_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_pseudo,
                            &valuetype_name
                          );
  m->fe_add_predefined_type (pdt);

  Identifier ValueBase_id ("ValueBase");
  UTL_ScopedName ValueBase_name (&ValueBase_id, 0);
  pdt =
    idl_global->gen ()->create_predefined_type (
                            AST_PredefinedType::PT_value,
                            &ValueBase_name
                          );
  m->fe_add_predefined_type (pdt);
}

// Populate idl_global's hash map with upper case versions of
// all the IDL keywords
void
fe_populate_idl_keywords (void)
{
  static const char *keywords[] =
    {
      "ABSTRACT",
      "ANY",
      "ATTRIBUTE",
      "BOOLEAN",
      "CASE",
      "CHAR",
      "COMPONENT",
      "CONST",
      "CONSUMES",
      "CONTEXT",
      "CUSTOM",
      "DEFAULT",
      "DOUBLE",
      "EMITS",
      "EXCEPTION",
      "ENUM",
      "EVENTTYPE",
      "FACTORY",
      "FALSE",
      "FINDER",
      "FIXED",
      "FLOAT",
      "GETRAISES",
      "HOME",
      "IMPORT",
      "IN",
      "INOUT",
      "INTERFACE",
      "LOCAL",
      "LONG",
      "MODULE",
      "MULTIPLE",
      "NATIVE",
      "OBJECT",
      "OCTET",
      "ONEWAY",
      "OUT",
      "PRIMARYKEY",
      "PRIVATE",
      "PROVIDES",
      "PUBLIC",
      "PUBLISHES",
      "RAISES",
      "READONLY",
      "SEQUENCE",
      "SETRAISES",
      "SHORT",
      "STRING",
      "STRUCT",
      "SUPPORTS",
      "SWITCH",
      "TRUE",
      "TRUNCATABLE",
      "TYPEDEF",
      "TYPEID",
      "TYPEPREFIX",
      "UNION",
      "UNSIGNED",
      "USES",
      "VALUEBASE",
      "VALUETYPE",
      "VOID",
      "WCHAR",
      "WSTRING"
    };

  ACE_Hash_Map_Manager<ACE_CString, int, ACE_Null_Mutex> &map =
    idl_global->idl_keywords ();

  u_long length = sizeof (keywords) / sizeof (char *);
  ACE_CString ext_id;
  int int_id = 0;

  for (u_long i = 0; i < length; ++i)
    {
      ext_id.set (keywords[i],
                  0);
      (void) map.bind (ext_id,
                       int_id);
    }
}

// FE initialization: create global scope and populate it.
void
FE_init (void)
{
  AST_Root *r;

  // Check that the BE init created a generator object
  if (idl_global->gen () == 0)
    {
      ACE_ERROR ((
          LM_ERROR,
          ACE_TEXT ("IDL: BE did not initialize idl_global->gen(), exiting\n")
        ));

      ACE_OS::exit (99);
    }

  // Create a global root for the AST. Note that the AST root has no name.
  Identifier root_id ("");
  UTL_ScopedName root_name (&root_id, 0);
  r = idl_global->gen ()->create_root (&root_name);
  idl_global->set_root (r);

  if (r == 0)
    {
      ACE_ERROR ((
          LM_ERROR,
          ACE_TEXT ("IDL: FE init failed to create AST root, exiting\n")
        ));

      ACE_OS::exit (99);
    }

  // Push it on the stack
  idl_global->scopes ().push (idl_global->root ());

  // Populate it with nodes for predefined types.
  fe_populate_global_scope (idl_global->root ());

  // Set flag to indicate we are processing the main file now.
  idl_global->set_in_main_file (I_TRUE);

  // Populate the IDL keyword container, for checking local identifiers.
  fe_populate_idl_keywords ();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?