|
From: Chris M. <zm...@us...> - 2002-02-27 22:25:49
|
Update of /cvsroot/kuml/kuml/libkuml/uml/tools
In directory usw-pr-cvs1:/tmp/cvs-serv20953
Modified Files:
gen_class_ccs.xsl gen_class_hs.xsl
Log Message:
Added partial translation for attributes with multiple values.
Only had to implement vector<string> for UML.
Index: gen_class_ccs.xsl
===================================================================
RCS file: /cvsroot/kuml/kuml/libkuml/uml/tools/gen_class_ccs.xsl,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** gen_class_ccs.xsl 11 Feb 2002 21:14:52 -0000 1.12
--- gen_class_ccs.xsl 27 Feb 2002 22:25:46 -0000 1.13
***************
*** 11,14 ****
--- 11,15 ----
+ <!-- Initialise attributes when class is constructed. -->
<xsl:template name="CONSTRUCT_ATTRIBUTE">
***************
*** 25,29 ****
</xsl:variable>
! <xsl:if test='$CORBA_type = "char*"'>
<xsl:variable name="attribute">
--- 26,33 ----
</xsl:variable>
! <xsl:variable name="upper"
! select="./Model:StructuralFeature.multiplicity/XMI.field[position()=2]"/>
!
! <xsl:if test='$CORBA_type = "char*" and not($upper = -1 or $upper > 1)'>
<xsl:variable name="attribute">
***************
*** 225,230 ****
<!-- Define the value of the CORBA_set_type variable by applying templates
! in the type_name mode to the descendant of the root node whos xmi.id
! attribute matches type_ref but only if the multiplicity is "many".
-->
<xsl:variable name="CORBA_set_type">
--- 229,234 ----
<!-- Define the value of the CORBA_set_type variable by applying templates
! in the type_set_namename mode to the descendant of the root node whos
! xmi.id attribute matches type_ref but only if the multiplicity is "many".
-->
<xsl:variable name="CORBA_set_type">
***************
*** 324,327 ****
--- 328,336 ----
-->
+ <!-- I've attempted a full translation here. However, since my XMI only
+ generates vector<string>, I'm only going to supply that type of
+ translation for the other multi-valued attribute functions.
+ Please feel free to fill in the gaps. ;-)
+ -->
<xsl:value-of select="$CORBA_set_type"/>
<xsl:text>Set* </xsl:text>
***************
*** 335,339 ****
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ // XXX </xsl:text>
<xsl:text>} </xsl:text>
--- 344,399 ----
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ </xsl:text>
! <xsl:value-of select="$CORBA_set_type"/>
! <xsl:text>Set_var res = new </xsl:text>
! <xsl:value-of select="$CORBA_set_type"/>
! <xsl:text>Set; </xsl:text>
!
! <xsl:text> res->length(fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.size()); </xsl:text>
!
! <xsl:text> int j = 0; </xsl:text>
!
! <xsl:text> for(</xsl:text>
! <xsl:choose>
! <xsl:when test='$is_ordered = "false"'>
! <xsl:text>vector</xsl:text>
! </xsl:when>
! <xsl:when test='$is_ordered = "true"'>
! <xsl:text>list</xsl:text>
! </xsl:when>
! </xsl:choose>
! <xsl:text><</xsl:text>
! <xsl:choose>
! <xsl:when test='$CORBA_type = "char*"'>
! <xsl:text>string</xsl:text>
! </xsl:when>
! <xsl:otherwise>
! <xsl:value-of select="$CORBA_set_type"/>
! </xsl:otherwise>
! </xsl:choose>
! <xsl:text>>::iterator i = fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.begin(); </xsl:text>
!
! <xsl:text> i != fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.end(); i++) </xsl:text>
!
! <xsl:text> res[j++] = </xsl:text>
! <xsl:choose>
! <xsl:when test='$CORBA_type = "char*"'>
! <xsl:text>CORBA::string_dup((*i).c_str())</xsl:text>
! </xsl:when>
! <xsl:otherwise>
! <xsl:value-of select="$CORBA_set_type"/>
! <xsl:text>_duplicate(*i)</xsl:text>
! </xsl:otherwise>
! </xsl:choose>
! <xsl:text>; </xsl:text>
!
! <xsl:text> return res._retn(); </xsl:text>
!
<xsl:text>} </xsl:text>
***************
*** 410,416 ****
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ // YYY </xsl:text>
<xsl:text>} </xsl:text>
</xsl:if>
--- 470,490 ----
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.erase(fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.begin(), fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.end()); </xsl:text>
! <xsl:text> for(int i = 0; i < new_value.length(); i++) </xsl:text>
!
! <xsl:text> fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.push_back(new_value[i].in()); </xsl:text>
!
<xsl:text>} </xsl:text>
+ <xsl:text> </xsl:text>
+
</xsl:if>
***************
*** 433,462 ****
<xsl:text>{ </xsl:text>
! <xsl:choose>
! <xsl:when test='contains($CORBA_type,"_ptr")'>
! <xsl:text>fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text> = </xsl:text>
! <xsl:value-of select='substring-before($CORBA_type,"_ptr")'/>
! <xsl:text>::_nil(); </xsl:text>
! </xsl:when>
! <xsl:when test='$CORBA_type = "char*"'>
! <xsl:text>if (fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text> != NULL) </xsl:text>
! <xsl:text> { free(fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>); </xsl:text>
! <xsl:text> fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text> = NULL; </xsl:text>
! <xsl:text> }; </xsl:text>
! </xsl:when>
! <xsl:otherwise>
! <xsl:text>fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text> = 0; </xsl:text>
! </xsl:otherwise>
! </xsl:choose>
<xsl:text>} </xsl:text>
--- 507,553 ----
<xsl:text>{ </xsl:text>
!
! <xsl:if test='$upper = 1 and $is_changeable="true"'>
!
! <xsl:choose>
! <xsl:when test='contains($CORBA_type,"_ptr")'>
! <xsl:text>fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text> = </xsl:text>
! <xsl:value-of select='substring-before($CORBA_type,"_ptr")'/>
! <xsl:text>::_nil(); </xsl:text>
! </xsl:when>
! <xsl:when test='$CORBA_type = "char*"'>
! <xsl:text>if (fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text> != NULL) </xsl:text>
! <xsl:text> { free(fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>); </xsl:text>
! <xsl:text> fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text> = NULL; </xsl:text>
! <xsl:text> }; </xsl:text>
! </xsl:when>
! <xsl:otherwise>
! <xsl:text>fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text> = 0; </xsl:text>
! </xsl:otherwise>
! </xsl:choose>
!
! </xsl:if>
!
! <xsl:if test='($upper > 1 or $upper = -1)'>
!
! <xsl:text>fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.erase(fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.begin(), fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.end()); </xsl:text>
!
! </xsl:if>
<xsl:text>} </xsl:text>
***************
*** 487,492 ****
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ // ZZZ </xsl:text>
<xsl:text>} </xsl:text>
</xsl:if>
--- 578,588 ----
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.push_back(new_element); </xsl:text>
!
<xsl:text>} </xsl:text>
+
+ <xsl:text> </xsl:text>
</xsl:if>
***************
*** 586,590 ****
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ // VVV </xsl:text>
<xsl:text>} </xsl:text>
--- 682,695 ----
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ string old_string = old_element; </xsl:text>
!
! <xsl:text> string new_string = new_element; </xsl:text>
!
! <xsl:text> replace(fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.begin(), fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.end(), old_string, new_string); </xsl:text>
!
<xsl:text>} </xsl:text>
***************
*** 644,650 ****
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ // LLL </xsl:text>
<xsl:text>} </xsl:text>
</xsl:if>
--- 749,764 ----
<xsl:text> ::Reflective::MofError) </xsl:text>
! <xsl:text>{ string old_string = old_element; </xsl:text>
!
! <xsl:text> remove(fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.begin(), fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>.end(), old_string); </xsl:text>
!
<xsl:text>} </xsl:text>
+ <xsl:text> </xsl:text>
+
</xsl:if>
***************
*** 761,766 ****
</xsl:variable>
! <!-- The value of the name attribute of a Model:Association descendant
! of the root node, which contains the referenced AssociationEnd.
-->
<xsl:variable name="base_assoc_name">
--- 875,880 ----
</xsl:variable>
! <!-- The name of a Model:Association
! which contains the referenced AssociationEnd.
-->
<xsl:variable name="base_assoc_name">
***************
*** 875,879 ****
<xsl:value-of select="$package_name"/>
<xsl:text>Package::_narrow(rp); </xsl:text>
-
<xsl:text> </xsl:text>
--- 989,992 ----
Index: gen_class_hs.xsl
===================================================================
RCS file: /cvsroot/kuml/kuml/libkuml/uml/tools/gen_class_hs.xsl,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** gen_class_hs.xsl 26 Dec 2001 00:03:36 -0000 1.9
--- gen_class_hs.xsl 27 Feb 2002 22:25:46 -0000 1.10
***************
*** 211,215 ****
select="./Model:StructuralFeature.multiplicity/XMI.field[position()=4]"/>
! <!-- xsl:if test='$lower=0 and $upper=1' -->
<!--<AttributeType> <attribute_name> ()
--- 211,216 ----
select="./Model:StructuralFeature.multiplicity/XMI.field[position()=4]"/>
! <xsl:choose>
! <xsl:when test='$upper=1'>
<!--<AttributeType> <attribute_name> ()
***************
*** 217,225 ****
-->
! <xsl:text> </xsl:text>
! <xsl:value-of select="$CORBA_type"/>
! <xsl:text> fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>; </xsl:text>
</xsl:template>
--- 218,258 ----
-->
! <xsl:text> </xsl:text>
! <xsl:value-of select="$CORBA_type"/>
! <xsl:text> fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>; </xsl:text>
!
! </xsl:when>
!
! <xsl:otherwise>
!
! <!--<AttributeType><CollectionKind> <attribute_name> ()
! raises (Reflective::MofError);
! -->
!
! <xsl:text> </xsl:text>
! <xsl:choose>
! <xsl:when test='$is_ordered = "false"'>
! <xsl:text>vector<</xsl:text>
! </xsl:when>
! <xsl:when test='$is_ordered = "true"'>
! <xsl:text>list<</xsl:text>
! </xsl:when>
! </xsl:choose>
! <xsl:choose>
! <xsl:when test='$CORBA_type = "char*"'>
! <xsl:text>string</xsl:text>
! </xsl:when>
! <xsl:otherwise>
! <xsl:value-of select="$CORBA_type"/>
! </xsl:otherwise>
! </xsl:choose>
! <xsl:text>> fc_</xsl:text>
! <xsl:value-of select="$attr_name"/>
! <xsl:text>; </xsl:text>
!
! </xsl:otherwise>
! </xsl:choose>
</xsl:template>
***************
*** 1158,1167 ****
<xsl:text>_impl.h</xsl:text>
</xsl:variable>
-
- <xsl:if test='@name = "Object"'>
- <xsl:text>class_filename </xsl:text>
- <xsl:value-of select="$class_filename"/>
- <xsl:text> </xsl:text>
- </xsl:if>
<xalan:write select="$class_filename">
--- 1191,1194 ----
|