summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_root
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-04-30 23:53:53 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-04-30 23:53:53 +0000
commit59fa9c3020ed33d8fd776fa2ffedc26cea6782a3 (patch)
treec83b4e7f3a801cb2229be9c5d32eab3af4c4ec28 /TAO/TAO_IDL/be/be_visitor_root
parent51a1358558db5534a1fce86f951d3a3a0fde3efb (diff)
downloadATCD-59fa9c3020ed33d8fd776fa2ffedc26cea6782a3.tar.gz
ChangeLogTag: Mon Apr 30 18:49:56 2001 Jeff Parsons <parsons@cs.wustl.edu>
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_root')
-rw-r--r--TAO/TAO_IDL/be/be_visitor_root/root.cpp26
-rw-r--r--TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp34
-rw-r--r--TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp203
3 files changed, 229 insertions, 34 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_root/root.cpp b/TAO/TAO_IDL/be/be_visitor_root/root.cpp
index 620cb1ed224..818ac16b87a 100644
--- a/TAO/TAO_IDL/be/be_visitor_root/root.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_root/root.cpp
@@ -64,7 +64,6 @@ int be_visitor_root::visit_root (be_root *node)
"codegen for scope failed\n"), -1);
}
-
// If we are generating the client header file, this is the place to
// generate the proxy broker factory function pointer declarations
// and the extern declarations for non-defined interfaces.
@@ -214,20 +213,18 @@ int be_visitor_root::visit_root (be_root *node)
break;
case TAO_CodeGen::TAO_ROOT_SH:
(void) tao_cg->end_server_header ();
-
- if (be_global->gen_tie_classes ())
- {
- (void) tao_cg->end_server_template_header ();
- }
-
return 0;
-
case TAO_CodeGen::TAO_ROOT_CI:
break;
case TAO_CodeGen::TAO_ROOT_IS:
break;
case TAO_CodeGen::TAO_ROOT_SI:
- return 0; // nothing to be done
+ if (be_global->gen_tie_classes ())
+ {
+ (void) tao_cg->end_server_template_inline ();
+ }
+
+ return 0;
case TAO_CodeGen::TAO_ROOT_SS:
if (be_global->gen_tie_classes ())
{
@@ -235,7 +232,14 @@ int be_visitor_root::visit_root (be_root *node)
}
(void) tao_cg->end_server_skeletons ();
- return 0; // nothing to be done
+ return 0;
+ case TAO_CodeGen::TAO_ROOT_TIE_SH:
+ if (be_global->gen_tie_classes ())
+ {
+ (void) tao_cg->end_server_template_header ();
+ }
+
+ return 0;
default:
{
ACE_ERROR_RETURN ((LM_ERROR,
@@ -296,6 +300,7 @@ int be_visitor_root::visit_root (be_root *node)
case TAO_CodeGen::TAO_ROOT_SI:
case TAO_CodeGen::TAO_ROOT_SS:
case TAO_CodeGen::TAO_ROOT_IS:
+ case TAO_CodeGen::TAO_ROOT_TIE_SH:
return 0; // nothing to be done
default:
{
@@ -798,6 +803,7 @@ be_visitor_root::visit_valuetype (be_valuetype *node)
case TAO_CodeGen::TAO_ROOT_SI:
case TAO_CodeGen::TAO_ROOT_SS:
case TAO_CodeGen::TAO_ROOT_IS:
+ case TAO_CodeGen::TAO_ROOT_TIE_SH:
case TAO_CodeGen::TAO_ROOT_ANY_OP_CH:
case TAO_CodeGen::TAO_ROOT_ANY_OP_CS:
return 0; // nothing to do, resp. not yet impl.
diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp
index 235f91da26a..3443aa6fac7 100644
--- a/TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp
@@ -47,32 +47,18 @@ be_visitor_root_sh::init (void)
if (tao_cg->start_server_header (be_global->be_get_server_hdr_fname ())
== -1)
{
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_visitor_root_sh::init - "
- "Error :%p: Unable to open server header file : %s\n",
- "start_server_header",
- be_global->be_get_server_hdr_fname ()),
- -1);
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ "(%N:%l) be_visitor_root_sh::init - "
+ "Error :%p: Unable to open server header file : %s\n",
+ "start_server_header",
+ be_global->be_get_server_hdr_fname ()
+ ),
+ -1
+ );
}
- if (be_global->gen_tie_classes ())
- {
- if (tao_cg->start_server_template_header (
- be_global->be_get_server_template_hdr_fname ()
- )
- == -1)
- {
- ACE_ERROR_RETURN ((
- LM_ERROR,
- "(%N:%l) be_visitor_root_sh::init - "
- "Error:Unable to openin server template header file : %s\n",
- be_global->be_get_server_template_hdr_fname ()
- ),
- -1
- );
- }
- }
- // set the stream and the next state
+ // set the stream and the next state.
this->ctx_->stream (tao_cg->server_header ());
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp
new file mode 100644
index 00000000000..6d5b615bf3f
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp
@@ -0,0 +1,203 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// root_sth.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for Root in the server template header
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
+
+#include "be_visitor_root.h"
+#include "be_visitor_interface.h"
+
+ACE_RCSID(be_visitor_root, root_sth, "$Id$")
+
+
+// ****************************************
+// Root visitor for server template header
+// ****************************************
+
+be_visitor_root_sth::be_visitor_root_sth (be_visitor_context *ctx)
+ : be_visitor_root (ctx)
+{
+}
+
+be_visitor_root_sth::~be_visitor_root_sth (void)
+{
+}
+
+int
+be_visitor_root_sth::init (void)
+{
+ // Open the file.
+ if (tao_cg->start_server_template_header (
+ be_global->be_get_server_template_hdr_fname ()
+ )
+ == -1)
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ "(%N:%l) be_visitor_root_sth::init - "
+ "Error:Unable to open server template header file : %s\n",
+ be_global->be_get_server_template_hdr_fname ()
+ ),
+ -1
+ );
+ }
+
+ // Set the stream and the next state.
+ this->ctx_->stream (tao_cg->server_template_header ());
+ return 0;
+}
+
+int
+be_visitor_root_sth::visit_scope (be_scope *node)
+{
+ // Proceed if the number of members in our scope is greater than 0.
+ if (node->nmembers () > 0)
+ {
+ // Initialize an iterator to iterate over our scope.
+ UTL_ScopeActiveIterator si (node,
+ UTL_Scope::IK_decls);
+ // Continue until each element is visited.
+ while (!si.is_done ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d == 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_root_sth::visit_scope - "
+ "bad node in this scope\n"),
+ -1);
+
+ }
+
+ AST_Decl::NodeType nt = d->node_type ();
+
+ // These are the onlh types we're interested in.
+ if (nt != AST_Decl::NT_module
+ && nt != AST_Decl::NT_interface)
+ {
+ si.next ();
+ continue;
+ }
+
+ 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);
+
+ // Send the visitor.
+ if (bd == 0 || bd->accept (this) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_root_sth::visit_scope - "
+ "codegen for scope failed\n"),
+ -1);
+
+ }
+
+ si.next ();
+ } // End of while loop.
+ } // End of if.
+
+ return 0;
+}
+
+int
+be_visitor_root_sth::visit_module (be_module *node)
+{
+ if (node->imported ())
+ {
+ return 0;
+ }
+
+ TAO_OutStream *os = tao_cg->server_template_header ();
+
+ // Generate the skeleton class name.
+
+ os->indent ();
+
+ // Now generate the class definition. The prefix POA_ is prepended to our
+ // name only if we are the outermost module.
+ *os << "TAO_NAMESPACE ";
+
+ if (node->is_nested ())
+ {
+ // We are inside another module.
+ *os << " " << node->local_name () << be_nl;
+ }
+ else
+ {
+ // We are outermost module.
+ *os << " POA_" << node->local_name () << be_nl;
+ }
+
+ *os << "{\n" << be_idt;
+
+ if (this->visit_scope (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_root_sth::"
+ "visit_module - "
+ "codegen for scope failed\n"),
+ -1);
+ }
+
+ os->decr_indent ();
+ *os << "}" << be_nl << "TAO_NAMESPACE_CLOSE // module "
+ << node->name () << "\n\n";
+
+ return 0;
+}
+
+int
+be_visitor_root_sth::visit_interface (be_interface *node)
+{
+ if (node->imported () || node->is_local ())
+ {
+ return 0;
+ }
+
+ // Generate the TIE class.
+
+ this->ctx_->state (TAO_CodeGen::TAO_INTERFACE_TIE_SH);
+ this->ctx_->node (node);
+
+ be_visitor_interface_tie_sh visitor (this->ctx_);
+
+ if (node->accept (&visitor) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_root_sth::"
+ "visit_interface - "
+ "codegen for TIE class failed\n"),
+ -1);
+ }
+
+ this->ctx_->state (TAO_CodeGen::TAO_ROOT_TIE_SH);
+
+ return 0;
+}
+