Patch 2 to omniidl2 for MSVC

Randy Shoup rshoup@tumbleweed.com
Mon, 15 Sep 1997 14:04:56 -0700


All -- 

  Below is the diff for a further patch to omniidl2 to work around
weaknesses in scope resolution in MSVC.  This patch builds on and
requires a patch written by Matthew Newhook (matthew_newhook@stratos.ca)
and posted to omniorb-list on 3 July 1997.  This patch generates IDL
which compiles on both MSVC and Solaris.  

  The crux of the modifications is to generate "minimally qualified"
identifiers -- identifiers which are neither fully scoped (which MSVC
does not like) nor completely unscoped (which no compiler likes).  I
don't doubt that there are cases I missed, so comments/criticisms are
welcome.

  The diffs appear below.  IDL examples which now generate
MSVC-compilable code after the patch appear below that.

------------
diff -u -r old/o2be.h new/o2be.h
--- old/o2be.h	Mon Sep 15 12:05:44 1997
+++ new/o2be.h	Mon Sep 15 12:25:06 1997
@@ -47,19 +47,19 @@
   o2be_name(AST_Decl *decl);
 
   // fully qualified name of the scope
-  virtual char *scopename() { return pd_scopename; }
+  virtual char *scopename() const { return pd_scopename; }
 
   // un-qualified name
-  virtual char *uqname()    { return pd_uqname; }
+  virtual char *uqname() const { return pd_uqname; }
 
   // fully qualified name, scope name + un-qualified name
-  virtual char *fqname()    { return pd_fqname; }
+  virtual char *fqname() const { return pd_fqname; }
 
   // same as scopename but with '_' as the separator
-  virtual char *_scopename() { return pd__scopename; }
+  virtual char *_scopename() const { return pd__scopename; }
 
   // same as fqname but with '_' as the separator
-  virtual char *_fqname()    { return pd__fqname; }
+  virtual char *_fqname() const { return pd__fqname; }
 
   virtual char *repositoryID();
 
@@ -75,8 +75,8 @@
   static char *narrow_and_produce__scopename(AST_Decl *type);
   static char *narrow_and_produce_uqname(AST_Decl *type);
 
-  void emit_sfqname(fstream& s, const char* fqname);
-  
+  void emit_sfqname(fstream& s, const char* fqname) const;
+
 private:
   o2be_name();
 
@@ -252,14 +252,13 @@
   void set_skel_produced_in_field() { pd_skel_produced_in_field =
I_TRUE; }
   idl_bool get_skel_produced_in_field() { return
pd_skel_produced_in_field; }
 
-  const char *out_adptarg_name() const { return pd_out_adptarg_name; }
+  void emit_out_adptarg_name(fstream &s, const o2be_name* scope) const;
 
 private:
   idl_bool pd_hdr_produced_in_field;
   idl_bool pd_skel_produced_in_field;
   idl_bool pd_isvar;
   idl_bool pd_nodefault;
-  char *pd_out_adptarg_name;
 
   o2be_union();
 
@@ -306,13 +305,12 @@
   void set_skel_produced_in_field() { pd_skel_produced_in_field =
I_TRUE; }
   idl_bool get_skel_produced_in_field() { return
pd_skel_produced_in_field; }
 
-  const char *out_adptarg_name() const { return pd_out_adptarg_name; }
+  void emit_out_adptarg_name(fstream &s, const o2be_name* scope) const;
 
 private:
   idl_bool pd_hdr_produced_in_field;
   idl_bool pd_skel_produced_in_field;
   idl_bool pd_isvar;
-  char *pd_out_adptarg_name;
 
   o2be_structure();
 
@@ -392,7 +390,7 @@
   void produce_struct_member_decl (fstream &s, AST_Decl *fieldtype);
   void produce_union_member_decl (fstream &s, AST_Decl *fieldtype);
 
-  const char *out_adptarg_name(o2be_typedef* tdef) const;
+  void emit_out_adptarg_name(fstream &s, o2be_typedef* tdef, const
o2be_name* scope) const;
 
 private:
   o2be_array();
