summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorgokhale <asgokhale@users.noreply.github.com>1997-08-10 14:28:08 +0000
committergokhale <asgokhale@users.noreply.github.com>1997-08-10 14:28:08 +0000
commit76c03b5df21b9d1e6996712764aec3f2075ce2f8 (patch)
tree58c560547e2938083f070e67c5b852acb17bf65b /TAO
parent0eb91f8d5346861908472c604bd03457aab534cf (diff)
downloadATCD-76c03b5df21b9d1e6996712764aec3f2075ce2f8.tar.gz
Added a new Demux test code generator.
Diffstat (limited to 'TAO')
-rw-r--r--TAO/tests/Demux_Test/CodeGen/Makefile316
-rw-r--r--TAO/tests/Demux_Test/CodeGen/README12
-rw-r--r--TAO/tests/Demux_Test/CodeGen/client.cpp39
-rw-r--r--TAO/tests/Demux_Test/CodeGen/gen.cpp173
-rw-r--r--TAO/tests/Demux_Test/CodeGen/impl.cpp72
-rw-r--r--TAO/tests/Demux_Test/CodeGen/objcreate.cpp51
-rw-r--r--TAO/tests/Demux_Test/CodeGen/perf.cpp21
-rw-r--r--TAO/tests/Demux_Test/CodeGen/skel.cpp217
-rw-r--r--TAO/tests/Demux_Test/CodeGen/stub.cpp155
-rw-r--r--TAO/tests/Demux_Test/CodeGen/tao.cpp96
-rw-r--r--TAO/tests/Demux_Test/CodeGen/tao.h21
11 files changed, 1173 insertions, 0 deletions
diff --git a/TAO/tests/Demux_Test/CodeGen/Makefile b/TAO/tests/Demux_Test/CodeGen/Makefile
new file mode 100644
index 00000000000..a60e594869e
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/Makefile
@@ -0,0 +1,316 @@
+#----------------------------------------------------------------------------
+# $Id$
+#
+# Makefile to compile the Demux application
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+BIN = tao
+LIB = libtao.a
+SHLIB = libtao.so
+
+FILES = tao \
+ gen \
+ client \
+ stub \
+ skel \
+ impl \
+ perf \
+ objcreate
+
+LSRC = $(addsuffix .cpp,$(FILES))
+LOBJ = $(addsuffix .o,$(FILES))
+SHOBJ = $(addsuffix .so,$(FILES))
+
+LDLIBS = -ltao
+LIBS = -lACE
+
+VLDLIBS = $(LDLIBS:%=%$(VAR))
+
+#BUILD = $(VLIB) $(VSHLIB) $(SHLIBA) $(VBIN)
+BUILD = $(VSHLIB) $(SHLIBA) $(VBIN)
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+# Local modifications to variables imported by includes above.
+#----------------------------------------------------------------------------
+
+CPPFLAGS += -DDEBUG
+
+#----------------------------------------------------------------------------
+# DO NOT DELETE THIS LINE -- g++dep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+
+.obj/tao.o .shobj/tao.so: tao.cpp tao.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/stdcpp.h \
+ $(WRAPPER_ROOT)/ace/OS.i \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/SString.i \
+ $(WRAPPER_ROOT)/ace/Containers.h \
+ $(WRAPPER_ROOT)/ace/Containers.i \
+ $(WRAPPER_ROOT)/ace/Singleton.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.i \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Thread.i \
+ $(WRAPPER_ROOT)/ace/Singleton.i \
+ $(WRAPPER_ROOT)/ace/Get_Opt.h \
+ $(WRAPPER_ROOT)/ace/Get_Opt.i
+.obj/gen.o .shobj/gen.so: gen.cpp tao.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/stdcpp.h \
+ $(WRAPPER_ROOT)/ace/OS.i \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/SString.i \
+ $(WRAPPER_ROOT)/ace/Containers.h \
+ $(WRAPPER_ROOT)/ace/Containers.i \
+ $(WRAPPER_ROOT)/ace/Singleton.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.i \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Thread.i \
+ $(WRAPPER_ROOT)/ace/Singleton.i \
+ $(WRAPPER_ROOT)/ace/Get_Opt.h \
+ $(WRAPPER_ROOT)/ace/Get_Opt.i
+.obj/client.o .shobj/client.so: client.cpp tao.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/stdcpp.h \
+ $(WRAPPER_ROOT)/ace/OS.i \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/SString.i \
+ $(WRAPPER_ROOT)/ace/Containers.h \
+ $(WRAPPER_ROOT)/ace/Containers.i \
+ $(WRAPPER_ROOT)/ace/Singleton.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.i \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Thread.i \
+ $(WRAPPER_ROOT)/ace/Singleton.i \
+ $(WRAPPER_ROOT)/ace/Get_Opt.h \
+ $(WRAPPER_ROOT)/ace/Get_Opt.i
+.obj/stub.o .shobj/stub.so: stub.cpp tao.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/stdcpp.h \
+ $(WRAPPER_ROOT)/ace/OS.i \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/SString.i \
+ $(WRAPPER_ROOT)/ace/Containers.h \
+ $(WRAPPER_ROOT)/ace/Containers.i \
+ $(WRAPPER_ROOT)/ace/Singleton.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.i \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Thread.i \
+ $(WRAPPER_ROOT)/ace/Singleton.i \
+ $(WRAPPER_ROOT)/ace/Get_Opt.h \
+ $(WRAPPER_ROOT)/ace/Get_Opt.i
+.obj/skel.o .shobj/skel.so: skel.cpp tao.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/stdcpp.h \
+ $(WRAPPER_ROOT)/ace/OS.i \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/SString.i \
+ $(WRAPPER_ROOT)/ace/Containers.h \
+ $(WRAPPER_ROOT)/ace/Containers.i \
+ $(WRAPPER_ROOT)/ace/Singleton.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.i \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Thread.i \
+ $(WRAPPER_ROOT)/ace/Singleton.i \
+ $(WRAPPER_ROOT)/ace/Get_Opt.h \
+ $(WRAPPER_ROOT)/ace/Get_Opt.i
+.obj/impl.o .shobj/impl.so: impl.cpp tao.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/stdcpp.h \
+ $(WRAPPER_ROOT)/ace/OS.i \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/SString.i \
+ $(WRAPPER_ROOT)/ace/Containers.h \
+ $(WRAPPER_ROOT)/ace/Containers.i \
+ $(WRAPPER_ROOT)/ace/Singleton.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.i \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Thread.i \
+ $(WRAPPER_ROOT)/ace/Singleton.i \
+ $(WRAPPER_ROOT)/ace/Get_Opt.h \
+ $(WRAPPER_ROOT)/ace/Get_Opt.i
+.obj/perf.o .shobj/perf.so: perf.cpp tao.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/stdcpp.h \
+ $(WRAPPER_ROOT)/ace/OS.i \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/SString.i \
+ $(WRAPPER_ROOT)/ace/Containers.h \
+ $(WRAPPER_ROOT)/ace/Containers.i \
+ $(WRAPPER_ROOT)/ace/Singleton.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.i \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Thread.i \
+ $(WRAPPER_ROOT)/ace/Singleton.i \
+ $(WRAPPER_ROOT)/ace/Get_Opt.h \
+ $(WRAPPER_ROOT)/ace/Get_Opt.i
+.obj/objcreate.o .shobj/objcreate.so: objcreate.cpp tao.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/stdcpp.h \
+ $(WRAPPER_ROOT)/ace/OS.i \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/SString.i \
+ $(WRAPPER_ROOT)/ace/Containers.h \
+ $(WRAPPER_ROOT)/ace/Containers.i \
+ $(WRAPPER_ROOT)/ace/Singleton.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Event_Handler.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.i \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Thread.i \
+ $(WRAPPER_ROOT)/ace/Singleton.i \
+ $(WRAPPER_ROOT)/ace/Get_Opt.h \
+ $(WRAPPER_ROOT)/ace/Get_Opt.i
+
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/TAO/tests/Demux_Test/CodeGen/README b/TAO/tests/Demux_Test/CodeGen/README
new file mode 100644
index 00000000000..13fcae3c48f
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/README
@@ -0,0 +1,12 @@
+This directory contains a code generator that will generate stubs and
+skeletons for an interface called "tao_demux". The number of
+operations in this interface is controlled by the -m option to the
+executable "tao".
+
+Usage:
+
+tao -o <num of objs> -m < num of operations>
+
+The stubs and skeletons are for 2-way calls. The operation names and
+object keys are automatically generated and have arbitrary string
+names. \ No newline at end of file
diff --git a/TAO/tests/Demux_Test/CodeGen/client.cpp b/TAO/tests/Demux_Test/CodeGen/client.cpp
new file mode 100644
index 00000000000..9260285ce37
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/client.cpp
@@ -0,0 +1,39 @@
+#include "tao.h"
+
+
+// Generate the client side include file "client.i". This file has a table of
+// function pointers to the the different operations of the
+// interface. Depending on the strategy chosen, we make appropriate calls
+
+long GenClientCode(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ fstream client_incl;
+ int i;
+ ACE_CString *str;
+
+ client_incl.open("client.i", ios::out);
+
+ for(i=0; i < limit; i++){
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+ client_incl << "void " << str->rep() << "(tao_demux_ptr obj)" << endl;
+ client_incl << "{" << endl;
+ client_incl << "\tCORBA_Environment env;" << endl << endl;
+ client_incl << "\tobj->" << str->rep() << "(env);" << endl;
+ client_incl << "}" << endl;
+ }
+ client_incl << endl;
+ client_incl << "static const method_db mtbl[] = {" << endl;
+ for (i=0; i < limit; i++){
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+ client_incl << "\t" << str->rep() << "," << endl;
+ }
+ client_incl << "};" << endl << endl;
+ client_incl.close();
+}
+
diff --git a/TAO/tests/Demux_Test/CodeGen/gen.cpp b/TAO/tests/Demux_Test/CodeGen/gen.cpp
new file mode 100644
index 00000000000..ecc4fd5ce5a
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/gen.cpp
@@ -0,0 +1,173 @@
+#include "tao.h"
+
+static long GenDistinctString(ACE_Unbounded_Queue<ACE_CString> &, int);
+static long GenRand(int, int);
+static long IsPresent(ACE_Unbounded_Queue<ACE_CString> &, int, ACE_CString &);
+static ACE_CString CreateString(long);
+static char GetVarChar(int);
+
+// object table generator
+long GenObjectTable(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ int i,j,k; // indices
+ long rnd; // random number
+ int opt;
+ fstream arrfp;
+ ACE_CString *str;
+
+
+ // Generate "limit" distinct strings
+ for (i=0; i < limit; i++)
+ {
+ if (GenDistinctString(arr, i) == -1) // side effect: inserts a new string
+ return -1; // at locn i in array "arr"
+ }
+
+ // write the strings into a file whose format will be understood by GPERF
+ arrfp.open("gperf_objects.dat",ios::out);
+
+ arrfp << "struct object_db {" << endl;
+ arrfp << "\tchar *name; // name of method" << endl;
+ arrfp << "\tCORBA_Object_ptr obj; //fn pointer to obj impl" << endl;
+ arrfp << "};" << endl;
+ arrfp << "%%" << endl;
+
+ for(i=0; i < limit; i++)
+ {
+ if (arr.get(str, i) == -1)
+ {
+ // error
+ return -1;
+ }
+ arrfp << str->rep() << ", " << "0" << endl;
+ // we do not know the addresses of the objects. We shall insert them
+ // later.
+ }
+ arrfp.close();
+ return 0;
+}
+
+// method table generator
+long GenMethodTable(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ int i,j,k; // indices
+ long rnd; // random number
+ int opt;
+ fstream arrfp;
+ ACE_CString *str;
+
+
+ // Generate "limit" distinct strings
+ for (i=0; i < limit; i++){
+ if (GenDistinctString(arr, i) == -1) // side effect: inserts a new string at locn i
+ return -1; // in array "arr"
+ }
+
+ // write the strings into a file whose format will be understood by GPERF
+ arrfp.open("gperf_methods.dat",ios::out);
+
+ arrfp << "struct method_db {" << endl;
+ arrfp << "\tchar *name; // name of method" << endl;
+ arrfp << "\tTAO_Skeleton skel_ptr; //fn pointer to skeleton" << endl;
+ arrfp << "};" << endl;
+ arrfp << "%%" << endl;
+
+ for(i=0; i < limit; i++)
+ {
+ if (arr.get(str, i) == -1)
+ {
+ // error
+ return -1;
+ }
+ arrfp << (str->rep()) << ", " << "_skel_tao_demux::" << str->rep() <<
+ "_skel" << endl;
+ }
+ arrfp.close();
+ return 0;
+}
+
+
+// generate a distinct string and insert it at location "limit"
+long GenDistinctString(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ int i, j; // indices
+ long rnd;
+ ACE_CString s;
+ long status;
+
+ rnd = GenRand(3,32); // get a random number between 3 and 32 which will be
+ // used as a string length of the distinct string to be
+ // generated. We use 3-32 because certain function
+ // names such as _N, _C cause name conflicts.
+ // Continue generating strings until a distinct one not generated before
+ // is formed
+ do {
+ s = CreateString(rnd);
+ status = IsPresent (arr, limit, s);
+ if (status == -1)
+ return -1;
+ } while (status > 0);
+
+ // save it at this location
+ if (arr.enqueue_tail(s) == -1)
+ {
+ return -1;
+ }
+ return 0;
+}
+
+// generate a random number in the given limits
+long GenRand(int low, int up)
+{
+ return (lrand48() % (up-low+1)) + low; // rnd will be the size of the
+}
+
+// check if the given string is present in the array
+long IsPresent(ACE_Unbounded_Queue<ACE_CString> &arr, int limit, ACE_CString &s)
+{
+ ACE_CString *str;
+
+ if (!strcasecmp(s.rep(), "_is_a"))
+ return 1;
+
+ for (int i=0; i < limit; i++){
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+ if (!strcasecmp(str->rep(), s.rep()))
+ return 1; // they are same
+ }
+ return 0; // not present
+}
+
+// create a string of length = len
+ACE_CString CreateString(long len)
+{
+ int i;
+ ACE_CString s;
+ char ch;
+
+ for (i=0; i < len; i++){
+ ch = GetVarChar(i);
+ s += ACE_CString(&ch);
+ }
+ return s;
+}
+
+// Generate a valid character for a C++ variable
+char GetVarChar(int i)
+{
+ // for i == 0, we cannot return a digit as the first character
+ char ch;
+ while(1) {
+ ch = GenRand(48, 122);
+ if (isdigit(ch) || isupper(ch) || islower(ch) || (ch == '_')){
+ if ((i == 0) && (isdigit(ch) || (ch == '_')))
+ continue;
+ break; //otherwise
+ }
+ }
+ return ch;
+}
+
diff --git a/TAO/tests/Demux_Test/CodeGen/impl.cpp b/TAO/tests/Demux_Test/CodeGen/impl.cpp
new file mode 100644
index 00000000000..6b3c7551558
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/impl.cpp
@@ -0,0 +1,72 @@
+#include "tao.h"
+
+// generate the implementation header
+long GenServantHeader(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ // generate the implementation class
+ fstream hdr;
+ int i;
+ ACE_CString *str;
+
+ hdr.open("tao_demux_i.h", ios::out);
+
+ hdr << "#if !defined(TAO_DEMUX_I_H)" << endl;
+ hdr << "#define TAO_DEMUX_I_H" << endl << endl;
+
+ hdr << "#include \"tao_demuxS.h\"" << endl << endl;
+
+ hdr << "class tao_demux_i: public virtual _skel_tao_demux" << endl;
+ hdr << "{" << endl;
+ hdr << "public:" << endl;
+ hdr << "\ttao_demux_i(char *obj_name);" << endl;
+ hdr << "\t~tao_demux_i();" << endl;
+ hdr << "\t//now all the methods" << endl;
+
+ for(i=0; i < limit; i++)
+ {
+ if (arr.get(str, i) == -1)
+ return -1;
+
+ hdr << "\tvoid " << str->rep() <<
+ "(CORBA_Environment &env);" << endl;
+ }
+ hdr << "};" << endl;
+
+ hdr << "#endif" << endl;
+}
+
+
+// generate the implementation
+long GenServantImpl(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ // generate the implementation class
+ fstream impl;
+ int i;
+ ACE_CString *str;
+
+ impl.open("tao_demux_i.cpp", ios::out);
+
+ impl << "#include <iostream.h>" << endl;
+ impl << "#include \"tao_demux_i.h\"" << endl << endl;
+
+ impl << "tao_demux_i::tao_demux_i(char *obj_name)" << endl;
+ impl << " :_skel_tao_demux(obj_name){}" << endl;
+ impl << "tao_demux_i::~tao_demux_i(){}" << endl;
+ impl << "\t//now all the methods" << endl;
+
+ for(i=0; i < limit; i++)
+ {
+ if (arr.get(str, i) == -1)
+ return -1;
+
+ impl << "void tao_demux_i::" << str->rep() <<
+ "(CORBA_Environment &env)" << endl;
+ impl << "{" << endl;
+ impl << "#ifdef DEBUG" << endl;
+ impl << " cout << \"Object name = \" << this->_get_name(env) << " <<
+ "\", Operation name = " << str->rep() << "\" << endl;" << endl;
+ impl << "#endif" << endl;
+ impl << "}" << endl << endl;
+ }
+}
+
diff --git a/TAO/tests/Demux_Test/CodeGen/objcreate.cpp b/TAO/tests/Demux_Test/CodeGen/objcreate.cpp
new file mode 100644
index 00000000000..e25dbd947d3
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/objcreate.cpp
@@ -0,0 +1,51 @@
+#include "tao.h"
+
+long GenObjectCreateCode(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ // code for creating objects. The strategy will be based on active demux or
+ // other strategies
+ fstream file;
+ int i;
+ ACE_CString *str;
+
+ file.open("obj_create.i", ios::out);
+
+ file << "\t if (params->demux_strategy() == " <<
+ "TAO_OA_Parameters::TAO_ACTIVE_DEMUX){" << endl;
+
+ for (i=0; i < limit; i++)
+ {
+ if (arr.get(str, i) == -1)
+ return -1;
+
+ file << "\t\tmymux[" << i << "] = new tao_demux_i(\"" << i << "\");" <<
+ endl;
+ file << "\t\tstr = orb_ptr->object_to_string(mymux[" << i << "], env);"
+ << endl;
+ file << "#ifdef DEBUG" << endl;
+ file << "\t\tcout << \"IOR = \" << (char *)str << endl;" << endl;
+ file << "#endif" << endl;
+ file << "\t\tiorfile << (char *)str << endl; " << endl;
+ file << "\t\tCORBA_string_free(str);" << endl;
+ }
+ file << "\t } else {" << endl;
+ for (i=0; i < limit; i++)
+ {
+ if (arr.get(str, i) == -1)
+ return -1;
+
+ file << "\t\tmymux[" << i << "] = new tao_demux_i(CORBA_string_dup (\""
+ << str->rep() << "\"));" << endl;
+ file << "\t\tstr = orb_ptr->object_to_string(mymux[" << i << "], env);"
+ << endl;
+ file << "#ifdef DEBUG" << endl;
+ file << "\t\tcout << \"IOR = \" << (char *)str << endl;" << endl;
+ file << "#endif" << endl;
+ file << "\t\tiorfile << (char *)str << endl; " << endl;
+ file << "\t\tCORBA_string_free(str);" << endl;
+ }
+ file << "\t }" << endl;
+
+ file.close();
+ return 0;
+}
diff --git a/TAO/tests/Demux_Test/CodeGen/perf.cpp b/TAO/tests/Demux_Test/CodeGen/perf.cpp
new file mode 100644
index 00000000000..ccd2da961ff
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/perf.cpp
@@ -0,0 +1,21 @@
+#include "tao.h"
+
+void GenGPERFCode()
+{
+ char command[500];
+
+ // first generate code for object hash
+ sprintf(command,
+ "gperf -c -C -D -E -T -f 0 -a -o -t -p -L C++ -Z Method_Hash %s >\
+gperf_method.i", "gperf_methods.dat");
+ system(command);
+
+ // omit the -C switch for gperf because we will not know the address of the
+ // objects until they are instantiated. But we do know the keys in advance.
+ sprintf(command,
+ "gperf -c -D -E -T -f 0 -a -o -t -p -L C++ -Z Object_Hash %s >\
+gperf_object.i", "gperf_objects.dat");
+ system(command);
+
+}
+
diff --git a/TAO/tests/Demux_Test/CodeGen/skel.cpp b/TAO/tests/Demux_Test/CodeGen/skel.cpp
new file mode 100644
index 00000000000..c5216cf706f
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/skel.cpp
@@ -0,0 +1,217 @@
+#include "tao.h"
+
+long GenServerHeader(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ fstream hdr;
+ int i;
+ ACE_CString *str;
+
+ hdr.open("tao_demuxS.h", ios::out);
+
+ hdr << "#if !defined(TAO_DEMUX_S_H)" << endl;
+ hdr << "#define TAO_DEMUX_S_H" << endl << endl;
+
+ hdr << "#include \"tao_demuxC.h\"" << endl;
+ hdr << "class _skel_tao_demux: public tao_demux" << endl;
+ hdr << "{" << endl;
+ hdr << "protected:" << endl;
+ hdr << "\t_skel_tao_demux(const char *objname=0);" << endl;
+ hdr << "\tvirtual ~_skel_tao_demux() {}" << endl;
+ hdr << "public:" << endl;
+ hdr << "\t//All methods defined on this interface" << endl;
+ for(i=0; i < limit; i++){
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+ //generate skeletons
+ hdr << "\tvirtual void " << str->rep() <<
+ "(CORBA_Environment &env) = 0;" << endl;
+ }
+ hdr << endl;
+ hdr << "\t// All skeletons used for dispatching" << endl;
+ for(i=0; i < limit; i++){
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+ //generate skeletons
+ hdr << "\tstatic void " << str->rep() <<
+ "_skel(CORBA_ServerRequest &req, CORBA_Object_ptr obj, " <<
+ "CORBA_Environment &env);" << endl;
+ }
+ hdr << "\tstatic void " <<
+ "_is_a_skel(CORBA_ServerRequest &req, CORBA_Object_ptr obj, " <<
+ "CORBA_Environment &env);" << endl;
+ hdr << "};" << endl;
+
+ hdr << "#endif" << endl;
+ hdr.close();
+}
+
+// generate server side skeletons
+long GenServerSkels(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ fstream skel;
+ int i;
+ ACE_CString *str;
+
+ skel.open("tao_demuxS.cpp", ios::out);
+
+ skel << "#include \"tao_demuxS.h\"" << endl;
+ // skel << "#include \"iiopobj.h\"" << endl;
+ // skel << "#include \"params.h\"" << endl;
+ // skel << "#include \"corba/optable.h\"" << endl;
+ // skel << "#include \"corba/corbacom.h\"" << endl << endl;
+
+ // table of methods
+ skel << "static const TAO_operation_db_entry tao_demux_operations [] = {" << endl;
+ for (i=0; i < limit; i++)
+ {
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+ skel << "\t{\"" << str->rep() << "\", &_skel_tao_demux::" << str->rep() <<
+ "_skel}," << endl;
+
+ }
+ skel << "\t{\"_is_a\", &_skel_tao_demux::_is_a_skel}" << endl;
+ skel << "};" << endl;
+
+ // table of methods
+ skel << "static const TAO_operation_db_entry tao_active_demux_operations [] = {" << endl;
+ for (i=0; i < limit; i++)
+ {
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+ skel << "\t{\"" << i << "\", &_skel_tao_demux::" << str->rep() <<
+ "_skel}," << endl;
+
+ }
+ skel << "\t{\"" << limit << "\", &_skel_tao_demux::_is_a_skel}" << endl;
+ skel << "};" << endl;
+
+ // instantiate operation lookup tables
+ skel << "// instantiate a dynamic hash operation table" << endl;
+ skel << "TAO_Dynamic_Hash_OpTable dyn_hash_tao_demux_op_tbl(" <<
+ "tao_demux_operations, " << (limit+1) << ", " << (limit+1)*2 << ");" << endl;
+
+ skel << "// instantiate a linear search based operation table" << endl;
+ skel << "TAO_Linear_OpTable linear_tao_demux_op_tbl(" <<
+ "tao_demux_operations, " << limit+1 << ");" << endl;
+
+ skel << "// instantiate a active demux operation table" << endl;
+ skel << "TAO_Active_Demux_OpTable active_tao_demux_op_tbl(" <<
+ "tao_active_demux_operations, " << limit+1 << ");" << endl;
+
+ skel << "// constructor for skel_tao_demux" << endl;
+ skel << "_skel_tao_demux::_skel_tao_demux(const char *obj_name)" << endl;
+ // skel << "\t:optable_(&tao_demux_op_tbl)" << endl;
+ skel << "{" << endl;
+ skel << "\tconst char* repoID = \"IDL:tao_demux:1.0\";" << endl;
+ skel << "\tCORBA_String_var _tao_typeid = repoID;" << endl;
+ skel << "\tIIOP_Object *data; // IIOP object reference" << endl;
+ skel << "\tCORBA_BOA_ptr oa = TAO_OA_PARAMS::instance()->oa(); // our OA" << endl;
+ skel << "\tTAO_Operation_Table_Parameters *op_params = " << endl;
+ skel << "\t\tTAO_OP_TABLE_PARAMETERS::instance();" << endl << endl;
+ skel << "\tCORBA_Long i;" << endl;
+
+ // set the operation table based on user's choice
+ skel << "\tswitch(op_params->lookup_strategy()){" << endl;
+ skel << "\tcase TAO_Operation_Table_Parameters::TAO_ACTIVE_DEMUX:" << endl;
+ skel << "\t\tthis->optable_ = &active_tao_demux_op_tbl;" << endl;
+ skel << "\t\tbreak;" << endl;
+ skel << "\tcase TAO_Operation_Table_Parameters::TAO_LINEAR:" << endl;
+ skel << "\t\tthis->optable_ = &linear_tao_demux_op_tbl;" << endl;
+ skel << "\t\tbreak;" << endl;
+ skel << "\tcase TAO_Operation_Table_Parameters::TAO_DYNAMIC_HASH:" << endl;
+ skel << "\t\tthis->optable_ = &dyn_hash_tao_demux_op_tbl;" << endl;
+ skel << "\t\tbreak;" << endl;
+ skel << "\tcase TAO_Operation_Table_Parameters::TAO_PERFECT_HASH:" << endl;
+ skel << "\t\tthis->optable_ = op_params->concrete_strategy ();" << endl;
+ skel << "\t\tbreak;" << endl;
+ skel << "\tcase TAO_Operation_Table_Parameters::TAO_USER_DEFINED:" << endl;
+ skel << "\t\tthis->optable_ = op_params->concrete_strategy ();" << endl;
+ skel << "\t\tbreak;" << endl;
+ skel << "\t}" << endl << endl;
+
+ // code to create IIOP object
+ skel << "\tdata = new IIOP_Object(CORBA_string_dup(_tao_typeid));" << endl;
+ skel << "\tdata->profile.iiop_version.major = IIOP::MY_MAJOR;" << endl;
+ skel << "\tdata->profile.iiop_version.minor = IIOP::MY_MINOR;" << endl;
+ skel << "\tdata->profile.host = ACE_OS::strdup(oa->get_addr().get_host_name());" << endl;
+ skel << "\tdata->profile.port = oa->get_addr().get_port_number();" << endl;
+ skel << "\tdata->profile.object_key.length = ACE_OS::strlen(obj_name);" << endl;
+ skel << "\tdata->profile.object_key.maximum = " <<
+ "data->profile.object_key.length;" << endl;
+ skel << "\tdata->profile.object_key.buffer = " <<
+ "new CORBA_Octet [(size_t)data->profile.object_key.length+1];" << endl;
+ skel << "\tACE_OS::memcpy(data->profile.object_key.buffer, obj_name, " <<
+ "data->profile.object_key.length);" << endl;
+ skel << "\tthis->set_parent(data);" << endl;
+ skel << "\tthis->sub_ = this;" << endl;
+ skel << "\tif (oa) oa->bind(data->profile.object_key, this);" <<
+ "// register ourselves" << endl;
+ skel << "}" << endl << endl;
+
+ // now the code for each skeleton
+ for(i=0; i < limit; i++){
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+ skel << "void _skel_tao_demux::" << str->rep() <<
+ "_skel(CORBA_ServerRequest &req, CORBA_Object_ptr obj, " <<
+ "CORBA_Environment&env)" << endl;
+ skel << "{" << endl;
+ skel << "\tCORBA_NVList_ptr nvlist;" << endl;
+ skel << "\ttao_demux_ptr impl;" << endl << endl;
+
+ // create a NVlist and populate it
+ skel << "\treq.orb()->create_list(0, nvlist);" << endl;
+ skel << "\treq.params(nvlist,env); //useless operation, but required "
+ << endl;
+ skel << "\t impl = (tao_demux_ptr) (obj->get_subclass());" << endl;
+ skel << "\t// now the magic of dynamic binding" << endl;
+ skel << "\timpl->" << str->rep() << "(env);" << endl;
+ skel << "}" << endl;
+ }
+
+ // finally the code for _is_a
+ skel << "void _skel_tao_demux::_is_a_skel" <<
+ "(CORBA_ServerRequest &req, CORBA_Object_ptr obj, " <<
+ "CORBA_Environment&env)" << endl;
+ skel << "{" << endl;
+ skel << "\tCORBA_NVList_ptr nvlist;" << endl;
+ skel << "\tCORBA_NamedValue_ptr nv;" << endl;
+ skel << "\tCORBA_Any temp_value(_tc_CORBA_String);" << endl;
+ skel << "\tchar *_tao_typeid = \"IDL:tao_demux:1.0\";" << endl << endl;
+
+ // create a NVlist and populate it
+ skel << "\treq.orb()->create_list(0, nvlist);" << endl;
+ skel << "\tnv = nvlist->add_value(0, temp_value, CORBA_ARG_IN, env);" << endl;
+ skel << "\treq.params(nvlist,env);" << endl;
+ skel << "\tif (env.exception() != 0)" << endl;
+ skel << "\t {" << endl;
+ skel << "\t\tdexc(env, \"is_a_skel, params\");" << endl;
+ skel << "\t\treturn;" << endl;
+ skel << "\t }" << endl << endl;
+ skel << "\tCORBA_Boolean *retval;" << endl;
+ skel << "\tCORBA_String value = *(CORBA_String *)nv->value()->value();" << endl;
+ skel << "\tif (strcmp((char *)value,(char *)_tao_typeid) == 0" << endl;
+ skel << "\t || strcmp((char *)value, _tc_CORBA_Object->id(env)) == 0)" << endl;
+ skel << "\t\tretval = new CORBA_Boolean(CORBA_B_TRUE);" << endl;
+ skel << "\telse" << endl;
+ skel << "\t\tretval = new CORBA_Boolean(CORBA_B_FALSE);" << endl;
+ skel << "\tCORBA_Any *any = new CORBA_Any(_tc_CORBA_Boolean, retval," <<
+ "CORBA_B_TRUE);" << endl;
+ skel << "\treq.result(any, env);" << endl;
+ skel << "\tdexc(env, \"_is_a, result\");" << endl;
+ skel << "}" << endl;
+
+ skel.close();
+}
+
diff --git a/TAO/tests/Demux_Test/CodeGen/stub.cpp b/TAO/tests/Demux_Test/CodeGen/stub.cpp
new file mode 100644
index 00000000000..136fbf1116a
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/stub.cpp
@@ -0,0 +1,155 @@
+#include "tao.h"
+
+long GenClientHeader(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ fstream hdr;
+ int i;
+ ACE_CString *str;
+
+ hdr.open("tao_demuxC.h", ios::out);
+
+ hdr << "//******** Generated by the tool: taoidl ********" << endl << endl;
+
+ hdr << "#if !defined (TAO_DEMUXC_H)" << endl;
+ hdr << "#define TAO_DEMUXC_H" << endl << endl;
+
+ hdr << "#include <stdlib.h>" << endl;
+ hdr << "#include \"tao/corba.h\"" << endl;
+ // hdr << "#include \"tao/orb.h\"" << endl;
+ // hdr << "#include \"tao/stub.h\"" << endl;
+ // hdr << "#include \"tao/optable.h\"" << endl;
+
+ hdr << "class tao_demux;" << endl;
+ hdr << "typedef tao_demux *\ttao_demux_ptr;" << endl;
+ hdr << "class tao_demux: public virtual CORBA_Object" << endl;
+ hdr << "{" << endl;
+ hdr << "public:" << endl;
+ // define the CORBA compliant mapping
+ hdr << "\tstatic tao_demux_ptr _duplicate(tao_demux_ptr obj);" << endl;
+ hdr << "\tstatic tao_demux_ptr _narrow(CORBA_Object_ptr obj);" << endl;
+ hdr << "\tstatic tao_demux_ptr _nil();" << endl << endl;
+
+ // now generate all the methods
+ for(i=0; i < limit; i++)
+ {
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+ hdr << "\tvirtual void " << str->rep() << "(CORBA_Environment &env);" << endl;
+ }
+ hdr << "protected:" << endl;
+ hdr << "\ttao_demux() {}" << endl;
+ hdr << "\ttao_demux(STUB_Object *objref): CORBA_Object(objref) {}" << endl;
+ hdr << "\tvirtual ~tao_demux() {}" << endl;
+ hdr << "private:" << endl;
+ hdr << "\t//copy constructor and assignment operator" << endl;
+ hdr << "\ttao_demux(const tao_demux&) { }" << endl;
+ hdr << "\tvoid operator=(const tao_demux&) { }" << endl;
+ hdr << "};" << endl;
+
+ hdr << "#endif" << endl;
+ hdr.close();
+}
+
+long GenClientStubs(ACE_Unbounded_Queue<ACE_CString> &arr, int limit)
+{
+ fstream stub;
+ int i;
+ ACE_CString *str;
+
+ stub.open("tao_demuxC.cpp", ios::out);
+
+ stub << "#include \"tao_demuxC.h\"" << endl << endl;
+
+ // generate the static functions
+
+ // the _duplicate method
+ stub << "tao_demux_ptr tao_demux::_duplicate(tao_demux_ptr obj)" << endl;
+ stub << "{" << endl;
+ stub << "\tif (obj) obj->AddRef();" << endl;
+ stub << "\treturn obj;" << endl;
+ stub << "}" << endl << endl;
+
+ // the _narrow method
+ stub << "tao_demux_ptr tao_demux::_narrow(CORBA_Object_ptr obj)" << endl;
+ stub << "{" << endl;
+ // check if object "is_a" IDL:tao_demux:1.0 and if so, addref and return a
+ // pointer to it
+ stub << "\tCORBA_Environment env;" << endl;
+ stub << "\tif (obj->_is_a(\"IDL:tao_demux:1.0\", env)){" << endl;
+ stub << "\t STUB_Object *istub;" << endl;
+ stub << "\t if (obj->QueryInterface(IID_STUB_Object, (void **)&istub)" <<
+ " != NOERROR){" << endl;
+ stub << "\t\treturn tao_demux::_nil();" << endl;
+ stub << "\t }" << endl;
+ stub << "\t tao_demux_ptr new_obj = new tao_demux(istub);" << endl;
+ stub << "\t return tao_demux::_duplicate(new_obj);" << endl;
+ stub << "\t}" << endl;
+ stub << "\treturn tao_demux::_nil();" << endl;
+ stub << "}" << endl << endl;
+
+ // the _nil method
+ stub << "tao_demux_ptr tao_demux::_nil()" << endl;
+ stub << "{" << endl;
+ stub << "\treturn (tao_demux_ptr)NULL;" << endl;
+ stub << "}" << endl << endl;
+
+ // All the TAO_Param_Data and TAO_Call_Data structures
+ stub <<
+ "// All the TAO_Param_Data and TAO_Call_Data structures required for invoking do_call"
+ << endl;
+ for(i=0; i < limit; i++){
+ if (arr.get(str, i) == -1)
+ {
+ return -1;
+ }
+
+ // generate TAO_Param_Data structure
+ stub << "static const TAO_Param_Data tao_demux_" << str->rep() <<
+ "_params[] = {" << endl;
+ stub << "\t{_tc_CORBA_Void, PARAM_RETURN, 0}" << endl;
+ stub << "};" << endl;
+
+ // generate TAO_Call_Data structure
+ stub << "static const TAO_Call_Data tao_demux_" << str->rep() <<
+ "_calldata = {" << endl;
+ stub << "\t\"" << str->rep() << "\"," << endl;
+ stub << "\tCORBA_B_TRUE, //twoway" << endl;
+ stub << "\t1, &tao_demux_" << str->rep() << "_params[0]," << endl;
+ stub << "\t0, 0" << endl;
+ stub << "};" << endl;
+
+ // generate TAO_Call_Data structure that uses active demultiplexing
+ stub << "static const TAO_Call_Data tao_demux_" << str->rep() <<
+ "_active_calldata = {" << endl;
+ stub << "\t\"" << i << "\"," << endl;
+ stub << "\tCORBA_B_TRUE, //twoway" << endl;
+ stub << "\t1, &tao_demux_" << str->rep() << "_params[0]," << endl;
+ stub << "\t0, 0" << endl;
+ stub << "};" << endl;
+
+ // now the actual stub
+ stub << "void tao_demux::" << str->rep() << "(CORBA_Environment &env)"
+ << endl;
+ stub << "{" << endl;
+ stub << "\tSTUB_Object *istub;" << endl;
+ stub << "\tif (this->QueryInterface (IID_STUB_Object, (void **) &istub) "
+ << "!= NOERROR){" << endl;
+ stub << "\t env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO));" << endl;
+ stub << "\t return;" << endl;
+ stub << "\t}" << endl;
+ stub << "\tTAO_Operation_Table_Parameters *paramTbl = " << endl;
+ stub << "\t\tTAO_OP_TABLE_PARAMETERS::instance();" << endl;
+ stub << "\tif (paramTbl->lookup_strategy() == ";
+ stub << "TAO_Operation_Table_Parameters::TAO_ACTIVE_DEMUX)" << endl;
+ stub << "\t\tistub->do_call(env, &tao_demux_" << str->rep() <<
+ "_active_calldata);" << endl;
+ stub << "\telse" << endl;
+ stub << "\t\tistub->do_call(env, &tao_demux_" << str->rep() <<
+ "_calldata);" << endl;
+ stub << "}" << endl << endl;
+ }
+ stub.close();
+}
+
diff --git a/TAO/tests/Demux_Test/CodeGen/tao.cpp b/TAO/tests/Demux_Test/CodeGen/tao.cpp
new file mode 100644
index 00000000000..b01df4002fe
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/tao.cpp
@@ -0,0 +1,96 @@
+#include "tao.h"
+
+int main (int argc, char *argv[])
+{
+ // define the two arrays that will hold generated object keys and method
+ // names of the hypothetical "tao_demux" interface
+ ACE_Unbounded_Queue<ACE_CString> *objectArr, *methodArr;
+
+ // provide default values to the limit on the number of object keys and
+ // method names
+ long objectLimit = 5,
+ methodLimit = 4;
+
+ // for parsing the arguments
+ ACE_Get_Opt get_opt (argc, argv, "hm:o:");
+
+ for (int c; (c = get_opt ()) != EOF;)
+ {
+ switch (c)
+ {
+ case 'm': // number of methods
+ methodLimit = ACE_OS::atoi (get_opt.optarg);
+ break;
+ case 'o': // number of object keys
+ objectLimit = ACE_OS::atoi (get_opt.optarg);
+ break;
+ case 'h': // usage
+ default:
+ Usage ();
+ return 1;
+ }
+ }
+
+ cout << "Generating code for " << objectLimit << " objects and " <<
+ methodLimit << " methods" << endl;
+ objectArr = new ACE_Unbounded_Queue<ACE_CString> [objectLimit];
+ methodArr = new ACE_Unbounded_Queue<ACE_CString> [methodLimit];
+
+ // generate the object keys
+ if (GenObjectTable (*objectArr, objectLimit) == -1)
+ {
+ }
+
+ // generate method names
+ if (GenMethodTable (*methodArr, methodLimit) == -1)
+ {
+ }
+
+ // generate client side stub headers
+ if (GenClientHeader (*methodArr, methodLimit) == -1)
+ {
+ }
+
+ // generate client stubs
+ if (GenClientStubs (*methodArr, methodLimit) == -1)
+ {
+ }
+
+ // generate include code for client-side main program
+ if (GenClientCode (*methodArr, methodLimit) == -1)
+ {
+ }
+
+ // generate server skeleton header
+ if (GenServerHeader (*methodArr, methodLimit) == -1)
+ {
+ }
+
+ // generate server skeletons
+ if (GenServerSkels (*methodArr, methodLimit) == -1)
+ {
+ }
+
+ // generate th eimpl header
+ if (GenServantHeader (*methodArr, methodLimit) == -1)
+ {
+ }
+
+ // generate impl
+ if (GenServantImpl (*methodArr, methodLimit) == -1)
+ {
+ }
+
+ // generate code that creates instances of objects
+ if (GenObjectCreateCode (*objectArr, objectLimit) == -1)
+ {
+ }
+
+ GenGPERFCode ();
+}
+
+void Usage (void)
+{
+ cerr << "Usage: tao [-m <#methods>] [-o <#objects>] [-h]" << endl;
+ return;
+}
diff --git a/TAO/tests/Demux_Test/CodeGen/tao.h b/TAO/tests/Demux_Test/CodeGen/tao.h
new file mode 100644
index 00000000000..cdabc2a3446
--- /dev/null
+++ b/TAO/tests/Demux_Test/CodeGen/tao.h
@@ -0,0 +1,21 @@
+#include <iostream.h>
+#include <fstream.h>
+
+#include "ace/SString.h"
+#include "ace/Containers.h"
+#include "ace/Singleton.h"
+#include "ace/Get_Opt.h"
+
+long GenObjectTable(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+long GenMethodTable(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+long GenClientHeader(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+long GenClientStubs(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+long GenClientCode(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+long GenObjectCreateCode(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+long GenServerHeader(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+long GenServerSkels(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+long GenServantHeader(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+long GenServantImpl(ACE_Unbounded_Queue<ACE_CString> &arr, int limit);
+void GenGPERFCode();
+void Usage();
+