mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 08:53:20 +00:00
ICU-7373 update, better enum handling
X-SVN-Rev: 28935
This commit is contained in:
parent
b0cdff9b4b
commit
be51ebe688
5 changed files with 74 additions and 22 deletions
|
@ -64,6 +64,7 @@
|
|||
<pathelement location="${build.dir}"/>
|
||||
<pathelement path="${java.class.path}/"/>
|
||||
<pathelement location="${lib.dir}/xalan.jar"/>
|
||||
<fileset dir="${lib.dir}"/>
|
||||
<pathelement location="${lib.dir}/xercesImpl.jar"/>
|
||||
<pathelement path="."/>
|
||||
</classpath>
|
||||
|
|
|
@ -608,7 +608,7 @@ public class StableAPI {
|
|||
|
||||
Element toXml(Document doc){
|
||||
Element ele = doc.createElement("func");
|
||||
ele.setAttribute("prototype", prototype);
|
||||
ele.setAttribute("prototype", formatCode(prototype));
|
||||
// ele.setAttribute("leftRefId", leftRefId);
|
||||
|
||||
ele.setAttribute("leftStatus", leftStatus);
|
||||
|
@ -627,6 +627,7 @@ public class StableAPI {
|
|||
ele.setAttribute("file", f);
|
||||
return ele;
|
||||
}
|
||||
|
||||
|
||||
public int compareTo(JoinedFunction o) {
|
||||
return comparableName.compareTo(o.comparableName);
|
||||
|
@ -871,5 +872,64 @@ public class StableAPI {
|
|||
Document doc = getDocumentBuilder().parse(inputSource);
|
||||
return doc;
|
||||
}
|
||||
static boolean tried = false;
|
||||
static Formatter aFormatter = null;
|
||||
|
||||
public interface Formatter {
|
||||
public String formatCode(String s);
|
||||
}
|
||||
|
||||
|
||||
public static String format_keywords[] = {
|
||||
"enum","#define","static"
|
||||
};
|
||||
|
||||
/**
|
||||
* Attempt to use a pretty formatter
|
||||
* @param prototype2
|
||||
* @return
|
||||
*/
|
||||
public static String formatCode(String prototype2) {
|
||||
if(!tried) {
|
||||
String theFormatter = StableAPI.class.getPackage().getName()+".CodeFormatter";
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<Formatter> formatClass = (Class<Formatter>) Class.forName(theFormatter);
|
||||
aFormatter = (Formatter) formatClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Note: Couldn't load " + theFormatter);
|
||||
aFormatter = new Formatter() {
|
||||
|
||||
public String formatCode(String s) {
|
||||
String str = HTMLSafe(s.trim());
|
||||
for(String keyword : format_keywords) {
|
||||
if(str.startsWith(keyword)) {
|
||||
str = str.replaceFirst(keyword, "<tt>"+keyword+"</tt>");
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
tried = true;
|
||||
}
|
||||
if(aFormatter != null) {
|
||||
return aFormatter.formatCode(prototype2);
|
||||
} else {
|
||||
return HTMLSafe(prototype2);
|
||||
}
|
||||
}
|
||||
|
||||
public static String HTMLSafe(String s) {
|
||||
if(s==null) return null;
|
||||
|
||||
return
|
||||
s.replaceAll("&","&")
|
||||
.replaceAll("<","<")
|
||||
.replaceAll(">",">")
|
||||
.replaceAll("\"",""");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -50,12 +50,9 @@
|
|||
<xsl:variable name="enum_node_name">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(name/text(), '@')">
|
||||
(anonymous)
|
||||
</xsl:when>
|
||||
(anonymous)</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="name/text()" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="name/text()" /></xsl:otherwise></xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- enum object -->
|
||||
|
@ -68,7 +65,7 @@
|
|||
<xsl:attribute name="status"><xsl:value-of select="$enum_status" /></xsl:attribute>
|
||||
<xsl:attribute name="version"><xsl:value-of select="$enum_status" /></xsl:attribute>
|
||||
<xsl:attribute name="prototype">enum <xsl:value-of
|
||||
select="$enum_node_name" /></xsl:attribute>
|
||||
select="$enum_node_name" /> {}</xsl:attribute>
|
||||
<xsl:copy-of select="location/@file" />
|
||||
</cppfunc>
|
||||
</xsl:if>
|
||||
|
|
|
@ -38,16 +38,10 @@
|
|||
<xsl:for-each select="$enum_node">
|
||||
|
||||
<!-- use a name, else '(anonymous)' -->
|
||||
<xsl:variable name="enum_node_name">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(name/text(), '@')">
|
||||
(anonymous)
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="name/text()" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="enum_node_name"><xsl:choose>
|
||||
<xsl:when test="contains(name/text(), '@')">(anonymous)</xsl:when>
|
||||
<xsl:otherwise><xsl:value-of select="name/text()" /></xsl:otherwise>
|
||||
</xsl:choose></xsl:variable>
|
||||
|
||||
<xsl:variable name="enum_status" select="detaileddescription/para/xrefsect/xreftitle/text()"/>
|
||||
<xsl:variable name="enum_version" select="detaileddescription/para/xrefsect/xrefdescription/para/text()"/>
|
||||
|
@ -59,9 +53,8 @@
|
|||
<xsl:attribute name="version"><xsl:value-of
|
||||
select="$enum_version" /></xsl:attribute>
|
||||
<xsl:attribute name="prototype">enum
|
||||
<xsl:value-of select="$compoundname"/>::
|
||||
<xsl:value-of
|
||||
select="$enum_node_name" /></xsl:attribute>
|
||||
<xsl:value-of select="$compoundname"/>::<xsl:value-of
|
||||
select="$enum_node_name" /> {}</xsl:attribute>
|
||||
<xsl:copy-of select="location/@file" />
|
||||
</cppfunc>
|
||||
|
||||
|
@ -97,6 +90,7 @@
|
|||
</xsl:attribute>
|
||||
<xsl:attribute name="prototype">enum
|
||||
<xsl:value-of select="$compoundname"/>::<xsl:value-of
|
||||
select="$enum_node_name" />::<xsl:value-of
|
||||
select="name/text()" /></xsl:attribute>
|
||||
<xsl:attribute name="file"><xsl:value-of select="$enum_node_file" /></xsl:attribute>
|
||||
</cppfunc>
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
-->
|
||||
</xsl:attribute>
|
||||
<td class='file'> <xsl:value-of select="@file" /> </td>
|
||||
<td class='proto'> <xsl:value-of select="@prototype" /> </td>
|
||||
<td class='proto'> <xsl:value-of disable-output-escaping="yes" select="@prototype" /> </td>
|
||||
<td>
|
||||
<xsl:attribute name="class">
|
||||
<xsl:if test ="@leftStatus = 'Stable'">
|
||||
|
@ -206,7 +206,7 @@
|
|||
-->
|
||||
</xsl:attribute>
|
||||
<td class='file'> <xsl:value-of select="@file" /> </td>
|
||||
<td class='proto'> <xsl:value-of select="@prototype" /> </td>
|
||||
<td class='proto'> <xsl:value-of disable-output-escaping="yes" select="@prototype" /> </td>
|
||||
<td>
|
||||
<xsl:attribute name="class">
|
||||
<xsl:if test ="@leftStatus = 'Stable'">
|
||||
|
|
Loading…
Add table
Reference in a new issue