<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#copied {background-color:#ccccff;}
tr.alt #copied {background-color:#bbbbf7;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="5">Commit in <b><tt>asxsd/trunk/src</tt></b></td></tr>
<tr><td><tt>main/java/uk/co/badgersinfoil/asxsd/<a href="#file1">MappingRegistryFactory.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td></td><td nowrap="nowrap" align="center">171 -> 172</td></tr>
<tr class="alt"><td><tt> /<a href="#file2">MarshalBuilder.java</a></tt> </td><td></td><td align="right" id="added">+9</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">171 -> 172</td></tr>
<tr><td><tt>main/java/uk/co/badgersinfoil/asxsd/components/<a href="#file3">AbstractSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+17</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">171 -> 172</td></tr>
<tr class="alt"><td><tt> /<a href="#file4"><span id="added">ListComponent.java</span></a></tt> </td><td></td><td align="right" id="added">+62</td><td></td><td nowrap="nowrap" align="right">added 172</td></tr>
<tr><td><tt>test/java/uk/co/badgersinfoil/asxsd/schemas/<a href="#file5"><span id="added">ListTest.java</span></a></tt> </td><td></td><td align="right" id="added">+12</td><td></td><td nowrap="nowrap" align="right">added 172</td></tr>
<tr class="alt"><td><tt>test/resources/xsd/<a href="#file6"><span id="added">ListTest.xsd</span></a></tt> </td><td></td><td align="right" id="added">+20</td><td></td><td nowrap="nowrap" align="right">added 172</td></tr>
<tr><td></td><td></td><td align="right" id="added">+122</td><td align="right" id="removed">-3</td><td></td></tr>
</table>
<small id="info">3 added + 3 modified, total 6 files</small><br />
<pre class="comment">
add support for <list>
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>MappingRegistryFactory.java</b></big> <small id="info">171 -> 172</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingRegistryFactory.java        2007-10-14 23:02:12 UTC (rev 171)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingRegistryFactory.java        2007-10-15 22:23:17 UTC (rev 172)
@@ -18,6 +18,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.components.ElementDeclarationReferenceComponent;
import uk.co.badgersinfoil.asxsd.components.FloatSimpleTypeComponent;
import uk.co.badgersinfoil.asxsd.components.IntSimpleTypeComponent;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.components.ListComponent;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.components.ModelGroupParticleComponent;
import uk.co.badgersinfoil.asxsd.components.MultiplyOccuringParticleComponent;
import uk.co.badgersinfoil.asxsd.components.OptionallyOccuringParticleComponent;
</pre><pre class="diff"><small id="info">@@ -47,6 +48,7 @@
</small></pre><pre class="diff" id="context">                 reg.register(new SequenceMappingComponent());
                // must come before any other simpleTypes
                reg.register(new SimpleContentComponent());