@@ -422,7 +420,7 @@
   static void produce_hdr_for_predefined_types(fstream &s);
   static AST_Sequence *attach_seq_to_base_type(AST_Sequence *se);
 
-  const char *out_adptarg_name(o2be_typedef* tdef) const;
+  void emit_out_adptarg_name(fstream &s, o2be_typedef* tdef, const
o2be_name* scope) const;
 
 private:
   char *pd_seq_template_name;
@@ -463,14 +461,13 @@
 
   void produce_decl_rd(fstream &s,
 		       const char *prefix = 0,
-		       idl_bool out_var_default = I_TRUE,
-		       idl_bool in_header = I_TRUE);
-  
+               idl_bool out_var_default = I_TRUE,
+               idl_bool in_header = I_TRUE);
 
   void produce_decl_wr(fstream &s,
 		       const char *prefix = 0,
 		       idl_bool out_var_default = I_TRUE,
-		       idl_bool in_header = I_TRUE);  
+               idl_bool in_header = I_TRUE);
 
   void produce_proxy_rd_skel(fstream &s,o2be_interface &defined_in);
   // produce the definition of the proxy's method to get this attribute
@@ -512,7 +509,7 @@
   void produce_decl(fstream &s,
 		    const char *prefix = 0,
 		    const char *alias_prefix = 0,
-		    idl_bool in_header = I_TRUE,
+            idl_bool in_header = I_TRUE,
 		    idl_bool out_var_default = I_TRUE);
   // produce the declaration of the mapping of this operation
 
@@ -583,7 +580,7 @@
 
   static
   void declareVarType(fstream &s, AST_Decl *decl, idl_bool is_var=0,
-			idl_bool is_arrayslice=0, idl_bool in_header = 1);
+                idl_bool is_arrayslice=0, idl_bool in_header = 1);
 
   static
   void produceUnMarshalCode(fstream &s, AST_Decl *decl,
@@ -668,8 +665,8 @@
   const char *nil_fqname() const { return pd_nil_fqname; }
   const char *IRrepoId() const { return pd_IRrepoId; }
   const size_t IRrepoIdSize() const { return pd_IRrepoIdSize; }
-  const char *inout_adptarg_name() const { return
pd_inout_adptarg_name; }
-  const char *out_adptarg_name() const { return pd_out_adptarg_name; }
+  void emit_inout_adptarg_name(fstream &s, const o2be_name* scope)
const;
+  void emit_out_adptarg_name(fstream &s, const o2be_name* scope) const;
 
   static idl_bool check_opname_clash(o2be_interface *p,char *opname);
 
@@ -686,8 +683,6 @@
   char *pd_nil_fqname;
   char *pd_IRrepoId;
   size_t pd_IRrepoIdSize;
-  char *pd_inout_adptarg_name;
-  char *pd_out_adptarg_name;
 
   o2be_interface();
 };
