summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp188
1 files changed, 188 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp b/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp
new file mode 100644
index 00000000000..15d17f4aba9
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp
@@ -0,0 +1,188 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// tie_si.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for TIE classes for the Interface node in the
+// inline file.
+//
+// = AUTHOR
+// Aniruddha Gokhale
+//
+// ============================================================================
+
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
+
+#include "be_visitor_interface.h"
+
+
+// ************************************************************************
+// Interface visitor for server inline
+// ************************************************************************
+
+be_visitor_interface_tie_si::be_visitor_interface_tie_si (be_visitor_context *ctx)
+ : be_visitor_interface (ctx)
+{
+}
+
+be_visitor_interface_tie_si::~be_visitor_interface_tie_si (void)
+{
+}
+
+int
+be_visitor_interface_tie_si::visit_interface (be_interface *node)
+{
+ TAO_OutStream *os; // output stream
+ static char fulltiename [NAMEBUFSIZE]; // holds the class name
+ static char localtiename [NAMEBUFSIZE]; // holds the tie name
+
+ if (node->srv_inline_gen () || node->imported ())
+ return 0;
+
+ ACE_OS::memset (fulltiename, '\0', NAMEBUFSIZE);
+ ACE_OS::memset (localtiename, '\0', NAMEBUFSIZE);
+
+ os = this->ctx_->stream ();
+
+ // generate the skeleton class name which will be used to determine the TIE
+ // class name
+
+ // we are outermost
+ ACE_OS::sprintf (fulltiename, "%s_tie", node->full_skel_name ());
+ if (!node->is_nested ())
+ {
+ ACE_OS::sprintf (localtiename, "POA_%s_tie",
+ node->local_name ()->get_string ());
+ }
+ else
+ {
+ ACE_OS::sprintf (localtiename, "%s_tie",
+ node->local_name ()->get_string ());
+ }
+
+ if (node->is_nested ())
+ {
+ *os << "\n#if defined (ACE_HAS_USING_KEYWORD)\n";
+ }
+
+ os->indent (); // start with whatever indentation level we are at
+
+ *os << "template <class T> ACE_INLINE" << be_nl
+ << fulltiename << "<T>::" << localtiename << " (T &t)" << be_nl
+ << "\t: ptr_ (&t)," << be_nl
+ << "\t poa_ (PortableServer::POA::_nil ())," << be_nl
+ << "\t rel_ (0)" << be_nl
+ << "{}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE" << be_nl
+ << fulltiename << "<T>::" << localtiename
+ << " (T &t, PortableServer::POA_ptr poa)" << be_nl
+ << "\t: ptr_ (&t)," << be_nl
+ << "\t poa_ (PortableServer::POA::_duplicate (poa))," << be_nl
+ << "\t rel_ (0)" << be_nl
+ << "{}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE" << be_nl
+ << fulltiename << "<T>::" << localtiename
+ << " (T *tp, CORBA::Boolean release)" << be_nl
+ << "\t: ptr_ (tp)," << be_nl
+ << "\t poa_ (PortableServer::POA::_nil ())," << be_nl
+ << "\t rel_ (release)" << be_nl
+ << "{}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE" << be_nl
+ << fulltiename << "<T>::" << localtiename
+ << " (T *tp, PortableServer::POA_ptr poa, CORBA::Boolean release)"
+ << be_nl
+ << "\t: ptr_ (tp)," << be_nl
+ << "\t poa_ (PortableServer::POA::_duplicate (poa))," << be_nl
+ << "\t rel_ (release)" << be_nl
+ << "{}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE" << be_nl
+ << fulltiename << "<T>::~" << localtiename << " (void)" << be_nl
+ << "{" << be_idt_nl
+ << "CORBA::release (this->poa_);" << be_nl
+ << "if (this->rel_) delete this->ptr_;" << be_uidt_nl
+ << "}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE T *" << be_nl
+ << fulltiename << "<T>::_tied_object (void)" << be_nl
+ << "{" << be_idt_nl
+ << "return this->ptr_;" << be_uidt_nl
+ << "}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE void" << be_nl
+ << fulltiename << "<T>::_tied_object (T &obj)" << be_nl
+ << "{" << be_idt_nl
+ << "if (this->rel_) delete this->ptr_;" << be_nl
+ << "this->ptr_ = &obj;" << be_nl
+ << "this->rel_ = 0;" << be_uidt_nl
+ << "}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE void" << be_nl
+ << fulltiename << "<T>::_tied_object (T *obj, "
+ << "CORBA::Boolean release)" << be_nl
+ << "{" << be_idt_nl
+ << "if (this->rel_) delete this->ptr_;" << be_nl
+ << "this->ptr_ = obj;" << be_nl
+ << "this->rel_ = release;" << be_uidt_nl
+ << "}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE CORBA::Boolean" << be_nl
+ << fulltiename << "<T>::_is_owner (void)" << be_nl
+ << "{" << be_idt_nl
+ << "return this->rel_;" << be_uidt_nl
+ << "}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE void" << be_nl
+ << fulltiename << "<T>::_is_owner (CORBA::Boolean b)" << be_nl
+ << "{" << be_idt_nl
+ << "this->rel_ = b;" << be_uidt_nl
+ << "}" << be_nl << be_nl;
+
+ *os << "template <class T> ACE_INLINE "
+ << "PortableServer::POA_ptr" << be_nl
+ << fulltiename << "<T>::_default_POA (CORBA::Environment &env)" << be_nl
+ << "{" << be_idt_nl
+ << "if (!CORBA::is_nil (this->poa_.in ()))" << be_idt_nl
+ << "return PortableServer::POA::_duplicate (this->poa_.in ());"
+ << be_uidt_nl
+ << "else" << be_nl
+ << "{" << be_idt_nl
+ << "TAO_POA *poa = TAO_ORB_Core_instance ()->root_poa ();" << be_nl
+ << "PortableServer::POA_var result = poa->_this (env);" << be_nl
+ << "if (env.exception () != 0)" << be_idt_nl
+ << "return PortableServer::POA::_nil ();" << be_uidt_nl
+ << "else" << be_idt_nl
+ << "return result._retn ();" << be_uidt << be_uidt_nl
+ << "}" << be_uidt
+ << "}\n\n";
+
+ // generate code for the operations in the scope
+ if (this->visit_scope (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_interface_tie_si::"
+ "visit_interface - "
+ "codegen for scope failed\n"),
+ -1);
+ }
+
+ if (node->is_nested ())
+ {
+ *os << "#endif /* ACE_HAS_USING_KEYWORD */\n";
+ }
+
+ return 0;
+}