summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL
diff options
context:
space:
mode:
authorbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-05-17 10:52:00 +0000
committerbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-05-17 10:52:00 +0000
commit15617b460456484cb2f1efd58139357cc109c5a5 (patch)
treed0720a0f6c87ce38287736e50f6dfd0b8b5e25e9 /TAO/TAO_IDL
parente4ed3d0036c533c6395eec03832d9d083b9dae29 (diff)
downloadATCD-15617b460456484cb2f1efd58139357cc109c5a5.tar.gz
ChangeLogTag:Thu May 17 03:15:42 2001 Darrell Brunsch <brunsch@uci.edu>
Diffstat (limited to 'TAO/TAO_IDL')
-rw-r--r--TAO/TAO_IDL/Makefile.BE1
-rw-r--r--TAO/TAO_IDL/TAO_IDL_BE.bor1
-rw-r--r--TAO/TAO_IDL/TAO_IDL_BE_DLL.dsp4
-rw-r--r--TAO/TAO_IDL/TAO_IDL_BE_LIB.dsp4
-rw-r--r--TAO/TAO_IDL/be/be_global.cpp12
-rw-r--r--TAO/TAO_IDL/be/be_interface_strategy.cpp34
-rw-r--r--TAO/TAO_IDL/be/be_operation_strategy.cpp42
-rw-r--r--TAO/TAO_IDL/be/be_produce.cpp22
-rw-r--r--TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp1310
-rw-r--r--TAO/TAO_IDL/be/be_visitor_factory.cpp8
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface.cpp4
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp41
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp58
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface/interface.cpp16
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp21
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp81
-rw-r--r--TAO/TAO_IDL/be/be_visitor_operation.cpp1
-rw-r--r--TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp89
-rw-r--r--TAO/TAO_IDL/be_include/be.h4
-rw-r--r--TAO/TAO_IDL/be_include/be_codegen.h4
-rw-r--r--TAO/TAO_IDL/be_include/be_global.h9
-rw-r--r--TAO/TAO_IDL/be_include/be_interface_strategy.h18
-rw-r--r--TAO/TAO_IDL/be_include/be_operation_strategy.h23
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_amh_pre_proc.h114
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_interface.h4
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_interface/amh_sh.h27
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_interface/amh_ss.h29
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_interface/interface_sh.h3
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h4
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_operation.h1
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_operation/amh_ss.h33
-rw-r--r--TAO/TAO_IDL/driver/drv_args.cpp5
32 files changed, 1987 insertions, 40 deletions
diff --git a/TAO/TAO_IDL/Makefile.BE b/TAO/TAO_IDL/Makefile.BE
index 46e4f87c834..1b9882d5c90 100644
--- a/TAO/TAO_IDL/Makefile.BE
+++ b/TAO/TAO_IDL/Makefile.BE
@@ -63,6 +63,7 @@ FILES = be/be_array \
be/be_visitor_factory \
be/be_visitor \
be/be_visitor_ami_pre_proc \
+ be/be_visitor_amh_pre_proc \
be/be_visitor_argument \
be/be_visitor_array \
be/be_visitor_attribute \
diff --git a/TAO/TAO_IDL/TAO_IDL_BE.bor b/TAO/TAO_IDL/TAO_IDL_BE.bor
index 05740262252..c86dc4dcffa 100644
--- a/TAO/TAO_IDL/TAO_IDL_BE.bor
+++ b/TAO/TAO_IDL/TAO_IDL_BE.bor
@@ -44,6 +44,7 @@ OBJFILES = \
$(OBJDIR)\be_valuetype_fwd.obj \
$(OBJDIR)\be_visitor.obj \
$(OBJDIR)\be_visitor_ami_pre_proc.obj \
+ $(OBJDIR)\be_visitor_amh_pre_proc.obj \
$(OBJDIR)\be_visitor_argument.obj \
$(OBJDIR)\be_visitor_array.obj \
$(OBJDIR)\be_visitor_attribute.obj \
diff --git a/TAO/TAO_IDL/TAO_IDL_BE_DLL.dsp b/TAO/TAO_IDL/TAO_IDL_BE_DLL.dsp
index 4f3184a076a..298aa1871c1 100644
--- a/TAO/TAO_IDL/TAO_IDL_BE_DLL.dsp
+++ b/TAO/TAO_IDL/TAO_IDL_BE_DLL.dsp
@@ -254,6 +254,10 @@ SOURCE=.\be\be_visitor.cpp
# End Source File
# Begin Source File
+SOURCE=.\be\be_visitor_amh_pre_proc.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\be\be_visitor_ami_pre_proc.cpp
# End Source File
# Begin Source File
diff --git a/TAO/TAO_IDL/TAO_IDL_BE_LIB.dsp b/TAO/TAO_IDL/TAO_IDL_BE_LIB.dsp
index 9afc3edf99a..ccd4c21e600 100644
--- a/TAO/TAO_IDL/TAO_IDL_BE_LIB.dsp
+++ b/TAO/TAO_IDL/TAO_IDL_BE_LIB.dsp
@@ -247,6 +247,10 @@ SOURCE=.\be\be_visitor.cpp
# End Source File
# Begin Source File
+SOURCE=.\be\be_visitor_amh_pre_proc.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\be\be_visitor_ami_pre_proc.cpp
# End Source File
# Begin Source File
diff --git a/TAO/TAO_IDL/be/be_global.cpp b/TAO/TAO_IDL/be/be_global.cpp
index b78aa016229..9a36eb232e0 100644
--- a/TAO/TAO_IDL/be/be_global.cpp
+++ b/TAO/TAO_IDL/be/be_global.cpp
@@ -776,6 +776,18 @@ BE_GlobalData::ami_call_back (void)
}
void
+BE_GlobalData::gen_amh_classes (idl_bool val)
+{
+ this->gen_amh_classes_ = val;
+}
+
+idl_bool
+BE_GlobalData::gen_amh_classes (void)
+{
+ return this->gen_amh_classes_;
+}
+
+void
BE_GlobalData::gen_tie_classes (idl_bool val)
{
this->gen_tie_classes_ = val;
diff --git a/TAO/TAO_IDL/be/be_interface_strategy.cpp b/TAO/TAO_IDL/be/be_interface_strategy.cpp
index d4cbb1a6be5..1d97878bbd2 100644
--- a/TAO/TAO_IDL/be/be_interface_strategy.cpp
+++ b/TAO/TAO_IDL/be/be_interface_strategy.cpp
@@ -961,3 +961,37 @@ be_interface_default_strategy::full_strategized_proxy_broker_name (void)
return this->full_strategized_proxy_broker_name_;
}
+
+
+// ****************************************************************
+// AMH Strategy
+
+be_interface_amh_strategy::be_interface_amh_strategy (be_interface *node)
+ : be_interface_default_strategy (node, AMH_INTERFACE)
+{
+}
+
+be_interface_amh_strategy::~be_interface_amh_strategy (void)
+{
+}
+
+
+TAO_CodeGen::CG_STATE
+be_interface_amh_strategy::next_state (TAO_CodeGen::CG_STATE current_state,
+ int is_extra_state)
+{
+ switch (current_state)
+ {
+ case TAO_CodeGen::TAO_INTERFACE_SS:
+ return TAO_CodeGen::TAO_INTERFACE_AMH_SS;
+ };
+
+ return current_state;
+}
+
+
+int
+be_interface_amh_strategy::has_extra_code_generation (TAO_CodeGen::CG_STATE current_state)
+{
+ return 0;
+}
diff --git a/TAO/TAO_IDL/be/be_operation_strategy.cpp b/TAO/TAO_IDL/be/be_operation_strategy.cpp
index a62a342eab4..72eca7923dc 100644
--- a/TAO/TAO_IDL/be/be_operation_strategy.cpp
+++ b/TAO/TAO_IDL/be/be_operation_strategy.cpp
@@ -261,3 +261,45 @@ be_operation_ami_handler_reply_stub_strategy::has_extra_code_generation (
}
}
+
+// ****************************************************************
+// AMY Strategy
+
+be_operation_amh_strategy::be_operation_amh_strategy (be_operation *node)
+ : be_operation_strategy (node, AMI_EXCEPTION_HOLDER_RAISE)
+{
+}
+
+be_operation_amh_strategy::~be_operation_amh_strategy (void)
+{
+}
+
+
+TAO_CodeGen::CG_STATE
+be_operation_amh_strategy::next_state (
+ TAO_CodeGen::CG_STATE current_state,
+ int is_extra_state
+ )
+{
+ switch (current_state)
+ {
+ case TAO_CodeGen::TAO_OPERATION_SS:
+ return TAO_CodeGen::TAO_OPERATION_AMH_SS;
+ case TAO_CodeGen::TAO_INTERFACE_SS:
+ return TAO_CodeGen::TAO_INTERFACE_AMH_SS;
+ default:
+ return current_state;
+ }
+}
+
+
+int
+be_operation_amh_strategy::has_extra_code_generation (
+ TAO_CodeGen::CG_STATE current_state
+ )
+{
+ return 0;
+}
+
+
+
diff --git a/TAO/TAO_IDL/be/be_produce.cpp b/TAO/TAO_IDL/be/be_produce.cpp
index b0338f3d09a..d6e95069c6c 100644
--- a/TAO/TAO_IDL/be/be_produce.cpp
+++ b/TAO/TAO_IDL/be/be_produce.cpp
@@ -154,6 +154,28 @@ BE_produce (void)
delete visitor;
}
+ if (be_global->gen_amh_classes () == I_TRUE)
+ {
+ // Make a first pass over the AST and introduce
+ // AMH specific code
+ be_visitor_context *local_ctx = 0;
+ ACE_NEW (local_ctx,
+ be_visitor_context (ctx));
+
+ ACE_NEW (visitor,
+ be_visitor_amh_pre_proc (local_ctx));
+
+ if (root->accept (visitor) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "(%N:%l) be_produce - "
+ "client header for Root failed\n"));
+ BE_abort ();
+ }
+
+ delete visitor;
+ }
+
// Code generation involves six steps because of the six files that we
// generate.
diff --git a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp
new file mode 100644
index 00000000000..7aa93d90786
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp
@@ -0,0 +1,1310 @@
+//=============================================================================
+/**
+ * @file be_visitor_amh_pre_proc.cpp
+ *
+ * $Id$
+ *
+ * This visitor creates for AMH implied IDL constructs the appropriate AST
+ * (Abstract Syntax Tree) node, sets the corresponding interface or operation
+ * strategy on it and enteres the nodes into the AST.
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#include "be_visitor_amh_pre_proc.h"
+
+be_visitor_amh_pre_proc::be_visitor_amh_pre_proc (be_visitor_context *ctx)
+ : be_visitor_scope (ctx)
+{
+}
+
+
+
+be_visitor_amh_pre_proc::~be_visitor_amh_pre_proc (void)
+{
+}
+
+
+
+int
+be_visitor_amh_pre_proc::visit_root (be_root *node)
+{
+ if (this->visit_scope (node) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::"
+ "visit_root - visit scope failed\n"),
+ -1);
+
+ return 0;
+}
+
+
+
+int
+be_visitor_amh_pre_proc::visit_module (be_module *node)
+{
+ if (!node->imported () && this->visit_scope (node) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::"
+ "visit_module - visit scope failed\n"),
+ -1);
+
+ return 0;
+}
+
+
+
+int
+be_visitor_amh_pre_proc::visit_interface (be_interface *node)
+{
+ if (!node->imported () && !node->is_local ())
+ {
+ AST_Module *module = AST_Module::narrow_from_scope (node->defined_in ());
+ if (!module)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::"
+ "visit_interface - module is null\n"),
+ -1);
+
+ be_interface *amh_class = this->create_amh_class (node);
+
+ if (amh_class)
+ {
+ amh_class->set_defined_in (node->defined_in ());
+
+ // Insert the new amh class after the node
+ module->be_add_interface (amh_class, node);
+
+ // Remember from whom we were cloned
+ amh_class->original_interface (node);
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::"
+ "visit_interface - "
+ "creating the amh_class failed\n"),
+ -1);
+ }
+
+ // Since this is server side only, don't generate the client stuff.
+ // We do this by pretending that all this stuff has already been
+ // generated.
+ amh_class->cli_hdr_gen (1);
+ amh_class->cli_stub_gen (1);
+ amh_class->cli_hdr_any_op_gen (1);
+ amh_class->cli_stub_any_op_gen (1);
+ amh_class->cli_hdr_cdr_op_gen (1);
+ amh_class->cli_stub_cdr_op_gen (1);
+ amh_class->cli_inline_cdr_op_gen (1);
+ amh_class->cli_inline_gen (1);
+
+ // Set the proper strategy
+ be_interface_strategy *old_strategy =
+ amh_class->set_strategy (new be_interface_amh_strategy (amh_class));
+
+ if (old_strategy)
+ delete old_strategy;
+
+ /*be_valuetype *excep_holder = this->create_exception_holder (node);
+
+ be_interface *response_handler = this->create_response_handler (node, excep_holder);
+ if (response_handler)
+ {
+ response_handler->set_defined_in (node->defined_in ());
+
+ // Insert the ami handler after the node, the
+ // exception holder will be placed between these two later.
+ module->be_add_interface (response_handler, node);
+
+ // Remember from whom we were cloned
+ response_handler->original_interface (node);
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::"
+ "visit_interface - "
+ "creating the response handler failed\n"),
+ -1);
+ }
+
+
+ // Set the proper strategy
+ be_interface_strategy *old_strategy =
+ node->set_strategy (new be_interface_ami_strategy (node,
+ response_handler));
+
+ if (old_strategy)
+ delete old_strategy;
+
+ if (excep_holder)
+ {
+ excep_holder->set_defined_in (node->defined_in ());
+ // Insert the exception holder after the original node,
+ // this way we ensure that it is *before* the
+ // ami handler, which is the way we want to have it.
+ module->be_add_interface (excep_holder, node);
+ module->set_has_nested_valuetype ();
+ // Remember from whom we were cloned
+ excep_holder->original_interface (node);
+ // Set the strategy
+ be_interface_strategy *old_strategy =
+ excep_holder->set_strategy (new be_interface_ami_exception_holder_strategy (excep_holder));
+ if (old_strategy)
+ delete old_strategy;
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::"
+ "visit_interface - "
+ "creating the exception holder failed\n"),
+ -1);
+ }
+ */
+
+ if (this->visit_scope (node) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::"
+ "visit_interface - visit scope failed\n"),
+ -1);
+ }
+
+ return 0;
+}
+
+
+
+int
+be_visitor_amh_pre_proc::visit_operation (be_operation *node)
+{
+ // We do nothing for oneways!
+ if (node->flags () == AST_Operation::OP_oneway)
+ return 0;
+/*
+ // Set the proper strategy
+ be_operation_strategy *old_strategy =
+ node->set_strategy (new be_operation_amh_strategy (node));
+
+ if (old_strategy)
+ delete old_strategy;
+
+/* be_operation *sendc_marshaling =
+ this->create_sendc_operation (node,
+ 0); // for arguments = FALSE
+
+ be_operation *sendc_arguments =
+ this->create_sendc_operation (node,
+ 1); // for arguments = TRUE
+
+ if (sendc_marshaling && sendc_arguments)
+ {
+ sendc_marshaling->set_defined_in (node->defined_in ());
+
+ sendc_arguments->set_defined_in (node->defined_in ());
+
+ // We do not copy the exceptions because the exceptions
+ // are delivered by the excep methods.
+
+ // Set the proper strategy, and store the specialized
+ // marshaling and arguments operations in it.
+ be_operation_strategy *old_strategy =
+ node->set_strategy (new be_operation_ami_sendc_strategy (node,
+ sendc_marshaling,
+ sendc_arguments));
+ if (old_strategy)
+ delete old_strategy;
+ }
+*/
+ return 0;
+}
+
+
+
+int
+be_visitor_amh_pre_proc::visit_attribute (be_attribute *node)
+{
+ // Temporarily generate the set operation.
+ be_operation *set_operation =
+ this->generate_set_operation (node);
+
+ this->visit_operation (set_operation);
+
+ // Retrieve the strategy set by the visit operation
+ be_operation_strategy *set_operation_strategy =
+ set_operation->set_strategy (new be_operation_default_strategy (set_operation));
+
+ // Assign it to the attribute as set_operation strategy
+ if (set_operation_strategy)
+ delete node->set_set_strategy (set_operation_strategy);
+
+ // Temporerily generate the get operation.
+ be_operation *get_operation =
+ this->generate_get_operation (node);
+
+ this->visit_operation (get_operation);
+
+ be_operation_strategy *get_operation_strategy =
+ get_operation->set_strategy (new be_operation_default_strategy (get_operation));
+
+ if (get_operation_strategy)
+ delete node->set_get_strategy (get_operation_strategy);
+
+
+ return 0;
+}
+
+
+
+be_valuetype *
+be_visitor_amh_pre_proc::create_exception_holder (be_interface *node)
+{
+
+ // Create a virtual module named "Messaging" and an valuetype "ExceptionHolder"
+ // from which we inherit.
+ UTL_ScopedName *inherit_name =
+ new UTL_ScopedName (new Identifier ("Messaging", 0,0,0),
+ 0);
+
+ inherit_name->nconc (new UTL_ScopedName (new Identifier ("ExceptionHolder",
+ 0,
+ 0,
+ 0),
+ 0));
+
+ be_valuetype *inherit_vt = new be_valuetype (inherit_name,
+ 0,
+ 0,
+ 0);
+ inherit_vt->set_name (inherit_name);
+
+ be_module *msg = new be_module (new UTL_ScopedName (new Identifier ("Messaging",
+ 0,
+ 0,
+ 0),
+ 0),
+ 0);
+
+ // Notice the valuetype "ExceptionHolder" that it is defined in the
+ // "Messaging" module
+ inherit_vt->set_defined_in (msg);
+
+ // Create the excpetion holder name
+ ACE_CString excep_holder_local_name;
+ this->generate_name (excep_holder_local_name,
+ "AMH_",
+ node->name ()->last_component ()->get_string(),
+ "");
+
+ UTL_ScopedName *excep_holder_name = ACE_static_cast (UTL_ScopedName *, node->name ()->copy ());
+ excep_holder_name->last_component ()->replace_string (excep_holder_local_name.rep ());
+
+ AST_Interface_ptr *p_intf = new AST_Interface_ptr[1];
+ p_intf[0] = ACE_static_cast (AST_Interface *, inherit_vt);
+
+ be_valuetype *excep_holder = new be_valuetype (excep_holder_name, // name
+ p_intf, // list of inherited
+ 1, // number of inherited
+ 0, // pragmas
+ 0); // set abstract
+ excep_holder->set_name (excep_holder_name);
+
+ // Now our customized valuetype is created, we have to
+ // add now the operations and attributes to the scope.
+
+ if (node->nmembers () > 0)
+ {
+ // initialize an iterator to iterate thru our scope
+ UTL_ScopeActiveIterator *si;
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (node,
+ UTL_Scope::IK_decls),
+ 0);
+ // continue until each element is visited
+ while (!si->is_done ())
+ {
+ AST_Decl *d = si->item ();
+ if (!d)
+ {
+ delete si;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::visit_interface - "
+ "bad node in this scope\n"),
+ 0);
+
+ }
+ be_decl *op = be_decl::narrow_from_decl (d);
+
+ if (d->node_type () == AST_Decl::NT_attr)
+ {
+ AST_Attribute *attribute = AST_Attribute::narrow_from_decl (d);
+
+ if (!attribute)
+ return 0;
+
+ this->create_raise_operation (op,
+ excep_holder,
+ GET_OPERATION);
+
+ if (!attribute->readonly ())
+ {
+ this->create_raise_operation (op,
+ excep_holder,
+ SET_OPERATION);
+ }
+
+ }
+ else
+ {
+ this->create_raise_operation (op,
+ excep_holder,
+ NORMAL);
+ }
+ si->next ();
+ } // end of while loop
+ delete si;
+ } // end of if
+
+ return excep_holder;
+}
+
+
+be_interface *
+be_visitor_amh_pre_proc::create_amh_class (be_interface *node)
+{
+ // Create the response handler name
+ ACE_CString amh_class_local_name;
+ this->generate_name (amh_class_local_name,
+ "AMH_",
+ node->name ()->last_component ()->get_string(),
+ "");
+
+ UTL_ScopedName *amh_class_name = ACE_static_cast (UTL_ScopedName *, node->name ()->copy ());
+ amh_class_name->last_component ()->replace_string (amh_class_local_name.rep ());
+
+ AST_Interface_ptr *p_intf = new AST_Interface_ptr[1];
+
+ be_interface *amh_class =
+ new be_interface (amh_class_name, // name
+ 0, // list of inherited
+ 0, // number of inherited
+ 0, // list of ancestors
+ 0, // number of ancestors
+ 0, // pragmas
+ 0, // non-local
+ 0); // non-abstract
+ amh_class->set_name (amh_class_name);
+
+ // Now our customized valuetype is created, we have to
+ // add now the operations and attributes to the scope.
+
+ if (node->nmembers () > 0)
+ {
+ // initialize an iterator to iterate thru our scope
+ UTL_ScopeActiveIterator *si;
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (node,
+ UTL_Scope::IK_decls),
+ 0);
+ this->elem_number_ = 0;
+ // continue until each element is visited
+ while (!si->is_done ())
+ {
+ AST_Decl *d = si->item ();
+ if (!d)
+ {
+ delete si;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::visit_interface - "
+ "bad node in this scope\n"),
+ 0);
+
+ }
+
+ if (d->node_type () == AST_Decl::NT_attr)
+ {
+ be_attribute *attribute = be_attribute::narrow_from_decl (d);
+
+ if (!attribute)
+ return 0;
+
+/* be_operation *get_operation = this->generate_get_operation (attribute);
+
+ this->create_response_handler_operation (get_operation,
+ response_handler);
+
+ this->create_excep_operation (get_operation,
+ response_handler,
+ excep_holder);
+
+ if (!attribute->readonly ())
+ {
+ be_operation *set_operation = this->generate_set_operation (attribute);
+ this->create_response_handler_operation (set_operation,
+ response_handler);
+
+ this->create_excep_operation (set_operation,
+ response_handler,
+ excep_holder);
+ }
+*/
+ }
+ else
+ {
+ be_operation* operation = be_operation::narrow_from_decl (d);
+
+ if (operation)
+ {
+ this->create_amh_operation (operation, amh_class);
+ }
+/*
+ if (operation)
+ {
+ this->create_response_handler_operation (operation,
+ response_handler);
+
+ this->create_excep_operation (be_operation::narrow_from_decl (d),
+ response_handler,
+ excep_holder);
+ }
+*/
+ }
+ si->next ();
+ } // end of while loop
+ delete si;
+ } // end of if
+
+ return amh_class;
+}
+
+
+
+int
+be_visitor_amh_pre_proc::create_amh_operation (be_operation *node,
+ be_interface *amh_class)
+{
+ if (!node)
+ return -1;
+
+ // We do nothing for oneways!
+ if (node->flags () == AST_Operation::OP_oneway)
+ return 0;
+
+ // Create the return type, which is "void"
+ be_predefined_type *rt = new be_predefined_type (AST_PredefinedType::PT_void,
+ new UTL_ScopedName
+ (new Identifier ("void", 1, 0, I_FALSE),
+ 0),
+ 0);
+
+ ACE_CString original_op_name (node
+ ->name ()
+ ->last_component ()
+ ->get_string ());
+
+ UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *, amh_class->name ()-> copy ());
+ op_name->nconc (new UTL_ScopedName (
+ new Identifier (
+ original_op_name.rep (), 1, 0, I_FALSE),
+ 0));
+
+ // Create the operation
+ be_operation *operation = new be_operation (node->return_type (),
+ AST_Operation::OP_noflags,
+ op_name,
+ 0,
+ 0,
+ 0);
+ operation->set_name (op_name);
+
+
+ ACE_CString new_op_name = ACE_CString ("reply_") + original_op_name;
+
+ UTL_ScopedName *rtop_name = ACE_static_cast (UTL_ScopedName *, node->name ()-> copy ());
+ op_name->last_component ()->replace_string (new_op_name.rep ());
+
+ // Create the operation
+ be_operation * rtoperation = new be_operation (node->return_type (),
+ AST_Operation::OP_noflags,
+ rtop_name,
+ 0,
+ 0,
+ 0);
+
+ rtoperation->set_name (op_name);
+
+ // Iterate over the arguments and put all the in and inout
+ // into the new method.
+ if (node->nmembers () > 0)
+ {
+ // initialize an iterator to iterate thru our scope
+ UTL_ScopeActiveIterator *si;
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (node,
+ UTL_Scope::IK_decls),
+ 0);
+
+ // continue until each element is visited
+ while (!si->is_done ())
+ {
+ AST_Decl *d = si->item ();
+ if (!d)
+ {
+ delete si;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::create_response_handler_operation - "
+ "bad node in this scope\n"),
+ -1);
+
+ }
+
+ AST_Argument *original_arg = AST_Argument::narrow_from_decl (d);
+
+ if (original_arg->direction () == AST_Argument::dir_INOUT ||
+ original_arg->direction () == AST_Argument::dir_IN)
+ {
+ // Create the argument
+ be_argument *arg = new be_argument (original_arg->direction (),
+ original_arg->field_type (),
+ original_arg->name (),
+ 0);
+
+ operation->add_argument_to_scope (arg);
+ }
+ if (original_arg->direction () == AST_Argument::dir_INOUT ||
+ original_arg->direction () == AST_Argument::dir_OUT)
+ {
+ // Create the argument
+ be_argument *arg = new be_argument (original_arg->direction (),
+ original_arg->field_type (),
+ original_arg->name (),
+ 0);
+
+ rtoperation->add_argument_to_scope (arg);
+ }
+ si->next ();
+ }
+ delete si;
+ }
+
+ // Set the proper strategy
+// be_operation_strategy *old_strategy =
+// operation->set_strategy (new be_operation_ami_handler_response_stub_strategy (operation));
+// if (old_strategy)
+// delete old_strategy;
+
+ operation->set_defined_in (amh_class);
+
+ // After having generated the operation we insert it into the
+ // AMH class interface.
+ amh_class->be_add_operation (operation);
+
+// rtoperation->set_defined_in (amh_class);
+
+// amh_class->be_add_operation (rtoperation);
+
+ return 0;
+}
+
+
+
+be_interface *
+be_visitor_amh_pre_proc::create_response_handler (be_interface *node,
+ be_valuetype *excep_holder)
+{
+ // Create a virtual module named "Messaging" and an interface "responseHandler"
+ // from which we inherit.
+ UTL_ScopedName *inherit_name =
+ new UTL_ScopedName (new Identifier ("Messaging", 0,0,0),
+ 0);
+
+ inherit_name->nconc (new UTL_ScopedName (new Identifier ("responseHandler", 0,0,0),
+ 0));
+
+ be_interface *inherit_intf = new be_interface (inherit_name,
+ 0, // inherited interfaces
+ 0, // number of inherited interfaces
+ 0, // ancestors
+ 0, // number of ancestors
+ 0, // pragmas
+ 0, // not local
+ 0); // not abstract
+ inherit_intf->set_name (inherit_name);
+
+ be_module *msg = new be_module (new UTL_ScopedName (new Identifier ("Messaging", 0,0,0),
+ 0),
+ 0);
+
+ // Notice the interface "ResponseHandler" that it is defined in the
+ // "Messaging" module
+ inherit_intf->set_defined_in (msg);
+
+
+ // Create the response handler name
+ ACE_CString response_handler_local_name;
+ this->generate_name (response_handler_local_name,
+ "AMH_",
+ node->name ()->last_component ()->get_string(),
+ "Handler");
+
+ UTL_ScopedName *response_handler_name = ACE_static_cast (UTL_ScopedName *, node->name ()->copy ());
+ response_handler_name->last_component ()->replace_string (response_handler_local_name.rep ());
+
+ AST_Interface_ptr *p_intf = new AST_Interface_ptr[1];
+ p_intf[0] = ACE_static_cast (AST_Interface *, inherit_intf);
+
+ be_interface *response_handler =
+ new be_interface (response_handler_name, // name
+ p_intf, // list of inherited
+ 1, // number of inherited
+ p_intf, // list of ancestors
+ 1, // number of ancestors
+ 0, // pragmas
+ 0, // non-local
+ 0); // non-abstract
+ response_handler->set_name (response_handler_name);
+
+ // Now our customized valuetype is created, we have to
+ // add now the operations and attributes to the scope.
+
+ if (node->nmembers () > 0)
+ {
+ // initialize an iterator to iterate thru our scope
+ UTL_ScopeActiveIterator *si;
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (node,
+ UTL_Scope::IK_decls),
+ 0);
+ this->elem_number_ = 0;
+ // continue until each element is visited
+ while (!si->is_done ())
+ {
+ AST_Decl *d = si->item ();
+ if (!d)
+ {
+ delete si;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::visit_interface - "
+ "bad node in this scope\n"),
+ 0);
+
+ }
+
+ if (d->node_type () == AST_Decl::NT_attr)
+ {
+ be_attribute *attribute = be_attribute::narrow_from_decl (d);
+
+ if (!attribute)
+ return 0;
+/*
+ be_operation *get_operation = this->generate_get_operation (attribute);
+ this->create_response_handler_operation (get_operation,
+ response_handler);
+
+ this->create_excep_operation (get_operation,
+ response_handler,
+ excep_holder);
+
+ if (!attribute->readonly ())
+ {
+ be_operation *set_operation = this->generate_set_operation (attribute);
+ this->create_response_handler_operation (set_operation,
+ response_handler);
+
+ this->create_excep_operation (set_operation,
+ response_handler,
+ excep_holder);
+ }
+*/
+ }
+ else
+ {
+ be_operation* operation = be_operation::narrow_from_decl (d);
+/*
+ if (operation)
+ {
+ this->create_response_handler_operation (operation,
+ response_handler);
+
+ this->create_excep_operation (be_operation::narrow_from_decl (d),
+ response_handler,
+ excep_holder);
+ }
+*/
+ }
+ si->next ();
+ } // end of while loop
+ delete si;
+ } // end of if
+
+ return response_handler;
+}
+
+
+int
+be_visitor_amh_pre_proc::create_raise_operation (be_decl *node,
+ be_valuetype *excep_holder,
+ Operation_Kind operation_kind)
+{
+ be_operation *orig_op = 0;
+ if (operation_kind == NORMAL)
+ {
+ orig_op = be_operation::narrow_from_decl (node);
+ if (orig_op)
+ {
+ if (orig_op->flags () == AST_Operation::OP_oneway)
+ // We do nothing for oneways!
+ return 0;
+ }
+ }
+
+ // Create the return type, which is "void"
+ be_predefined_type *rt = new be_predefined_type (AST_PredefinedType::PT_void,
+ new UTL_ScopedName
+ (new Identifier ("void",
+ 1,
+ 0,
+ I_FALSE),
+ 0),
+ 0);
+
+ // Name the operation properly
+ UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *,
+ excep_holder->name ()-> copy ());
+
+ ACE_CString new_local_name ("raise_");
+ if (operation_kind == SET_OPERATION)
+ new_local_name += "set_";
+ else if (operation_kind == GET_OPERATION)
+ new_local_name += "get_";
+ new_local_name += node
+ ->name ()
+ ->last_component ()
+ ->get_string ();
+
+ op_name->nconc (new UTL_ScopedName (
+ new Identifier (
+ new_local_name.rep (), 1, 0, I_FALSE),
+ 0));
+
+ be_operation *operation = new be_operation (rt,
+ AST_Operation::OP_noflags,
+ op_name,
+ 0,
+ 0,
+ 0);
+ operation->set_name (op_name);
+ operation->set_defined_in (excep_holder);
+
+ if (operation_kind == NORMAL)
+ {
+ if (orig_op)
+ {
+ // Copy the exceptions.
+ if (orig_op->exceptions ())
+ {
+ UTL_ExceptList *exceptions = orig_op->exceptions ();
+ operation->be_add_exceptions (exceptions);
+ }
+ }
+ }
+
+ // Set the proper strategy
+ be_operation_strategy *old_strategy =
+ operation->set_strategy (new be_operation_ami_exception_holder_raise_strategy (operation));
+ if (old_strategy)
+ delete old_strategy;
+
+ // After having generated the operation we insert it into the
+ // exceptionholder valuetype.
+ excep_holder->be_add_operation (operation);
+
+ return 0;
+}
+
+/*
+be_operation *
+be_visitor_amh_pre_proc::create_sendc_operation (be_operation *node,
+ int for_arguments)
+{
+ if (node->flags () == AST_Operation::OP_oneway)
+ // We do nothing for oneways!
+ return 0;
+
+ // Create the return type, which is "void"
+ be_predefined_type *rt = new be_predefined_type (AST_PredefinedType::PT_void,
+ new UTL_ScopedName
+ (new Identifier ("void", 1, 0, I_FALSE),
+ 0),
+ 0);
+
+ // Create the new name
+ // Prepend "sendc_" to the name of the operation
+ ACE_CString original_op_name (node
+ ->name ()
+ ->last_component ()
+ ->get_string ());
+ ACE_CString new_op_name = ACE_CString ("sendc_") + original_op_name;
+
+ UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *, node->name ()-> copy ());
+ op_name->last_component ()->replace_string (new_op_name.rep ());
+
+ // Create the operation
+ be_operation * op = new be_operation (rt,
+ AST_Operation::OP_noflags,
+ op_name,
+ 0,
+ 0,
+ 0);
+
+ // Create the first argument, which is a Response Handler
+
+ if (for_arguments)
+ {
+ // Create the field type
+ be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl ();
+
+ // Add the pre- and suffix
+ ACE_CString excep_holder_name;
+ this->generate_name (excep_holder_name,
+ "AMI_",
+ parent
+ ->name ()
+ ->last_component ()
+ ->get_string (),
+ "Handler");
+ UTL_ScopedName *field_name = ACE_static_cast (UTL_ScopedName *, parent->name ()->copy ());
+ field_name->last_component ()->replace_string (excep_holder_name.rep ());
+ be_interface *field_type= new be_interface (field_name,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0);
+ field_type->set_defined_in (node->defined_in ());
+
+ // Create the argument
+ be_argument *arg = new be_argument (AST_Argument::dir_IN,
+ field_type, // is also a valuetype
+ new UTL_ScopedName (
+ new Identifier (
+ "ami_handler",
+ 1,
+ 0,
+ I_FALSE
+ ),
+ 0
+ ),
+ 0);
+
+ // Add the response handler to the argument list
+ op->add_argument_to_scope (arg);
+
+ }
+
+ // Iterate over the arguments and put all the in and inout
+ // into the new method.
+ if (node->nmembers () > 0)
+ {
+ // initialize an iterator to iterate thru our scope
+ UTL_ScopeActiveIterator *si;
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (node,
+ UTL_Scope::IK_decls),
+ 0);
+
+ // continue until each element is visited
+ while (!si->is_done ())
+ {
+ AST_Decl *d = si->item ();
+ if (!d)
+ {
+ delete si;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::create_sendc_method - "
+ "bad node in this scope\n"),
+ 0);
+
+ }
+ //be_decl *arg = be_decl::narrow_from_decl (d);
+ AST_Argument *original_arg = AST_Argument::narrow_from_decl (d);
+
+ if (original_arg->direction () == AST_Argument::dir_IN ||
+ original_arg->direction () == AST_Argument::dir_INOUT)
+ {
+ // Create the argument
+ be_argument *arg = new be_argument (AST_Argument::dir_IN,
+ original_arg->field_type (),
+ original_arg->name (),
+ 0);
+
+ op->add_argument_to_scope (arg);
+ }
+ si->next ();
+ } // end of while loop
+ delete si;
+ } // end of if
+
+ return op;
+}
+
+
+
+int
+be_visitor_amh_pre_proc::create_response_handler_operation (be_operation *node,
+ be_interface *response_handler)
+{
+ if (!node)
+ return -1;
+
+ if (node->flags () == AST_Operation::OP_oneway)
+ // We do nothing for oneways!
+ return 0;
+
+ // Create the return type, which is "void"
+ be_predefined_type *rt = new be_predefined_type (AST_PredefinedType::PT_void,
+ new UTL_ScopedName
+ (new Identifier ("void", 1, 0, I_FALSE),
+ 0),
+ 0);
+
+ ACE_CString original_op_name (node
+ ->name ()
+ ->last_component ()
+ ->get_string ());
+
+ UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *, response_handler->name ()-> copy ());
+ op_name->nconc (new UTL_ScopedName (
+ new Identifier (
+ original_op_name.rep (), 1, 0, I_FALSE),
+ 0));
+
+ // Create the operation
+ be_operation *operation = new be_operation (rt,
+ AST_Operation::OP_noflags,
+ op_name,
+ 0,
+ 0,
+ 0);
+ operation->set_name (op_name);
+
+ // If return type is non-void add it as first argument
+
+ if (!node->void_return_type ())
+ {
+
+ // Create the argument
+ be_argument *arg = new be_argument (AST_Argument::dir_IN,
+ node->return_type (),
+ new UTL_ScopedName
+ (new Identifier
+ ("ami_return_val", 1, 0, I_FALSE),
+ 0),
+ 0);
+
+ // Add the response handler to the argument list
+ operation->add_argument_to_scope (arg);
+ }
+
+ // Iterate over the arguments and put all the in and inout
+ // into the new method.
+ if (node->nmembers () > 0)
+ {
+ // initialize an iterator to iterate thru our scope
+ UTL_ScopeActiveIterator *si;
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (node,
+ UTL_Scope::IK_decls),
+ 0);
+
+ // continue until each element is visited
+ while (!si->is_done ())
+ {
+ AST_Decl *d = si->item ();
+ if (!d)
+ {
+ delete si;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_amh_pre_proc::create_response_handler_operation - "
+ "bad node in this scope\n"),
+ -1);
+
+ }
+ //be_decl *arg = be_decl::narrow_from_decl (d);
+ AST_Argument *original_arg = AST_Argument::narrow_from_decl (d);
+
+ if (original_arg->direction () == AST_Argument::dir_INOUT ||
+ original_arg->direction () == AST_Argument::dir_OUT)
+ {
+ // Create the argument
+ be_argument *arg = new be_argument (AST_Argument::dir_IN,
+ original_arg->field_type (),
+ original_arg->name (),
+ 0);
+
+ operation->add_argument_to_scope (arg);
+ }
+ si->next ();
+ } // end of while loop
+ delete si;
+ } // end of if
+
+ // Set the proper strategy
+ be_operation_strategy *old_strategy =
+ operation->set_strategy (new be_operation_ami_handler_response_stub_strategy (operation));
+ if (old_strategy)
+ delete old_strategy;
+
+ operation->set_defined_in (response_handler);
+
+ // We do not copy the exceptions because the exceptions
+ // are delivered by the excep methods.
+
+ // After having generated the operation we insert it into the
+ // response handler interface.
+ response_handler->be_add_operation (operation);
+
+ return 0;
+}
+
+
+
+int
+be_visitor_amh_pre_proc::create_excep_operation (be_operation *node,
+ be_interface *response_handler,
+ be_valuetype *excep_holder)
+{
+ if (!node)
+ return -1;
+
+ if (node->flags () == AST_Operation::OP_oneway)
+ // We do nothing for oneways!
+ return 0;
+
+ // Create the return type, which is "void"
+ be_predefined_type *rt = new be_predefined_type (AST_PredefinedType::PT_void,
+ new UTL_ScopedName
+ (new Identifier ("void", 1, 0, I_FALSE),
+ 0),
+ 0);
+
+ // Create the argument
+ be_argument *arg = new be_argument (AST_Argument::dir_IN,
+ excep_holder, // is also a valuetype
+ new UTL_ScopedName (
+ new Identifier (
+ "excep_holder", 1, 0, I_FALSE),
+ 0),
+ 0);
+
+ // Create the new name
+ // Append _execp to the name of the operation
+ ACE_CString original_op_name (node
+ ->name ()
+ ->last_component ()
+ ->get_string ());
+ ACE_CString new_op_name = original_op_name + ACE_CString ("_excep");
+
+ UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *, response_handler->name ()-> copy ());
+ op_name->nconc (new UTL_ScopedName
+ (new Identifier
+ (new_op_name.rep (), 1, 0, I_FALSE),
+ 0));
+
+ // create the operation
+ be_operation *operation = new be_operation (rt,
+ AST_Operation::OP_noflags,
+ op_name,
+ 0,
+ 0,
+ 0);
+ operation->set_name (op_name);
+ operation->add_argument_to_scope (arg);
+
+ operation->set_defined_in (response_handler);
+
+ // We do not copy the exceptions because the exceptions
+ // are delivered by the excep methods.
+
+ // After having generated the operation we insert it into the
+ // response handler interface.
+ response_handler->be_add_operation (operation);
+
+ return 0;
+}
+*/
+
+// visit the scope and its elements
+int
+be_visitor_amh_pre_proc::visit_scope (be_scope *node)
+{
+
+ // proceed if the number of members in our scope is greater than 0
+ if (node->nmembers () > 0)
+ {
+ int number_of_elements = 0;
+
+ {
+ // initialize an iterator to iterate thru our scope
+ UTL_ScopeActiveIterator *si;
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (node,
+ UTL_Scope::IK_decls),
+ -1);
+
+ while (!si->is_done ())
+ {
+ number_of_elements++;
+ si->next ();
+ }
+ delete si;
+ }
+
+ AST_Decl **elements = new AST_Decl *[number_of_elements];
+
+ {
+ int position = 0;
+ // initialize an iterator to iterate thru our scope
+ UTL_ScopeActiveIterator *si;
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (node,
+ UTL_Scope::IK_decls),
+ -1);
+
+ while (!si->is_done ())
+ {
+ elements[position++] = si->item ();
+ si->next ();
+ }
+ delete si;
+ }
+
+
+ int elem_number = 0;
+
+ // continue until each element is visited
+ while (elem_number < number_of_elements)
+ {
+ AST_Decl *d = elements[elem_number];
+ if (!d)
+ {
+ delete [] elements;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_scope::visit_scope - "
+ "bad node in this scope\n"), -1);
+
+ }
+
+ be_decl *bd = be_decl::narrow_from_decl (d);
+
+ // set the scope node as "node" in which the code is being
+ // generated so that elements in the node's scope can use it
+ // for code generation
+ this->ctx_->scope (node->decl ());
+
+ // set the node to be visited
+ this->ctx_->node (bd);
+ elem_number++;
+
+
+ // Send the visitor.
+ if (bd == 0 || bd->accept (this) == -1)
+ {
+ delete [] elements;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_scope::visit_scope - "
+ "codegen for scope failed\n"), -1);
+
+ }
+ } // end of while loop
+ delete [] elements;
+ } // end of if
+ return 0;
+}
+
+// Helper methods
+
+int
+be_visitor_amh_pre_proc::generate_name (ACE_CString &destination,
+ const char *prefix,
+ const char *middle_name,
+ const char *suffix)
+{
+ destination = prefix;
+ destination += middle_name;
+ destination += suffix;
+ return 0;
+}
+
+
+
+be_operation *
+be_visitor_amh_pre_proc::generate_get_operation (be_attribute *node)
+{
+ ACE_CString original_op_name (node
+ ->name ()
+ ->last_component ()
+ ->get_string ());
+ ACE_CString new_op_name = ACE_CString ("get_") + original_op_name;
+
+ UTL_ScopedName *get_name = ACE_static_cast (UTL_ScopedName *,
+ node->name ()-> copy ());
+ get_name->last_component ()->replace_string (new_op_name.rep ());
+
+ be_operation *operation =
+ new be_operation (node->field_type (),
+ AST_Operation::OP_noflags,
+ get_name,
+ 0,
+ 0,
+ 0);
+ operation->set_name (get_name);
+ operation->set_defined_in (node->defined_in ());
+
+ return operation;
+}
+
+be_operation *
+be_visitor_amh_pre_proc::generate_set_operation (be_attribute *node)
+{
+ ACE_CString original_op_name (node
+ ->name ()
+ ->last_component ()
+ ->get_string ());
+ ACE_CString new_op_name = ACE_CString ("set_") + original_op_name;
+
+ UTL_ScopedName *set_name = ACE_static_cast (UTL_ScopedName *,
+ node->name ()-> copy ());
+ set_name->last_component ()->replace_string (new_op_name.rep ());
+
+ // the return type is "void"
+ be_predefined_type *rt = new be_predefined_type (AST_PredefinedType::PT_void,
+ new UTL_ScopedName
+ (new Identifier
+ ("void", 1, 0, I_FALSE), 0),
+ 0);
+
+ // argument type is the same as the attribute type
+ be_argument *arg = new be_argument (AST_Argument::dir_IN,
+ node->field_type (),
+ set_name,
+ 0);
+ arg->set_name (node->name ());
+
+ // create the operation
+ be_operation *operation = new be_operation (rt,
+ AST_Operation::OP_noflags,
+ set_name,
+ 0,
+ 0,
+ 0);
+ operation->set_name (set_name);
+ operation->set_defined_in (node->defined_in ());
+ operation->add_argument_to_scope (arg);
+
+ return operation;
+}
diff --git a/TAO/TAO_IDL/be/be_visitor_factory.cpp b/TAO/TAO_IDL/be/be_visitor_factory.cpp
index b01abaaa357..94c055fda76 100644
--- a/TAO/TAO_IDL/be/be_visitor_factory.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_factory.cpp
@@ -764,6 +764,14 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx)
case TAO_CodeGen::TAO_AMI_EXCEPTION_HOLDER_VALUETYPE_CS:
return new be_visitor_valuetype_ami_exception_holder_cs (new_ctx);
+ // AMH
+
+ case TAO_CodeGen::TAO_INTERFACE_AMH_SS:
+ return new be_visitor_amh_interface_ss (new_ctx);
+
+ case TAO_CodeGen::TAO_OPERATION_AMH_SS:
+ return new be_visitor_amh_operation_ss (new_ctx);
+
default:
// cannot handle it; delegate it to the common visitor factory
delete new_ctx;
diff --git a/TAO/TAO_IDL/be/be_visitor_interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface.cpp
index 830bcea703d..06cb2754599 100644
--- a/TAO/TAO_IDL/be/be_visitor_interface.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_interface.cpp
@@ -69,4 +69,8 @@
#include "be_visitor_interface/direct_proxy_impl_sh.cpp"
#include "be_visitor_interface/direct_proxy_impl_ss.cpp"
+// AMH
+#include "be_visitor_interface/amh_ss.cpp"
+#include "be_visitor_interface/amh_sh.cpp"
+
ACE_RCSID(be, be_visitor_interface, "$Id$")
diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp
new file mode 100644
index 00000000000..c813836228f
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp
@@ -0,0 +1,41 @@
+//=============================================================================
+/**
+ * @file amh_sh.cpp
+ *
+ * $Id$
+ *
+ * Specialized interface visitor for AMH.
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
+
+#include "be_visitor_interface.h"
+
+be_visitor_amh_interface_sh::be_visitor_amh_interface_sh (be_visitor_context *ctx)
+ : be_visitor_interface_sh (ctx)
+{
+}
+
+be_visitor_amh_interface_sh::~be_visitor_amh_interface_sh (void)
+{
+}
+
+void
+be_visitor_amh_interface_sh::this_method (be_interface *node)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ const char *non_amh_name = node->full_name () + 4;
+
+ // Print out the _this() method.
+ *os << "::" << non_amh_name << " *_this (" << be_idt << be_idt_nl
+ << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl
+ << "TAO_default_environment ()"
+ << be_uidt << be_uidt_nl
+ << ");\n" << be_uidt_nl;
+}
diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp
new file mode 100644
index 00000000000..a2f1fa28343
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp
@@ -0,0 +1,58 @@
+//=============================================================================
+/**
+ * @file amh_ss.cpp
+ *
+ * $Id$
+ *
+ * Specialized interface visitor for AMH.
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
+
+#include "be_visitor_interface.h"
+
+be_visitor_amh_interface_ss::be_visitor_amh_interface_ss (be_visitor_context *ctx)
+ : be_visitor_interface_ss (ctx)
+{
+}
+
+be_visitor_amh_interface_ss::~be_visitor_amh_interface_ss (void)
+{
+}
+
+void
+be_visitor_amh_interface_ss::this_method (be_interface *node)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // the _this () operation
+ const char *non_amh_name = node->full_name () + 4;
+
+ *os << non_amh_name << "*" << be_nl
+ << node->full_skel_name ()
+ << "::_this (CORBA_Environment &ACE_TRY_ENV)" << be_nl
+ << "{" << be_idt_nl // idt = 1
+ << "TAO_Stub *stub = this->_create_stub (ACE_TRY_ENV);" << be_nl
+ << "ACE_CHECK_RETURN (0);" << be_nl << be_nl;
+}
+
+void
+be_visitor_amh_interface_ss::dispatch_method (be_interface *node)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // now the dispatch method
+ *os << "void " << node->full_skel_name () <<
+ "::_dispatch (TAO_ServerRequest &req, " <<
+ "void *context, CORBA::Environment &ACE_TRY_ENV)" << be_nl;
+ *os << "{" << be_idt_nl;
+ // @todo ACE_TRY_ENV without check;
+ *os << "this->asynchronous_upcall_dispatch (req, context, this, ACE_TRY_ENV);" << be_nl;
+ *os << "this->asynchronous_upcall_reply (req);" << be_uidt_nl;
+ *os << "}" << be_nl;
+}
diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp
index 5da2c0b859f..e26eba9b1cc 100644
--- a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp
@@ -77,6 +77,7 @@ be_visitor_interface::visit_attribute (be_attribute *node)
ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_IH);
break;
case TAO_CodeGen::TAO_INTERFACE_SS:
+ case TAO_CodeGen::TAO_INTERFACE_AMH_SS:
ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_SS);
break;
case TAO_CodeGen::TAO_INTERFACE_IS:
@@ -268,6 +269,8 @@ be_visitor_interface::visit_constant (be_constant *node)
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH:
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS:
+ case TAO_CodeGen::TAO_INTERFACE_AMH_SS:
+
return 0; // nothing to be done
default:
{
@@ -380,6 +383,9 @@ be_visitor_interface::visit_enum (be_enum *node)
case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS:
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH:
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS:
+
+ case TAO_CodeGen::TAO_INTERFACE_AMH_SS:
+
return 0; // nothing to be done
default:
{
@@ -493,6 +499,9 @@ be_visitor_interface::visit_exception (be_exception *node)
case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS:
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH:
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS:
+
+ case TAO_CodeGen::TAO_INTERFACE_AMH_SS:
+
return 0; // nothing to be done
default:
{
@@ -556,6 +565,7 @@ be_visitor_interface::visit_operation (be_operation *node)
ctx.state (TAO_CodeGen::TAO_OPERATION_IH);
break;
case TAO_CodeGen::TAO_INTERFACE_SS:
+ case TAO_CodeGen::TAO_INTERFACE_AMH_SS:
ctx.state (TAO_CodeGen::TAO_OPERATION_SS);
break;
case TAO_CodeGen::TAO_INTERFACE_IS:
@@ -778,6 +788,8 @@ be_visitor_interface::visit_structure (be_structure *node)
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH:
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS:
+ case TAO_CodeGen::TAO_INTERFACE_AMH_SS:
+
return 0; // nothing to be done
default:
{
@@ -892,6 +904,8 @@ be_visitor_interface::visit_union (be_union *node)
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH:
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS:
+ case TAO_CodeGen::TAO_INTERFACE_AMH_SS:
+
return 0; // nothing to be done
default:
{
@@ -1006,6 +1020,8 @@ be_visitor_interface::visit_typedef (be_typedef *node)
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH:
case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS:
+ case TAO_CodeGen::TAO_INTERFACE_AMH_SS:
+
return 0; // nothing to be done
default:
{
diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp
index 7a44cf5cb8e..96e7190522b 100644
--- a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp
@@ -180,12 +180,7 @@ be_visitor_interface_sh::visit_interface (be_interface *node)
<< be_uidt << be_uidt_nl
<< ");\n" << be_uidt_nl;
- // Print out the _this() method.
- *os << "::" << node->full_name () << " *_this (" << be_idt << be_idt_nl
- << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl
- << "TAO_default_environment ()"
- << be_uidt << be_uidt_nl
- << ");\n" << be_uidt_nl;
+ this->this_method (node);
// The _interface_repository_id method.
*os << "virtual const char* _interface_repository_id "
@@ -304,3 +299,17 @@ be_visitor_interface_sh::visit_interface (be_interface *node)
*os << "\n";
return 0;
}
+
+
+void
+be_visitor_interface_sh::this_method (be_interface *node)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // Print out the _this() method.
+ *os << "::" << node->full_name () << " *_this (" << be_idt << be_idt_nl
+ << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl
+ << "TAO_default_environment ()"
+ << be_uidt << be_uidt_nl
+ << ");\n" << be_uidt_nl;
+}
diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp
index 7b108226fef..855dab36832 100644
--- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp
@@ -415,30 +415,12 @@ be_visitor_interface_ss::visit_interface (be_interface *node)
*os << "return 0;" << be_uidt_nl
<< "}" << be_nl << be_nl;
- // now the dispatch method
- *os << "void " << node->full_skel_name () <<
- "::_dispatch (TAO_ServerRequest &req, " <<
- "void *context, CORBA::Environment &ACE_TRY_ENV)" << be_nl;
- *os << "{" << be_idt_nl;
- //BRT
- *os << "this->synchronous_upcall_dispatch(req, context, this, ACE_TRY_ENV);" << be_uidt_nl;
-// *os << "TAO_Skeleton skel; // pointer to skeleton for operation" << be_nl;
-// *os << "const char *opname = req.operation (); // retrieve operation name"
-// << be_nl;
-// *os << "// find the skeleton corresponding to this opname" << be_nl;
-// *os << "if (this->_find (opname, skel, req.operation_length ()) == -1)" << be_nl;
-// *os << "{" << be_idt_nl;
-// *os << "ACE_ERROR ((LM_ERROR, \"Bad operation <%s>\\n\", opname));" << be_nl;
-// if (idl_global->use_raw_throw ())
-// *os << "throw CORBA_BAD_OPERATION ();";
-// else
-// *os << "ACE_THROW (CORBA_BAD_OPERATION ());";
-// *os << be_uidt_nl;
-// *os << "}" << be_nl;
-// *os << "else" << be_idt_nl;
-// *os << "skel (req, this, context, ACE_TRY_ENV);" << be_uidt << be_uidt_nl;
- *os << "}" << be_nl << be_nl;
+ // Print out dispatch method
+ this->dispatch_method (node);
+
+ *os << be_nl;
+
*os << "const char* " << node->full_skel_name ()
<< "::_interface_repository_id (void) const"
<< be_nl;
@@ -446,13 +428,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node)
*os << "return \"" << node->repoID () << "\";" << be_uidt_nl;
*os << "}" << be_nl << be_nl;
- // the _this () operation
- *os << node->full_name () << "*" << be_nl
- << node->full_skel_name ()
- << "::_this (CORBA_Environment &ACE_TRY_ENV)" << be_nl
- << "{" << be_idt_nl // idt = 1
- << "TAO_Stub *stub = this->_create_stub (ACE_TRY_ENV);" << be_nl
- << "ACE_CHECK_RETURN (0);" << be_nl << be_nl;
+ this->this_method (node);
*os << "CORBA::Object_ptr tmp = CORBA::Object::_nil ();" << be_nl
<< be_nl
@@ -529,3 +505,48 @@ be_visitor_interface_ss::visit_interface (be_interface *node)
return 0;
}
+
+
+void
+be_visitor_interface_ss::this_method (be_interface *node)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // the _this () operation
+ *os << node->full_name () << "*" << be_nl
+ << node->full_skel_name ()
+ << "::_this (CORBA_Environment &ACE_TRY_ENV)" << be_nl
+ << "{" << be_idt_nl // idt = 1
+ << "TAO_Stub *stub = this->_create_stub (ACE_TRY_ENV);" << be_nl
+ << "ACE_CHECK_RETURN (0);" << be_nl << be_nl;
+}
+
+void
+be_visitor_interface_ss::dispatch_method (be_interface *node)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // now the dispatch method
+ *os << "void " << node->full_skel_name () <<
+ "::_dispatch (TAO_ServerRequest &req, " <<
+ "void *context, CORBA::Environment &ACE_TRY_ENV)" << be_nl;
+ *os << "{" << be_idt_nl;
+ //BRT
+ *os << "this->synchronous_upcall_dispatch(req, context, this, ACE_TRY_ENV);" << be_uidt_nl;
+ // *os << "TAO_Skeleton skel; // pointer to skeleton for operation" << be_nl;
+// *os << "const char *opname = req.operation (); // retrieve operation name"
+// << be_nl;
+// *os << "// find the skeleton corresponding to this opname" << be_nl;
+// *os << "if (this->_find (opname, skel, req.operation_length ()) == -1)" << be_nl;
+// *os << "{" << be_idt_nl;
+// *os << "ACE_ERROR ((LM_ERROR, \"Bad operation <%s>\\n\", opname));" << be_nl;
+// if (idl_global->use_raw_throw ())
+// *os << "throw CORBA_BAD_OPERATION ();";
+// else
+// *os << "ACE_THROW (CORBA_BAD_OPERATION ());";
+// *os << be_uidt_nl;
+// *os << "}" << be_nl;
+// *os << "else" << be_idt_nl;
+// *os << "skel (req, this, context, ACE_TRY_ENV);" << be_uidt << be_uidt_nl;
+ *os << "}" << be_nl << be_nl;
+}
diff --git a/TAO/TAO_IDL/be/be_visitor_operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation.cpp
index 652ab9c141e..cb1f5107b1d 100644
--- a/TAO/TAO_IDL/be/be_visitor_operation.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_operation.cpp
@@ -53,6 +53,7 @@
#include "be_visitor_operation/tie_sh.cpp"
#include "be_visitor_operation/tie_si.cpp"
#include "be_visitor_operation/rettype_pre_invoke_cs.cpp"
+#include "be_visitor_operation/amh_ss.cpp"
#include "be_visitor_operation/ami_ch.cpp"
#include "be_visitor_operation/ami_cs.cpp"
#include "be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp"
diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp
new file mode 100644
index 00000000000..5bd2d361ed2
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp
@@ -0,0 +1,89 @@
+//=============================================================================
+/**
+ * @file amh_ss.cpp
+ *
+ * $Id$
+ *
+ * Creates code for AMH operations.
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
+
+#include "be_visitor_operation.h"
+
+be_visitor_amh_operation_ss::be_visitor_amh_operation_ss (be_visitor_context *ctx)
+ : be_visitor_operation (ctx)
+{
+}
+
+be_visitor_amh_operation_ss::~be_visitor_amh_operation_ss (void)
+{
+}
+
+int
+be_visitor_amh_operation_ss::visit_operation (be_operation *node)
+{
+ this->ctx_->node (node);
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // If there is an argument of type "native", return immediately.
+ if (node->has_native ())
+ return 0;
+
+ // We need the interface node in which this operation was defined. However,
+ // if this operation node was an attribute node in disguise, we get this
+ // information from the context
+ be_interface *intf;
+ intf = this->ctx_->attribute ()
+ ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ())
+ : be_interface::narrow_from_scope (node->defined_in ());
+
+ if (!intf)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_operation_ss::"
+ "visit_operation - "
+ "bad interface scope\n"),
+ -1);
+ }
+
+ os->indent ();
+ *os << "void " << intf->full_skel_name () << "::";
+
+ // Check if we are an attribute node in disguise
+ if (this->ctx_->attribute ())
+ {
+ // now check if we are a "get" or "set" operation
+ if (node->nmembers () == 1) // set
+ *os << "_set_";
+ else
+ *os << "_get_";
+ }
+
+ *os << node->local_name ()
+ << "_skel (" << be_idt << be_idt_nl
+ << "TAO_ServerRequest &_tao_server_request," << be_nl
+ << "void *_tao_object_reference, " << be_nl
+ << "void * /* context */, " << be_nl
+ << "CORBA::Environment &ACE_TRY_ENV" << be_uidt_nl
+ << ")" << be_uidt_nl;
+
+ // Generate the actual code for the skeleton. However, if any of the argument
+ // types is "native", we do not generate any skeleton
+ // last argument - is always CORBA::Environment.
+ *os << "{" << be_idt_nl;
+
+ *os << "// foo" << be_uidt_nl;
+
+ *os << "}" << be_nl << be_nl;
+
+
+ // see <be_visitor_operation_ss::visit_operation> for more info
+
+ return 0;
+}
diff --git a/TAO/TAO_IDL/be_include/be.h b/TAO/TAO_IDL/be_include/be.h
index 885783aae53..07574c7b570 100644
--- a/TAO/TAO_IDL/be_include/be.h
+++ b/TAO/TAO_IDL/be_include/be.h
@@ -135,8 +135,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
#include "be_visitor.h" // abstract visitor
#include "be_visitor_factory.h" // visitor factory
#include "be_visitor_context.h" // visitor context
-#include "be_visitor_ami_pre_proc.h" // visitor to generate
- // AMI implied IDL
+#include "be_visitor_ami_pre_proc.h" // generate AMI implied IDL
+#include "be_visitor_amh_pre_proc.h" // generate AMH implied IDL
#include "be_interface_strategy.h" // strategy for interface nodes
diff --git a/TAO/TAO_IDL/be_include/be_codegen.h b/TAO/TAO_IDL/be_include/be_codegen.h
index 829795d65ed..25b45b4fc10 100644
--- a/TAO/TAO_IDL/be_include/be_codegen.h
+++ b/TAO/TAO_IDL/be_include/be_codegen.h
@@ -395,6 +395,10 @@ public:
TAO_AMI_EXCEPTION_HOLDER_VALUETYPE_CS,
TAO_AMI_EXCEPTION_HOLDER_RAISE_OPERATION_CS,
+ // AMH stuff
+ TAO_INTERFACE_AMH_SS,
+ TAO_OPERATION_AMH_SS,
+
// Emitting code for root.
TAO_ROOT_CH,
TAO_ROOT_CI,
diff --git a/TAO/TAO_IDL/be_include/be_global.h b/TAO/TAO_IDL/be_include/be_global.h
index 8326271b019..0dc210aa3ed 100644
--- a/TAO/TAO_IDL/be_include/be_global.h
+++ b/TAO/TAO_IDL/be_include/be_global.h
@@ -317,6 +317,12 @@ public:
virtual idl_bool ami_call_back (void);
// Return the flag.
+ virtual void gen_amh_classes (idl_bool value);
+ // To enable or disable AMH in the generated code.
+
+ virtual idl_bool gen_amh_classes (void);
+ // Return the flag.
+
virtual void gen_tie_classes (idl_bool value);
// Toggle the generation of tie classes and files.
@@ -447,6 +453,9 @@ private:
// Messaging specification should be enabled for the generated files
// or not.
+ idl_bool gen_amh_classes_;
+ // Flag for generating AMH classes.
+
idl_bool gen_tie_classes_;
// Flag to indicate whether we generate the tie classes and
// files or not.
diff --git a/TAO/TAO_IDL/be_include/be_interface_strategy.h b/TAO/TAO_IDL/be_include/be_interface_strategy.h
index 609e741854b..4d135631fd6 100644
--- a/TAO/TAO_IDL/be_include/be_interface_strategy.h
+++ b/TAO/TAO_IDL/be_include/be_interface_strategy.h
@@ -35,7 +35,8 @@ public:
DEFAULT = 0,
AMI_INTERFACE,
AMI_HANDLER,
- AMI_EXCEPTION_HOLDER
+ AMI_EXCEPTION_HOLDER,
+ AMH_INTERFACE
};
be_interface_strategy (be_interface *node,
@@ -413,5 +414,20 @@ private:
be_interface *handler_;
};
+class be_interface_amh_strategy
+ : public be_interface_default_strategy
+{
+public:
+ be_interface_amh_strategy (be_interface *node);
+
+ virtual ~be_interface_amh_strategy ();
+
+ // overridden methods.
+ virtual TAO_CodeGen::CG_STATE next_state (TAO_CodeGen::CG_STATE current_state,
+ int is_extra_state = 0);
+
+ virtual int has_extra_code_generation (TAO_CodeGen::CG_STATE current_state);
+
+};
#endif // if !defined
diff --git a/TAO/TAO_IDL/be_include/be_operation_strategy.h b/TAO/TAO_IDL/be_include/be_operation_strategy.h
index 19586c9a2fa..ce6db752c61 100644
--- a/TAO/TAO_IDL/be_include/be_operation_strategy.h
+++ b/TAO/TAO_IDL/be_include/be_operation_strategy.h
@@ -162,4 +162,25 @@ public:
int is_extra_state = 0);
};
-#endif // if !defined
+
+// AMH strategy
+
+class be_operation_amh_strategy
+ : public be_operation_strategy
+{
+public:
+ be_operation_amh_strategy (be_operation *node);
+
+ virtual ~be_operation_amh_strategy ();
+
+ // overridden methods.
+ TAO_CodeGen::CG_STATE next_state (TAO_CodeGen::CG_STATE current_state,
+ int is_extra_state = 0);
+
+ virtual int has_extra_code_generation (TAO_CodeGen::CG_STATE current_state);
+
+
+private:
+};
+
+#endif // TAO_BE_OPERATION_STRATEGY_H
diff --git a/TAO/TAO_IDL/be_include/be_visitor_amh_pre_proc.h b/TAO/TAO_IDL/be_include/be_visitor_amh_pre_proc.h
new file mode 100644
index 00000000000..29ecf71af38
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_amh_pre_proc.h
@@ -0,0 +1,114 @@
+//=============================================================================
+/**
+ * @file be_visitor_amh_pre_proc.h
+ *
+ * $Id$
+ *
+ * This visitor creates for AMH implied IDL constructs the appropriate AST
+ * (Abstract Syntax Tree) node, sets the corresponding interface or operation
+ * strategy on it and enteres the nodes into the AST.
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_BE_VISITOR_AMH_PRE_PROC_H
+#define TAO_BE_VISITOR_AMH_PRE_PROC_H
+
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
+
+#include "be_root.h"
+#include "be_module.h"
+#include "be_interface.h"
+#include "be_visitor_scope.h"
+
+/**
+ * @class be_visitor_amh_pre_proc
+ *
+ * @brief Adds AMH implied IDL code into the AST
+ */
+class be_visitor_amh_pre_proc : public be_visitor_scope
+{
+private:
+ typedef AST_Interface *AST_Interface_ptr;
+
+ typedef enum {
+ NORMAL,
+ GET_OPERATION,
+ SET_OPERATION
+ } Operation_Kind;
+
+public:
+ be_visitor_amh_pre_proc (be_visitor_context *ctx);
+
+ virtual ~be_visitor_amh_pre_proc (void);
+
+ virtual int visit_root (be_root *node);
+
+ virtual int visit_module (be_module *node);
+
+ virtual int visit_interface (be_interface *node);
+
+ virtual int visit_operation (be_operation *node);
+
+ virtual int visit_attribute (be_attribute *node);
+
+private:
+
+ /// Creates a raise operation from node and inserts it in
+ /// excep_holder, while obeying if it is a normal operation
+ /// or a set or get attribute.
+ int create_raise_operation (be_decl *node,
+ be_valuetype *excep_holder,
+ Operation_Kind operation_kind);
+
+ /// Creates the AMH version of the interface
+ be_interface *create_amh_class (be_interface *node);
+
+ /// Create a method in the AMH tree
+ int create_amh_operation (be_operation *node,
+ be_interface *amh_class);
+
+ /// Create the reponse handler interface
+ be_interface *create_response_handler (be_interface *node,
+ be_valuetype *excep_holder);
+
+ /// Create the exception holder valuetype
+ be_valuetype *create_exception_holder (be_interface *node);
+
+ /// Create a method with "sendc_" prepended, if for_arguments
+ /// equals one the sendc operation contains also the
+ /// object reference to the response handler as the first argument,
+ /// but this should not be marhaled, therefore we need the switch
+// be_operation *create_sendc_operation (be_operation *node,
+// int for_arguments);
+
+ /// Create a method with "_excep" appended
+// int create_excep_operation (be_operation *node,
+// be_interface *response_handler,
+// be_valuetype *excep_holder);
+
+ /// Create an operation with only the OUT and INOUT arguments
+// int create_response_handler_operation (be_operation *node,
+// be_interface *response_handler);
+
+ /// Specialized visit_scope
+ int visit_scope (be_scope *node);
+
+ /// Concatenate 3 strings into one.
+ int generate_name (ACE_CString &destination,
+ const char *prefix,
+ const char *middle_name,
+ const char *suffix);
+
+ /// Generate a get operation out of the attribute.
+ be_operation *generate_get_operation (be_attribute *node);
+
+ /// Generate a set operation out of the attribute.
+ be_operation *generate_set_operation (be_attribute *node);
+};
+
+
+#endif // TAO_BE_VISITOR_AMH_PRE_PROC_H
diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface.h b/TAO/TAO_IDL/be_include/be_visitor_interface.h
index e472055f52d..4f7a42cd533 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_interface.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_interface.h
@@ -69,4 +69,8 @@
#include "be_visitor_interface/direct_proxy_impl_sh.h"
#include "be_visitor_interface/direct_proxy_impl_ss.h"
+// AMH
+#include "be_visitor_interface/amh_ss.h"
+#include "be_visitor_interface/amh_sh.h"
+
#endif /* _BE_VISITOR_INTERFACE_H */
diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/amh_sh.h b/TAO/TAO_IDL/be_include/be_visitor_interface/amh_sh.h
new file mode 100644
index 00000000000..8b9527c5285
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_interface/amh_sh.h
@@ -0,0 +1,27 @@
+//=============================================================================
+/**
+ * @file amh_sh.h
+ *
+ * $Id$
+ *
+ * Specialized interface visitor for AMH.
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef AMH_SH_H_
+#define AMH_SH_H_
+
+class be_visitor_amh_interface_sh : public be_visitor_interface_sh
+{
+public:
+ be_visitor_amh_interface_sh (be_visitor_context *ctx);
+
+ ~be_visitor_amh_interface_sh (void);
+
+protected:
+ virtual void this_method (be_interface *node);
+};
+
+#endif /* AMH_SH_H_ */
diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/amh_ss.h b/TAO/TAO_IDL/be_include/be_visitor_interface/amh_ss.h
new file mode 100644
index 00000000000..f27a1d17f6b
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_interface/amh_ss.h
@@ -0,0 +1,29 @@
+//=============================================================================
+/**
+ * @file amh_ss.h
+ *
+ * $Id$
+ *
+ * Specialized interface visitor for AMH.
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef AMH_INTERFACE_SS_H
+#define AMH_INTERFACE_SS_H
+
+
+class be_visitor_amh_interface_ss : public be_visitor_interface_ss
+{
+public:
+ be_visitor_amh_interface_ss (be_visitor_context *ctx);
+
+ ~be_visitor_amh_interface_ss (void);
+
+protected:
+ virtual void this_method (be_interface *node);
+ virtual void dispatch_method (be_interface *node);
+};
+
+#endif /* AMH_INTERFACE_SS_H */
diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_sh.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_sh.h
index 526a92af825..bbbffafe4d5 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_sh.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_sh.h
@@ -41,6 +41,9 @@ public:
virtual int visit_interface (be_interface *node);
// set the right context and make a visitor
+
+protected:
+ virtual void this_method (be_interface *node);
};
#endif /* _BE_INTERFACE_INTERFACE_SH_H_ */
diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h
index e57a272a3be..043dab13cf8 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h
@@ -41,6 +41,10 @@ public:
virtual int visit_interface (be_interface *node);
// set the right context and make a visitor
+
+protected:
+ virtual void this_method (be_interface *node);
+ virtual void dispatch_method (be_interface *node);
};
#endif /* _BE_INTERFACE_INTERFACE_SS_H_ */
diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation.h b/TAO/TAO_IDL/be_include/be_visitor_operation.h
index 6c9f1e0d406..53a37626e73 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_operation.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_operation.h
@@ -52,6 +52,7 @@
#include "be_visitor_operation/rettype_post_upcall_ss.h"
#include "be_visitor_operation/rettype_marshal_ss.h"
#include "be_visitor_operation/rettype_pre_invoke_cs.h"
+#include "be_visitor_operation/amh_ss.h"
#include "be_visitor_operation/ami_ch.h"
#include "be_visitor_operation/ami_cs.h"
#include "be_visitor_operation/ami_handler_reply_stub_operation_ch.h"
diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/amh_ss.h b/TAO/TAO_IDL/be_include/be_visitor_operation/amh_ss.h
new file mode 100644
index 00000000000..26e0a799850
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_operation/amh_ss.h
@@ -0,0 +1,33 @@
+//=============================================================================
+/**
+ * @file amh_ss.h
+ *
+ * $Id$
+ *
+ * Creates code for AMH operations.
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef AMH_OPERATION_SS_H
+#define AMH_OPERATION_SS_H
+
+/**
+ * @class be_visitor_operation_amh_ss
+ *
+ * @brief This is a concrete visitor to generate the server source for
+ * AMH operations
+ */
+class be_visitor_amh_operation_ss : public be_visitor_operation
+{
+public:
+ be_visitor_amh_operation_ss (be_visitor_context *ctx);
+
+ ~be_visitor_amh_operation_ss (void);
+
+ virtual int visit_operation (be_operation *node);
+
+};
+
+#endif /* AMH_OPERATION_SS_H */
diff --git a/TAO/TAO_IDL/driver/drv_args.cpp b/TAO/TAO_IDL/driver/drv_args.cpp
index 8b9731b4648..3319c561fa8 100644
--- a/TAO/TAO_IDL/driver/drv_args.cpp
+++ b/TAO/TAO_IDL/driver/drv_args.cpp
@@ -953,6 +953,11 @@ DRV_parse_args (long ac, char **av)
// AMI with Call back.
be_global->ami_call_back (I_TRUE);
}
+ else if (av[i][2] == 'H')
+ {
+ // AMH classes.
+ be_global->gen_amh_classes (I_TRUE);
+ }
else if (av[i][2] == 'e')
{
int option = ACE_OS::atoi (av[i+1]);