diff -u -r old/o2be_array.cc new/o2be_array.cc
--- old/o2be_array.cc	Mon Sep 15 12:05:44 1997
+++ new/o2be_array.cc	Mon Sep 15 12:25:21 1997
@@ -27,6 +27,9 @@
 
 /*
   $Log: o2be_array.cc,v $
+// Revision 1.1  1997/06/27  16:21:03  matthew
+// Initial revision
+//
 // Revision 1.5  1997/05/06  13:49:08  sll
 // Public release.
 //
@@ -713,20 +716,16 @@
   s << ";\n\n";
 }
 
-const char*
-o2be_array::out_adptarg_name(o2be_typedef* tdef) const
+void
+o2be_array::emit_out_adptarg_name(fstream &s, o2be_typedef* tdef, const
o2be_name* scope) const
 {
-  char* p = new char[strlen(ADPT_CLASS_TEMPLATE)+strlen("<, >")+
-		     strlen(tdef->fqname()) + strlen("_slice") +
-		     strlen(tdef->fqname()) + strlen("_var")+1];
-  strcpy(p,ADPT_CLASS_TEMPLATE);
-  strcat(p,"<");
-  strcat(p,tdef->fqname());
-  strcat(p,"_slice");
-  strcat(p,",");
-  strcat(p,tdef->fqname());
-  strcat(p,"_var >");
-  return p;  
+  s << ADPT_CLASS_TEMPLATE;
+  s << "<";
+  scope->emit_sfqname(s, tdef->fqname());
+  s << "_slice";
+  s << ",";
+  scope->emit_sfqname(s, tdef->fqname());
+  s << "_var >";
 }
 
 
diff -u -r old/o2be_interface.cc new/o2be_interface.cc
--- old/o2be_interface.cc	Mon Sep 15 12:05:45 1997
+++ new/o2be_interface.cc	Mon Sep 15 12:25:28 1997
@@ -27,6 +27,9 @@
 
 /*
   $Log: o2be_interface.cc,v $
+// Revision 1.1  1997/06/27  17:31:12  matthew
+// Initial revision
+//
 // Revision 1.9  1997/05/06  13:58:53  sll
 // Public release.
 //
@@ -67,8 +70,6 @@
       pd_objref_fqname = "CORBA::Object_ptr";
       pd_fieldmem_uqname = "Object_member";
       pd_fieldmem_fqname = "CORBA::Object_member";
-      pd_inout_adptarg_name = "CORBA::Object_INOUT_arg";
-      pd_out_adptarg_name = "CORBA::Object_OUT_arg";
       return;
     }
 
@@ -143,7 +144,7 @@
   strcat(pd_fieldmem_uqname,">");
 
   pd_fieldmem_fqname = new char[strlen(uqname())+
-			        strlen(uqname())+strlen("_Helper")+
+                    strlen(uqname())+strlen("_Helper")+
 			        strlen(FIELD_MEMBER_TEMPLATE)+4];
   strcpy(pd_fieldmem_fqname,FIELD_MEMBER_TEMPLATE);
   strcat(pd_fieldmem_fqname,"<");
@@ -158,37 +159,6 @@
   strcpy(pd_IRrepoId,_fqname());
   strcat(pd_IRrepoId,IRREPOID_POSTFIX);
 
-  pd_inout_adptarg_name = new char[strlen(ADPT_INOUT_CLASS_TEMPLATE)+
-				   strlen("<,, >")+
-                                   strlen(uqname())+
-				   strlen(uqname())+strlen("_var")+
-				   strlen(pd_fieldmem_uqname)+1];
-  strcpy(pd_inout_adptarg_name,ADPT_INOUT_CLASS_TEMPLATE);
-  strcat(pd_inout_adptarg_name,"<");
-  strcat(pd_inout_adptarg_name,uqname());
-  strcat(pd_inout_adptarg_name,",");
-  strcat(pd_inout_adptarg_name,uqname());
-  strcat(pd_inout_adptarg_name,"_var,");
-  strcat(pd_inout_adptarg_name,pd_fieldmem_uqname);
-  strcat(pd_inout_adptarg_name," >");
-
-  pd_out_adptarg_name = new char[strlen(ADPT_OUT_CLASS_TEMPLATE)+
-				   strlen("<,,, >")+
-                                   strlen(uqname())+
-				   strlen(uqname())+strlen("_var")+
-				   strlen(pd_fieldmem_uqname)+
-				   strlen(uqname())+strlen("_Helper")+1];
-  strcpy(pd_out_adptarg_name,ADPT_OUT_CLASS_TEMPLATE);
-  strcat(pd_out_adptarg_name,"<");
-  strcat(pd_out_adptarg_name,uqname());
-  strcat(pd_out_adptarg_name,",");
-  strcat(pd_out_adptarg_name,uqname());
-  strcat(pd_out_adptarg_name,"_var,");
-  strcat(pd_out_adptarg_name,pd_fieldmem_uqname);
-  strcat(pd_out_adptarg_name,",");
-  strcat(pd_out_adptarg_name,uqname());
-  strcat(pd_out_adptarg_name,"_Helper");
-  strcat(pd_out_adptarg_name," >");
 }
 
 o2be_interface_fwd::o2be_interface_fwd(UTL_ScopedName *n, UTL_StrList
*p)
@@ -1179,6 +1149,51 @@
     << ";\n";
 }
 
+
+
+void 
+o2be_interface::emit_inout_adptarg_name(fstream &s, const o2be_name*
scope) const
+{ 
+  if (strcmp(fqname(),"Object") == 0)
+    {
+      s << "CORBA::Object_INOUT_arg";
+    }
+  else
+    {
+      s << ADPT_INOUT_CLASS_TEMPLATE;
+      s << "<";
+      scope->emit_sfqname(s, fqname());
+      s << ",";
+      scope->emit_sfqname(s, fqname());
+      s << "_var,";
+      s << pd_fieldmem_uqname;
+      s << " >";
+    }
+}
+
+
+void 
+o2be_interface::emit_out_adptarg_name(fstream &s, const o2be_name*
scope) const
+{ 
+  if (strcmp(fqname(),"Object") == 0)
+    {
+      s << "CORBA::Object_OUT_arg";
+    }
+  else
+    {
+      s << ADPT_OUT_CLASS_TEMPLATE;
+      s << "<";
+      scope->emit_sfqname(s, fqname());
+      s << ",";
+      scope->emit_sfqname(s, fqname());
+      s << "_var,";
+      s << pd_fieldmem_uqname;
+      s << ",";
+      scope->emit_sfqname(s, fqname());
+      s << "_Helper";
+      s << " >";
+    }
+}
 
 IMPL_NARROW_METHODS1(o2be_interface, AST_Interface)
 IMPL_NARROW_FROM_DECL(o2be_interface)
diff -u -r old/o2be_name.cc new/o2be_name.cc
--- old/o2be_name.cc	Mon Sep 15 12:05:45 1997
+++ new/o2be_name.cc	Mon Sep 15 12:25:36 1997
@@ -27,6 +27,9 @@
 
 /*
   $Log: o2be_name.cc,v $
+// Revision 1.1  1997/06/30  17:00:03  matthew
+// Initial revision
+//
 // Revision 1.5  1997/05/06  14:01:18  sll
 // Public release.
 //
@@ -511,7 +514,7 @@
 o2be_name::emit_sfqname(
   fstream& s,
   const char* fqname
-)
+) const
 {
   const char* sn_start = scopename();
   const char* sn_end;
@@ -525,11 +528,11 @@
     {
       int fq_len = fq_end - fq_start;
       if (fq_len == sn_end - sn_start &&
-	  strncmp(fq_start, sn_start, fq_len) == 0)
+         strncmp(fq_start, sn_start, fq_len) == 0)
       {
-	fq_start = fq_end + 2; // skip ::
-	sn_start = sn_end + 2;
-	continue;
+       fq_start = fq_end + 2; // skip ::
+       sn_start = sn_end + 2;
+       continue;
       }
     }
     break;
@@ -541,4 +544,4 @@
   //cout << "emitting: " << fq_start << endl;
 
   s << fq_start;
- }
+}
diff -u -r old/o2be_operation.cc new/o2be_operation.cc
--- old/o2be_operation.cc	Mon Sep 15 12:05:46 1997
+++ new/o2be_operation.cc	Mon Sep 15 12:25:48 1997
@@ -28,6 +28,9 @@
 
 /*
   $Log: o2be_operation.cc,v $
+// Revision 1.1  1997/06/25  15:31:03  matthew
+// Initial revision
+//
 // Revision 1.11  1997/05/06  14:03:08  sll
 // Public release.
 //
@@ -59,7 +62,7 @@
 o2be_operation::produce_decl(fstream &s,
 			     const char *prefix,
 			     const char *alias_prefix,
-			     idl_bool in_header,
+                 idl_bool in_header,
 			     idl_bool out_var_default /* ignored */)
 {
   if (context())
@@ -80,27 +83,27 @@
 	while (decl->node_type() == AST_Decl::NT_typedef) {
 	  decl = o2be_typedef::narrow_from_decl(decl)->base_type();
 	}
-	if (in_header)
-	{
-	  emit_sfqname(s,
o2be_interface::narrow_from_decl(decl)->objref_fqname());
-	}
-	else
-	{
-	  s << o2be_interface::narrow_from_decl(decl)->objref_fqname();
-	}
+    if (in_header)
+    {
+      emit_sfqname(s,
o2be_interface::narrow_from_decl(decl)->objref_fqname());
+    }
+    else
+    {
+      s << o2be_interface::narrow_from_decl(decl)->objref_fqname();
+    }
       }
       else if (ntype == tString) {
 	s << "char *";
       }
       else {
 	if (in_header)
-	{
-	  emit_sfqname(s,
o2be_name::narrow_and_produce_fqname(return_type()));
-	}
-	else
-	{
-	  s << o2be_name::narrow_and_produce_fqname(return_type());
-	}
+    {
+      emit_sfqname(s,
o2be_name::narrow_and_produce_fqname(return_type()));
+    }
+    else
+    {
+      s << o2be_name::narrow_and_produce_fqname(return_type());
+    }
       }
       s << ((mapping.is_arrayslice) ? "_slice":"")
 	<< " "
