<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/main/java/uk/co/badgersinfoil/asxsd</tt></b></td></tr>
<tr><td><tt><a href="#file1">BaseCodegenContext.java</a></tt> </td><td></td><td align="right" id="added">+15</td><td align="right" id="removed">-15</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt><a href="#file2">CodegenContext.java</a></tt> </td><td></td><td align="right" id="added">+3</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td><tt><a href="#file3">MappingCodeGenerator.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">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt><a href="#file4">MappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+4</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td><tt><a href="#file5">MarshalBuilder.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt><a href="#file6">TypeBuilder.java</a></tt> </td><td></td><td align="right" id="added">+5</td><td align="right" id="removed">-69</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td><tt>components/<a href="#file7">AbstractMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+10</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file8">AbstractParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+23</td><td align="right" id="removed">-5</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file9">AbstractSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+24</td><td align="right" id="removed">-5</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file10">ArrayElementDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+12</td><td align="right" id="removed">-5</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file11">ArrayTypeDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+4</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file12">AttributeUseComponent.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">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file13">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">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file14">ChoiceMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+16</td><td align="right" id="removed">-10</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file15">ComplexTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+31</td><td align="right" id="removed">-7</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file16">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">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file17">ElementDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+35</td><td align="right" id="removed">-11</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file18">ElementDeclarationReferenceComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file19">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">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file20">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">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file21">ListComponent.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">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file22">MultiplyOccuringParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+16</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file23">OptionallyOccuringParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file24">SinglyOccuringParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file25">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">175 -&gt; 176</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file26">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">175 -&gt; 176</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file27">UnknownSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+10</td><td align="right" id="removed">-3</td><td nowrap="nowrap" align="center">175 -&gt; 176</td></tr>
<tr><td></td><td></td><td align="right" id="added">+232</td><td align="right" id="removed">-161</td><td></td></tr>
</table>
<small id="info">27 modified files</small><br />
<pre class="comment">
Fix bugs due to the confused lifecycle for mapped types.
Works more like the lifecycle for MappingFunctions.
</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">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/BaseCodegenContext.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/BaseCodegenContext.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -10,6 +10,7 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDConcreteComponent;
 import uk.co.badgersinfoil.metaas.ActionScriptFactory;
 import uk.co.badgersinfoil.metaas.ActionScriptProject;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASExpression;
 import uk.co.badgersinfoil.metaas.dom.ASMethod;
 import uk.co.badgersinfoil.metaas.dom.StatementContainer;
</pre><pre class="diff"><small id="info">@@ -25,7 +26,7 @@
</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="removed">-        private TypeStore typeStore = new TypeStore();
</pre><pre class="diff" id="added">+        private Map typeStore = new HashMap();
</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"><small id="info">@@ -46,12 +47,17 @@
</small></pre><pre class="diff" id="context">         public MappingRegistry getRegistry() {
                 return registry;
         }
</pre><pre class="diff" id="added">+        
+        public TypeDescriptor typeDescriptorFor(XSDConcreteComponent component) {
+                MappingComponent mapComp = componentFor(component);
+                return mapComp.typeDescriptorFor(this, component);
+        }
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-        public TypeDescriptor <span id="removedchars">get</span>TypeDescriptor(XSDConcreteComponent component) {
</pre><pre class="diff" id="added">+        public TypeDescriptor <span id="addedchars">create</span>TypeDescriptor(XSDConcreteComponent component) {
</pre><pre class="diff" id="context">                 MappingComponent mapComp = componentFor(component);
                 pushAttrScope();
                 setCurrentRole(CodegenRole.TYPE);
</pre><pre class="diff" id="removed">-                TypeDescriptor result = mapComp.<span id="removedchars">get</span>TypeDescriptor(this, component);
</pre><pre class="diff" id="added">+                TypeDescriptor result = mapComp.<span id="addedchars">create</span>TypeDescriptor(this, component);
</pre><pre class="diff" id="context">                 popAttrScope();
                 return result;
         }
</pre><pre class="diff"><small id="info">@@ -99,20 +105,19 @@
</small></pre><pre class="diff" id="context">         }
 
         public TypeDescriptor getOrCreateType(XSDConcreteComponent component) {
</pre><pre class="diff" id="removed">-                CodegenRole role = getCurrentRole();
-                TypeDescriptor typeDesc = typeStore.get(role, component);
</pre><pre class="diff" id="added">+                TypeDescriptor typeDesc = (TypeDescriptor)typeStore.get(component);
</pre><pre class="diff" id="context">                 if (typeDesc == null) {
                         pushAttrScope();
</pre><pre class="diff" id="removed">-                        typeDesc = createType(component);
-                        typeStore.put(role, component, typeDesc);
-                        TypeBuilder.setCurrentTypeCompilationUnit(this, typeDesc.getImplementation());
-                        generateCode(component);
</pre><pre class="diff" id="added">+                        typeDesc = createTypeDescriptor(component);
+                        typeStore.put(component, typeDesc);
+                        ASCompilationUnit unit = createType(component);
+                        typeDesc.setImplementation(unit);
</pre><pre class="diff" id="context">                         popAttrScope();
                 }
                 return typeDesc;
         }
 