</pre><pre class="diff" id="added">+                reg.register(new ListComponent());
</pre><pre class="diff" id="context">                 reg.register(new StringSimpleTypeComponent("string", "http://www.w3.org/2001/XMLSchema"));
                // too big for Flash's Number type, so treat as a String
                reg.register(new StringSimpleTypeComponent("long", "http://www.w3.org/2001/XMLSchema"));
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>MarshalBuilder.java</b></big> <small id="info">171 -> 172</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MarshalBuilder.java        2007-10-14 23:02:12 UTC (rev 171)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MarshalBuilder.java        2007-10-15 22:23:17 UTC (rev 172)
@@ -10,6 +10,7 @@
</small></pre><pre class="diff" id="context"> import java.util.Map;
import org.eclipse.xsd.XSDComplexTypeDefinition;
import org.eclipse.xsd.XSDElementDeclaration;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDNamedComponent;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDSimpleTypeDefinition;
import org.eclipse.xsd.XSDTypeDefinition;
</pre><pre class="diff"><small id="info">@@ -79,7 +80,14 @@
</small></pre><pre class="diff" id="context">         }
        public String methodNameFor(XSDTypeDefinition typeDef) {
</pre><pre class="diff" id="removed">-                return "marshal" + StringUtils.sanitize(typeDef.getName());
</pre><pre class="diff" id="added">+                String stub;
+                if (XSDUtils.isAnonymous(typeDef)) {
+                        XSDNamedComponent container = (XSDNamedComponent)typeDef.getContainer();
+                        stub = container.getName();
+                } else {
+                        stub = typeDef.getName();
+                }
+                return "unmarshal" + StringUtils.sanitize(stub);
</pre><pre class="diff" id="context">         }
        public String methodNameFor(XSDElementDeclaration elementDecl) {
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>AbstractSimpleTypeComponent.java</b></big> <small id="info">171 -> 172</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractSimpleTypeComponent.java        2007-10-14 23:02:12 UTC (rev 171)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractSimpleTypeComponent.java        2007-10-15 22:23:17 UTC (rev 172)
@@ -5,6 +5,7 @@
</small></pre><pre class="diff" id="context"> package uk.co.badgersinfoil.asxsd.components;
import org.eclipse.xsd.XSDConcreteComponent;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDNamedComponent;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDSimpleTypeDefinition;
import uk.co.badgersinfoil.asxsd.BasicMappingFunction;
import uk.co.badgersinfoil.asxsd.CodegenContext;
</pre><pre class="diff"><small id="info">@@ -14,6 +15,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.StringUtils;
import uk.co.badgersinfoil.asxsd.TypeDescriptor;
import uk.co.badgersinfoil.asxsd.UnmarshalBuilder;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.XSDUtils;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASArg;
import uk.co.badgersinfoil.metaas.dom.ASClassType;
import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
</pre><pre class="diff"><small id="info">@@ -61,7 +63,7 @@
</small></pre><pre class="diff" id="context">                         UnmarshalBuilder builder = context.getUnmarshalBuilder();
                        ASCompilationUnit unit = builder.getClassForNamespace(simpleType.getTargetNamespace());
                        ASClassType clazz = (ASClassType)unit.getType();
</pre><pre class="diff" id="removed">-                        String methodName = "unmarshal" + StringUtils.sanitize(simpleType.getName());
</pre><pre class="diff" id="added">+                        String methodName = unmarshalMethodNameFor(simpleType);
</pre><pre class="diff" id="context">                         String qname;
                        if (unit.getPackageName() != null) {
                                qname = unit.getPackageName()+"."+clazz.getName()+"."+methodName;
</pre><pre class="diff"><small id="info">@@ -86,6 +88,17 @@
</small></pre><pre class="diff" id="context">                 throw new IllegalArgumentException(getClass().getName() + " does not support role "+role);
        }
</pre><pre class="diff" id="added">+        private String unmarshalMethodNameFor(XSDSimpleTypeDefinition simpleType) {
+                String stub;
+                if (XSDUtils.isAnonymous(simpleType)) {
+                        XSDNamedComponent container = (XSDNamedComponent)simpleType.getContainer();
+                        stub = container.getName();
+                } else {
+                        stub = simpleType.getName();
+                }
+                return "unmarshal" + StringUtils.sanitize(stub);
+        }
+
</pre><pre class="diff" id="context">         public ASMethod createFunction(CodegenContext context,
         XSDConcreteComponent component)
        {
</pre><pre class="diff"><small id="info">@@ -96,13 +109,14 @@
</small></pre><pre class="diff" id="context">                         ASCompilationUnit unit = builder.getClassForNamespace(simpleType.getTargetNamespace());
                        ASClassType clazz = (ASClassType)unit.getType();
                        TypeDescriptor typeDesc = context.getTypeDescriptor(simpleType);
</pre><pre class="diff" id="removed">-                        String methodName = "unmarshal" + StringUtils.sanitize(simpleType.getName());
</pre><pre class="diff" id="added">+                        String methodName = unmarshalMethodNameFor(simpleType);
</pre><pre class="diff" id="context">                         ASMethod meth = clazz.newMethod(methodName, Visibility.PUBLIC, typeDesc.getTypeName());
                        ASArg arg = meth.addParam("thisValue", "String");
                        String doc = "a value of type "+simpleType.getURI();
                        arg.setDescription(doc);
                        meth.setStatic(true);
                        context.pushAttrScope();
</pre><pre class="diff" id="added">+                        UnmarshalBuilder.setCurrentSourceExpr(context, arg.getName());
</pre><pre class="diff" id="context">                         context.setCurrentMethodCode(meth);
                        context.generateCode(simpleType);
                        context.popAttrScope();
</pre><pre class="diff"><small id="info">@@ -118,6 +132,7 @@
</small></pre><pre class="diff" id="context">                         builder.buildMethodParams(meth, simpleType);
                        meth.setStatic(true);
                        context.pushAttrScope();
</pre><pre class="diff" id="added">+                        MarshalBuilder.setCurrentSourceExpr(context, "thisValue");
</pre><pre class="diff" id="context">                         context.setCurrentMethodCode(meth);
                        context.generateCode(simpleType);
                        context.popAttrScope();
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader" id="added"><big><b>ListComponent.java</b></big> <small id="info">added at 172</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ListComponent.java         (rev 0)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ListComponent.java        2007-10-15 22:23:17 UTC (rev 172)
@@ -0,0 +1,62 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.asxsd.components;
+
+import org.eclipse.xsd.XSDConcreteComponent;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
+import org.eclipse.xsd.XSDVariety;
+import uk.co.badgersinfoil.asxsd.CodegenContext;
+import uk.co.badgersinfoil.asxsd.CodegenRole;
+import uk.co.badgersinfoil.asxsd.MappingFunction;
+import uk.co.badgersinfoil.asxsd.MarshalBuilder;
+import uk.co.badgersinfoil.asxsd.TypeDescriptor;
+import uk.co.badgersinfoil.asxsd.UnmarshalBuilder;
+import uk.co.badgersinfoil.metaas.dom.ASIfStatement;
+import uk.co.badgersinfoil.metaas.dom.StatementContainer;
+
+public class ListComponent extends AbstractSimpleTypeComponent {
+
+        public TypeDescriptor getTypeDescriptorFor(CodegenContext context,
+         XSDSimpleTypeDefinition listType)
+        {
+                XSDSimpleTypeDefinition itemType = listType.getItemTypeDefinition();
+                TypeDescriptor itemTypeDesc = context.getTypeDescriptor(itemType);
+                String docs = "Items of type "+itemTypeDesc.getTypeName()+" ("+itemType.getURI()+")";
+                return new TypeDescriptor("Array", true, docs, listType);
+        }
+        
+        public void generateCode(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                XSDSimpleTypeDefinition listType = (XSDSimpleTypeDefinition)component;
+                XSDSimpleTypeDefinition itemType = listType.getItemTypeDefinition();
+                CodegenRole role = context.getCurrentRole();
+                if (role == CodegenRole.UNMARSHAL) {
+                        StatementContainer block = context.getCurrentMethodCode();
+                        String srcExpr = UnmarshalBuilder.getCurrentSourceExpr(context);
+                        block.addStmt("var _tmp = new Array()");
+                        StatementContainer loop = block.newForEachIn("var listItem", srcExpr+".split(\" \")");
+                        MappingFunction fn = context.functionFor(itemType);
+                        String converted = fn.appliedTo("listItem");
+                        loop.addStmt("_tmp.push("+converted+")");
+                        block.newReturn("_tmp");
+                } else if (role == CodegenRole.MARSHAL) {
+                        StatementContainer block = context.getCurrentMethodCode();
+                        String srcExpr = MarshalBuilder.getCurrentSourceExpr(context);
+                        block.addStmt("var _tmp = null");
+                        StatementContainer loop = block.newForEachIn("var listItem", srcExpr);
+                        MappingFunction fn = context.functionFor(itemType);
+                        String converted = fn.appliedTo("listItem");
+                        ASIfStatement ifFirst = loop.newIf("_tmp == null");
+                        ifFirst.addStmt("_tmp = " + converted);
+                        ifFirst.getElse().addStmt("_tmp += \" \" + "+converted);
+                        block.newReturn("_tmp");
+                } else {
+                        super.generateCode(context, component);
+                }
+        }
+
+
+
+        public boolean willAcceptType(XSDSimpleTypeDefinition simpleType) {
+                return simpleType.getVariety() == XSDVariety.LIST_LITERAL;
+        }
+}
</pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas</span><br />
<div class="fileheader" id="added"><big><b>ListTest.java</b></big> <small id="info">added at 172</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/ListTest.java         (rev 0)
+++ trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/ListTest.java        2007-10-15 22:23:17 UTC (rev 172)
@@ -0,0 +1,12 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.asxsd.schemas;
+
+import uk.co.badgersinfoil.metaas.dom.ASClassType;
+import uk.co.badgersinfoil.metaas.dom.ASField;
+
+public class ListTest extends SchemaTestCase {
+        public void testClassName() {
+                ASClassType clazz = getTestASClass();
+                ASField prop = clazz.getField("a");
+                assertEquals("Array", prop.getType());
+        }
+}
</pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/test/resources/xsd</span><br />
<div class="fileheader" id="added"><big><b>ListTest.xsd</b></big> <small id="info">added at 172</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/resources/xsd/ListTest.xsd         (rev 0)
+++ trunk/src/test/resources/xsd/ListTest.xsd        2007-10-15 22:23:17 UTC (rev 172)
@@ -0,0 +1,20 @@
</small></pre><pre class="diff" id="added">+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ targetNamespace="http://example.org/test"
+ xmlns:t="http://example.org/test">
+
+ <simpleType name="TestList">
+ <list itemType="int"/>
+ </simpleType>
+
+ <complexType name="Test">
+ <sequence>
+ <element name="a" type="t:TestList"/>
+ </sequence>
+ <attribute name="b">
+ <simpleType>
+ <list itemType="string"/>
+ </simpleType>
+ </attribute>
+ </complexType>
+</schema>
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.12</small></center>
</body></html>