@@ -358,7 +361,7 @@
 		}
 		else if (mapping.is_reference && mapping.is_pointer) {
 		  IND(s); s << "_" << a->uqname() << " = new ";
-		  declareVarType(s,a->field_type(), 0, 0 ,0);
+		  declareVarType(s,a->field_type(), 0, 0, 0);
 		  s << ";\n";
 		}
 	      }
@@ -431,7 +434,7 @@
 		    strcpy(_argname,"_");
 		    strcat(_argname,a->uqname());
 		    IND(s);
-		    declareVarType(s,a->field_type(),0,0);
+		    declareVarType(s,a->field_type(),0,0,0);
 		    s << " " << _argname << ";\n";
 		    produceUnMarshalCode(s,a->field_type(),"_c",_argname,
 					 ntype,mapping);
@@ -530,8 +533,8 @@
 	{
 	  o2be_exception *excpt = o2be_exception::narrow_from_decl(i.item());
 	  int len = strlen(excpt->repositoryID())+1;
-	  if (len > maxIdsize)
-	    maxIdsize = len;
+      if (len > maxIdsize)
+        maxIdsize = len;
 	  i.next();
 	}
     }
@@ -985,7 +988,7 @@
 	IND(s); s << "size_t _msgsize = (size_t)
GIOP_S::ReplyHeaderSize();\n";
 
 	int len = strlen(excpt->repositoryID())+1;