</pre><pre class="diff" id="removed">-        private <span id="removedchars">TypeDescriptor</span> createType(XSDConcreteComponent component) {
</pre><pre class="diff" id="added">+        private <span id="addedchars">ASCompilationUnit</span> createType(XSDConcreteComponent component) {
</pre><pre class="diff" id="context">                 MappingComponent mapComp = componentFor(component);
                 return mapComp.createType(this, component);
         }
</pre><pre class="diff"><small id="info">@@ -209,9 +214,4 @@
</small></pre><pre class="diff" id="context">         public MappingFunctionStore getMappingFunctionStore() {
                 return functionStore;
         }
</pre><pre class="diff" id="removed">-
-        /** @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">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenContext.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenContext.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -15,8 +15,10 @@
</small></pre><pre class="diff" id="context"> 
         public ActionScriptFactory getFactory();
 
</pre><pre class="diff" id="removed">-        public TypeDescriptor <span id="removedchars">getTypeDescript</span>or(XSDConcreteComponent component);
</pre><pre class="diff" id="added">+        public TypeDescriptor <span id="addedchars">typeDescriptorF</span>or(XSDConcreteComponent component);
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="added">+        public TypeDescriptor createTypeDescriptor(XSDConcreteComponent component);
+
</pre><pre class="diff" id="context">         public String createTypeNameFor(XSDConcreteComponent component);
 
         public CodegenRole getCurrentRole();
</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>MappingCodeGenerator.java</b></big> <small id="info">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingCodeGenerator.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingCodeGenerator.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -49,7 +49,7 @@
</small></pre><pre class="diff" id="context">                 for (Iterator i = types.iterator(); i.hasNext(); ) {
                         XSDTypeDefinition typeDef = (XSDTypeDefinition)i.next();
                         if (typeDef instanceof XSDComplexTypeDefinition) {
</pre><pre class="diff" id="removed">-                                typeBuilder.representationClassForComplexType((XSDComplexTypeDefinition)typeDef);
</pre><pre class="diff" id="added">+                                context.typeDescriptorFor(typeDef);
</pre><pre class="diff" id="context">                         }
                 }
         }
</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>MappingComponent.java</b></big> <small id="info">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -5,19 +5,21 @@
</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.ASCompilationUnit;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASExpression;
 import uk.co.badgersinfoil.metaas.dom.ASMethod;
 
 public interface MappingComponent {
 
         public boolean willAccept(XSDConcreteComponent component);
</pre><pre class="diff" id="removed">-        public TypeDescriptor <span id="removedchars">getTypeDescript</span>or(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="added">+        public TypeDescriptor <span id="addedchars">typeDescriptorF</span>or(CodegenContext context, XSDConcreteComponent component);
+        public TypeDescriptor createTypeDescriptor(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="context">         public String createTypeNameFor(CodegenContext context, XSDConcreteComponent component);
         public void generateCode(CodegenContext context, XSDConcreteComponent component);
         public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component);
         public MappingFunction createFunctionRef(CodegenContext context, XSDConcreteComponent component);
         public ASMethod createFunction(CodegenContext context, XSDConcreteComponent component);
         public ASExpression createExpression(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="removed">-        public <span id="removedchars">TypeDescriptor</span> createType(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="added">+        public <span id="addedchars">ASCompilationUnit</span> createType(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="context">         public String variableNameFor(CodegenContext context, XSDConcreteComponent component);
 }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></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>MarshalBuilder.java</b></big> <small id="info">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MarshalBuilder.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MarshalBuilder.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -61,7 +61,7 @@
</small></pre><pre class="diff" id="context">         }
 
         public void buildMethodParams(ASMethod meth, XSDElementDeclaration elementDecl) {
</pre><pre class="diff" id="removed">-                TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(elementDecl);
</pre><pre class="diff" id="added">+                TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(elementDecl);
</pre><pre class="diff" id="context">                 if (elementDecl.getType() instanceof XSDComplexTypeDefinition) {
                         meth.addParam("thisObject", typeDesc.getTypeName());
                 } else {
</pre><pre class="diff"><small id="info">@@ -70,7 +70,7 @@
</small></pre><pre class="diff" id="context">         }
 
         public void buildMethodParams(ASMethod meth, XSDTypeDefinition typeDef) {
</pre><pre class="diff" id="removed">-                TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(typeDef);
</pre><pre class="diff" id="added">+                TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(typeDef);
</pre><pre class="diff" id="context">                 if (typeDef instanceof XSDComplexTypeDefinition) {
                         meth.addParam("_result", "XML");
                         meth.addParam("thisObject", typeDesc.getTypeName());
</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>TypeBuilder.java</b></big> <small id="info">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/TypeBuilder.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/TypeBuilder.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -9,6 +9,7 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDComplexTypeDefinition;
 import org.eclipse.xsd.XSDElementDeclaration;
 import org.eclipse.xsd.XSDParticle;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDSimpleTypeDefinition;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDTypeDefinition;
 import uk.co.badgersinfoil.metaas.dom.ASClassType;
 import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
</pre><pre class="diff"><small id="info">@@ -28,82 +29,17 @@
</small></pre><pre class="diff" id="context">         }
 
         public String typeNameFor(XSDTypeDefinition typeDef) {
</pre><pre class="diff" id="removed">-                if (typeDef instanceof XSDComplexTypeDefinition) {
-                        ASCompilationUnit unit = representationClassForComplexType((XSDComplexTypeDefinition)typeDef);
-                        if (unit.getPackageName() == null) {
-                                return unit.getType().getName();
-                        }
-                        return unit.getPackageName() + "." + unit.getType().getName();
-                }
</pre><pre class="diff" id="context">                 return nameGen.typeName(typeDef);
         }
</pre><pre class="diff" id="removed">-
-        public String typeNameFor(XSDElementDeclaration elementDecl) {
-                if (elementDecl.isElementDeclarationReference()) {
-                        elementDecl = elementDecl.getResolvedElementDeclaration();
-                }
-                XSDElementDeclaration listElement = XSDUtils.getElementIfContainerForList(elementDecl);
-                if (listElement != null) {
-                        return "Array";
-                }
-                XSDTypeDefinition typeDef = elementDecl.getType();
-                if (typeDef!=null &amp;&amp; typeDef.getName()!=null) {
-                        return typeNameFor(typeDef);
-                }
-                typeDef = elementDecl.getAnonymousTypeDefinition();
-                if (typeDef instanceof XSDComplexTypeDefinition) {
-                        ASCompilationUnit unit = representationClassForComplexType(elementDecl);
-                        if (unit.getPackageName() == null) {
-                                return unit.getType().getName();
-                        }
-                        return unit.getPackageName() + "." + unit.getType().getName();
-                }
-                return nameGen.typeName(typeDef);
-        }
-
-
-        public TypeDescriptor typeDescriptorForElementDecl(XSDParticle particle, XSDElementDeclaration elementDecl) {
-                return context.getTypeDescriptor(particle);
-        }
-
-        public ASCompilationUnit representationClassForComplexType(XSDComplexTypeDefinition typeDef) {
-                String name = nameGen.typeName(typeDef);
-                ASCompilationUnit result = (ASCompilationUnit)representationClassesByQName.get(name);
</pre><pre class="diff" id="added">+        
+        public static ASCompilationUnit getCurrentTypeCompilationUnit(CodegenContext context) {
+                ASCompilationUnit result = (ASCompilationUnit)context.getAttribute(KEY_CURRENT_TYPE_COMPILATION_UNIT);
</pre><pre class="diff" id="context">                 if (result == null) {
</pre><pre class="diff" id="removed">-                        result = context.getProject().newClass(name);
-                        representationClassesByQName.put(name, result);
-                        // only now that we have the class in the Map to we
-                        // process it, to prevent infinate loops when processing
-                        // self-referential structures
-                        context.pushAttrScope();
-                        context.setAttribute(KEY_CURRENT_TYPE_COMPILATION_UNIT, result);
-                        processComplexType(typeDef);
-                        context.popAttrScope();
</pre><pre class="diff" id="added">+                        throw new IllegalStateException("No current compilation unit");
</pre><pre class="diff" id="context">                 }
                 return result;
         }
 
</pre><pre class="diff" id="removed">-        public ASCompilationUnit representationClassForComplexType(XSDElementDeclaration elementDecl) {
-                String name = nameGen.getNameFor(elementDecl);
-                ASCompilationUnit result = (ASCompilationUnit)representationClassesByQName.get(name);
-                if (result == null) {
-                        result = context.getProject().newClass(name);
-                        representationClassesByQName.put(name, result);
-                        // only now that we have the class in the Map do we
-                        // process it, to prevent infinate loops when processing
-                        // self-referential structures
-                        context.pushAttrScope();
-                        context.setAttribute(KEY_CURRENT_TYPE_COMPILATION_UNIT, result);
-                        processComplexType((XSDComplexTypeDefinition)elementDecl.getTypeDefinition());
-                        context.popAttrScope();
-                }
-                return result;
-        }
-        
-        public static ASCompilationUnit getCurrentTypeCompilationUnit(CodegenContext context) {
-                return (ASCompilationUnit)context.getAttribute(KEY_CURRENT_TYPE_COMPILATION_UNIT);
-        }
-
</pre><pre class="diff" id="context">         public static ASClassType getCurrentType(CodegenContext context) {
                 return (ASClassType)getCurrentTypeCompilationUnit(context).getType();
         }
</pre></div>
<hr /><a name="file7" /><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">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractMappingComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractMappingComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -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.ASCompilationUnit;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASExpression;
 import uk.co.badgersinfoil.metaas.dom.ASMethod;
 
</pre><pre class="diff"><small id="info">@@ -24,12 +25,19 @@
</small></pre><pre class="diff" id="context">                 throw new RuntimeException(getClass().getName()+" does not suppport operation generateCode(role="+role+", component="+component+") at "+XSDUtils.path(component));
         }
 
</pre><pre class="diff" id="removed">-        public TypeDescriptor <span id="removedchars">getTypeDescript</span>or(CodegenContext context,
</pre><pre class="diff" id="added">+        public TypeDescriptor <span id="addedchars">typeDescriptorF</span>or(CodegenContext context,
</pre><pre class="diff" id="context">                                                 XSDConcreteComponent component)
         {
                 return context.getOrCreateType(component);
         }
 
</pre><pre class="diff" id="added">+        public TypeDescriptor createTypeDescriptor(CodegenContext context,
+                                                   XSDConcreteComponent component)
+        {
+                CodegenRole role = context.getCurrentRole();
+                throw new RuntimeException(getClass().getName()+" does not suppport operation createTypeDescriptor(role="+role+", component="+component+") at "+XSDUtils.path(component));
+        }
+
</pre><pre class="diff" id="context">         public String createTypeNameFor(CodegenContext context,
                                         XSDConcreteComponent component)
         {
</pre><pre class="diff"><small id="info">@@ -51,7 +59,7 @@
</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="removed">-        public <span id="removedchars">TypeDescriptor</span> createType(CodegenContext context, XSDConcreteComponent component) {
</pre><pre class="diff" id="added">+        public <span id="addedchars">ASCompilationUnit</span> createType(CodegenContext context, XSDConcreteComponent component) {
</pre><pre class="diff" id="context">                 CodegenRole role = context.getCurrentRole();
                 throw new RuntimeException(getClass().getName()+" does not suppport operation createType(role="+role+") at "+XSDUtils.path(component));
         }
</pre></div>
<hr /><a name="file8" /><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">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractParticleComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractParticleComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -9,20 +9,38 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.CodegenContext;
 import uk.co.badgersinfoil.asxsd.CodegenRole;
 import uk.co.badgersinfoil.asxsd.TypeDescriptor;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.XSDUtils;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASExpression;
 
 public abstract class AbstractParticleComponent extends AbstractMappingComponent {
 
</pre><pre class="diff" id="removed">-        public TypeDescriptor getTypeDescriptor(CodegenContext context,
-                                                XSDConcreteComponent component)
</pre><pre class="diff" id="added">+        public TypeDescriptor typeDescriptorFor(CodegenContext context,
+                                                   XSDConcreteComponent component)
</pre><pre class="diff" id="context">         {
                 XSDParticle particle = (XSDParticle)component;
</pre><pre class="diff" id="removed">-                return <span id="removedchars">getT</span>ypeDescriptorFor(context, particle);
</pre><pre class="diff" id="added">+                return <span id="addedchars">t</span>ypeDescriptorFor(context, particle);
</pre><pre class="diff" id="context">         }
 
</pre><pre class="diff" id="removed">-        protected abstract TypeDescriptor getTypeDescriptorFor(CodegenContext context,
-                                                               XSDParticle particle);
</pre><pre class="diff" id="added">+        protected TypeDescriptor typeDescriptorFor(CodegenContext context,
+                                                               XSDParticle particle)
+        {
+                return super.typeDescriptorFor(context, particle);
+        }
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="added">+        public TypeDescriptor createTypeDescriptor(CodegenContext context,
+                                                   XSDConcreteComponent component)
+        {
+                XSDParticle particle = (XSDParticle)component;
+                return createTypeDescriptor(context, particle);
+        }
+
+        protected TypeDescriptor createTypeDescriptor(CodegenContext context,
+                                                               XSDParticle particle)
+        {
+                CodegenRole role = context.getCurrentRole();
+                throw new RuntimeException(getClass().getName()+" does not suppport operation createTypeDescriptor(role="+role+", particle="+particle+") at "+XSDUtils.path(particle));
+        }
+
</pre><pre class="diff" id="context">         public String createTypeNameFor(CodegenContext context,
                                         XSDConcreteComponent component)
         {
</pre></div>
<hr /><a name="file9" /><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">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractSimpleTypeComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractSimpleTypeComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -25,13 +25,32 @@
</small></pre><pre class="diff" id="context"> 
 public abstract class AbstractSimpleTypeComponent extends AbstractMappingComponent {
 
</pre><pre class="diff" id="removed">-        public TypeDescriptor <span id="removedchars">getTypeDescript</span>or(CodegenContext context,
</pre><pre class="diff" id="added">+        public TypeDescriptor <span id="addedchars">typeDescriptorF</span>or(CodegenContext context,
</pre><pre class="diff" id="context">                                                 XSDConcreteComponent component)
         {
                 XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition)component;
</pre><pre class="diff" id="removed">-                return <span id="removedchars">getT</span>ypeDescriptorFor(context, simpleType);
</pre><pre class="diff" id="added">+                return <span id="addedchars">t</span>ypeDescriptorFor(context, simpleType);
</pre><pre class="diff" id="context">         }
 
</pre><pre class="diff" id="added">+        protected TypeDescriptor typeDescriptorFor(CodegenContext context,
+                                                   XSDSimpleTypeDefinition simpleType)
+        {
+                return super.typeDescriptorFor(context, simpleType);
+        }
+
+        public TypeDescriptor createTypeDescriptor(CodegenContext context,
+                                                XSDConcreteComponent component)
+        {
+                XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition)component;
+                return createTypeDescriptor(context, simpleType);
+        }
+
+        public ASCompilationUnit createType(CodegenContext context,
+                                            XSDConcreteComponent component)
+        {
+                return null;
+        }
+
</pre><pre class="diff" id="context">         public void generateCode(CodegenContext context,
                                  XSDConcreteComponent component)
         {
</pre><pre class="diff"><small id="info">@@ -51,8 +70,8 @@
</small></pre><pre class="diff" id="context">                 }
         }
 
</pre><pre class="diff" id="removed">-        protected abstract TypeDescriptor getTypeDescriptorFor(CodegenContext context,
-                                                               XSDSimpleTypeDefinition simpleType);
</pre><pre class="diff" id="added">+        protected abstract TypeDescriptor createTypeDescriptor(CodegenContext context,
+                                                            XSDSimpleTypeDefinition simpleType);
</pre><pre class="diff" id="context"> 
         public MappingFunction createFunctionRef(CodegenContext context,
                                               XSDConcreteComponent component)
</pre><pre class="diff"><small id="info">@@ -108,7 +127,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">-                        TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(simpleType);
</pre><pre class="diff" id="added">+                        TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(simpleType);
</pre><pre class="diff" id="context">                         String methodName = unmarshalMethodNameFor(simpleType);
                         ASMethod meth = clazz.newMethod(methodName, Visibility.PUBLIC, typeDesc.getTypeName());
                         ASArg arg = meth.addParam("thisValue", "String");
</pre></div>
<hr /><a name="file10" /><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">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayElementDeclarationComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayElementDeclarationComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -27,16 +27,23 @@
</small></pre><pre class="diff" id="context"> 
 public class ArrayElementDeclarationComponent extends AbstractMappingComponent {
 
</pre><pre class="diff" id="removed">-        public TypeDescriptor <span id="removedchars">get</span>TypeDescriptor(CodegenContext context,
</pre><pre class="diff" id="added">+        public TypeDescriptor <span id="addedchars">create</span>TypeDescriptor(CodegenContext context,
</pre><pre class="diff" id="context">                                                 XSDConcreteComponent component)
         {
                 XSDElementDeclaration elementDecl = (XSDElementDeclaration)component;
                 XSDElementDeclaration listElement = XSDUtils.getElementIfContainerForList(elementDecl);
</pre><pre class="diff" id="removed">-                TypeDescriptor elementType = context.<span id="removedchars">getTypeDescript</span>or(listElement);
</pre><pre class="diff" id="added">+                TypeDescriptor elementType = context.<span id="addedchars">typeDescriptorF</span>or(listElement);
</pre><pre class="diff" id="context">                 String doc = "Elements of type {@link " + elementType.getTypeName()+"}";
                 return new TypeDescriptor(ASConstants.TYPE_ARRAY, true, doc, elementDecl);
         }
 
</pre><pre class="diff" id="added">+        public ASCompilationUnit createType(CodegenContext context,
+                                            XSDConcreteComponent component)
+        {
+                // no implementation (built in type)
+                return null;
+        }
+
</pre><pre class="diff" id="context">         public boolean willAccept(XSDConcreteComponent component) {
                 return component instanceof XSDElementDeclaration
                     &amp;&amp; XSDUtils.getElementIfContainerForList((XSDElementDeclaration)component)!=null
</pre><pre class="diff"><small id="info">@@ -51,7 +58,7 @@
</small></pre><pre class="diff" id="context">                         XSDElementDeclaration listElement = XSDUtils.getElementIfContainerForList(elementDecl);
                         String listName = "_"+context.variableNameFor(elementDecl);
                         containingBlock.addStmt("var "+listName+":XML = &lt;"+elementDecl.getName()+"/&gt;");
</pre><pre class="diff" id="removed">-                        TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(listElement);
</pre><pre class="diff" id="added">+                        TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(listElement);
</pre><pre class="diff" id="context">                         String elementType = typeDesc.getTypeName();
                         String childVarName = listName+"_child";
                         String accessExpr = MarshalBuilder.getCurrentSourceExpr(context);
</pre><pre class="diff"><small id="info">@@ -72,7 +79,7 @@
</small></pre><pre class="diff" id="context">                 } else if (role == CodegenRole.TYPE) {
                         ASCompilationUnit unit = TypeBuilder.getCurrentTypeCompilationUnit(context);
                         ASClassType clazz = (ASClassType)unit.getType();
</pre><pre class="diff" id="removed">-                        TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(elementDecl.getContainer());
</pre><pre class="diff" id="added">+                        TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(elementDecl.getContainer());
</pre><pre class="diff" id="context">                         ASField field = clazz.newField(context.variableNameFor(elementDecl.getResolvedElementDeclaration()), Visibility.PUBLIC, typeDesc.getTypeName());
                         field.setDescription(typeDesc.getDocumentation());                        
                 } else {
</pre><pre class="diff"><small id="info">@@ -113,7 +120,7 @@
</small></pre><pre class="diff" id="context">                         ASClassType clazz = (ASClassType)unit.getType();
                         String name = StringUtils.sanitize(elementDecl.getName());
                         String methodName = "unmarshal" + name;
</pre><pre class="diff" id="removed">-                        TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(elementDecl);
</pre><pre class="diff" id="added">+                        TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(elementDecl);
</pre><pre class="diff" id="context">                         ASMethod meth = clazz.newMethod(methodName, Visibility.PUBLIC, typeDesc.getTypeName());
                         ASArg arg = meth.addParam("thisElement", "XML");
                         String doc = "a &amp;lt;" + elementDecl.getName()+"/&amp;gt; element";
</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>ArrayTypeDeclarationComponent.java</b></big> <small id="info">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayTypeDeclarationComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayTypeDeclarationComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -21,12 +21,12 @@
</small></pre><pre class="diff" id="context"> 
 public class ArrayTypeDeclarationComponent extends AbstractMappingComponent {
 
</pre><pre class="diff" id="removed">-        public TypeDescriptor <span id="removedchars">get</span>TypeDescriptor(CodegenContext context,
</pre><pre class="diff" id="added">+        public TypeDescriptor <span id="addedchars">create</span>TypeDescriptor(CodegenContext context,
</pre><pre class="diff" id="context">                                                 XSDConcreteComponent component)
         {
                 XSDTypeDefinition typeDef = (XSDTypeDefinition)component;
                 XSDElementDeclaration listElement = XSDUtils.getElementIfContainerForList(typeDef);
</pre><pre class="diff" id="removed">-                TypeDescriptor elementType = context.<span id="removedchars">getTypeDescript</span>or(listElement);
</pre><pre class="diff" id="added">+                TypeDescriptor elementType = context.<span id="addedchars">typeDescriptorF</span>or(listElement);
</pre><pre class="diff" id="context">                 String doc = "Elements of type {@link " + elementType.getTypeName()+"}";
                 return new TypeDescriptor(ASConstants.TYPE_ARRAY, true, doc, component);
         }
</pre><pre class="diff"><small id="info">@@ -45,7 +45,7 @@
</small></pre><pre class="diff" id="context">                         StatementContainer block = context.getCurrentMethodCode();
                         block.addStmt("default xml namespace = NAMESPACE");
                         XSDElementDeclaration listElement = XSDUtils.getElementIfContainerForList((XSDTypeDefinition)component);
</pre><pre class="diff" id="removed">-                        String elementType = context.<span id="removedchars">getTypeDescript</span>or(listElement).getTypeName();
</pre><pre class="diff" id="added">+                        String elementType = context.<span id="addedchars">typeDescriptorF</span>or(listElement).getTypeName();
</pre><pre class="diff" id="context">                         String fieldAccess = "_result";
                         String childVarName = "_child";
                         StatementContainer loop = block.newForEachIn("var "+childVarName+":"+elementType, "thisObject"
</pre><pre class="diff"><small id="info">@@ -67,7 +67,7 @@
</small></pre><pre class="diff" id="context">                 } else if (role == CodegenRole.UNMARSHAL) {
                         StatementContainer block = context.getCurrentMethodCode();
                         block.addStmt("default xml namespace = NAMESPACE");
</pre><pre class="diff" id="removed">-                        TypeDescriptor typeDesc = context.<span id="removedchars">get</span>TypeDescriptor(component);
</pre><pre class="diff" id="added">+                        TypeDescriptor typeDesc = context.<span id="addedchars">create</span>TypeDescriptor(component);
</pre><pre class="diff" id="context">                         block.addStmt("var _result:"+typeDesc.getTypeName()+" = new "+typeDesc.getTypeName()+"()");
                         XSDElementDeclaration listElement = XSDUtils.getElementIfContainerForList((XSDTypeDefinition)component);
                         block.addStmt("var _children:XMLList = thisElement.elements()");
</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>AttributeUseComponent.java</b></big> <small id="info">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AttributeUseComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AttributeUseComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -53,7 +53,7 @@
</small></pre><pre class="diff" id="context">                 } else if (role == CodegenRole.TYPE) {
                         XSDAttributeDeclaration attrDecl = attrUse.getAttributeDeclaration();
                         ASClassType clazz = TypeBuilder.getCurrentType(context);
</pre><pre class="diff" id="removed">-                        TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(attrDecl.getTypeDefinition());
</pre><pre class="diff" id="added">+                        TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(attrDecl.getTypeDefinition());
</pre><pre class="diff" id="context">                         ASField field = clazz.newField(context.variableNameFor(attrDecl), Visibility.PUBLIC,
                                                        typeDesc.getTypeName());
                         String doc = DocUtils.findDocumentation(attrDecl.getAnnotation());
</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>BooleanSimpleTypeComponent.java</b></big> <small id="info">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/BooleanSimpleTypeComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/BooleanSimpleTypeComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -15,7 +15,7 @@
</small></pre><pre class="diff" id="context"> 
 public class BooleanSimpleTypeComponent extends AbstractSimpleTypeComponent {
 
</pre><pre class="diff" id="removed">-        protected TypeDescriptor <span id="removedchars">getTypeDescriptorF</span>or(CodegenContext context, XSDSimpleTypeDefinition simpleType) {
</pre><pre class="diff" id="added">+        protected TypeDescriptor <span id="addedchars">createTypeDescript</span>or(CodegenContext context, XSDSimpleTypeDefinition simpleType) {
</pre><pre class="diff" id="context">                 return new TypeDescriptor("Boolean", false, null, simpleType);
         }
 
</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>ChoiceMappingComponent.java</b></big> <small id="info">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ChoiceMappingComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ChoiceMappingComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -18,6 +18,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.MappingFunction;
 import uk.co.badgersinfoil.asxsd.MarshalBuilder;
 import uk.co.badgersinfoil.asxsd.StringUtils;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.TypeBuilder;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.TypeDescriptor;
 import uk.co.badgersinfoil.asxsd.UnmarshalBuilder;
 import uk.co.badgersinfoil.metaas.ActionScriptFactory;
</pre><pre class="diff"><small id="info">@@ -118,18 +119,23 @@
</small></pre><pre class="diff" id="context">                 return context.createTypeNameFor(component.getContainer()) + "Choice";
         }
 
</pre><pre class="diff" id="removed">-        public TypeDescriptor createType(CodegenContext context,
</pre><pre class="diff" id="added">+        public TypeDescriptor createType<span id="addedchars">Descriptor</span>(CodegenContext context,
+                                                   XSDConcreteComponent component)
+        {
+                String typeName = createTypeNameFor(context, component);
+                String docs = null;
+                return new TypeDescriptor(typeName, false, docs, component);
+        }
+
+        public ASCompilationUnit createType(CodegenContext context,
</pre><pre class="diff" id="context">                                          XSDConcreteComponent component)
         {
</pre><pre class="diff" id="removed">-                // TODO: create the descriptor, but don't create the
-                // ASCompilationUnit yet; leave that to generateCode()
-                
</pre><pre class="diff" id="context">                 String typeName = createTypeNameFor(context, component);
</pre><pre class="diff" id="removed">-                String docs = null;
-                TypeDescriptor result = new TypeDescriptor(typeName, false, docs, component);
</pre><pre class="diff" id="context">                 ASCompilationUnit unit = context.getProject().newClass(typeName);
</pre><pre class="diff" id="removed">-                result.setImplementation(unit);
-                return result;
</pre><pre class="diff" id="added">+                TypeBuilder.setCurrentTypeCompilationUnit(context, unit);
+                context.setCurrentRole(CodegenRole.TYPE);
+                context.generateCode(component);
+                return unit;
</pre><pre class="diff" id="context">         }
 
         public boolean willAccept(XSDConcreteComponent component) {
</pre><pre class="diff"><small id="info">@@ -156,7 +162,7 @@
</small></pre><pre class="diff" id="context">                         UnmarshalBuilder builder = context.getUnmarshalBuilder();
                         ASCompilationUnit unit = builder.getClassForNamespace(modelGroup.getSchema().getTargetNamespace());
                         ASClassType clazz = (ASClassType)unit.getType();
</pre><pre class="diff" id="removed">-                        TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(modelGroup);
</pre><pre class="diff" id="added">+                        TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(modelGroup);
</pre><pre class="diff" id="context">                         String methodName = "unmarshal" + StringUtils.sanitize(localName(typeDesc));
                         String qname;
                         if (unit.getPackageName() != null) {
</pre><pre class="diff"><small id="info">@@ -179,7 +185,7 @@
</small></pre><pre class="diff" id="context">                         UnmarshalBuilder builder = context.getUnmarshalBuilder();
                         ASCompilationUnit unit = builder.getClassForNamespace(modelGroup.getSchema().getTargetNamespace());
                         ASClassType clazz = (ASClassType)unit.getType();
</pre><pre class="diff" id="removed">-                        TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(modelGroup);
</pre><pre class="diff" id="added">+                        TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(modelGroup);
</pre><pre class="diff" id="context">                         String methodName = "unmarshal" + StringUtils.sanitize(localName(typeDesc));
                         ASMethod meth = clazz.newMethod(methodName, Visibility.PUBLIC, localName(typeDesc));
                         ASArg arg = meth.addParam("thisElement", "XML");
</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>ComplexTypeComponent.java</b></big> <small id="info">175 -&gt; 176</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ComplexTypeComponent.java        2007-10-19 07:16:08 UTC (rev 175)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ComplexTypeComponent.java        2007-10-19 20:49:30 UTC (rev 176)
@@ -33,21 +33,45 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.Visibility;
 
 public class ComplexTypeComponent extends AbstractMappingComponent {
</pre><pre class="diff" id="removed">-        
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context">         TypeNameGenerator nameGen = new TypeNameGenerator();
 
</pre><pre class="diff" id="removed">-        public TypeDescriptor <span id="removedchars">get</span>TypeDescriptor(CodegenContext context,
</pre><pre class="diff" id="added">+        public TypeDescriptor <span id="addedchars">create</span>TypeDescriptor(CodegenContext context,
</pre><pre class="diff" id="context">                                                 XSDConcreteComponent component)
         {
                 XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)component;
</pre><pre class="diff" id="removed">-                TypeBuilder builder = context.getTypeBuilder();
</pre><pre class="diff" id="context">                 context.pushAttrScope();
                 String docs = null;
</pre><pre class="diff" id="removed">-                TypeDescriptor result = new TypeDescriptor(builder.typeNameFor(complexType), false, docs, component);
</pre><pre class="diff" id="added">+                String typeName = context.createTypeNameFor(complexType);
+                TypeDescriptor result = new TypeDescriptor(typeName, false, docs, component);
</pre><pre class="diff" id="context">                 context.popAttrScope();
                 return result;
         }
 
</pre><pre class="diff" id="added">+        public TypeDescriptor typeDescriptorFor(CodegenContext context,
+                                                XSDConcreteComponent component)
+        {
+                XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)component;
+                if (XSDUtils.isAnonymous(complexType)) {
+                        return context.typeDescriptorFor(complexType.getContainer());
+                }
+                return super.typeDescriptorFor(context, component);
+        }
+
+        public ASCompilationUnit createType(CodegenContext context,
+                                         XSDConcreteComponent component)
+        {
+                XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)component;
+                String typeName = context.createTypeNameFor(complexType);
+                ASCompilationUnit unit = context.getProject().newClass(typeName);
+                context.pushAttrScope();
+                TypeBuilder.setCurrentTypeCompilationUnit(context, unit);
+                context.setCurrentRole(CodegenRole.TYPE);
+                context.generateCode(complexType);
+                context.popAttrScope();
+                return unit;
+        }
+
</pre><pre class="diff" id="context">         public String createTypeNameFor(CodegenContext context,
                                         XSDConcreteComponent component)
         {
</pre><pre class="diff"><small id="info">@@ -62,7 +86,7 @@
</small></pre><pre class="diff" id="context">                         StatementContainer block = context.getCurrentMethodCode();
                         if (!XSDUtils.isAnonymous(complexType)) {
                                 block.addStmt("default xml namespace = NAMESPACE");
</pre><pre class="diff" id="removed">-                                TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(complexType);
</pre><pre class="diff" id="added">+                                TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(complexType);
</pre><pre class="diff" id="context">                                 block.addStmt("var _result:"+typeDesc.getTypeName()+" = new "+typeDesc.getTypeName()+"()");
                         }
                         processComplexTypeBaseTypeUnmarshal(context, complexType);
</pre><pre class="diff"><small id="info">@@ -212,7 +236,7 @@
</small></pre><pre class="diff" id="context">                         UnmarshalBuilder builder = context.getUnmarshalBuilder();
                         ASCompilationUnit unit = builder.getClassForNamespace(complexType.getTargetNamespace());
                         ASClassType clazz = (ASClassType)unit.getType();
</pre><pre class="diff" id="removed">-                        TypeDescriptor typeDesc = context.<span id="removedchars">getTypeDescript</span>or(complexType);
</pre><pre class="diff" id="added">+                        TypeDescriptor typeDesc = context.<span id="addedchars">typeDescriptorF</span>or(complexType);
</pre><pre class="diff" id="context">