summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-01-31 21:17:48 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-01-31 21:17:48 +0000
commitea68f39a36ceec1379d57e6e5689e7b1f8b84dbe (patch)
treeaee293f8267a9b0970af3bd91b972d3911e74c7e /TAO/TAO_IDL
parentc6f3be4e6fdcbe8012ed8ac45afb72e7f60facf0 (diff)
downloadATCD-ea68f39a36ceec1379d57e6e5689e7b1f8b84dbe.tar.gz
ChangeLogTag:Thu Jan 31 13:17:24 2002 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'TAO/TAO_IDL')
-rw-r--r--TAO/TAO_IDL/be/be_interface.cpp6
-rw-r--r--TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp89
-rw-r--r--TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp2
-rw-r--r--TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp62
-rw-r--r--TAO/TAO_IDL/be/be_visitor_operation/operation.cpp62
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_amh_pre_proc.h106
6 files changed, 212 insertions, 115 deletions
diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp
index 92dfbee10c7..6bde2a5978f 100644
--- a/TAO/TAO_IDL/be/be_interface.cpp
+++ b/TAO/TAO_IDL/be/be_interface.cpp
@@ -1099,9 +1099,9 @@ be_interface::gen_operation_table (const char *flat_name,
this->skel_count_++;
os->indent ();
- *os << "_interface, &"
+ *os << "{\"_interface\", &"
<< skeleton_class_name
- << "::_interface_skel\n";
+ << "::_interface_skel}\n";
this->skel_count_++;
os->decr_indent ();
@@ -1213,7 +1213,7 @@ be_interface::gen_operation_table (const char *flat_name,
// Generate the skeleton for the is_a method.
os->indent ();
- *os << "_is_a" << ", &"
+ *os << "_is_a, &"
<< skeleton_class_name
<< "::_is_a_skel\n";
this->skel_count_++;
diff --git a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp
index 03fb18d9e61..712e6721b4b 100644
--- a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp
@@ -87,13 +87,13 @@ be_visitor_amh_pre_proc::visit_interface (be_interface *node)
this->create_exception_holder (node);
excep_holder->set_defined_in (node->defined_in ());
excep_holder->original_interface (node);
- module->be_add_interface (excep_holder, node);
module->set_has_nested_valuetype ();
// Remember from whom we were cloned
// Create the ResponseHandler class
- be_interface *response_handler = this->create_response_handler (node);
+ be_interface *response_handler =
+ this->create_response_handler (node, excep_holder);
if (response_handler == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
@@ -110,13 +110,17 @@ be_visitor_amh_pre_proc::visit_interface (be_interface *node)
// Remember from whom we were cloned
response_handler->original_interface (node);
+ // Add the ExceptionHolder after the ResponseHandler, seems to
+ // generate the code in the right order....
+ module->be_add_interface (excep_holder, node);
return 0;
}
be_interface *
-be_visitor_amh_pre_proc::create_response_handler (be_interface *node)
+be_visitor_amh_pre_proc::create_response_handler (be_interface *node,
+ be_valuetype *exception_holder)
{
// Generate 'AMH_InterfaceResponseHandler'
ACE_CString class_name;
@@ -150,7 +154,7 @@ be_visitor_amh_pre_proc::create_response_handler (be_interface *node)
response_handler->set_line (node->line ());
response_handler->set_file_name (node->file_name ());
- this->add_rh_node_members (node, response_handler);
+ this->add_rh_node_members (node, response_handler, exception_holder);
return response_handler;
}
@@ -158,7 +162,8 @@ be_visitor_amh_pre_proc::create_response_handler (be_interface *node)
int
be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node,
- be_interface *response_handler)
+ be_interface *response_handler,
+ be_valuetype *exception_holder)
{
// Now our customized valuetype is created, we have to
// add now the operations and attributes to the scope.
@@ -196,7 +201,8 @@ be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node,
if (operation)
{
this->create_response_handler_operation (operation,
- response_handler);
+ response_handler,
+ exception_holder);
}
}
}
@@ -206,20 +212,67 @@ be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node,
int
be_visitor_amh_pre_proc::create_response_handler_operation (be_operation *node,
- be_interface *response_handler
- )
+ be_interface *response_handler,
+ be_valuetype *exception_holder)
{
if (!node)
{
return -1;
}
+ // @@ Mayur, we do want to generate code for oneways! This is
+ // needed to support reliable oneways with the SYNC_WITH_TARGET
+ // policy.
if (node->flags () == AST_Operation::OP_oneway)
{
// We do nothing for oneways!
return 0;
}
+ if (this->add_normal_reply (node, response_handler) == -1)
+ return -1;
+
+ return this->add_exception_reply (node, response_handler, exception_holder);
+}
+
+int
+be_visitor_amh_pre_proc::add_exception_reply (be_operation *node,
+ be_interface *response_handler,
+ be_valuetype *exception_holder)
+{
+ // 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"),
+ 0));
+
+ // Create the name...
+ UTL_ScopedName *operation_name =
+ node->compute_name ("", "_excep");
+
+ be_operation *node_excep;
+ ACE_NEW_RETURN (node_excep,
+ be_operation (rt, AST_Operation::OP_noflags,
+ operation_name, 1, 0),
+ -1);
+
+ be_argument *argument =
+ new be_argument (AST_Argument::dir_IN,
+ exception_holder,
+ new UTL_ScopedName (new Identifier ("holder"), 0));
+ argument->set_defined_in (node_excep);
+ node_excep->add_argument_to_scope (argument);
+
+ node_excep->set_defined_in (response_handler);
+ response_handler->be_add_operation (node_excep);
+
+ return 0;
+}
+
+int
+be_visitor_amh_pre_proc::add_normal_reply (be_operation *node,
+ be_interface *response_handler)
+{
// Create the return type, which is "void"
be_predefined_type *rt =
new be_predefined_type (AST_PredefinedType::PT_void,
@@ -306,6 +359,9 @@ be_visitor_amh_pre_proc::create_response_handler_operation (be_operation *node,
int
be_visitor_amh_pre_proc::visit_operation (be_operation *node)
{
+ // @@ Mayur, we do want to generate code for oneways! This is
+ // needed to support reliable oneways with the SYNC_WITH_TARGET
+ // policy.
// We do nothing for oneways!
if (node->flags () == AST_Operation::OP_oneway)
return 0;
@@ -465,20 +521,10 @@ be_visitor_amh_pre_proc::create_exception_holder (be_interface *node)
// "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(),
- "ExceptionHolder");
-
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 ()
- );
+ node->compute_name ("AMH_", "ExceptionHolder");
- AST_Interface_ptr *p_intf = new AST_Interface_ptr[1];
+ AST_Interface **p_intf = new AST_Interface*[1];
p_intf[0] = ACE_static_cast (AST_Interface *, inherit_vt);
be_valuetype *excep_holder =
@@ -552,6 +598,9 @@ be_visitor_amh_pre_proc::create_raise_operation (be_decl *node,
orig_op = be_operation::narrow_from_decl (node);
if (orig_op)
{
+ // @@ Mayur, we do want to generate code for oneways! This is
+ // needed to support reliable oneways with the SYNC_WITH_TARGET
+ // policy, the user can raise system exceptions here.
if (orig_op->flags () == AST_Operation::OP_oneway)
// We do nothing for oneways!
return 0;
diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp
index c96fc851330..12cfa035143 100644
--- a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp
@@ -72,8 +72,6 @@ be_visitor_amh_rh_operation_sh::visit_operation (be_operation *node)
// Step 1 : Generate return type: always void
os->indent ();
*os << "virtual void ";
- // only for source: *os << intf->full_skel_name () << "::";
-
// Step 2: Generate the method name
// Check if we are an attribute node in disguise.
diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp
index 84b8c390b2c..b63dcab75dc 100644
--- a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp
@@ -99,14 +99,64 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node)
delete visitor;
- // Step 3: Generate actual code for the method
- *os << "{" << be_idt_nl
- << "this->_tao_rh_init_reply ();" << be_nl << be_nl;
+ int is_an_exception_reply = 0;
+
+ // Find out if the operation is one of the *_excep() operations, the
+ // conditions are:
+ // 1) The local_name ends in _excep()
+ // 2) There is exactly one argument
+ // 3) The argument takes an implied valuetype generated from the
+ // original interface
+ // 4) The implied valuetype ends in ExceptionHolder
+ if (ACE_OS::strstr (node->full_name (), "_excep") != 0)
+ {
+ if (node->nmembers () == 1)
+ {
+ UTL_ScopeActiveIterator i (node, UTL_Scope::IK_decls);
+ if (!i.is_done ())
+ {
+ be_argument *argument =
+ be_argument::narrow_from_decl (i.item ());
+ be_valuetype *vt =
+ be_valuetype::narrow_from_decl (argument->field_type ());
+ if (vt != 0
+ && vt->original_interface () == intf->original_interface ()
+ && ACE_OS::strstr (vt->full_name (), "ExceptionHolder") != 0)
+ {
+ is_an_exception_reply = 1;
+ }
+ }
+ }
+ }
- marshal_params (node);
+ if (is_an_exception_reply)
+ {
+ *os << "{" << be_idt_nl
+ << "ACE_TRY" << be_nl
+ << "{" << be_nl
+ << "ACE_UNUSED_ARG (holder);" << be_nl
+ // << " holder->raise_" << node->local_name ()
+ // << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_nl
+ // << " ACE_TRY_CHECK;" << be_nl
+ << "}" << be_nl
+ << "ACE_CATCH (CORBA::Exception, ex)" << be_nl
+ << "{" << be_nl
+ << " this->_tao_rh_send_exception (ex);" << be_nl
+ << "}" << be_nl
+ << "ACE_ENDTRY;" << be_uidt_nl
+ << "}\n" << be_nl;
+ }
+ else
+ {
+ // Step 3: Generate actual code for the method
+ *os << "{" << be_idt_nl
+ << "this->_tao_rh_init_reply ();" << be_nl << be_nl;
- *os << "this->_tao_rh_send_reply ();" << be_uidt_nl
- << "}" << be_nl;
+ this->marshal_params (node);
+
+ *os << "this->_tao_rh_send_reply ();" << be_uidt_nl
+ << "}" << be_nl;
+ }
return 0;
diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp
index 05dddecb079..864423484dd 100644
--- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp
@@ -58,7 +58,7 @@ int
be_visitor_operation::has_param_type (be_operation *node,
AST_Argument::Direction dir)
{
- return node->count_arguments_with_direction (dir);
+ return (node->count_arguments_with_direction (dir) != 0);
}
size_t
@@ -101,28 +101,30 @@ be_visitor_operation::gen_throw_spec (be_operation *node)
{
TAO_OutStream *os = this->ctx_->stream (); // grab the out stream
- if (be_global->use_raw_throw ())
- *os << be_idt_nl << "throw (";
- else
- *os << be_idt_nl << "ACE_THROW_SPEC ((";
+ const char *throw_spec_open = "throw (";
+ const char *throw_spec_close = ")";
+
+ if (!be_global->use_raw_throw ())
+ {
+ throw_spec_open = "ACE_THROW_SPEC ((";
+ throw_spec_close = "))";
+ }
- *os << be_idt_nl << "CORBA::SystemException";
+ *os << be_idt_nl << throw_spec_open
+ << be_idt_nl << "CORBA::SystemException";
if (node->exceptions ())
{
// initialize an iterator to iterate thru the exception list
- UTL_ExceptlistActiveIterator *ei;
- ACE_NEW_RETURN (ei,
- UTL_ExceptlistActiveIterator (node->exceptions ()),
- -1);
- // continue until each element is visited
- while (!ei->is_done ())
+ for (UTL_ExceptlistActiveIterator ei (node->exceptions ());
+ !ei.is_done ();
+ ei.next ())
{
- be_exception *excp = be_exception::narrow_from_decl (ei->item ());
+ be_exception *excp =
+ be_exception::narrow_from_decl (ei.item ());
if (excp == 0)
{
- delete ei;
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation"
"gen_throw_spec - "
@@ -130,24 +132,12 @@ be_visitor_operation::gen_throw_spec (be_operation *node)
}
- *os << "," << be_nl;
- // allocator method
- *os << excp->name ();
- ei->next ();
- } // end of while loop
-
- delete ei;
- } // end of if
-
- if (be_global->use_raw_throw ())
- {
- *os << be_uidt_nl << ")" << be_uidt;
- }
- else
- {
- *os << be_uidt_nl << "))" << be_uidt;
+ *os << be_nl << ", " << excp->name ();
+ }
}
+ *os << be_uidt_nl << throw_spec_close << be_uidt;
+
return 0;
}
@@ -155,12 +145,12 @@ int
be_visitor_operation::gen_environment_decl (int argument_emitted,
be_operation *node)
{
- TAO_OutStream *os = this->ctx_->stream (); // grab the out stream
-
// generate the CORBA::Environment parameter for the alternative mapping
if (be_global->exception_support ())
return 0;
+ TAO_OutStream *os = this->ctx_->stream (); // grab the out stream
+
// Use ACE_ENV_SINGLE_ARG_DECL or ACE_ENV_ARG_DECL depending on
// whether the operation node has parameters.
const char *env_decl = "ACE_ENV_SINGLE_ARG_DECL";
@@ -191,7 +181,7 @@ be_visitor_operation::gen_environment_decl (int argument_emitted,
return 0;
}
-//Method that returns the appropriate CORBA::Environment variable
+// Method that returns the appropriate CORBA::Environment variable
const char *
be_visitor_operation::gen_environment_var ()
{
@@ -223,7 +213,9 @@ be_visitor_operation::gen_raise_exception (be_type *return_type,
return 0;
}
- if (return_type == 0 || this->void_return_type (return_type))
+ int is_void =
+ return_type == 0 || this->void_return_type (return_type);
+ if (is_void)
{
*os << "ACE_THROW (";
}
@@ -233,7 +225,7 @@ be_visitor_operation::gen_raise_exception (be_type *return_type,
}
*os << exception_name << " (" << exception_arguments << ")";
- if (return_type == 0 || this->void_return_type (return_type))
+ if (is_void)
{
*os << ");\n";
return 0;
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
index ec8f0c5a9c5..9f2ec8ddc3b 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_amh_pre_proc.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_amh_pre_proc.h
@@ -4,7 +4,7 @@
*
* $Id$
*
-* This visitor creates for AMH implied IDL constructs for the ResponseHandler,
+* This visitor creates for AMH implied IDL constructs for the ResponseHandler,
* the appropriate AST
* (Abstract Syntax Tree) node, sets the corresponding interface or operation
* strategy on it and enters the node into the AST.
@@ -26,73 +26,81 @@
#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
+ *
+ * @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;
+private:
+ typedef enum {
+ NORMAL,
+ GET_OPERATION,
+ SET_OPERATION
+ } Operation_Kind;
+
+public:
+ be_visitor_amh_pre_proc (be_visitor_context *ctx);
- typedef enum {
- NORMAL,
- GET_OPERATION,
- SET_OPERATION
- } Operation_Kind;
+ virtual ~be_visitor_amh_pre_proc (void);
- public:
- be_visitor_amh_pre_proc (be_visitor_context *ctx);
+ virtual int visit_root (be_root *node);
- virtual ~be_visitor_amh_pre_proc (void);
+ virtual int visit_module (be_module *node);
- virtual int visit_root (be_root *node);
+ virtual int visit_interface (be_interface *node);
- virtual int visit_module (be_module *node);
+ virtual int visit_operation (be_operation *node);
- virtual int visit_interface (be_interface *node);
+ virtual int visit_attribute (be_attribute *node);
- virtual int visit_operation (be_operation *node);
+ virtual int visit_scope (be_scope *node);
- virtual int visit_attribute (be_attribute *node);
+private:
+ /// Create the reponse handler interface
+ be_interface *create_response_handler (be_interface *node,
+ be_valuetype *exception_holder);
- private:
+ /// method to add memebers to the response handler interfaces
+ int add_rh_node_members ( be_interface *node,
+ be_interface *response_handler,
+ be_valuetype *exception_holder);
- /// 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);
+ /// Create an operation with return, OUT and INOUT arguments
+ int create_response_handler_operation (be_operation *node,
+ be_interface *response_handler,
+ be_valuetype *exception_holder);
- /// Create the reponse handler interface
- be_interface *create_response_handler (be_interface *node);
+ /// Add the normal reply handler for the @c node operation
+ int add_normal_reply (be_operation *node,
+ be_interface *response_handler);
- /// method to add memebers to the response handler interfaces
- int add_rh_node_members ( be_interface *node,
- be_interface *response_handler);
-
- /// Create the exception holder valuetype
- be_valuetype *create_exception_holder (be_interface *node);
+ /// Add the exception version of @c node
+ int add_exception_reply (be_operation *node,
+ be_interface *response_handler,
+ be_valuetype *exception_holder);
- /// Create an operation with return, OUT and INOUT arguments
- int create_response_handler_operation (be_operation *node,
- be_interface *response_handler);
+ /// Create the exception holder valuetype
+ be_valuetype *create_exception_holder (be_interface *node);
- /// Specialized visit_scope
- int visit_scope (be_scope *node);
+ /// 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);
- /// Concatenate 3 strings into one.
- int generate_name (ACE_CString &destination,
- const char *prefix,
- const char *middle_name,
- const char *suffix);
+ /// 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 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);
+ /// Generate a set operation out of the attribute.
+ be_operation *generate_set_operation (be_attribute *node);
};