<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">BaseCodegenContext.java</a></tt> </td><td></td><td align="right" id="added">+66</td><td align="right" id="removed">-18</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file2">CodegenContext.java</a></tt> </td><td></td><td align="right" id="added">+15</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file3">CodegenRole.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td></td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file4">Main.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file5">MappingCodeGenerator.java</a></tt> </td><td></td><td align="right" id="added">+5</td><td align="right" id="removed">-3</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file6">MappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+5</td><td></td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file7">MarshalBuilder.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file8">TypeBuilder.java</a></tt> </td><td></td><td align="right" id="added">+4</td><td align="right" id="removed">-9</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file9">TypeDescriptor.java</a></tt> </td><td></td><td align="right" id="added">+29</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file10">UnmarshalBuilder.java</a></tt> </td><td></td><td align="right" id="added">+6</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt>main/java/uk/co/badgersinfoil/asxsd/components/<a href="#file11">AbstractMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+28</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file12">AbstractParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+19</td><td></td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file13">ArrayElementDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+8</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file14">ArrayTypeDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file15">AttributeDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+8</td><td></td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file16">BooleanSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file17">ChoiceMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+104</td><td align="right" id="removed">-10</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file18">ComplexTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+22</td><td align="right" id="removed">-5</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file19">DateTimeSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file20">ElementDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+37</td><td align="right" id="removed">-6</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file21">ElementDeclarationReferenceComponent.java</a></tt> </td><td></td><td align="right" id="added">+6</td><td></td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file22">FloatSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file23">IntSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file24">ModelGroupParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+6</td><td></td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file25">MultiplyOccuringParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+17</td><td align="right" id="removed">-13</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file26">OptionallyOccuringParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file27">SequenceMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+3</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file28">SinglyOccuringParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt> /<a href="#file29">StringSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt> /<a href="#file30">UnionSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr><td><tt>test/java/uk/co/badgersinfoil/asxsd/<a href="#file31">BaseCodegenContextTest.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt>test/java/uk/co/badgersinfoil/asxsd/schemas/<a href="#file32"><span id="added">OptionalChoiceInSequenceTest.java</span></a></tt> </td><td></td><td align="right" id="added">+20</td><td></td><td nowrap="nowrap" align="right">added 159</td></tr>
<tr><td><tt> /<a href="#file33">SchemaTestCase.java</a></tt> </td><td></td><td align="right" id="added">+38</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">158 -> 159</td></tr>
<tr class="alt"><td><tt>test/resources/xsd/<a href="#file34"><span id="added">OptionalChoiceInSequenceTest.xsd</span></a></tt> </td><td></td><td align="right" id="added">+13</td><td></td><td nowrap="nowrap" align="right">added 159</td></tr>
<tr><td></td><td></td><td align="right" id="added">+474</td><td align="right" id="removed">-94</td><td></td></tr>
</table>
<small id="info">2 added + 32 modified, total 34 files</small><br />
<div class="tasklist"><ul>
<li><a href="#task1">TODO: ensure name is unique within this context</a></li>
<li><a href="#task2">TODO: just handle XSDNamedComponent in superclass?</a></li>
<li><a href="#task3">TODO: create the descriptor, but don't create the</a></li>
</ul></div>
<pre class="comment">
Generalise unmarshaling prediction mechanism.
Create types to hold <choice> appearing in <sequence>.
</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>BaseCodegenContext.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/BaseCodegenContext.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/BaseCodegenContext.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -8,13 +8,14 @@
</small></pre><pre class="diff" id="context"> import java.util.Map;
import java.util.Stack;
import org.eclipse.xsd.XSDConcreteComponent;
</pre><pre class="diff" id="removed">-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDNamedComponent;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.ActionScriptFactory;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.ActionScriptProject;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASExpression;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.StatementContainer;
public class BaseCodegenContext implements CodegenContext {
        private MappingRegistry registry;
</pre><pre class="diff" id="added">+        private ActionScriptFactory factory;
</pre><pre class="diff" id="context">         private ActionScriptProject project;
        private UnmarshalBuilder unmarshalBuilder;
        private MarshalBuilder marshalBuilder;
</pre><pre class="diff"><small id="info">@@ -23,26 +24,43 @@
</small></pre><pre class="diff" id="context">         private TypeBuilder typeBuilder;
        private Stack scopeStack = new Stack();
        private MappingFunctionStore functionStore = new MappingFunctionStore();
</pre><pre class="diff" id="added">+        private TypeStore typeStore = new TypeStore();
</pre><pre class="diff" id="context">         private static final String KEY_ROLE = BaseCodegenContext.class.getName() + ".role";
        private static final String KEY_CODE = BaseCodegenContext.class.getName() + ".code";
</pre><pre class="diff" id="removed">-        public BaseCodegenContext(MappingRegistry registry, ActionScriptProject project) {
</pre><pre class="diff" id="added">+        public BaseCodegenContext(MappingRegistry registry, ActionScript<span id="addedchars">Factory factory, ActionScript</span>Project project) {
</pre><pre class="diff" id="context">                 this.registry = registry;
</pre><pre class="diff" id="added">+                this.factory = factory;
</pre><pre class="diff" id="context">                 this.project = project;
        }
</pre><pre class="diff" id="removed">-//        public ActionScriptProject getProject() {
-//                return project;
-//        }
</pre><pre class="diff" id="added">+        public ActionScriptProject getProject() {
+                return project;
+        }
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="added">+        public ActionScriptFactory getFactory() {
+                return factory;
+        }
+
</pre><pre class="diff" id="context">         public MappingRegistry getRegistry() {
                return registry;
        }
</pre><pre class="diff" id="removed">-        
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context">         public TypeDescriptor getTypeDescriptor(XSDConcreteComponent component) {
                MappingComponent mapComp = componentFor(component);
</pre><pre class="diff" id="removed">-                return mapComp.getTypeDescriptor(this, component);
</pre><pre class="diff" id="added">+                pushAttrScope();
+                setCurrentRole(CodegenRole.TYPE);
+                TypeDescriptor result = mapComp.getTypeDescriptor(this, component);
+                popAttrScope();
+                return result;
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="added">+        
+        public String createTypeNameFor(XSDConcreteComponent component) {
+                MappingComponent mapComp = componentFor(component);
+                String name = mapComp.createTypeNameFor(this, component);
<a name="task1" />+                // <span class="task">TODO</span>: ensure name is unique within this context
+                return name;
+        }
</pre><pre class="diff" id="context">
        public CodegenRole getCurrentRole() {
                return (CodegenRole)getAttribute(KEY_ROLE);
</pre><pre class="diff"><small id="info">@@ -63,26 +81,44 @@
</small></pre><pre class="diff" id="context">         }
        public MappingFunction getOrCreateFunction(XSDConcreteComponent component) {
</pre><pre class="diff" id="removed">-                XSDNamedComponent namedComponent = (XSDNamedComponent)component;
</pre><pre class="diff" id="context">                 CodegenRole role = getCurrentRole();
</pre><pre class="diff" id="removed">-                MappingFunction convert = functionStore.get(role, <span id="removedchars">namedC</span>omponent);
</pre><pre class="diff" id="added">+                MappingFunction convert = functionStore.get(role, <span id="addedchars">c</span>omponent);
</pre><pre class="diff" id="context">                 if (convert == null) {
                        pushAttrScope();
</pre><pre class="diff" id="removed">-                        convert = createFunction(<span id="removedchars">namedC</span>omponent);
</pre><pre class="diff" id="added">+                        convert = createFunction(<span id="addedchars">c</span>omponent);
</pre><pre class="diff" id="context">                         if (convert.getImplementation() == null) {
</pre><pre class="diff" id="removed">-                                throw new RuntimeException("null fn for "+<span id="removedchars">namedC</span>omponent);
</pre><pre class="diff" id="added">+                                throw new RuntimeException("null fn for "+<span id="addedchars">c</span>omponent);
</pre><pre class="diff" id="context">                         }
</pre><pre class="diff" id="removed">-                        functionStore.put(role, <span id="removedchars">namedC</span>omponent, convert);
</pre><pre class="diff" id="added">+                        functionStore.put(role, <span id="addedchars">c</span>omponent, convert);
</pre><pre class="diff" id="context">                         // now that we've got a ref to the method in the map,
                        // its safe to generate the method body without the
                        // potential for infinite recursion,
                        setCurrentMethodCode(convert.getImplementation());
</pre><pre class="diff" id="removed">-                        generateCode(<span id="removedchars">namedC</span>omponent);
</pre><pre class="diff" id="added">+                        generateCode(<span id="addedchars">c</span>omponent);
</pre><pre class="diff" id="context">                         popAttrScope();
                }
                return convert;
        }
</pre><pre class="diff" id="added">+        public TypeDescriptor getOrCreateType(XSDConcreteComponent component) {
+                CodegenRole role = getCurrentRole();
+                TypeDescriptor typeDesc = typeStore.get(role, component);
+                if (typeDesc == null) {
+                        pushAttrScope();
+                        typeDesc = createType(component);
+                        typeStore.put(role, component, typeDesc);
+                        TypeBuilder.setCurrentTypeCompilationUnit(this, typeDesc.getImplementation());
+                        generateCode(component);
+                        popAttrScope();
+                }
+                return typeDesc;
+        }
+
+        private TypeDescriptor createType(XSDConcreteComponent component) {
+                MappingComponent mapComp = componentFor(component);
+                return mapComp.createType(this, component);
+        }
+
</pre><pre class="diff" id="context">         public StatementContainer getCurrentMethodCode() {
                return (StatementContainer)getAttribute(KEY_CODE);
        }
</pre><pre class="diff"><small id="info">@@ -95,6 +131,11 @@
</small></pre><pre class="diff" id="context">                 return mapComp.createFunction(this, component);
        }
</pre><pre class="diff" id="added">+        public ASExpression createExpression(XSDConcreteComponent component) {
+                MappingComponent mapComp = componentFor(component);
+                return mapComp.createExpression(this, component);
+        }
+
</pre><pre class="diff" id="context">         private MappingComponent componentFor(XSDConcreteComponent component) {
                if (component == null) {
                        throw new IllegalArgumentException("component must not be null");
</pre><pre class="diff"><small id="info">@@ -124,11 +165,13 @@
</small></pre><pre class="diff" id="context">         }
        public String variableNameFor(XSDConcreteComponent component) {
</pre><pre class="diff" id="removed">-                if (component instanceof XSDElementDeclaration) {
-                        component = ((XSDElementDeclaration)component).getResolvedElementDeclaration();
-                }
-                return varNameGen.fieldName(component);
</pre><pre class="diff" id="added">+                MappingComponent mapComp = componentFor(component);
+                return mapComp.variableNameFor(this, component);
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="added">+        
+        public String toVariableName(String baseName) {
+                return varNameGen.fieldName(baseName);
+        }
</pre><pre class="diff" id="context">
        public void setAttribute(String key, Object value) {
                if (attrs.containsKey(key)) {
</pre><pre class="diff"><small id="info">@@ -163,4 +206,9 @@
</small></pre><pre class="diff" id="context">         public MappingFunctionStore getMappingFunctionStore() {
                return functionStore;
        }
</pre><pre class="diff" id="added">+
+        /** @deprecated */
+        public TypeStore getTypeStore() {
+                return typeStore;
+        }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></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>CodegenContext.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenContext.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenContext.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -1,16 +1,23 @@
</small></pre><pre class="diff" id="context"> package uk.co.badgersinfoil.asxsd;
import org.eclipse.xsd.XSDConcreteComponent;
</pre><pre class="diff" id="removed">-import org.eclipse.xsd.XSDElementDeclaration;
-import uk.co.badgersinfoil.metaas.dom.ASMethod;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.ActionScriptFactory;
+import uk.co.badgersinfoil.metaas.ActionScriptProject;
+import uk.co.badgersinfoil.metaas.dom.ASExpression;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.StatementContainer;
public interface CodegenContext {
</pre><pre class="diff" id="added">+        
+        public ActionScriptProject getProject();
</pre><pre class="diff" id="context">
        public MappingRegistry getRegistry();
</pre><pre class="diff" id="added">+        public ActionScriptFactory getFactory();
+
</pre><pre class="diff" id="context">         public TypeDescriptor getTypeDescriptor(XSDConcreteComponent component);
</pre><pre class="diff" id="added">+        public String createTypeNameFor(XSDConcreteComponent component);
+
</pre><pre class="diff" id="context">         public CodegenRole getCurrentRole();
        public void setCurrentRole(CodegenRole role);
</pre><pre class="diff"><small id="info">@@ -22,6 +29,8 @@
</small></pre><pre class="diff" id="context">
        public MappingFunction getOrCreateFunction(XSDConcreteComponent component);
</pre><pre class="diff" id="added">+        public TypeDescriptor getOrCreateType(XSDConcreteComponent component);
+
</pre><pre class="diff" id="context">         public StatementContainer getCurrentMethodCode();
        public void setCurrentMethodCode(StatementContainer code);
</pre><pre class="diff"><small id="info">@@ -46,4 +55,8 @@
</small></pre><pre class="diff" id="context">         public void popAttrScope();
        public MappingFunctionStore getMappingFunctionStore();
</pre><pre class="diff" id="added">+
+        public ASExpression createExpression(XSDConcreteComponent component);
+        
+        public String toVariableName(String baseName);
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>CodegenRole.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenRole.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenRole.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -14,6 +14,7 @@
</small></pre><pre class="diff" id="context">         public static final CodegenRole UNMARSHAL = new CodegenRole("UNMARSHAL");
        public static final CodegenRole MARSHAL = new CodegenRole("MARSHAL");
        public static final CodegenRole TYPE = new CodegenRole("TYPE");
</pre><pre class="diff" id="added">+        public static final CodegenRole DETECT = new CodegenRole("DETECT");
</pre><pre class="diff" id="context">
        public String toString() { return name; }
}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>Main.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/Main.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/Main.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -52,7 +52,7 @@
</small></pre><pre class="diff" id="context">                 XSDSchema mainSchema = loadSchema(filename);
                ActionScriptFactory fact = new ActionScriptFactory();
                ActionScriptProject project = fact.newEmptyASProject(destDir);
</pre><pre class="diff" id="removed">-                MappingCodeGenerator generator = new MappingCodeGenerator(project);
</pre><pre class="diff" id="added">+                MappingCodeGenerator generator = new MappingCodeGenerator(<span id="addedchars">fact, </span>project);
</pre><pre class="diff" id="context">                 generator.processSchema(mainSchema);
                project.performAutoImport();
                project.writeAll();
</pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>MappingCodeGenerator.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingCodeGenerator.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingCodeGenerator.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -12,6 +12,7 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDConcreteComponent;
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDTypeDefinition;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.ActionScriptFactory;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.ActionScriptProject;
</pre><pre class="diff"><small id="info">@@ -22,10 +23,11 @@
</small></pre><pre class="diff" id="context">         private TypeBuilder typeBuilder;
        private CodegenContext context;
</pre><pre class="diff" id="removed">-        public MappingCodeGenerator(ActionScriptProject project) {
-                typeBuilder = new TypeBuilder(project, nameGen);
</pre><pre class="diff" id="added">+        public MappingCodeGenerator(ActionScriptFactory factory, ActionScriptProject project) {
+                MappingRegistry reg = MappingRegistryFactory.createMappingRegistry();
+                BaseCodegenContext ctxt = new BaseCodegenContext(reg, factory, project);
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">-                BaseCodegenContext ctxt = new BaseCodegenContext(MappingRegistryFactory.createMappingRegistry(), project);
</pre><pre class="diff" id="added">+                typeBuilder = new TypeBuilder(ctxt, nameGen);
</pre><pre class="diff" id="context">                 ctxt.setTypeBuilder(typeBuilder);
                unmarshalerBuilder = new UnmarshalBuilder(project, typeBuilder, ctxt);
</pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>MappingComponent.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingComponent.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingComponent.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -5,12 +5,17 @@
</small></pre><pre class="diff" id="context"> package uk.co.badgersinfoil.asxsd;
import org.eclipse.xsd.XSDConcreteComponent;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASExpression;
</pre><pre class="diff" id="context">
public interface MappingComponent {
        public boolean willAccept(XSDConcreteComponent component);
        public TypeDescriptor getTypeDescriptor(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="added">+        public String createTypeNameFor(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="context">         public void generateCode(CodegenContext context, XSDConcreteComponent component);
        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component);
        public MappingFunction createFunction(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="added">+        public ASExpression createExpression(CodegenContext context, XSDConcreteComponent component);
+        public TypeDescriptor createType(CodegenContext context, XSDConcreteComponent component);
+        public String variableNameFor(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file7" /><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">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MarshalBuilder.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MarshalBuilder.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -123,7 +123,7 @@
</small></pre><pre class="diff" id="context">                 throw new IllegalArgumentException(typeDef.getClass().getName());
        }
</pre><pre class="diff" id="removed">-        p<span id="removedchars">rivate</span> ASCompilationUnit getClassForNamespace(String namespace) {
</pre><pre class="diff" id="added">+        p<span id="addedchars">ublic</span> ASCompilationUnit getClassForNamespace(String namespace) {
</pre><pre class="diff" id="context">                 ASCompilationUnit result = (ASCompilationUnit)converterClassesByNamespace.get(namespace);
                if (result == null) {
                        result = createClassForNamespace(namespace);
</pre></div>
<hr /><a name="file8" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>TypeBuilder.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/TypeBuilder.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/TypeBuilder.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -10,7 +10,6 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDElementDeclaration;
import org.eclipse.xsd.XSDParticle;
import org.eclipse.xsd.XSDTypeDefinition;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.metaas.ActionScriptProject;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASClassType;
import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
</pre><pre class="diff"><small id="info">@@ -19,17 +18,13 @@
</small></pre><pre class="diff" id="context">
        private static final String KEY_CURRENT_TYPE_COMPILATION_UNIT = "uk.co.badgersinfoil.asxsd.currentTypeCompilationUnit";
        TypeNameGenerator nameGen;
</pre><pre class="diff" id="removed">-        private ActionScriptProject project;
</pre><pre class="diff" id="context">         private Map representationClassesByQName = new HashMap();
        
        private CodegenContext context;
</pre><pre class="diff" id="removed">-        public TypeBuilder(<span id="removedchars">ActionScriptProject projec</span>t, TypeNameGenerator nameGen) {
</pre><pre class="diff" id="added">+        public TypeBuilder(<span id="addedchars">CodegenContext contex</span>t, TypeNameGenerator nameGen) {
</pre><pre class="diff" id="context">                 this.nameGen = nameGen;
</pre><pre class="diff" id="removed">-                this.project = project;
-                BaseCodegenContext ctxt = new BaseCodegenContext(MappingRegistryFactory.createMappingRegistry(), project);
-                ctxt.setTypeBuilder(this);
-                context = ctxt;
</pre><pre class="diff" id="added">+                this.context = context;
</pre><pre class="diff" id="context">         }
        public String typeNameFor(XSDTypeDefinition typeDef) {
</pre><pre class="diff"><small id="info">@@ -75,7 +70,7 @@
</small></pre><pre class="diff" id="context">                 String name = nameGen.typeName(typeDef);
                ASCompilationUnit result = (ASCompilationUnit)representationClassesByQName.get(name);
                if (result == null) {
</pre><pre class="diff" id="removed">-                        result = project.newClass(name);
</pre><pre class="diff" id="added">+                        result = context.getProject().newClass(name);
</pre><pre class="diff" id="context">                         representationClassesByQName.put(name, result);
                        // only now that we have the class in the Map to we
                        // process it, to prevent infinate loops when processing
</pre><pre class="diff"><small id="info">@@ -92,7 +87,7 @@
</small></pre><pre class="diff" id="context">                 String name = nameGen.getNameFor(elementDecl);
                ASCompilationUnit result = (ASCompilationUnit)representationClassesByQName.get(name);
                if (result == null) {
</pre><pre class="diff" id="removed">-                        result = project.newClass(name);
</pre><pre class="diff" id="added">+                        result = context.getProject().newClass(name);
</pre><pre class="diff" id="context">                         representationClassesByQName.put(name, result);
                        // only now that we have the class in the Map do we
                        // process it, to prevent infinate loops when processing
</pre></div>
<hr /><a name="file9" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>TypeDescriptor.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/TypeDescriptor.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/TypeDescriptor.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -1,14 +1,24 @@
</small></pre><pre class="diff" id="context"> package uk.co.badgersinfoil.asxsd;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDConcreteComponent;
+import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
+
</pre><pre class="diff" id="context"> public class TypeDescriptor {
        private String typeName;
        private boolean array;
        private String documentation;
</pre><pre class="diff" id="removed">-        public TypeDescriptor(String typeName, boolean array, String documentation) {
-                super();
</pre><pre class="diff" id="added">+        private ASCompilationUnit implementation;
+        private XSDConcreteComponent component;
+
+        public TypeDescriptor(String typeName,
+         boolean array,
+         String documentation,
+         XSDConcreteComponent component)
+        {
</pre><pre class="diff" id="context">                 this.typeName = typeName;
                this.array = array;
                this.documentation = documentation;
</pre><pre class="diff" id="added">+                this.component = component;
</pre><pre class="diff" id="context">         }
        public boolean isArray() {
                return array;
</pre><pre class="diff"><small id="info">@@ -28,5 +38,20 @@
</small></pre><pre class="diff" id="context">         public void setTypeName(String typeName) {
                this.typeName = typeName;
        }
</pre><pre class="diff" id="removed">-        
-}
</pre><pre class="diff" id="added">+        public ASCompilationUnit getImplementation() {
+                return implementation;
+        }
+        /**
+         * Returns the schema component for which this object describes the
+         * ActionScript-mapped type.
+         */
+        public XSDConcreteComponent getComponent() {
+                return component;
+        }
+        public void setImplementation(ASCompilationUnit implementation) {
+                this.implementation = implementation;
+        }
+        public boolean hasImplementation() {
+                return implementation != null;
+        }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file10" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>UnmarshalBuilder.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/UnmarshalBuilder.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/UnmarshalBuilder.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -101,7 +101,7 @@
</small></pre><pre class="diff" id="context">                 return new BasicMappingFunction(unit, meth);
        }
</pre><pre class="diff" id="removed">-        p<span id="removedchars">rivate</span> ASCompilationUnit getClassForNamespace(String namespace) {
</pre><pre class="diff" id="added">+        p<span id="addedchars">ublic</span> ASCompilationUnit getClassForNamespace(String namespace) {
</pre><pre class="diff" id="context">                 ASCompilationUnit result = (ASCompilationUnit)converterClassesByNamespace.get(namespace);
                if (result == null) {
                        result = createClassForNamespace(namespace);
</pre><pre class="diff"><small id="info">@@ -122,7 +122,11 @@
</small></pre><pre class="diff" id="context">         }
        public static String getCurrentSourceExpr(CodegenContext context) {
</pre><pre class="diff" id="removed">-                <span id="removedchars">return</span> (String)context.getAttribute(KEY_UNMARSHAL_CURRENT_SOURCE_EXPR);
</pre><pre class="diff" id="added">+                <span id="addedchars">String result =</span> (String)context.getAttribute(KEY_UNMARSHAL_CURRENT_SOURCE_EXPR);
+                if (result == null) {
+                        throw new IllegalStateException("no expression is defined");
+                }
+                return result;
</pre><pre class="diff" id="context">         }
        public static void setCurrentSourceExpr(CodegenContext context, String expr) {
                context.setAttribute(KEY_UNMARSHAL_CURRENT_SOURCE_EXPR, expr);
</pre></div>
<hr /><a name="file11" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>AbstractMappingComponent.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractMappingComponent.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractMappingComponent.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -11,6 +11,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.MappingComponent;
import uk.co.badgersinfoil.asxsd.TypeDescriptor;
import uk.co.badgersinfoil.asxsd.XSDUtils;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASExpression;
</pre><pre class="diff" id="context">
public abstract class AbstractMappingComponent implements MappingComponent {
</pre><pre class="diff"><small id="info">@@ -25,9 +26,16 @@
</small></pre><pre class="diff" id="context">         public TypeDescriptor getTypeDescriptor(CodegenContext context,
         XSDConcreteComponent component)
        {
</pre><pre class="diff" id="removed">-                throw new RuntimeException(getClass().getName()+" does not suppport operation getTypeDescriptor() at "+XSDUtils.path(component));
</pre><pre class="diff" id="added">+                return context.getOrCreateType(component);
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="added">+        public String createTypeNameFor(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                CodegenRole role = context.getCurrentRole();
+                throw new RuntimeException(getClass().getName()+" does not suppport operation createTypeNameFor(role="+role+") at "+XSDUtils.path(component));
+        }
+
</pre><pre class="diff" id="context">         public MappingFunction createFunction(CodegenContext context,
         XSDConcreteComponent component)
        {
</pre><pre class="diff"><small id="info">@@ -35,7 +43,26 @@
</small></pre><pre class="diff" id="context">                 throw new RuntimeException(getClass().getName()+" does not suppport operation createFunction(role="+role+") at "+XSDUtils.path(component));
        }
</pre><pre class="diff" id="added">+        public TypeDescriptor createType(CodegenContext context, XSDConcreteComponent component) {
+                CodegenRole role = context.getCurrentRole();
+                throw new RuntimeException(getClass().getName()+" does not suppport operation createType(role="+role+") at "+XSDUtils.path(component));
+        }
+
+        public ASExpression createExpression(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                CodegenRole role = context.getCurrentRole();
+                throw new RuntimeException(getClass().getName()+" does not suppport operation createExpression(role="+role+") at "+XSDUtils.path(component));
+        }
+
</pre><pre class="diff" id="context">         public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component) {
                return context.getOrCreateFunction(component);
        }
</pre><pre class="diff" id="added">+
+        public String variableNameFor(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                CodegenRole role = context.getCurrentRole();
+                throw new RuntimeException(getClass().getName()+" does not suppport operation variableNameFor(role="+role+") at "+XSDUtils.path(component));
+        }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file12" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>AbstractParticleComponent.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractParticleComponent.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractParticleComponent.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -7,7 +7,9 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDConcreteComponent;
import org.eclipse.xsd.XSDParticle;
import uk.co.badgersinfoil.asxsd.CodegenContext;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.CodegenRole;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.TypeDescriptor;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASExpression;
</pre><pre class="diff" id="context">
public abstract class AbstractParticleComponent extends AbstractMappingComponent {
</pre><pre class="diff"><small id="info">@@ -21,6 +23,12 @@
</small></pre><pre class="diff" id="context">         protected abstract TypeDescriptor getTypeDescriptorFor(CodegenContext context,
         XSDParticle particle);
</pre><pre class="diff" id="added">+        public String createTypeNameFor(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                return context.createTypeNameFor(component.getContainer());
+        }
+
</pre><pre class="diff" id="context">         public boolean willAccept(XSDConcreteComponent component) {
                return component instanceof XSDParticle
                 && willAcceptParticle((XSDParticle)component);
</pre><pre class="diff"><small id="info">@@ -34,4 +42,15 @@
</small></pre><pre class="diff" id="context">         }
        protected abstract void generateCodeFor(CodegenContext context, XSDParticle particle);
</pre><pre class="diff" id="added">+
+        public ASExpression createExpression(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                CodegenRole role = context.getCurrentRole();
+                XSDParticle particle = (XSDParticle)component;
+                if (role == CodegenRole.DETECT) {
+                        return context.createExpression(particle.getContent());
+                }
+                return super.createExpression(context, component);
+        }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file13" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>ArrayElementDeclarationComponent.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayElementDeclarationComponent.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayElementDeclarationComponent.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -9,7 +9,6 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.CodegenContext;
import uk.co.badgersinfoil.asxsd.CodegenRole;
import uk.co.badgersinfoil.asxsd.MappingFunction;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.asxsd.MappingComponent;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.MarshalBuilder;
import uk.co.badgersinfoil.asxsd.TypeBuilder;
import uk.co.badgersinfoil.asxsd.TypeDescriptor;
</pre><pre class="diff"><small id="info">@@ -31,7 +30,7 @@
</small></pre><pre class="diff" id="context">                 XSDElementDeclaration listElement = XSDUtils.getElementIfContainerForList(elementDecl);
                TypeDescriptor elementType = context.getTypeDescriptor(listElement);
                String doc = "Elements of type {@link " + elementType.getTypeName()+"}";
</pre><pre class="diff" id="removed">-                return new TypeDescriptor(ASConstants.TYPE_ARRAY, true, doc);
</pre><pre class="diff" id="added">+                return new TypeDescriptor(ASConstants.TYPE_ARRAY, true, doc<span id="addedchars">, elementDecl</span>);
</pre><pre class="diff" id="context">         }
        public boolean willAccept(XSDConcreteComponent component) {
</pre><pre class="diff"><small id="info">@@ -87,4 +86,11 @@
</small></pre><pre class="diff" id="context">                 }
                throw new IllegalArgumentException(getClass().getName() + " does not support role "+role);
        }
</pre><pre class="diff" id="added">+
+        public String variableNameFor(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                XSDElementDeclaration elementDecl = (XSDElementDeclaration)component;
+                return context.toVariableName(elementDecl.getName());
+        }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file14" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>ArrayTypeDeclarationComponent.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayTypeDeclarationComponent.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayTypeDeclarationComponent.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -11,7 +11,6 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.CodegenContext;
import uk.co.badgersinfoil.asxsd.CodegenRole;
import uk.co.badgersinfoil.asxsd.MappingFunction;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.asxsd.MappingComponent;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.TypeBuilder;
import uk.co.badgersinfoil.asxsd.TypeDescriptor;
import uk.co.badgersinfoil.asxsd.UnmarshalBuilder;
</pre><pre class="diff"><small id="info">@@ -29,7 +28,7 @@
</small></pre><pre class="diff" id="context">                 XSDElementDeclaration listElement = XSDUtils.getElementIfContainerForList(typeDef);
                TypeDescriptor elementType = context.getTypeDescriptor(listElement);
                String doc = "Elements of type {@link " + elementType.getTypeName()+"}";
</pre><pre class="diff" id="removed">-                return new TypeDescriptor(ASConstants.TYPE_ARRAY, true, doc);
</pre><pre class="diff" id="added">+                return new TypeDescriptor(ASConstants.TYPE_ARRAY, true, doc<span id="addedchars">, component</span>);
</pre><pre class="diff" id="context">         }
        public boolean willAccept(XSDConcreteComponent component) {
</pre></div>
<hr /><a name="file15" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>AttributeDeclarationComponent.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AttributeDeclarationComponent.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AttributeDeclarationComponent.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -36,4 +36,12 @@
</small></pre><pre class="diff" id="context">                         super.generateCode(context, component);
                }
        }
</pre><pre class="diff" id="added">+
+        public String variableNameFor(CodegenContext context,
+         XSDConcreteComponent component)
+        {
<a name="task2" />+                // <span class="task">TODO</span>: just handle XSDNamedComponent in superclass?
+                XSDAttributeDeclaration attrDecl = (XSDAttributeDeclaration)component;
+                return context.toVariableName(attrDecl.getName());
+        }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file16" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>BooleanSimpleTypeComponent.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/BooleanSimpleTypeComponent.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/BooleanSimpleTypeComponent.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -16,7 +16,7 @@
</small></pre><pre class="diff" id="context"> public class BooleanSimpleTypeComponent extends AbstractSimpleTypeComponent {
        protected TypeDescriptor getTypeDescriptorFor(CodegenContext context, XSDSimpleTypeDefinition simpleType) {
</pre><pre class="diff" id="removed">-                return new TypeDescriptor("Boolean", false, null);
</pre><pre class="diff" id="added">+                return new TypeDescriptor("Boolean", false, null<span id="addedchars">, simpleType</span>);
</pre><pre class="diff" id="context">         }
        protected boolean willAcceptType(XSDSimpleTypeDefinition simpleType) {
</pre></div>
<hr /><a name="file17" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>ChoiceMappingComponent.java</b></big> <small id="info">158 -> 159</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ChoiceMappingComponent.java        2007-10-07 00:47:34 UTC (rev 158)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ChoiceMappingComponent.java        2007-10-07 01:03:06 UTC (rev 159)
@@ -10,13 +10,24 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDConcreteComponent;
import org.eclipse.xsd.XSDElementDeclaration;
import org.eclipse.xsd.XSDModelGroup;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDNamedComponent;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDParticle;
import org.eclipse.xsd.XSDParticleContent;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.BasicMappingFunction;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.CodegenContext;
import uk.co.badgersinfoil.asxsd.CodegenRole;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.MappingFunction;
+import uk.co.badgersinfoil.asxsd.StringUtils;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.TypeDescriptor;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.UnmarshalBuilder;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.ActionScriptFactory;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASArg;
+import uk.co.badgersinfoil.metaas.dom.ASClassType;
+import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
+import uk.co.badgersinfoil.metaas.dom.ASExpression;
+import uk.co.badgersinfoil.metaas.dom.ASMethod;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.StatementContainer;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.Visibility;
</pre><pre class="diff" id="context">
public class ChoiceMappingComponent extends AbstractMappingComponent {
</pre><pre class="diff"><small id="info">@@ -28,17 +39,28 @@
</small></pre><pre class="diff" id="context">                         XSDModelGroup modelGroup = (XSDModelGroup)component;
                        List particles = modelGroup.getParticles();
                        StatementContainer code = context.getCurrentMethodCode();
</pre><pre class="diff" id="added">+                        XSDParticle particle = (XSDParticle)modelGroup.getContainer();
+                        if (!(particle.getContainer() instanceof XSDNamedComponent)) {
+                                code.addStmt("default xml namespace = NAMESPACE");
+                                TypeDescriptor typeDesc = context.getTypeDescriptor(modelGroup);
+                                code.addStmt("var _result:"+typeDesc.getTypeName()+" = new "+typeDesc.getTypeName()+"()");
+                                UnmarshalBuilder.setCurrentSourceExpr(context, "thisElement");
+                                context.setAttribute("element-access-expression", "thisElement");
+                        }
</pre><pre class="diff" id="context">                         code.addComment(" process choice,");
                        // TODO: could this be expressed as a switch-case rather than a sequence of ifs?
                        for (Iterator i=particles.iterator(); i.hasNext(); ) {
                                XSDParticle part = (XSDParticle)i.next();
                                XSDParticleContent partContent = part.getContent();
</pre><pre class="diff" id="removed">-                                StatementContainer choiceBlock = detectElementContent<span id="removedchars">(</span>partContent, code);
</pre><pre class="diff" id="added">+                                StatementContainer choiceBlock = detectElementContent<span id="addedchars">Unmarshal(context, </span>partContent, code);
</pre><pre class="diff" id="context">                                 context.pushAttrScope();
                                context.setCurrentMethodCode(choiceBlock);
                                context.generateCode(part);
                                context.popAttrScope();
                        }
</pre><pre class="diff" id="added">+                        if (!(part