-	produceConstStringSizeCalculation(s,"_msgsize", len);
+    produceConstStringSizeCalculation(s,"_msgsize", len);
 	produceSizeCalculation(s,i.item(),"_s","_msgsize","ex",ntype,mapping);
 
 	IND(s); s <<
"_s.InitialiseReply(GIOP::USER_EXCEPTION,(CORBA::ULong)_msgsize);\n"; 
@@ -1369,7 +1372,7 @@
 	      s << "char *";
 	    }
 	    else {
-	      s << o2be_name::narrow_and_produce_uqname(a->field_type());
+	      emit_sfqname(s,
o2be_name::narrow_and_produce_fqname(a->field_type()));
 	    }
 	    s << ((mapping.is_arrayslice) ? "_slice":"")
 	      << " "
@@ -1388,10 +1391,12 @@
 		}
 		o2be_interface* intf = o2be_interface::narrow_from_decl(decl);
 		if (a->direction() == AST_Argument::dir_INOUT) {
-		  s << intf->inout_adptarg_name() << " ";
+		  intf->emit_inout_adptarg_name(s, this);
+		  s << " ";
 		}
 		else {
-		  s << intf->out_adptarg_name() << " ";
+		  intf->emit_out_adptarg_name(s, this);
+		  s << " ";
 		}
 		break;
 	      }
@@ -1420,7 +1425,8 @@
 		}
 		o2be_structure* p = o2be_structure::narrow_from_decl(decl);
 		if (a->direction() == AST_Argument::dir_OUT) {
-		  s << p->out_adptarg_name() << " ";
+		  p->emit_out_adptarg_name(s, this);
+		  s << " ";
 		}
 		break;
 	      }
@@ -1432,7 +1438,8 @@
 		}
 		o2be_union* p = o2be_union::narrow_from_decl(decl);
 		if (a->direction() == AST_Argument::dir_OUT) {
-		  s << p->out_adptarg_name() << " ";
+		  p->emit_out_adptarg_name(s, this);
+		  s << " ";
 		}
 		break;
 	      }
