be_generator.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 896 行 · 第 1/2 页
CPP
896 行
// be_generator.cpp,v 1.40 2003/10/28 18:30:36 bala Exp
/*
COPYRIGHT
Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
States of America. All Rights Reserved.
This product is protected by copyright and distributed under the following
license restricting its use.
The Interface Definition Language Compiler Front End (CFE) is made
available for your use provided that you include this license and copyright
notice on all media and documentation and the software program in which
this product is incorporated in whole or part. You may copy and extend
functionality (but may not remove functionality) of the Interface
Definition Language CFE without charge, but you are not authorized to
license or distribute it to anyone else except as part of a product or
program developed by you or with the express written consent of Sun
Microsystems, Inc. ("Sun").
The names of Sun Microsystems, Inc. and any of its subsidiaries or
affiliates may not be used in advertising or publicity pertaining to
distribution of Interface Definition Language CFE as permitted herein.
This license is effective until terminated by Sun for failure to comply
with this license. Upon termination, you shall destroy or return all code
and documentation for the Interface Definition Language CFE.
INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
DEALING, USAGE OR TRADE PRACTICE.
INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Use, duplication, or disclosure by the government is subject to
restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
52.227-19.
Sun, Sun Microsystems and the Sun logo are trademarks or registered
trademarks of Sun Microsystems, Inc.
SunSoft, Inc.
2550 Garcia Avenue
Mountain View, California 94043
NOTE:
SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
trademarks or registered trademarks of Sun Microsystems, Inc.
*/
// Implementation of BE generator class.
//
// This implements the same protocol as AST_Generator but creates instances
// of the BE-subclassed classes instead of of AST classes.
#include "be_generator.h"
#include "be_root.h"
#include "be_predefined_type.h"
#include "be_module.h"
#include "be_valuetype.h"
#include "be_valuetype_fwd.h"
#include "be_eventtype.h"
#include "be_eventtype_fwd.h"
#include "be_component.h"
#include "be_component_fwd.h"
#include "be_home.h"
#include "be_union.h"
#include "be_union_fwd.h"
#include "be_structure.h"
#include "be_structure_fwd.h"
#include "be_exception.h"
#include "be_operation.h"
#include "be_enum.h"
#include "be_field.h"
#include "be_argument.h"
#include "be_attribute.h"
#include "be_union_branch.h"
#include "be_union_label.h"
#include "be_constant.h"
#include "be_expression.h"
#include "be_enum_val.h"
#include "be_array.h"
#include "be_sequence.h"
#include "be_string.h"
#include "be_typedef.h"
#include "be_native.h"
#include "be_factory.h"
#include "utl_identifier.h"
#include "nr_extern.h"
#include "ace/config-all.h"
ACE_RCSID (be,
be_generator,
"be_generator.cpp,v 1.40 2003/10/28 18:30:36 bala Exp")
AST_Root *
be_generator::create_root (UTL_ScopedName *n)
{
be_root *retval = 0;
ACE_NEW_RETURN (retval,
be_root (n),
0);
return retval;
}
AST_PredefinedType *
be_generator::create_predefined_type (AST_PredefinedType::PredefinedType t,
UTL_ScopedName *n)
{
be_predefined_type *retval = 0;
ACE_NEW_RETURN (retval,
be_predefined_type (t,
n),
0);
return retval;
}
AST_Module *
be_generator::create_module (UTL_Scope *s,
UTL_ScopedName *n)
{
// We create this first so if we find a module with the
// same name from an included file, we can add its
// members to the new module's scope.
AST_Module *retval = 0;
ACE_NEW_RETURN (retval,
be_module (n),
0);
// Check for another module of the same name in this scope.
for (UTL_ScopeActiveIterator iter (s, UTL_Scope::IK_decls);
!iter.is_done ();
iter.next ())
{
AST_Decl *d = iter.item ();
if (d->node_type () == AST_Decl::NT_module)
{
// Does it have the same name as the one we're
// supposed to create.
if (d->local_name ()->compare (n->last_component ()))
{
AST_Module *m = AST_Module::narrow_from_decl (d);
// Get m's previous_ member, plus all it's decls,
// into the new modules's previous_ member.
retval->add_to_previous (m);
retval->prefix (ACE_const_cast (char *, m->prefix ()));
}
}
}
// If this scope is itself a module, and has been previously
// opened, the previous opening may contain a previous opening
// of the module we're creating.
AST_Decl *d = ScopeAsDecl (s);
AST_Decl::NodeType nt = d->node_type ();
if (nt == AST_Decl::NT_module || nt == AST_Decl::NT_root)
{
AST_Module *m = AST_Module::narrow_from_decl (d);
// AST_Module::previous_ is a set, so it contains each
// entry only once, but previous_ will contain the decls
// from all previous openings. See comment in
// AST_Module::add_to_previous() body.
d = m->look_in_previous (n->last_component ());
if (d != 0)
{
if (d->node_type () == AST_Decl::NT_module)
{
m = AST_Module::narrow_from_decl (d);
retval->add_to_previous (m);
}
}
}
return retval;
}
AST_Interface *
be_generator::create_interface (UTL_ScopedName *n,
AST_Interface **ih,
long nih,
AST_Interface **ih_flat,
long nih_flat,
idl_bool l,
idl_bool a)
{
be_interface *retval = 0;
ACE_NEW_RETURN (retval,
be_interface (n,
ih,
nih,
ih_flat,
nih_flat,
l,
a),
0);
return retval;
}
AST_InterfaceFwd *
be_generator::create_interface_fwd (UTL_ScopedName *n,
idl_bool local,
idl_bool abstract)
{
AST_Interface *dummy = this->create_interface (n,
0,
-1,
0,
0,
local,
abstract);
be_interface_fwd *retval = 0;
ACE_NEW_RETURN (retval,
be_interface_fwd (dummy,
n),
0);
return retval;
}
AST_ValueType *
be_generator::create_valuetype (UTL_ScopedName *n,
AST_Interface **inherits,
long n_inherits,
AST_ValueType *inherits_concrete,
AST_Interface **inherits_flat,
long n_inherits_flat,
AST_Interface **supports,
long n_supports,
AST_Interface *supports_concrete,
idl_bool abstract,
idl_bool truncatable,
idl_bool custom)
{
be_valuetype *retval = 0;
ACE_NEW_RETURN (retval,
be_valuetype (n,
inherits,
n_inherits,
inherits_concrete,
inherits_flat,
n_inherits_flat,
supports,
n_supports,
supports_concrete,
abstract,
truncatable,
custom),
0);
return retval;
}
AST_ValueTypeFwd *
be_generator::create_valuetype_fwd (UTL_ScopedName *n,
idl_bool abstract)
{
AST_ValueType *dummy = this->create_valuetype (n,
0,
-1,
0,
0,
0,
0,
0,
0,
abstract,
0,
0);
be_valuetype_fwd *retval = 0;
ACE_NEW_RETURN (retval,
be_valuetype_fwd (dummy,
n),
0);
return retval;
}
AST_EventType *
be_generator::create_eventtype (UTL_ScopedName *n,
AST_Interface **inherits,
long n_inherits,
AST_ValueType *inherits_concrete,
AST_Interface **inherits_flat,
long n_inherits_flat,
AST_Interface **supports,
long n_supports,
AST_Interface *supports_concrete,
idl_bool abstract,
idl_bool truncatable,
idl_bool custom)
{
be_eventtype *retval = 0;
ACE_NEW_RETURN (retval,
be_eventtype (n,
inherits,
n_inherits,
inherits_concrete,
inherits_flat,
n_inherits_flat,
supports,
n_supports,
supports_concrete,
abstract,
truncatable,
custom),
0);
return retval;
}
AST_EventTypeFwd *
be_generator::create_eventtype_fwd (UTL_ScopedName *n,
idl_bool abstract)
{
AST_EventType *dummy = this->create_eventtype (n,
0,
-1,
0,
0,
0,
0,
0,
0,
abstract,
0,
0);
be_eventtype_fwd *retval = 0;
ACE_NEW_RETURN (retval,
be_eventtype_fwd (dummy,
n),
0);
return retval;
}
AST_Component *
be_generator::create_component (UTL_ScopedName *n,
AST_Component *base_component,
AST_Interface **supports,
long n_supports,
AST_Interface **supports_flat,
long n_supports_flat)
{
be_component *retval = 0;
ACE_NEW_RETURN (retval,
be_component (n,
base_component,
supports,
n_supports,
supports_flat,
n_supports_flat),
0);
return retval;
}
AST_ComponentFwd *
be_generator::create_component_fwd (UTL_ScopedName *n)
{
AST_Component *dummy = this->create_component (n,
0,
0,
-1,
0,
0);
be_component_fwd *retval = 0;
ACE_NEW_RETURN (retval,
be_component_fwd (dummy,
n),
0);
return retval;
}
AST_Home *
be_generator::create_home (UTL_ScopedName *n,
AST_Home *base_home,
AST_Component *managed_component,
AST_ValueType *primary_key,
AST_Interface **supports,
long n_supports,
AST_Interface **supports_flat,
long n_supports_flat)
{
be_home *retval = 0;
ACE_NEW_RETURN (retval,
be_home (n,
base_home,
managed_component,
primary_key,
supports,
n_supports,
supports_flat,
n_supports_flat),
0);
return retval;
}
AST_Exception *
be_generator::create_exception (UTL_ScopedName *n,
idl_bool local,
idl_bool abstract)
{
be_exception *retval = 0;
ACE_NEW_RETURN (retval,
be_exception (n,
local,
abstract),
0);
return retval;
}
AST_Structure *
be_generator::create_structure (UTL_ScopedName *n,
idl_bool local,
idl_bool abstract)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?