diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-01-25 02:18:22 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-01-25 02:18:22 +0000 |
commit | c372de73fc778de5deb509632c278f5ab0864bf0 (patch) | |
tree | b57c9b55bae62025b9322debf1c1f96bdcf4f527 | |
parent | 7e2e9f5aa1ad7835d2b1a31b971fe703ee6b3d71 (diff) | |
download | ATCD-c372de73fc778de5deb509632c278f5ab0864bf0.tar.gz |
ChangeLogTag:Thu Jan 24 17:47:00 2002 Carlos O'Ryan <coryan@uci.edu>
-rw-r--r-- | TAO/ChangeLogs/ChangeLog-02a | 53 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_decl.cpp | 9 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_interface.cpp | 16 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_argument.cpp | 1 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp | 2 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp | 8 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp | 149 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp | 23 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp | 147 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp | 237 | ||||
-rw-r--r-- | TAO/TAO_IDL/be_include/be_visitor_interface/amh_ss.h | 2 | ||||
-rw-r--r-- | TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h | 2 | ||||
-rw-r--r-- | TAO/TAO_IDL/be_include/be_visitor_operation/amh_sh.h | 14 | ||||
-rw-r--r-- | TAO/TAO_IDL/be_include/be_visitor_operation/amh_ss.h | 25 |
14 files changed, 470 insertions, 218 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 5b64d22a530..ffa12706073 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,56 @@ +Thu Jan 24 17:47:00 2002 Carlos O'Ryan <coryan@uci.edu> + + * TAO_IDL/be/be_decl.cpp: + Fixed the implementation of compute_flat_name() there was + nothing flat about the named computed: it used the regular full + name for the containing scope, so for nested modules the results + were wrong. + + * TAO_IDL/be/be_interface.cpp: + Fixed warning about unused argument and made several cosmetic + fixes. + + * TAO_IDL/be/be_visitor_argument.cpp: + * TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp: + Cosmetic fixes. + + * TAO_IDL/be/be_visitor_interface/amh_sh.cpp: + * TAO_IDL/be/be_visitor_interface/amh_ss.cpp: + Implement code to process attributes as well as operations. + + * TAO_IDL/be/be_visitor_interface/amh_ss.cpp: + Fixed implementation of the _downcast() method on the AMH + skeleton. + + * TAO_IDL/be_include/be_visitor_interface/amh_ss.h: + * TAO_IDL/be/be_visitor_interface/amh_ss.cpp: + * TAO_IDL/be_include/be_visitor_interface/interface_ss.h: + * TAO_IDL/be/be_visitor_interface/interface_ss.cpp: + Generate correct code for AMH-copy constructors. I used the new + class-based traverse_inheritance_graph(). + + * TAO_IDL/be_include/be_visitor_operation/amh_sh.h: + * TAO_IDL/be_include/be_visitor_operation/amh_ss.h: + * TAO_IDL/be/be_visitor_operation/amh_sh.cpp: + * TAO_IDL/be/be_visitor_operation/amh_ss.cpp: + Add support for attributes, in both cases I used a technique + slightly different from what the rest of the IDL compiler does. + Normally a fake be_operation node is generated on the fly + (usually heap allocated) and used to generate the code "as if" + it was a real operation. However, the code to generate + operations has to be modified to treat these nodes with some + magic, because the attribute name (on GIOP) are different than + the actual name of the attribute. + My approach was to re-factor the common code to generate + attributes and operations in these new fangled things called + "subroutines". The attribute code calls the subroutines to + generate the desired code. I did have to generate a temporary + node (of type be_argument), but I was able to stack-allocate it + and use it in a very localized section of the code. + Also, none of the operation code has to understand about + attributes. + + Thu Jan 24 15:48:01 2002 Mayur Deshpande <mayur@ics.uci.edu> * tao/TAO_Static.dsp: diff --git a/TAO/TAO_IDL/be/be_decl.cpp b/TAO/TAO_IDL/be/be_decl.cpp index 933aceb95a8..f6f5e972f87 100644 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ b/TAO/TAO_IDL/be/be_decl.cpp @@ -312,7 +312,8 @@ be_decl::compute_flat_name (const char *prefix, else { // Get scope name. - be_decl *parent = be_scope::narrow_from_scope (this->defined_in ())->decl (); + be_decl *parent = + be_scope::narrow_from_scope (this->defined_in ())->decl (); if (parent == 0) { ACE_ERROR ((LM_ERROR, @@ -322,11 +323,11 @@ be_decl::compute_flat_name (const char *prefix, } // Parent name. - result_str = ACE_CString (parent->full_name ()); + result_str = ACE_CString (parent->flat_name ()); // _ - if (ACE_OS::strcmp (parent->full_name (), "") != 0) - result_str += ACE_CString ("_"); + if (ACE_OS::strcmp (parent->flat_name (), "") != 0) + result_str += "_"; // Prefix. result_str += prefix_str; diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 45db4d35681..5124e7aa803 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -1048,7 +1048,7 @@ TAO_IDL_Gen_OpTable_Worker (const char *skeleton_name) } int -TAO_IDL_Gen_OpTable_Worker::emit (be_interface *derived_interface, +TAO_IDL_Gen_OpTable_Worker::emit (be_interface * /* derived_interface */, TAO_OutStream *os, be_interface *base_interface) { @@ -1301,7 +1301,7 @@ be_interface::gen_optable_entries (const char *full_skeleton_name, { // Start from current indentation level. os->indent (); - + // We are an operation node. *os << "{\"" << d->original_local_name () << "\", &" << full_skeleton_name << "::" @@ -1628,10 +1628,10 @@ be_interface::gen_gperf_things (const char *flat_name) case BE_GlobalData::TAO_PERFECT_HASH: // Output a class definition deriving from // TAO_Perfect_Hash_OpTable. - gen_perfect_hash_class_definition (flat_name); + this->gen_perfect_hash_class_definition (flat_name); // Call GPERF and get the methods defined. - if (gen_gperf_lookup_methods (flat_name) == -1) + if (this->gen_gperf_lookup_methods (flat_name) == -1) { return -1; } @@ -2068,10 +2068,6 @@ be_interface::gen_skel_helper (be_interface *derived, be_interface *ancestor, TAO_OutStream *os) { - UTL_ScopeActiveIterator *si = 0;; - AST_Decl *d = 0; - TAO_NL nl; - // If derived and ancestor are same, skip it. if (derived == ancestor) { @@ -2092,7 +2088,7 @@ be_interface::gen_skel_helper (be_interface *derived, si.next ()) { // Get the next AST decl node - d = si.item (); + AST_Decl *d = si.item (); if (d->node_type () == AST_Decl::NT_op) { // Start from current indentation level. @@ -2176,7 +2172,7 @@ be_interface::gen_skel_helper (be_interface *derived, << ancestor->full_skel_name () << "_ptr impl = (" << derived->full_skel_name () - << "_ptr) obj;" << nl; + << "_ptr) obj;" << be_nl; *os << ancestor->full_skel_name () << "::_get_" << d->local_name () << "_skel (" << be_idt << be_idt_nl diff --git a/TAO/TAO_IDL/be/be_visitor_argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument.cpp index 965b7582b85..2d436b89bae 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument.cpp @@ -41,4 +41,3 @@ #include "be_visitor_argument/request_info_arglist.cpp" ACE_RCSID(be, be_visitor_argument, "$Id$") - diff --git a/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp index 1886c07cb8f..eba9ac33fd7 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp @@ -462,5 +462,3 @@ int be_visitor_args_vardecl_ss::visit_typedef (be_typedef *node) this->ctx_->alias (0); return 0; } - - diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp index ef701a48dfc..9ea03ac459f 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp @@ -193,12 +193,10 @@ be_visitor_amh_interface_sh::visit_operation (be_operation *node) } int -be_visitor_amh_interface_sh::visit_attribute (be_attribute *) +be_visitor_amh_interface_sh::visit_attribute (be_attribute *node) { - ACE_DEBUG ((LM_DEBUG, - "be_visitor_amh_interface_ss::visit_attribute - " - "ignoring attribute, must generate code later\n")); - return 0; + be_visitor_amh_operation_sh visitor (this->ctx_); + return visitor.visit_attribute (node); } int diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp index d306d870525..94bf1737db1 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp @@ -17,19 +17,6 @@ #include "be_visitor_interface.h" #include "be_visitor_operation.h" -class TAO_IDL_Downcast_Implementation_Worker - : public TAO_IDL_Inheritance_Hierarchy_Worker -{ -public: - TAO_IDL_Downcast_Implementation_Worker (); - - virtual int emit (be_interface *base, - TAO_OutStream *os, - be_interface *derived); -}; - -// **************************************************************** - be_visitor_amh_interface_ss::be_visitor_amh_interface_ss (be_visitor_context *ctx) : be_visitor_interface_ss (ctx) { @@ -47,12 +34,10 @@ be_visitor_amh_interface_ss::visit_operation (be_operation *node) } int -be_visitor_amh_interface_ss::visit_attribute (be_attribute *) +be_visitor_amh_interface_ss::visit_attribute (be_attribute *node) { - ACE_DEBUG ((LM_DEBUG, - "be_visitor_amh_interface_ss::visit_attribute - " - "ignoring attribute, must generate code later\n")); - return 0; + be_visitor_amh_operation_ss visitor (this->ctx_); + return visitor.visit_attribute (node); } int @@ -150,6 +135,49 @@ be_visitor_amh_interface_ss::generate_proxy_classes (be_interface *) return 0; } +// **************************************************************** + +class TAO_IDL_Downcast_Implementation_Worker + : public TAO_IDL_Inheritance_Hierarchy_Worker +{ +public: + TAO_IDL_Downcast_Implementation_Worker (); + + virtual int emit (be_interface *base, + TAO_OutStream *os, + be_interface *derived); +}; + +TAO_IDL_Downcast_Implementation_Worker:: +TAO_IDL_Downcast_Implementation_Worker (void) +{ +} + +int +TAO_IDL_Downcast_Implementation_Worker:: +emit (be_interface * /* derived */, + TAO_OutStream *os, + be_interface *base) +{ + // @@ This whole thing would be more efficient if we could pass the + // ACE_CString to compute_full_name, after all it uses that + // internally. + ACE_CString amh_name ("POA_"); + + // @@ The following code is *NOT* exception-safe. + char *buf = 0; + base->compute_full_name ("AMH_", "", buf); + amh_name += buf; + delete[] buf; + + *os << "if (ACE_OS::strcmp (logical_type_id, \"" + << base->repoID () << "\") == 0)" << be_idt_nl + << "return ACE_static_cast (" + << amh_name.c_str () << "*, this);" << be_uidt_nl; + + return 0; +} + int be_visitor_amh_interface_ss::generate_downcast_implementation (be_interface *node, TAO_OutStream *os) @@ -158,6 +186,59 @@ be_visitor_amh_interface_ss::generate_downcast_implementation (be_interface *nod return node->traverse_inheritance_graph (worker, os); } +// **************************************************************** + +class TAO_IDL_Copy_Ctor_Worker + : public TAO_IDL_Inheritance_Hierarchy_Worker +{ +public: + TAO_IDL_Copy_Ctor_Worker (void); + + virtual int emit (be_interface *base, + TAO_OutStream *os, + be_interface *derived); +}; + +TAO_IDL_Copy_Ctor_Worker:: +TAO_IDL_Copy_Ctor_Worker (void) +{ +} + +int +TAO_IDL_Copy_Ctor_Worker:: +emit (be_interface *derived, + TAO_OutStream *os, + be_interface *base) +{ + if (derived == base) + return 0; + + // @@ This whole thing would be more efficient if we could pass the + // ACE_CString to compute_full_name, after all it uses that + // internally. + ACE_CString amh_name ("POA_"); + + // @@ The following code is *NOT* exception-safe. + char *buf = 0; + base->compute_full_name ("AMH_", "", buf); + amh_name += buf; + delete[] buf; + + *os << amh_name.c_str () << " (rhs)," << be_nl; + + return 0; +} + +int +be_visitor_amh_interface_ss::generate_copy_ctor (be_interface *node, + TAO_OutStream *os) +{ + TAO_IDL_Copy_Ctor_Worker worker; + return node->traverse_inheritance_graph (worker, os); +} + +// **************************************************************** + ACE_CString be_visitor_amh_interface_ss::generate_flat_name (be_interface *node) { @@ -166,7 +247,7 @@ be_visitor_amh_interface_ss::generate_flat_name (be_interface *node) node->compute_flat_name ("AMH_", "", buf); // @@ This whole thing would be more efficient if we could pass the - // ACE_CString to compute_full_name, after all it uses that + // ACE_CString to compute_flat_name, after all it uses that // internally. ACE_CString result (buf); delete[] buf; @@ -198,33 +279,3 @@ be_visitor_amh_interface_ss::generate_full_skel_name (be_interface *node) return result; } - -TAO_IDL_Downcast_Implementation_Worker:: -TAO_IDL_Downcast_Implementation_Worker (void) -{ -} - -int -TAO_IDL_Downcast_Implementation_Worker:: -emit (be_interface * /* derived */, - TAO_OutStream *os, - be_interface *base) -{ - // @@ This whole thing would be more efficient if we could pass the - // ACE_CString to compute_full_name, after all it uses that - // internally. - ACE_CString amh_name ("POA_"); - - // @@ The following code is *NOT* exception-safe. - char *buf = 0; - base->compute_full_name ("AMH_", "", buf); - amh_name += buf; - delete[] buf; - - *os << "if (ACE_OS::strcmp (logical_type_id, \"" - << base->repoID () << "\") == 0)" << be_idt_nl - << "return ACE_static_cast (" - << amh_name.c_str () << "*, this);" << be_uidt_nl; - - return 0; -} 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 b5d9039df26..b6f3684674c 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp @@ -89,7 +89,11 @@ be_visitor_interface_ss::visit_interface (be_interface *node) if (this->generate_proxy_classes (node) == -1) { - return -1; + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ss::" + "visit_interface - " + "codegen for proxy classes\n"), + -1); } *os << "// TAO_IDL - Generated from " << be_nl @@ -122,18 +126,19 @@ be_visitor_interface_ss::visit_interface (be_interface *node) *os << full_skel_name << "::" << local_name_prefix << node_local_name << " (" << "const " << local_name_prefix << node_local_name << "& rhs)"; + *os << be_idt_nl - << ": "; + << ":"; - if (node->traverse_inheritance_graph ( - be_interface::copy_ctor_helper, os - ) == -1) + if (this->generate_copy_ctor (node, os) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ss::visit_interface - " " copy ctor generation failed\n"), -1); } + + *os << " TAO_ServantBase (rhs)" << be_uidt_nl << "{}" << be_nl << be_nl; @@ -558,6 +563,14 @@ be_visitor_interface_ss::generate_downcast_implementation (be_interface *node, os); } +int +be_visitor_interface_ss::generate_copy_ctor (be_interface *node, + TAO_OutStream *os) +{ + return node->traverse_inheritance_graph (be_interface::copy_ctor_helper, + os); +} + ACE_CString be_visitor_interface_ss::generate_flat_name (be_interface *node) { diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp index c1421f03f01..16f332b6286 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp @@ -25,8 +25,9 @@ #include "ast_decl.h" #include "be_visitor_operation.h" +#include "be_visitor_argument.h" -ACE_RCSID(be_visitor_operation, operation_amh_sh, "$Id$") +ACE_RCSID(be_visitor_operation, amh_sh, "$Id$") // ****************************************************** @@ -53,19 +54,89 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl; + this->generate_shared_prolog (node, os, ""); + + int argument_count = + node->count_arguments_with_direction (AST_Argument::dir_IN + | AST_Argument::dir_INOUT); + if (argument_count != 0) + { + *os << "," << be_nl; + } + + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); + + be_visitor_operation_arglist arglist_visitor (&ctx); + if (arglist_visitor.visit_scope (node) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) - visit_scope failed\n"), -1); + + if (arglist_visitor.gen_environment_decl (1, node) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) - gen_environment_decl failed\n"), -1); + + *os << be_uidt_nl << ")" << be_uidt; + if (arglist_visitor.gen_throw_spec (node) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) - gen_throe_spec failed\n"), -1); + *os << " = 0;\n" << be_nl; + + return 0; +} + +int +be_visitor_amh_operation_sh::visit_attribute (be_attribute *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + this->generate_shared_prolog (node, os, "_get_"); + + if (!be_global->exception_support ()) + { + *os << be_nl << "TAO_ENV_SINGLE_ARG_DECL"; + } + *os << be_uidt_nl << ")" << be_uidt_nl + << "ACE_THROW_SPEC ((CORBA::SystemException)) = 0;\n" << be_nl; + + if (node->readonly ()) + return 0; + + this->generate_shared_prolog (node, os, "_set_"); + + *os << "," << be_nl; + + be_argument the_argument (AST_Argument::dir_IN, + node->field_type (), + node->name ()); + be_visitor_context ctx (*this->ctx_); + be_visitor_args_arglist visitor (&ctx); - *os << "static void "; - if (this->ctx_->attribute ()) + if (visitor.visit_argument (&the_argument) == -1) + return -1; + + *os << the_argument.local_name (); + + if (!be_global->exception_support ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "_set_"; - else - *os << "_get_"; + *os << be_nl << "TAO_ENV_SINGLE_ARG_DECL"; } - *os << node->local_name () + *os << be_uidt_nl << ")" << be_uidt_nl + << "ACE_THROW_SPEC ((CORBA::SystemException)) = 0;\n" << be_nl; + + return 0; +} + +void +be_visitor_amh_operation_sh::generate_shared_prolog (be_decl *node, + TAO_OutStream *os, + const char *skel_prefix) +{ + os->indent (); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl; + + *os << "static void " << skel_prefix + << node->local_name () << "_skel (" << be_idt << be_idt_nl << "TAO_ServerRequest &_tao_req," << be_nl << "void *_tao_obj," << be_nl @@ -73,7 +144,6 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) << "TAO_ENV_ARG_DECL" << be_uidt_nl << ");" << be_uidt << "\n\n"; - // 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 @@ -84,11 +154,11 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) if (intf == 0) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_operation_sh::" - "visit_operation - " - "bad interface scope\n"), - -1); + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_visitor_amh_operation_sh::" + "visit_operation - " + "bad interface scope\n")); + return; } // Step 1 : Generate return type: always void @@ -96,25 +166,12 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) *os << "virtual void "; // Step 2: Generate the method 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) - { - *os << "set_"; - } - else - { - *os << "get_"; - } - } + *os << node->local_name() << " (" << be_idt << be_idt_nl; // STEP 3: Generate the argument list with the appropriate // mapping. For these we grab a visitor that generates the // parameter listing. We also generate the ResponseHandler // argument 'on the fly' and add it to the argument list - *os << node->local_name() << " (" << be_idt << be_idt_nl; char *buf; // @@ TODO this must be kept consistent with the code in @@ -123,32 +180,4 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) *os << buf << " _tao_rh"; delete[] buf; - - int argument_count = - node->count_arguments_with_direction (AST_Argument::dir_IN - | AST_Argument::dir_INOUT); - if (argument_count != 0) - { - *os << "," << be_nl; - } - - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - - be_visitor_operation_arglist arglist_visitor (&ctx); - if (arglist_visitor.visit_scope (node) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) - visit_scope failed\n"), -1); - - if (arglist_visitor.gen_environment_decl (1, node) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) - gen_environment_decl failed\n"), -1); - - *os << be_uidt_nl << ")" << be_uidt; - if (arglist_visitor.gen_throw_spec (node) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) - gen_throe_spec failed\n"), -1); - *os << " = 0;\n" << be_nl; - - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp index 2fd705534fa..470e0e5a5cd 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp @@ -35,6 +35,154 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); + if (this->generate_shared_prolog (node, os, "") == -1) + return -1; + + { + // Declare variables for arguments. + be_visitor_context ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + + if (!visitor || (node->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_operation_ss::" + "visit_operation - " + "codegen for return var decl failed\n"), + -1); + } + delete visitor; + } + + int argument_count = + node->count_arguments_with_direction (AST_Argument::dir_IN + | AST_Argument::dir_INOUT); + + if (argument_count != 0) + { + // Avoid warnings in generated code due to unused arguments. + *os << be_nl + << "TAO_InputCDR &_tao_in =" + << " _tao_server_request.incoming ();\n\n"; + } + + // Demarshal parameters. + if (this->demarshal_params (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_operation_ss::" + "visit_operation - " + "demarshal_params failed\n"), + -1); + } + + if (this->generate_shared_section (node, os, argument_count) == -1) + return -1; + + { + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS); + be_visitor_operation_argument visitor (&ctx); + if (node->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_operation_ss::" + "visit_operation - " + "codegen for upcall args failed\n"), + -1); + } + } + + if (this->generate_shared_epilogue (os) == -1) + return -1; + + return 0; + +} + +int +be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); + + if (this->generate_shared_prolog (node, os, "_get_") == -1) + return -1; + + if (this->generate_shared_section (node, os, 0) == -1) + return -1; + + *os << "TAO_ENV_ARG_PARAMETER"; + + if (this->generate_shared_epilogue (os) == -1) + return -1; + + if (node->readonly ()) + return 0; + + if (this->generate_shared_prolog (node, os, "_set_") == -1) + return -1; + + be_argument the_argument (AST_Argument::dir_IN, + node->field_type (), + node->name ()); + + { + be_visitor_context ctx (*this->ctx_); + be_visitor_args_vardecl_ss visitor (&ctx); + + if (visitor.visit_argument (&the_argument) == -1) + return -1; + } + + *os << be_nl + << "TAO_InputCDR &_tao_in =" + << " _tao_server_request.incoming ();\n" + << be_nl + << "if (!(\n" << be_idt; + + { + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); + be_visitor_args_marshal_ss visitor (&ctx); + + if (visitor.visit_argument (&the_argument) == -1) + return -1; + + *os << be_uidt_nl << "))" << be_idt_nl; + + // If marshaling fails, raise exception. + if (this->gen_raise_exception (0, + "CORBA::MARSHAL", + "") == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) gen_raise_exception failed\n"), + -1); + } + *os << be_uidt << "\n"; + } + + if (this->generate_shared_section (node, os, 1) == -1) + return -1; + + *os << node->local_name () + << be_nl << "TAO_ENV_ARG_PARAMETER"; + + if (this->generate_shared_epilogue (os) == -1) + return -1; + + return 0; +} + +int +be_visitor_amh_operation_ss::generate_shared_prolog (be_decl *node, + TAO_OutStream *os, + const char *skel_prefix) +{ *os << "// TAO_IDL - Generated from " << __FILE__ << ":" << __LINE__ << be_nl; @@ -43,8 +191,6 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) // information from the context be_interface *intf = be_interface::narrow_from_scope (node->defined_in ()); - if (this->ctx_->attribute () != 0) - intf = be_interface::narrow_from_scope (this->ctx_->attribute()->defined_in ()); if (intf == 0) { @@ -64,19 +210,9 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) os->indent (); *os << "void" << be_nl - << amh_skel_name.c_str () << "::"; - - // 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 () + << amh_skel_name.c_str () << "::" + << skel_prefix + << node->local_name () << "_skel (" << be_idt << be_idt_nl << "TAO_ServerRequest &_tao_server_request," << be_nl << "void *_tao_object_reference, " << be_nl @@ -84,8 +220,7 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) << "TAO_ENV_ARG_DECL" << 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 + // Generate the actual code for the skeleton. // last argument - is always TAO_ENV_ARG_PARAMETER. *os << "{" << be_idt_nl; @@ -96,47 +231,19 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) << "_tao_object_reference" << be_uidt << be_uidt_nl << ");\n" << be_uidt; - { - // Declare variables for arguments. - be_visitor_context ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_operation_ss::" - "visit_operation - " - "codegen for return var decl failed\n"), - -1); - } - delete visitor; - } - - int argument_count = - node->count_arguments_with_direction (AST_Argument::dir_IN - | AST_Argument::dir_INOUT); - - if (argument_count != 0) - { - // Avoid warnings in generated code due to unused arguments. - *os << be_nl - << "TAO_InputCDR &_tao_in =" - << " _tao_server_request.incoming ();\n\n"; - } + return 0; +} - // Demarshal parameters. - if (this->demarshal_params (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_operation_ss::" - "visit_operation - " - "demarshal_params failed\n"), - -1); - } +int +be_visitor_amh_operation_ss::generate_shared_section (be_decl *node, + TAO_OutStream *os, + int argument_count) +{ + be_interface *intf = + be_interface::narrow_from_scope (node->defined_in ()); // Create the response handler + char *buf; intf->compute_full_name ("AMH_", "ResponseHandler", buf); ACE_CString response_handler_name (buf); delete[] buf; @@ -159,29 +266,19 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) if (argument_count != 0) *os << ","; - { - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS); - be_visitor_operation_argument visitor (&ctx); - if (node->accept (&visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_operation_ss::" - "visit_operation - " - "codegen for upcall args failed\n"), - -1); - } - } + return 0; +} +int +be_visitor_amh_operation_ss::generate_shared_epilogue (TAO_OutStream *os) +{ *os << be_uidt_nl << ");" << be_uidt << be_uidt_nl << "}\n\n"; return 0; - } - int be_visitor_amh_operation_ss::demarshal_params (be_operation *node) { 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 index 232db86e290..d836cc22d59 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/amh_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/amh_ss.h @@ -33,6 +33,8 @@ protected: virtual int generate_proxy_classes (be_interface *node); virtual int generate_downcast_implementation (be_interface *node, TAO_OutStream *os); + virtual int generate_copy_ctor (be_interface *node, + TAO_OutStream *os); virtual ACE_CString generate_flat_name (be_interface *node); virtual ACE_CString generate_local_name (be_interface *node); virtual ACE_CString generate_full_skel_name (be_interface *node); 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 c3a6589b53e..2f0b008520d 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 @@ -50,6 +50,8 @@ protected: virtual int generate_proxy_classes (be_interface *node); virtual int generate_downcast_implementation (be_interface *node, TAO_OutStream *os); + virtual int generate_copy_ctor (be_interface *node, + TAO_OutStream *os); virtual ACE_CString generate_flat_name (be_interface *node); virtual ACE_CString generate_local_name (be_interface *node); virtual ACE_CString generate_full_skel_name (be_interface *node); diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/amh_sh.h b/TAO/TAO_IDL/be_include/be_visitor_operation/amh_sh.h index e9dc268fa55..045a8b5f6fb 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/amh_sh.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/amh_sh.h @@ -21,13 +21,17 @@ */ class be_visitor_amh_operation_sh : public be_visitor_operation { - public: - be_visitor_amh_operation_sh (be_visitor_context *ctx); +public: + be_visitor_amh_operation_sh (be_visitor_context *ctx); + ~be_visitor_amh_operation_sh (void); - ~be_visitor_amh_operation_sh (void); - - virtual int visit_operation (be_operation *node); + virtual int visit_operation (be_operation *node); + virtual int visit_attribute (be_attribute *node); +private: + void generate_shared_prolog (be_decl *node, + TAO_OutStream *os, + const char *skel_prefix); }; #endif /* AMH_OPERATION_SS_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 index dbe56f0d257..9ec003a908a 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/amh_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/amh_ss.h @@ -21,15 +21,24 @@ */ 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); +public: + be_visitor_amh_operation_ss (be_visitor_context *ctx); - protected: - virtual int demarshal_params (be_operation *node); + ~be_visitor_amh_operation_ss (void); + + virtual int visit_operation (be_operation *node); + virtual int visit_attribute (be_attribute *node); + +protected: + virtual int demarshal_params (be_operation *node); + + int generate_shared_prolog (be_decl *node, + TAO_OutStream *os, + const char *skel_prefix); + int generate_shared_section (be_decl *node, + TAO_OutStream *os, + int argument_count); + int generate_shared_epilogue (TAO_OutStream *os); }; #endif /* AMH_OPERATION_SS_H */ |