@@ -1449,7 +1456,8 @@
 		}
 		o2be_sequence* p = o2be_sequence::narrow_from_decl(decl);
 		if (a->direction() == AST_Argument::dir_OUT) {
-		  s << p->out_adptarg_name(tp) << " ";
+		  p->emit_out_adptarg_name(s, tp, this);
+		  s << " ";
 		}
 		break;
 	      }
@@ -1466,7 +1474,8 @@
 		}
 		o2be_array* p = o2be_array::narrow_from_decl(decl);
 		if (a->direction() == AST_Argument::dir_OUT) {
-		  s << p->out_adptarg_name(tp) << " ";
+		  p->emit_out_adptarg_name(s, tp, this);
+		  s << " ";
 		}
 		break;
 	      }
@@ -1870,27 +1879,27 @@
   if (truetype->node_type() == AST_Decl::NT_interface)
     {
       if (!is_var)
-      {
-	if (in_header)
 	{
-	  s << o2be_interface::narrow_from_decl(truetype)->objref_uqname();
-	}
-	else
-	{
-	  s << o2be_interface::narrow_from_decl(truetype)->objref_fqname();
-	}
-      }
+     if (in_header)
+     {
+       s <<
o2be_interface::narrow_from_decl(truetype)->objref_uqname();
+     }
+     else
+     {
+       s <<
o2be_interface::narrow_from_decl(truetype)->objref_fqname();
+     }
+    }
       else
-      {
-	if (in_header)
 	{
-	  s << o2be_name::narrow_and_produce_uqname(truetype) << "_var";
-	}
-	else
-	{
-	  s << o2be_name::narrow_and_produce_fqname(truetype) << "_var";
-	}
-      }
+     if (in_header)
+     {
+       s << o2be_name::narrow_and_produce_uqname(truetype) << "_var";
+     }
+     else
+     {
+       s << o2be_name::narrow_and_produce_fqname(truetype) << "_var";
+     }
+    }
     }
   else 
     if (truetype->node_type() == AST_Decl::NT_string)
