From: Chris M. <zm...@us...> - 2001-05-28 22:35:38
|
Update of /cvsroot/kuml/kuml/libkuml/uml/tools In directory usw-pr-cvs1:/tmp/cvs-serv9727 Modified Files: common_code.xsl gen_class_hs.xsl gen_proxy_hs.xsl Log Message: Deal with multiple inheritance uniformly. Index: common_code.xsl =================================================================== RCS file: /cvsroot/kuml/kuml/libkuml/uml/tools/common_code.xsl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** common_code.xsl 2001/05/22 23:00:40 1.2 --- common_code.xsl 2001/05/28 22:35:35 1.3 *************** *** 157,161 **** <!-- Templates for finding CORBA IDL type implementations. --> ! <!-- These setup the CORBA_type variable. --> --- 157,161 ---- <!-- Templates for finding CORBA IDL type implementations. --> ! <!-- These use the type_name mode and setup the CORBA_type variable. --> *************** *** 166,176 **** --- 166,179 ---- </xsl:template> + <xsl:template match="XMI.CorbaTcBoolean" mode="type_name"> <xsl:text>CORBA::Boolean</xsl:text> </xsl:template> + <xsl:template match="XMI.CorbaTcString" mode="type_name"> <xsl:text>char*</xsl:text> </xsl:template> + <xsl:template match="XMI.CorbaTcEnum" mode="type_name"> Index: gen_class_hs.xsl =================================================================== RCS file: /cvsroot/kuml/kuml/libkuml/uml/tools/gen_class_hs.xsl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** gen_class_hs.xsl 2001/05/16 22:21:39 1.2 --- gen_class_hs.xsl 2001/05/28 22:35:35 1.3 *************** *** 11,20 **** <xsl:template name="CLASS_INSTANCE"> <xsl:variable name="package_name" select="ancestor::Model:Package/@name"/> <xsl:variable name="class_name" select="@name"/> - <xsl:variable name="supertypes" select="@supertypes"/> - <xsl:variable name="superclass" select="/descendant::Model:Class[@xmi.id=$supertypes]/@name"/> <xsl:text>#ifndef __</xsl:text> --- 11,129 ---- + <!-- Templates to do #includes of superclass header files. + These templates all use the include mode. + WARNING! These templates are very similar to the the ones in + gen_proxy_hs.xsl but they aren't equivalent so don't attempt to + put them in common_code.xsl + --> + + + <!-- Replace the default rule. --> + <xsl:template match="*" mode="include"/> + + + <!-- Certain nodes do nothing. --> + <xsl:template mode="include" + match="/ | XMI | XMI.content | Model:Package | Model:Namespace.contents | Model:DataType.typeCode | XMI.CorbaTypeCode"> + <xsl:apply-templates mode="include"/> + </xsl:template> + + + <xsl:template match="Model:Class" mode="include"> + <xsl:variable name="classname" select="@name"/> + <xsl:text>#include "</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>_impl.h" </xsl:text> + + <xsl:text> </xsl:text> + + </xsl:template> + + + <xsl:template name="include-supertypes"> + <xsl:choose> + <xsl:when test="count(attribute::supertypes) = 0"> + <xsl:text>#include "Reflective_impl.h" </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="supertypes" select="@supertypes"/> + <xsl:choose> + <xsl:when test='contains(@supertypes," ")'> + + <xsl:apply-templates mode="include" + select='/descendant::Model:Class[@xmi.id=substring-before($supertypes," ")]'/> + + <xsl:apply-templates mode="include" + select='/descendant::Model:Class[@xmi.id=substring-after($supertypes," ")]'/> + + </xsl:when> + <xsl:otherwise> + + <xsl:apply-templates mode="include" + select='/descendant::Model:Class[@xmi.id=$supertypes]'/> + + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <!-- Templates to do inheritance + These templates all use the inherit mode. + --> + + + <!-- Replace the default rule. --> + <xsl:template match="*" mode="inherit"/> + + + <!-- Certain nodes do nothing. --> + <xsl:template mode="inherit" + match="/ | XMI | XMI.content | Model:Package | Model:Namespace.contents | Model:DataType.typeCode | XMI.CorbaTypeCode"> + <xsl:apply-templates mode="inherit"/> + </xsl:template> + + + <xsl:template match="Model:Class" mode="inherit"> + <xsl:text> virtual public </xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>_impl, </xsl:text> + </xsl:template> + + + <xsl:template name="inherits"> + <xsl:choose> + <xsl:when test="count(attribute::supertypes) = 0"> + <xsl:text> virtual public Reflective::RefObject, </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="supertypes" select="@supertypes"/> + <xsl:choose> + <xsl:when test='contains(@supertypes," ")'> + + <xsl:apply-templates mode="inherit" + select='/descendant::Model:Class[@xmi.id=substring-before($supertypes," ")]'/> + + <xsl:apply-templates mode="inherit" + select='/descendant::Model:Class[@xmi.id=substring-after($supertypes," ")]'/> + + </xsl:when> + <xsl:otherwise> + + <xsl:apply-templates mode="inherit" + select='/descendant::Model:Class[@xmi.id=$supertypes]'/> + + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="CLASS_INSTANCE"> <xsl:variable name="package_name" select="ancestor::Model:Package/@name"/> <xsl:variable name="class_name" select="@name"/> <xsl:text>#ifndef __</xsl:text> *************** *** 40,48 **** <xsl:text> </xsl:text> ! <xsl:text>#include "</xsl:text> ! <xsl:value-of select="$superclass"/> ! <xsl:text>_impl.h" </xsl:text> ! ! <xsl:text> </xsl:text> <xsl:text>#include "Core.h" </xsl:text> --- 149,153 ---- <xsl:text> </xsl:text> ! <xsl:call-template name="include-supertypes"/> <xsl:text>#include "Core.h" </xsl:text> *************** *** 54,59 **** <xsl:text> </xsl:text> - <xsl:text> </xsl:text> - <xsl:text>class </xsl:text> <xsl:value-of select="$class_name"/> --- 159,162 ---- *************** *** 64,70 **** <xsl:text>Class_impl, </xsl:text> ! <xsl:text> virtual public </xsl:text> ! <xsl:value-of select="$superclass"/> ! <xsl:text>_impl, </xsl:text> <xsl:text> virtual public POA_</xsl:text> --- 167,171 ---- <xsl:text>Class_impl, </xsl:text> ! <xsl:call-template name="inherits"/> <xsl:text> virtual public POA_</xsl:text> *************** *** 99,102 **** --- 200,205 ---- <xsl:text>}; </xsl:text> + + <xsl:text> </xsl:text> <xsl:text>#endif</xsl:text> Index: gen_proxy_hs.xsl =================================================================== RCS file: /cvsroot/kuml/kuml/libkuml/uml/tools/gen_proxy_hs.xsl,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** gen_proxy_hs.xsl 2001/05/23 22:18:43 1.5 --- gen_proxy_hs.xsl 2001/05/28 22:35:35 1.6 *************** *** 13,16 **** --- 13,19 ---- <!-- Templates to do #includes These templates all use the include mode. + WARNING! These templates are very similar to the the ones in + gen_class_hs.xsl but they aren't equivalent so don't attempt to + put them in common_code.xsl --> *************** *** 38,41 **** --- 41,73 ---- + <xsl:template name="include-supertypes"> + <xsl:choose> + <xsl:when test="count(attribute::supertypes) = 0"> + <xsl:text>#include "Reflective_impl.h" </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="supertypes" select="@supertypes"/> + <xsl:choose> + <xsl:when test='contains(@supertypes," ")'> + + <xsl:apply-templates mode="include" + select='/descendant::Model:Class[@xmi.id=substring-before($supertypes," ")]'/> + + <xsl:apply-templates mode="include" + select='/descendant::Model:Class[@xmi.id=substring-after($supertypes," ")]'/> + + </xsl:when> + <xsl:otherwise> + + <xsl:apply-templates mode="include" + select='/descendant::Model:Class[@xmi.id=$supertypes]'/> + + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <!-- Templates to do inheritance These templates all use the inherit mode. *************** *** 61,64 **** --- 93,125 ---- + <xsl:template name="inherits"> + <xsl:choose> + <xsl:when test="count(attribute::supertypes) = 0"> + <xsl:text> virtual public Reflective::RefObject, </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="supertypes" select="@supertypes"/> + <xsl:choose> + <xsl:when test='contains(@supertypes," ")'> + + <xsl:apply-templates mode="inherit" + select='/descendant::Model:Class[@xmi.id=substring-before($supertypes," ")]'/> + + <xsl:apply-templates mode="inherit" + select='/descendant::Model:Class[@xmi.id=substring-after($supertypes," ")]'/> + + </xsl:when> + <xsl:otherwise> + + <xsl:apply-templates mode="inherit" + select='/descendant::Model:Class[@xmi.id=$supertypes]'/> + + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <!-- Templates to do parameters to the create_<class> method. These templates all use the create_params mode. *************** *** 104,110 **** <xsl:variable name="supertypes" select="@supertypes"/> - <!-- xsl:variable name="superclass" - select="/descendant::Model:Class[@xmi.id=$supertypes]"/ --> - <!-- if a supertype exists recurse on supertype --> <xsl:if test='count(attribute::supertypes) > 0'> --- 165,168 ---- *************** *** 135,139 **** <xsl:variable name="package_name" select="ancestor::Model:Package/@name"/> <xsl:variable name="class_name" select="@name"/> - <xsl:variable name="supertypes" select="@supertypes"/> <xsl:variable name="processed_cn"> --- 193,196 ---- *************** *** 162,189 **** <!-- Includes. --> ! <xsl:choose> ! <xsl:when test="count(attribute::supertypes) = 0"> ! <xsl:text>#include "Reflective_impl.h" </xsl:text> ! </xsl:when> ! <xsl:otherwise> ! <xsl:choose> ! <xsl:when test='contains(@supertypes," ")'> ! ! <xsl:apply-templates mode="include" ! select='/descendant::Model:Class[@xmi.id=substring-before($supertypes," ")]'/> ! ! <xsl:apply-templates mode="include" ! select='/descendant::Model:Class[@xmi.id=substring-after($supertypes," ")]'/> ! ! </xsl:when> ! <xsl:otherwise> ! ! <xsl:apply-templates mode="include" ! select='/descendant::Model:Class[@xmi.id=$supertypes]'/> ! ! </xsl:otherwise> ! </xsl:choose> ! </xsl:otherwise> ! </xsl:choose> <xsl:text>#include "Core.h" </xsl:text> --- 219,223 ---- <!-- Includes. --> ! <xsl:call-template name="include-supertypes"/> <xsl:text>#include "Core.h" </xsl:text> *************** *** 199,226 **** <xsl:text>Class_impl : </xsl:text> ! <xsl:choose> ! <xsl:when test="count(attribute::supertypes) = 0"> ! <xsl:text> virtual public Reflective::RefObject, </xsl:text> ! </xsl:when> ! <xsl:otherwise> ! <xsl:choose> ! <xsl:when test='contains(@supertypes," ")'> ! ! <xsl:apply-templates mode="inherit" ! select='/descendant::Model:Class[@xmi.id=substring-before($supertypes," ")]'/> ! ! <xsl:apply-templates mode="inherit" ! select='/descendant::Model:Class[@xmi.id=substring-after($supertypes," ")]'/> ! ! </xsl:when> ! <xsl:otherwise> ! ! <xsl:apply-templates mode="inherit" ! select='/descendant::Model:Class[@xmi.id=$supertypes]'/> ! ! </xsl:otherwise> ! </xsl:choose> ! </xsl:otherwise> ! </xsl:choose> <xsl:text> virtual public POA_</xsl:text> --- 233,237 ---- <xsl:text>Class_impl : </xsl:text> ! <xsl:call-template name="inherits"/> <xsl:text> virtual public POA_</xsl:text> |