summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp266
1 files changed, 144 insertions, 122 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp b/TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp
index c625d5f4945..4df0dab9b12 100644
--- a/TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp
@@ -1,17 +1,26 @@
-
-//=============================================================================
-/**
- * @file home_svh.cpp
- *
- * $Id$
- *
- * Visitor generating code for HOmes in the servant header.
- *
- *
- * @author Jeff Parsons
- */
-//=============================================================================
-
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// home_svh.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for HOmes in the servant header.
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+ACE_RCSID (be_visitor_home,
+ home_svh,
+ "$Id$")
// ******************************************************
// Home visitor for server header
@@ -45,16 +54,16 @@ be_visitor_home_svh::visit_home (be_home *node)
{
return 0;
}
-
+
node_ = node;
comp_ = node_->managed_component ();
-
+
/// CIDL-generated namespace used 'CIDL_' + composition name.
/// Now we use 'CIAO_' + component's flat name.
os_ << be_nl << be_nl
<< "namespace CIAO_" << comp_->flat_name () << "_Impl" << be_nl
<< "{" << be_idt;
-
+
if (this->gen_servant_class () == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
@@ -63,12 +72,12 @@ be_visitor_home_svh::visit_home (be_home *node)
ACE_TEXT ("gen_servant_class() failed\n")),
-1);
}
-
+
this->gen_entrypoint ();
os_ << be_uidt_nl
<< "}";
-
+
return 0;
}
@@ -87,62 +96,26 @@ be_visitor_home_svh::visit_attribute (be_attribute *node)
}
int
-be_visitor_home_svh::visit_factory (be_factory *node)
-{
- // An inherited factory/finder needs to return the managed
- // component of the home where it is defined.
- be_home *h =
- be_home::narrow_from_scope (node->defined_in ());
-
- AST_Component *c = h->managed_component ();
-
- os_ << be_nl << be_nl
- << "virtual ::" << c->name () << "_ptr" << be_nl
- << node->local_name ();
-
- // We can reuse this visitor.
- be_visitor_valuetype_init_arglist_ch v (this->ctx_);
-
- if (v.visit_factory (node) != 0)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("be_visitor_home_svh::")
- ACE_TEXT ("visit_factory - ")
- ACE_TEXT ("codegen for argument ")
- ACE_TEXT ("list failed\n")),
- -1);
- }
-
- os_ << ";";
-
- return 0;
-}
-
-int
-be_visitor_home_svh::visit_finder (be_finder *node)
-{
- return this->visit_factory (node);
-}
-
-int
be_visitor_home_svh::gen_servant_class (void)
{
AST_Decl *scope = ScopeAsDecl (node_->defined_in ());
ACE_CString sname_str (scope->full_name ());
const char *sname = sname_str.c_str ();
-
+
// No '_cxx_' prefix.
const char *lname =
node_->original_local_name ()->get_string ();
-
+
const char *clname = comp_->local_name ()->get_string ();
const char *global = (sname_str == "" ? "" : "::");
-
+ bool swapping = be_global->gen_component_swapping ();
+
os_ << be_nl
<< "class " << export_macro_.c_str () << " " << lname
<< "_Servant" << be_idt_nl
<< ": public virtual" << be_idt << be_idt_nl
<< "::CIAO::"
+ << (swapping ? "Swapping_" : "")
<< "Home_Servant_Impl<" << be_idt_nl
<< "::" << node_->full_skel_name () << "," << be_nl
<< global << sname << "::CCM_" << lname << "," << be_nl
@@ -150,86 +123,135 @@ be_visitor_home_svh::gen_servant_class (void)
<< be_uidt << be_uidt << be_uidt << be_uidt_nl
<< "{" << be_nl
<< "public:" << be_idt_nl;
-
+
os_ << lname << "_Servant (" << be_idt_nl
<< global << sname << "::CCM_" << lname << "_ptr exe," << be_nl
<< "const char * ins_name," << be_nl
<< "::CIAO::Container_ptr c);" << be_uidt;
-
+
os_ << be_nl << be_nl
<< "virtual ~" << lname << "_Servant (void);";
+
+ this->gen_ops_attrs ();
+
+ this->gen_factories ();
+
+ this->gen_finders ();
+
+ os_ << be_uidt_nl
+ << "};";
+
+ return 0;
+}
- AST_Type *pk = node_->primary_key ();
-
- if (pk != 0)
+int
+be_visitor_home_svh::gen_ops_attrs (void)
+{
+ os_ << be_nl << be_nl
+ << "// All operations and attributes.";
+
+ int status =
+ node_->traverse_inheritance_graph (
+ be_visitor_home_svh::op_attr_decl_helper,
+ &os_);
+
+ if (status == -1)
{
- os_ << be_nl << be_nl
- << "// Implicit home primary key operations - not supported.";
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_home_svh::")
+ ACE_TEXT ("gen_ops_attrs - ")
+ ACE_TEXT ("traverse_inheritance_graph() ")
+ ACE_TEXT ("failed\n")),
+ -1);
+ }
+
+ return 0;
+}
- os_ << be_nl << be_nl
- << "virtual ::" << comp_->name () << "_ptr" << be_nl
- << "create (" << be_idt_nl
- << "::" << pk->name () << " * key);" << be_uidt;
+int
+be_visitor_home_svh::gen_factories (void)
+{
+ os_ << be_nl << be_nl
+ << "// Factory operations.";
+
+ return this->gen_factories_r (node_);
+}
- os_ << be_nl << be_nl
- << "virtual ::" << comp_->name () << "_ptr" << be_nl
- << "find_by_primary_key (" << be_idt_nl
- << "::" << pk->name () << " * key);" << be_uidt;
+int
+be_visitor_home_svh::gen_factories_r (AST_Home *node)
+{
+ if (node == 0)
+ {
+ return 0;
+ }
+
+ if (this->gen_init_ops_i (node->factories ()) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_home_svh::")
+ ACE_TEXT ("gen_factories_r - ")
+ ACE_TEXT ("gen_init_ops_i() failed\n")),
+ -1);
+ }
+
+ AST_Home *base = node->base_home ();
+
+ return this->gen_factories_r (base);
+}
- os_ << be_nl << be_nl
- << "virtual void" << be_nl
- << "remove (" << be_idt_nl
- << "::" << pk->name () << " * key);" << be_uidt;
+int
+be_visitor_home_svh::gen_finders (void)
+{
+ os_ << be_nl << be_nl
+ << "// Finder operations.";
+
+ return this->gen_finders_r (node_);
+}
- os_ << be_nl << be_nl
- << "virtual ::" << pk->name () << " *" << be_nl
- << "get_primary_key (" << be_idt_nl
- << "::" << comp_->name () << "_ptr comp);" << be_uidt;
+int
+be_visitor_home_svh::gen_finders_r (AST_Home *node)
+{
+ if (node == 0)
+ {
+ return 0;
}
+
+ if (this->gen_init_ops_i (node->finders ()) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_home_svh::")
+ ACE_TEXT ("gen_finders_r - ")
+ ACE_TEXT ("gen_init_ops_i() failed\n")),
+ -1);
+ }
+
+ AST_Home *base = node->base_home ();
+
+ return this->gen_finders_r (base);
+}
- be_home *h = node_;
-
- while (h != 0)
+int
+be_visitor_home_svh::gen_init_ops_i (AST_Home::INIT_LIST & list)
+{
+ AST_Operation **op = 0;
+
+ for (AST_Home::INIT_LIST::ITERATOR i = list.begin ();
+ !i.done ();
+ i.advance ())
{
- if (this->visit_scope (h) != 0)
+ i.next (op);
+ be_operation *bop = be_operation::narrow_from_decl (*op);
+
+ if (this->visit_operation (bop) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_home_svh::")
- ACE_TEXT ("gen_servant_class - ")
- ACE_TEXT ("visit_scope() failed\n")),
+ ACE_TEXT ("gen_init_ops_i - ")
+ ACE_TEXT ("visit_operation() failed\n")),
-1);
}
-
- for (long i = 0; i < h->n_inherits (); ++i)
- {
- // A closure of all the supported interfaces is stored
- // in the base class 'pd_inherits_flat' member.
- be_interface *bi =
- be_interface::narrow_from_decl (h->inherits ()[i]);
-
- int status =
- bi->traverse_inheritance_graph (
- be_visitor_home_svh::op_attr_decl_helper,
- &os_);
-
- if (status == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("be_visitor_home_svh::")
- ACE_TEXT ("gen_servant_class - ")
- ACE_TEXT ("traverse_inheritance_graph() ")
- ACE_TEXT ("failed for %s\n"),
- bi->full_name ()),
- -1);
- }
- }
-
- h = be_home::narrow_from_decl (h->base_home ());
}
-
- os_ << be_uidt_nl
- << "};";
-
+
return 0;
}
@@ -243,7 +265,7 @@ be_visitor_home_svh::gen_entrypoint (void)
<< "_Servant (" << be_idt_nl
<< "::Components::HomeExecutorBase_ptr p," << be_nl
<< "::CIAO::Container_ptr c," << be_nl
- << "const char * ins_name);" << be_uidt;
+ << "const char * ins_name);" << be_uidt;
}
int
@@ -257,8 +279,8 @@ be_visitor_home_svh::op_attr_decl_helper (be_interface * /* derived */,
ctx.state (TAO_CodeGen::TAO_ROOT_SVH);
ctx.stream (os);
be_visitor_home_svh visitor (&ctx);
-
- /// Since this visitor overriddes only visit_operation() and
+
+ /// Since this visitor overriddes only visit_operation() and
/// visit_attribute(), we can get away with this for the declarations.
return visitor.visit_scope (ancestor);
}