@@ -1903,9 +1912,9 @@
   else
     {
       if (in_header)
-	s << o2be_name::narrow_and_produce_uqname(decl);
+       s << o2be_name::narrow_and_produce_uqname(decl);
       else
-	s << o2be_name::narrow_and_produce_fqname(decl);
+       s << o2be_name::narrow_and_produce_fqname(decl);
       if (is_var)
 	s << "_var";
       else
diff -u -r old/o2be_sequence.cc new/o2be_sequence.cc
--- old/o2be_sequence.cc	Mon Sep 15 12:05:46 1997
+++ new/o2be_sequence.cc	Mon Sep 15 12:25:59 1997
@@ -27,6 +27,9 @@
 
 /*
   $Log: o2be_sequence.cc,v $
+// Revision 1.1  1997/06/27  17:14:36  matthew
+// Initial revision
+//
 // Revision 1.5  1997/05/06  14:05:26  sll
 // Public release.
 //
@@ -569,18 +572,15 @@
 #endif
 }
 
-const char*
-o2be_sequence::out_adptarg_name(o2be_typedef* tdef) const
+void
+o2be_sequence::emit_out_adptarg_name(fstream &s, o2be_typedef* tdef,
const o2be_name* scope) const
 {
-  char* p = new char[strlen(SEQUENCE_TEMPLATE_ADPT_CLASS)+strlen("<,
>")+
-		     strlen(tdef->fqname())*2+strlen("_var")+1];
-  strcpy(p,SEQUENCE_TEMPLATE_ADPT_CLASS);
-  strcat(p,"<");
-  strcat(p,tdef->uqname());
-  strcat(p,",");
-  strcat(p,tdef->uqname());
-  strcat(p,"_var >");
-  return p;
+  s << SEQUENCE_TEMPLATE_ADPT_CLASS;
+  s << "<";
+  scope->emit_sfqname(s, tdef->fqname());
+  s << ",";
+  scope->emit_sfqname(s, tdef->fqname());
+  s << "_var >";
 }
 
 
diff -u -r old/o2be_struct.cc new/o2be_struct.cc
--- old/o2be_struct.cc	Mon Sep 15 12:05:47 1997
+++ new/o2be_struct.cc	Mon Sep 15 12:26:08 1997
@@ -118,16 +118,6 @@
   pd_isvar = I_FALSE;
   pd_hdr_produced_in_field = I_FALSE;
   pd_skel_produced_in_field = I_FALSE;
-
-  pd_out_adptarg_name = new
char[strlen(ADPT_CLASS_TEMPLATE)+strlen("<,>")+
-				 strlen(uqname())+
-				 strlen(uqname())+strlen("_var")+1];
-  strcpy(pd_out_adptarg_name,ADPT_CLASS_TEMPLATE);
-  strcat(pd_out_adptarg_name,"<");
-  strcat(pd_out_adptarg_name,uqname());
-  strcat(pd_out_adptarg_name,",");
-  strcat(pd_out_adptarg_name,uqname());
-  strcat(pd_out_adptarg_name,"_var>");  
 }
 
 AST_Field *
@@ -259,12 +249,12 @@
 		{
 		  if (decl->node_type() == AST_Decl::NT_interface)
 		  {
-		    emit_sfqname(s,
o2be_interface::narrow_from_decl(decl)->fieldMemberType_fqname());
-		  }
+            emit_sfqname(s,
o2be_interface::narrow_from_decl(decl)->fieldMemberType_fqname());
+          }
 		  else
 		  {
-		    s <<
o2be_interface::narrow_from_decl(decl)->fieldMemberType_uqname();
-		  }
+            s <<
o2be_interface::narrow_from_decl(decl)->fieldMemberType_uqname();
+          }
 		  s <<" "<< o2be_field::narrow_from_decl(d)->uqname() << ";\n";
 
 		  break;
@@ -274,7 +264,7 @@
 		  if (decl->node_type() == AST_Decl::NT_array)
 		   
o2be_array::narrow_from_decl(decl)->produce_struct_member_decl(s,d);
 		  else {
-		    s << o2be_typedef::narrow_from_decl(decl)->uqname();
+            emit_sfqname(s,
o2be_typedef::narrow_from_decl(decl)->fqname());
 		    s <<" "<< o2be_field::narrow_from_decl(d)->uqname() << ";\n";
 		  }
 		  break;
@@ -289,15 +279,15 @@
 		      << ";\n";
 		  }
 		  else {
-		    s << o2be_typedef::narrow_from_decl(decl)->uqname();
+            emit_sfqname(s,
o2be_typedef::narrow_from_decl(decl)->fqname());
 		    s <<" "<< o2be_field::narrow_from_decl(d)->uqname() << ";\n";
 		  }
 		  break;
 		}
 #endif
 	      default:
-		s << o2be_name::narrow_and_produce_uqname(decl)
-		  << " " << o2be_field::narrow_from_decl(d)->uqname() << ";\n";
+            emit_sfqname(s,
o2be_name::narrow_and_produce_fqname(decl));
+		s << " " << o2be_field::narrow_from_decl(d)->uqname() << ";\n";
 	      }
 	  }
 	i.next();
@@ -576,3 +566,16 @@
 IMPL_NARROW_METHODS1(o2be_structure, AST_Structure)
 IMPL_NARROW_FROM_DECL(o2be_structure)
 IMPL_NARROW_FROM_SCOPE(o2be_structure)
+
+
+void 
+o2be_structure::emit_out_adptarg_name(fstream &s, const o2be_name*
scope) const
+{ 
+  s << ADPT_CLASS_TEMPLATE;
+  s << "<";
+  scope->emit_sfqname(s, fqname());
+  s << ",";
+  scope->emit_sfqname(s, fqname());
+  s << "_var>";  
+}
+
diff -u -r old/o2be_union.cc new/o2be_union.cc
--- old/o2be_union.cc	Mon Sep 15 12:05:47 1997
+++ new/o2be_union.cc	Mon Sep 15 12:26:18 1997
@@ -142,16 +142,6 @@
   pd_nodefault = I_TRUE;
   pd_hdr_produced_in_field = I_FALSE;
   pd_skel_produced_in_field = I_FALSE;
-
-  pd_out_adptarg_name = new
char[strlen(ADPT_CLASS_TEMPLATE)+strlen("<,>")+
-				 strlen(uqname())+
-				 strlen(uqname())+strlen("_var")+1];
-  strcpy(pd_out_adptarg_name,ADPT_CLASS_TEMPLATE);
-  strcat(pd_out_adptarg_name,"<");
-  strcat(pd_out_adptarg_name,uqname());
-  strcat(pd_out_adptarg_name,",");
-  strcat(pd_out_adptarg_name,uqname());
-  strcat(pd_out_adptarg_name,"_var>");  
 }
 
 AST_UnionBranch *
@@ -1043,8 +1033,8 @@
 		  }
 		else
 		  {
-		    IND(s); s <<
o2be_typedef::narrow_from_decl(f->field_type())->fqname()
-			      << " pd_" << f->uqname() << ";\n";
+		    IND(s); emit_sfqname(s,
o2be_typedef::narrow_from_decl(f->field_type())->fqname());
+			s << " pd_" << f->uqname() << ";\n";
 		  }
 #else
 		IND(s); s << o2be_name::narrow_and_produce_uqname(f->field_type())
@@ -1059,8 +1049,8 @@
 		  }
 		else
 		  {
-		    IND(s); s <<
o2be_typedef::narrow_from_decl(f->field_type())->fqname()
-			      << " pd_" << f->uqname() << ";\n";
+		    IND(s); emit_sfqname(s,
o2be_typedef::narrow_from_decl(f->field_type())->fqname());
+			s << " pd_" << f->uqname() << ";\n";
 		  }
 		break;
 	      default:
@@ -2078,3 +2068,15 @@
 IMPL_NARROW_FROM_DECL(o2be_union)
 IMPL_NARROW_FROM_SCOPE(o2be_union)
 
+
+
+void 
+o2be_union::emit_out_adptarg_name(fstream &s, const o2be_name* scope)
const
+{ 
+  s << ADPT_CLASS_TEMPLATE;
+  s << "<";
+  scope->emit_sfqname(s, fqname());
+  s << ",";
+  scope->emit_sfqname(s, fqname());
+  s << "_var>";  
+}


------------
// scope1.idl
module TW_Type {
typedef sequence<boolean>		BooleanArray;

enum AttributeType {
	BOOLEAN_ARRAY	
};

union AttributeValue switch(AttributeType) {
case BOOLEAN_ARRAY: BooleanArray	m_boolean_array;				  				  
};

struct Attribute {
	AttributeValue	value;
};

}; // module TW_Type

------------
// scope2.idl
module TW_Type {
typedef unsigned long			Time;

}; // module TW_Type

struct TW_StreamDescriptor {
	TW_Type::Time				m_create_time;
};

------------
// scope3.idl
module TW_Type {
typedef sequence<boolean>		BooleanArray;
}; // module TW_Type

interface TW_HttpTemplateExtension {
	boolean	GenerateTemplate(
	in TW_Type::BooleanArray output_variables,
	out string			outstring
	);
};

------------
// scope4.idl
module TW_Type {
typedef sequence<boolean>		BooleanArray;
}; // module TW_Type

interface TW_HttpTemplateExtension {
	boolean	GenerateTemplate(
	in TW_Type::BooleanArray output_variables,
	out string			outstring
	);
};

------------
// scope5.idl
module TW_Type {
typedef sequence<string>		StringArray;
}; // module TW_Type

interface TW_SessionCentral {
	struct State {
		TW_Type::StringArray	m_billing_codes;
	};
};

------------
// scope6.idl
module TW_Type {
struct Error {
	string m_code;
};

}; // module TW_Type

interface TW_AccountManagerExtension {
	boolean	 ValidateAccountDescriptor(
	out TW_Type::Error error
	);
};

------------

-- Randy
_________________________________________________________________  
Randy Shoup                                     (415)569-3682  
Senior Software Developer                       rshoup@tumbleweed.com  
Tumbleweed Software Corporation