<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">+32</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt><a href="#file2">BasicMappingFunction.java</a></tt> </td><td></td><td align="right" id="added">+21</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td><tt><a href="#file3">CodegenContext.java</a></tt> </td><td></td><td align="right" id="added">+9</td><td></td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt><a href="#file4">MappingComponent.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">143 -&gt; 144</td></tr>
<tr><td><tt><a href="#file5">MappingFunction.java</a></tt> </td><td></td><td align="right" id="added">+4</td><td></td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt><a href="#file6">MappingFunctionStore.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">143 -&gt; 144</td></tr>
<tr><td><tt><a href="#file7">MarshalBuilder.java</a></tt> </td><td></td><td align="right" id="added">+11</td><td align="right" id="removed">-42</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt><a href="#file8">UnmarshalBuilder.java</a></tt> </td><td></td><td align="right" id="added">+10</td><td align="right" id="removed">-43</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td><tt>components/<a href="#file9">AbstractMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+3</td><td align="right" id="removed">-3</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file10">AbstractSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+7</td><td align="right" id="removed">-12</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file11">ArrayElementDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+6</td><td align="right" id="removed">-6</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file12">ArrayTypeDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+6</td><td align="right" id="removed">-7</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file13">AttributeDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-16</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file14">AttributeUseComponent.java</a></tt> </td><td></td><td align="right" id="added">+4</td><td align="right" id="removed">-6</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file15">BooleanSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-6</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file16">ChoiceMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+5</td><td align="right" id="removed">-15</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file17">ComplexTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+21</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file18">DateTimeSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file19">ElementDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+10</td><td align="right" id="removed">-9</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file20">FloatSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file21">IdentityMappingFunction.java</a></tt> </td><td></td><td align="right" id="added">+8</td><td></td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file22">IntSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file23">MultiplyOccuringParticleComponent.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">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file24">OptionallyOccuringParticleComponent.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">143 -&gt; 144</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file25">SequenceMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+3</td><td align="right" id="removed">-13</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file26">SinglyOccuringParticleComponent.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">143 -&gt; 144</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file27">StringSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td align="right" id="removed">-15</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file28">UnknownSimpleTypeComponent.java</a></tt> </td><td></td><td></td><td align="right" id="removed">-11</td><td nowrap="nowrap" align="center">143 -&gt; 144</td></tr>
<tr><td></td><td></td><td align="right" id="added">+183</td><td align="right" id="removed">-240</td><td></td></tr>
</table>
<small id="info">28 modified files</small><br />
<pre class="comment">
factor method caching out of MarshalBuilder/UnmarshalBuilder and into CodegenContext
bringing us closer to the point where we canget rid of the former classes
</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">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/BaseCodegenContext.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/BaseCodegenContext.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -9,7 +9,9 @@
</small></pre><pre class="diff" id="context"> import java.util.Stack;
 import org.eclipse.xsd.XSDConcreteComponent;
 import org.eclipse.xsd.XSDElementDeclaration;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDNamedComponent;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.ActionScriptProject;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.StatementContainer;
</pre><pre class="diff" id="context"> 
 public class BaseCodegenContext implements CodegenContext {
         private MappingRegistry registry;
</pre><pre class="diff"><small id="info">@@ -22,6 +24,7 @@
</small></pre><pre class="diff" id="context">         private Stack scopeStack = new Stack();
         private MappingFunctionStore functionStore = new MappingFunctionStore();
         private static final String KEY_ROLE = BaseCodegenContext.class.getName() + ".role";
</pre><pre class="diff" id="added">+        private static final String KEY_CODE = BaseCodegenContext.class.getName() + ".code";
</pre><pre class="diff" id="context"> 
         public BaseCodegenContext(MappingRegistry registry, ActionScriptProject project) {
                 this.registry = registry;
</pre><pre class="diff"><small id="info">@@ -55,8 +58,36 @@
</small></pre><pre class="diff" id="context">         }
 
         public MappingFunction functionFor(XSDConcreteComponent component) {
</pre><pre class="diff" id="added">+                XSDNamedComponent namedComponent = (XSDNamedComponent)component;
+                CodegenRole role = getCurrentRole();
+                MappingFunction convert = functionStore.get(role, namedComponent);
+                if (convert == null) {
+                        convert = createFunction(namedComponent);
+                        if (convert.getImplementation() == null) {
+                                throw new RuntimeException("null fn for "+namedComponent);
+                        }
+                        functionStore.put(role, namedComponent, convert);
+                        // 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,
+                        pushAttrScope();
+                        setCurrentMethodCode(convert.getImplementation());
+                        generateCode(namedComponent);
+                        popAttrScope();
+                }
+                return convert;
+        }
+
+        public StatementContainer getCurrentMethodCode() {
+                return (StatementContainer)getAttribute(KEY_CODE);
+        }
+        public void setCurrentMethodCode(StatementContainer code) {
+                setAttribute(KEY_CODE, code);
+        }
+
+        public MappingFunction createFunction(XSDConcreteComponent component) {
</pre><pre class="diff" id="context">                 MappingComponent mapComp = componentFor(component);
</pre><pre class="diff" id="removed">-                return mapComp.<span id="removedchars">functionFor</span>(this, component);
</pre><pre class="diff" id="added">+                return mapComp.<span id="addedchars">createFunction</span>(this, component);
</pre><pre class="diff" id="context">         }
 
         private MappingComponent componentFor(XSDConcreteComponent component) {
</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>BasicMappingFunction.java</b></big> <small id="info">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/BasicMappingFunction.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/BasicMappingFunction.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -4,16 +4,33 @@
</small></pre><pre class="diff" id="context"> 
 package uk.co.badgersinfoil.asxsd;
 
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
+import uk.co.badgersinfoil.metaas.dom.ASMethod;
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context"> public class BasicMappingFunction implements MappingFunction {
         
</pre><pre class="diff" id="removed">-        private String qualifiedMethodName;
</pre><pre class="diff" id="added">+        private ASCompilationUnit unit;
+        private ASMethod impl;
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-        public BasicMappingFunction(String qualifiedMethodName) {
-                this.qualifiedMethodName = qualifiedMethodName;
</pre><pre class="diff" id="added">+        public BasicMappingFunction(ASCompilationUnit unit, ASMethod impl) {
+                this.unit = unit;
+                this.impl = impl;
</pre><pre class="diff" id="context">         }
 
         public String appliedTo(String accessExpr) {
</pre><pre class="diff" id="removed">-                return qualifiedMethodName + "(" + accessExpr + ")";
</pre><pre class="diff" id="added">+                return qualifiedMethodName<span id="addedchars">()</span> + "(" + accessExpr + ")";
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="added">+
+        public ASMethod getImplementation() {
+                return impl;
+        }
+
+        private String qualifiedMethodName() {
+                String pkgName = unit.getPackageName();
+                if (pkgName == null) {
+                        return unit.getType().getName() + "." + impl.getName();
+                }
+                return pkgName + "." + unit.getType().getName() + "." + impl.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="file3" /><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">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenContext.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenContext.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -1,6 +1,9 @@
</small></pre><pre class="diff" id="context"> package uk.co.badgersinfoil.asxsd;
 
 import org.eclipse.xsd.XSDConcreteComponent;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDElementDeclaration;
+import uk.co.badgersinfoil.metaas.dom.ASMethod;
+import uk.co.badgersinfoil.metaas.dom.StatementContainer;
</pre><pre class="diff" id="context"> 
 public interface CodegenContext {
 
</pre><pre class="diff"><small id="info">@@ -15,6 +18,12 @@
</small></pre><pre class="diff" id="context"> 
         public MappingFunction functionFor(XSDConcreteComponent component);
 
</pre><pre class="diff" id="added">+        public MappingFunction createFunction(XSDConcreteComponent component);
+
+        public StatementContainer getCurrentMethodCode();
+
+        public void setCurrentMethodCode(StatementContainer code);
+
</pre><pre class="diff" id="context">         /** @deprecated */
         public UnmarshalBuilder getUnmarshalBuilder();
 
</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">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingComponent.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingComponent.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -11,5 +11,5 @@
</small></pre><pre class="diff" id="context">         public boolean willAccept(XSDConcreteComponent component);
         public TypeDescriptor getTypeDescriptor(CodegenContext context, XSDConcreteComponent component);
         public void generateCode(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="removed">-        public MappingFunction <span id="removedchars">functionFor</span>(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="added">+        public MappingFunction <span id="addedchars">createFunction</span>(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="file5" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>MappingFunction.java</b></big> <small id="info">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingFunction.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingFunction.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -4,8 +4,12 @@
</small></pre><pre class="diff" id="context"> 
 package uk.co.badgersinfoil.asxsd;
 
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASMethod;
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context"> public interface MappingFunction {
 
         public String appliedTo(String accessExpr);
</pre><pre class="diff" id="added">+
+        public ASMethod getImplementation();
</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="file6" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd</span><br />
<div class="fileheader"><big><b>MappingFunctionStore.java</b></big> <small id="info">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingFunctionStore.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingFunctionStore.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -3,21 +3,20 @@
</small></pre><pre class="diff" id="context"> import java.util.HashMap;
 import java.util.Map;
 import org.eclipse.xsd.XSDConcreteComponent;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.metaas.dom.ASMethod;
</pre><pre class="diff" id="context"> 
 public class MappingFunctionStore {
         private Map store = new HashMap();
         
</pre><pre class="diff" id="removed">-        public <span id="removedchars">ASMethod</span> get(CodegenRole role,
</pre><pre class="diff" id="added">+        public <span id="addedchars">MappingFunction</span> get(CodegenRole role,
</pre><pre class="diff" id="context">                             XSDConcreteComponent component)
         {
                 Key key = new Key(role, component);
</pre><pre class="diff" id="removed">-                return (ASMethod)store.get(key);
</pre><pre class="diff" id="added">+                return (MappingFunction)store.get(key);
</pre><pre class="diff" id="context">         }
 
         public void put(CodegenRole role,
                         XSDConcreteComponent component,
</pre><pre class="diff" id="removed">-                        ASMethod fn)
</pre><pre class="diff" id="added">+                        MappingFunction fn)
</pre><pre class="diff" id="context">         {
                 Key key = new Key(role, component);
                 if (store.containsKey(key)) {
</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">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MarshalBuilder.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MarshalBuilder.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -9,8 +9,8 @@
</small></pre><pre class="diff" id="context"> import java.util.List;
 import java.util.Map;
 import org.eclipse.xsd.XSDComplexTypeDefinition;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDConcreteComponent;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDElementDeclaration;
</pre><pre class="diff" id="removed">-import org.eclipse.xsd.XSDNamedComponent;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDSchema;
 import org.eclipse.xsd.XSDSimpleTypeDefinition;
 import org.eclipse.xsd.XSDTypeDefinition;
</pre><pre class="diff"><small id="info">@@ -22,7 +22,6 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASConstants;
 import uk.co.badgersinfoil.metaas.dom.ASField;
 import uk.co.badgersinfoil.metaas.dom.ASMethod;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.metaas.dom.StatementContainer;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.Visibility;
 
 
</pre><pre class="diff"><small id="info">@@ -49,11 +48,14 @@
</small></pre><pre class="diff" id="context"> 
         public void processSchema(XSDSchema schema) {
                 List types = schema.getTypeDefinitions();
</pre><pre class="diff" id="added">+                context.pushAttrScope();
+                context.setCurrentRole(CodegenRole.MARSHAL);
</pre><pre class="diff" id="context">                 for (Iterator i = types.iterator(); i.hasNext(); ) {
                         XSDTypeDefinition typeDef = (XSDTypeDefinition)i.next();
                         if (typeDef instanceof XSDComplexTypeDefinition) {
                                 XSDComplexTypeDefinition ctype = (XSDComplexTypeDefinition)typeDef;
</pre><pre class="diff" id="removed">-                                conversionMethodFor(ctype);
</pre><pre class="diff" id="added">+<span id="addedchars">//</span>                                conversionMethodFor(ctype);
+                                context.functionFor(ctype);
</pre><pre class="diff" id="context">                         }
                 }
 //                List elements = schema.getElementDeclarations();
</pre><pre class="diff"><small id="info">@@ -61,9 +63,10 @@
</small></pre><pre class="diff" id="context"> //                        XSDElementDeclaration elementDecl = (XSDElementDeclaration)i.next();
 //                        conversionMethodFor(elementDecl);
 //                }
</pre><pre class="diff" id="added">+                context.popAttrScope();
</pre><pre class="diff" id="context">         }
 
</pre><pre class="diff" id="removed">-        private <span id="removedchars">ASMethod</span> createMethodForType(XSDTypeDefinition typeDef) {
</pre><pre class="diff" id="added">+        private <span id="addedchars">MappingFunction</span> createMethodForType(XSDTypeDefinition typeDef) {
</pre><pre class="diff" id="context">                 ASCompilationUnit unit = getClassForNamespace(typeDef.getTargetNamespace());
                 ASClassType clazz = (ASClassType)unit.getType();
                 String typeName = xmlReturnTypeFor(typeDef);
</pre><pre class="diff"><small id="info">@@ -71,10 +74,10 @@
</small></pre><pre class="diff" id="context">                 ASMethod meth = clazz.newMethod(methodName, Visibility.PUBLIC, typeName);
                 buildMethodParams(meth, typeDef);
                 meth.setStatic(true);
</pre><pre class="diff" id="removed">-                return meth;
</pre><pre class="diff" id="added">+                return new BasicMappingFunction(unit, meth);
</pre><pre class="diff" id="context">         }
 
</pre><pre class="diff" id="removed">-        private <span id="removedchars">ASMethod</span> createMethodForElement(XSDElementDeclaration elementDecl) {
</pre><pre class="diff" id="added">+        private <span id="addedchars">MappingFunction</span> createMethodForElement(XSDElementDeclaration elementDecl) {
</pre><pre class="diff" id="context">                 ASCompilationUnit unit = getClassForNamespace(elementDecl.getTargetNamespace());
                 ASClassType clazz = (ASClassType)unit.getType();
                 String typeName = "XML";
</pre><pre class="diff"><small id="info">@@ -82,7 +85,7 @@
</small></pre><pre class="diff" id="context">                 ASMethod meth = clazz.newMethod(methodName, Visibility.PUBLIC, typeName);
                 buildMethodParams(meth, elementDecl);
                 meth.setStatic(true);
</pre><pre class="diff" id="removed">-                return meth;
</pre><pre class="diff" id="added">+                return new BasicMappingFunction(unit, meth);
</pre><pre class="diff" id="context">         }
 
         private void buildMethodParams(ASMethod meth, XSDElementDeclaration elementDecl) {
</pre><pre class="diff"><small id="info">@@ -143,13 +146,6 @@
</small></pre><pre class="diff" id="context">                 return cu;
         }
 
</pre><pre class="diff" id="removed">-        public static StatementContainer getCurrentMethodCode(CodegenContext context) {
-                return (StatementContainer)context.getAttribute(KEY_MARSHAL_CURRENT_METHOD_CODE);
-        }
-        public static void setCurrentMethodCode(CodegenContext context, StatementContainer code) {
-                context.setAttribute(KEY_MARSHAL_CURRENT_METHOD_CODE, code);
-        }
-
</pre><pre class="diff" id="context">         public static String getCurrentSourceExpr(CodegenContext context) {
                 return (String)context.getAttribute(KEY_MARSHAL_CURRENT_SOURCE_EXPR);
         }
</pre><pre class="diff"><small id="info">@@ -164,26 +160,7 @@
</small></pre><pre class="diff" id="context">                 context.setAttribute(KEY_MARSHAL_CURRENT_TARGET_PARENTELEMENT_EXPR, expr);
         }
 
</pre><pre class="diff" id="removed">-        public MappingFunction conversionMethodFor(XSDNamedComponent namedComponent) {
-                MappingFunctionStore mappingFunctions = context.getMappingFunctionStore();
-                ASMethod convert = mappingFunctions.get(CodegenRole.MARSHAL, namedComponent);
-                ASCompilationUnit unit = getClassForNamespace(namedComponent.getTargetNamespace());
-                if (convert == null) {
-                        convert = createMethodFor(namedComponent);
-                        mappingFunctions.put(CodegenRole.MARSHAL, namedComponent, convert);
-                        // 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 recusion,
-                        context.pushAttrScope();
-                        setCurrentMethodCode(context, convert);
-                        context.setCurrentRole(CodegenRole.MARSHAL);
-                        context.generateCode(namedComponent);
-                        context.popAttrScope();
-                }
-                return new BasicMappingFunction(qualifiedMethodName(unit, convert));
-        }
-
-        private ASMethod createMethodFor(XSDNamedComponent namedComponent) {
</pre><pre class="diff" id="added">+        public MappingFunction createMethodFor(XSDConcreteComponent namedComponent) {
</pre><pre class="diff" id="context">                 if (namedComponent instanceof XSDElementDeclaration) {
                         return createMethodForElement((XSDElementDeclaration)namedComponent);
                 }
</pre><pre class="diff"><small id="info">@@ -193,14 +170,6 @@
</small></pre><pre class="diff" id="context">                 throw new IllegalArgumentException(namedComponent.getClass().getName());
         }
 
</pre><pre class="diff" id="removed">-        private String qualifiedMethodName(ASCompilationUnit unit, ASMethod convert) {
-                String pkgName = unit.getPackageName();
-                if (pkgName == null) {
-                        return unit.getType().getName() + "." + convert.getName();
-                }
-                return pkgName + "." + unit.getType().getName() + "." + convert.getName();
-        }
-
</pre><pre class="diff" id="context">         public static void warn(String msg) {
                 System.err.println(msg);
         }
</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>UnmarshalBuilder.java</b></big> <small id="info">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/UnmarshalBuilder.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/UnmarshalBuilder.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -9,8 +9,8 @@
</small></pre><pre class="diff" id="context"> import java.util.List;
 import java.util.Map;
 import org.eclipse.xsd.XSDComplexTypeDefinition;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDConcreteComponent;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDElementDeclaration;
</pre><pre class="diff" id="removed">-import org.eclipse.xsd.XSDNamedComponent;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDSchema;
 import org.eclipse.xsd.XSDSimpleTypeDefinition;
 import org.eclipse.xsd.XSDTypeDefinition;
</pre><pre class="diff"><small id="info">@@ -21,7 +21,6 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
 import uk.co.badgersinfoil.metaas.dom.ASField;
 import uk.co.badgersinfoil.metaas.dom.ASMethod;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.metaas.dom.StatementContainer;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.Visibility;
 
 
</pre><pre class="diff"><small id="info">@@ -46,11 +45,13 @@
</small></pre><pre class="diff" id="context"> 
         public void processSchema(XSDSchema schema) {
                 List types = schema.getTypeDefinitions();
</pre><pre class="diff" id="added">+                context.pushAttrScope();
+                context.setCurrentRole(CodegenRole.UNMARSHAL);
</pre><pre class="diff" id="context">                 for (Iterator i = types.iterator(); i.hasNext(); ) {
                         XSDTypeDefinition typeDef = (XSDTypeDefinition)i.next();
                         if (typeDef instanceof XSDComplexTypeDefinition) {
                                 XSDComplexTypeDefinition ctype = (XSDComplexTypeDefinition)typeDef;
</pre><pre class="diff" id="removed">-                                conversionMethodFor(ctype);
</pre><pre class="diff" id="added">+                                context.functionFor(ctype);
</pre><pre class="diff" id="context">                         }
                 }
 //                List elements = schema.getElementDeclarations();
</pre><pre class="diff"><small id="info">@@ -58,9 +59,10 @@
</small></pre><pre class="diff" id="context"> //                        XSDElementDeclaration elementDecl = (XSDElementDeclaration)i.next();
 //                        conversionMethodFor(elementDecl);
 //                }
</pre><pre class="diff" id="added">+                context.popAttrScope();
</pre><pre class="diff" id="context">         }
 
</pre><pre class="diff" id="removed">-        private <span id="removedchars">ASMethod</span> createMethodForType(XSDTypeDefinition typeDef) {
</pre><pre class="diff" id="added">+        private <span id="addedchars">MappingFunction</span> createMethodForType(XSDTypeDefinition typeDef) {
</pre><pre class="diff" id="context">                 ASCompilationUnit unit = getClassForNamespace(typeDef.getTargetNamespace());
                 ASClassType clazz = (ASClassType)unit.getType();
                 TypeDescriptor typeDesc = context.getTypeDescriptor(typeDef);
</pre><pre class="diff"><small id="info">@@ -77,10 +79,10 @@
</small></pre><pre class="diff" id="context">                         arg.setDescription(doc);
                 }
                 meth.setStatic(true);
</pre><pre class="diff" id="removed">-                return meth;
</pre><pre class="diff" id="added">+                return new BasicMappingFunction(unit, meth);
</pre><pre class="diff" id="context">         }
 
</pre><pre class="diff" id="removed">-        private <span id="removedchars">ASMethod</span> createMethodForElement(XSDElementDeclaration elementDecl) {
</pre><pre class="diff" id="added">+        private <span id="addedchars">MappingFunction</span> createMethodForElement(XSDElementDeclaration elementDecl) {
</pre><pre class="diff" id="context">                 ASCompilationUnit unit = getClassForNamespace(elementDecl.getTargetNamespace());
                 ASClassType clazz = (ASClassType)unit.getType();
                 TypeDescriptor typeDesc = context.getTypeDescriptor(elementDecl);
</pre><pre class="diff"><small id="info">@@ -99,7 +101,7 @@
</small></pre><pre class="diff" id="context">                         meth.setVisibility(Visibility.PRIVATE);
                 }
                 meth.setStatic(true);
</pre><pre class="diff" id="removed">-                return meth;
</pre><pre class="diff" id="added">+                return new BasicMappingFunction(unit, meth);
</pre><pre class="diff" id="context">         }
 
         private ASCompilationUnit getClassForNamespace(String namespace) {
</pre><pre class="diff"><small id="info">@@ -122,14 +124,6 @@
</small></pre><pre class="diff" id="context">                 return cu;
         }
 
</pre><pre class="diff" id="removed">-        public static StatementContainer getCurrentMethodCode(CodegenContext context) {
-                return (StatementContainer)context.getAttribute(KEY_UNMARSHAL_CURRENT_METHOD_CODE);
-        }
-
-        public static void setCurrentMethodCode(CodegenContext context, StatementContainer code) {
-                context.setAttribute(KEY_UNMARSHAL_CURRENT_METHOD_CODE, code);
-        }
-
</pre><pre class="diff" id="context">         public static String getCurrentSourceExpr(CodegenContext context) {
                 return (String)context.getAttribute(KEY_UNMARSHAL_CURRENT_SOURCE_EXPR);
         }
</pre><pre class="diff"><small id="info">@@ -137,26 +131,7 @@
</small></pre><pre class="diff" id="context">                 context.setAttribute(KEY_UNMARSHAL_CURRENT_SOURCE_EXPR, expr);
         }
 
</pre><pre class="diff" id="removed">-        public MappingFunction conversionMethodFor(XSDNamedComponent namedComponent) {
-                MappingFunctionStore mappingFunctions = context.getMappingFunctionStore();
-                ASMethod convert = mappingFunctions.get(CodegenRole.UNMARSHAL, namedComponent);
-                ASCompilationUnit unit = getClassForNamespace(namedComponent.getTargetNamespace());
-                if (convert == null) {
-                        convert = createMethodFor(namedComponent);
-                        mappingFunctions.put(CodegenRole.UNMARSHAL, namedComponent, convert);
-                        // 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 recusion,
-                        context.pushAttrScope();
-                        setCurrentMethodCode(context, convert);
-                        context.setCurrentRole(CodegenRole.UNMARSHAL);
-                        context.generateCode(namedComponent);
-                        context.popAttrScope();
-                }
-                return new BasicMappingFunction(qualifiedMethodName(unit, convert));
-        }
-
-        private ASMethod createMethodFor(XSDNamedComponent namedComponent) {
</pre><pre class="diff" id="added">+        public MappingFunction createMethodFor(XSDConcreteComponent namedComponent) {
</pre><pre class="diff" id="context">                 if (namedComponent instanceof XSDElementDeclaration) {
                         return createMethodForElement((XSDElementDeclaration)namedComponent);
                 }
</pre><pre class="diff"><small id="info">@@ -166,14 +141,6 @@
</small></pre><pre class="diff" id="context">                 throw new IllegalArgumentException(namedComponent.getClass().getName());
         }
 
</pre><pre class="diff" id="removed">-        private String qualifiedMethodName(ASCompilationUnit unit, ASMethod convert) {
-                String pkgName = unit.getPackageName();
-                if (pkgName == null) {
-                        return unit.getType().getName() + "." + convert.getName();
-                }
-                return pkgName + "." + unit.getType().getName() + "." + convert.getName();
-        }
-
</pre><pre class="diff" id="context">         public static void warn(String msg) {
                 System.err.println(msg);
         }
</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>AbstractMappingComponent.java</b></big> <small id="info">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractMappingComponent.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractMappingComponent.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -27,10 +27,10 @@
</small></pre><pre class="diff" id="context">                 throw new RuntimeException(getClass().getName()+" does not suppport operation getTypeDescriptor()");
         }
 
</pre><pre class="diff" id="removed">-        public MappingFunction functionFor(CodegenContext context, 
-                                            XSDConcreteComponent component)
</pre><pre class="diff" id="added">+        public MappingFunction createFunction(CodegenContext context,
+                                       XSDConcreteComponent component)
</pre><pre class="diff" id="context">         {
                 CodegenRole role = context.getCurrentRole();
</pre><pre class="diff" id="removed">-                throw new RuntimeException(getClass().getName()+" does not suppport operation <span id="removedchars">functionFor</span>(role="+role+")");
</pre><pre class="diff" id="added">+                throw new RuntimeException(getClass().getName()+" does not suppport operation <span id="addedchars">createFunction</span>(role="+role+")");
</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="file10" /><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">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractSimpleTypeComponent.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractSimpleTypeComponent.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -6,7 +6,6 @@
</small></pre><pre class="diff" id="context"> 
 import org.eclipse.xsd.XSDConcreteComponent;
 import org.eclipse.xsd.XSDSimpleTypeDefinition;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.asxsd.BasicMappingFunction;
</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"><small id="info">@@ -29,12 +28,12 @@
</small></pre><pre class="diff" id="context">         {
                 CodegenRole role = context.getCurrentRole();
                 if (role == CodegenRole.UNMARSHAL) {
</pre><pre class="diff" id="removed">-                        StatementContainer block = UnmarshalBuilder.getCurrentMethodCode(context);
</pre><pre class="diff" id="added">+                        StatementContainer block = context.getCurrentMethodCode();
</pre><pre class="diff" id="context">                         MappingFunction fn = context.functionFor(component);
                         String converted = fn.appliedTo("thisValue");
                         block.addStmt("return "+converted);
                 } else if (role == CodegenRole.MARSHAL) {
</pre><pre class="diff" id="removed">-                        StatementContainer block = MarshalBuilder.getCurrentMethodCode(context);
</pre><pre class="diff" id="added">+                        StatementContainer block = context.getCurrentMethodCode();
</pre><pre class="diff" id="context">                         MappingFunction fn = context.functionFor(component);
                         String converted = fn.appliedTo("thisValue");
                         block.addStmt("return "+converted);
</pre><pre class="diff"><small id="info">@@ -45,21 +44,17 @@
</small></pre><pre class="diff" id="context"> 
         protected abstract TypeDescriptor getTypeDescriptorFor(CodegenContext context,
                                                                XSDSimpleTypeDefinition simpleType);
</pre><pre class="diff" id="removed">-
-        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component) {
-                XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition)component;
-                return functionFor(context, simpleType);
-        }
-
-        protected MappingFunction functionFor(CodegenContext context, XSDSimpleTypeDefinition simpleType) {
</pre><pre class="diff" id="added">+        public MappingFunction createFunction(CodegenContext context,
+                                              XSDConcreteComponent component)
+        {
</pre><pre class="diff" id="context">                 CodegenRole role = context.getCurrentRole();
                 if (role == CodegenRole.UNMARSHAL) {
                         UnmarshalBuilder builder = context.getUnmarshalBuilder();
</pre><pre class="diff" id="removed">-                        return builder.conversionMethodFor(simpleType);
</pre><pre class="diff" id="added">+                        return builder.createMethodFor(component);
</pre><pre class="diff" id="context">                 }
                 if (role == CodegenRole.MARSHAL) {
                         MarshalBuilder builder = context.getMarshalBuilder();
</pre><pre class="diff" id="removed">-                        return builder.conversionMethodFor(simpleType);
</pre><pre class="diff" id="added">+                        return builder.createMethodFor(component);
</pre><pre class="diff" id="context">                 }
                 throw new IllegalArgumentException(getClass().getName() + " does not support role "+role);
         }
</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>ArrayElementDeclarationComponent.java</b></big> <small id="info">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayElementDeclarationComponent.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayElementDeclarationComponent.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -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.BasicMappingFunction;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.MappingComponent;
 import uk.co.badgersinfoil.asxsd.MarshalBuilder;
 import uk.co.badgersinfoil.asxsd.TypeBuilder;
</pre><pre class="diff"><small id="info">@@ -45,7 +44,7 @@
</small></pre><pre class="diff" id="context">                 XSDElementDeclaration elementDecl = (XSDElementDeclaration)component;
                 CodegenRole role = context.getCurrentRole();
                 if (role == CodegenRole.MARSHAL) {
</pre><pre class="diff" id="removed">-                        StatementContainer containingBlock = MarshalBuilder.getCurrentMethodCode(context);
</pre><pre class="diff" id="added">+                        StatementContainer containingBlock = context.getCurrentMethodCode();
</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"><small id="info">@@ -55,7 +54,7 @@
</small></pre><pre class="diff" id="context">                         String accessExpr = MarshalBuilder.getCurrentSourceExpr(context);
                         StatementContainer forEachLoop = containingBlock.newForEachIn("var "+childVarName+":"+elementType, accessExpr);
                         context.pushAttrScope();
</pre><pre class="diff" id="removed">-                        MarshalBuilder.setCurrentMethodCode(context, forEachLoop);
</pre><pre class="diff" id="added">+                        context.setCurrentMethodCode(forEachLoop);
</pre><pre class="diff" id="context">                         MarshalBuilder.setCurrentSourceExpr(context, childVarName);
                         MarshalBuilder.setCurrentTargetParentElementExpr(context, listName);
 
</pre><pre class="diff"><small id="info">@@ -78,12 +77,13 @@
</small></pre><pre class="diff" id="context">                 }
         }
 
</pre><pre class="diff" id="removed">-        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component) {
</pre><pre class="diff" id="added">+        public MappingFunction createFunction(CodegenContext context,
+                                              XSDConcreteComponent component)
+        {
</pre><pre class="diff" id="context">                 CodegenRole role = context.getCurrentRole();
                 if (role == CodegenRole.UNMARSHAL) {
</pre><pre class="diff" id="removed">-                        XSDElementDeclaration elementDecl = (XSDElementDeclaration)component;
</pre><pre class="diff" id="context">                         UnmarshalBuilder builder = context.getUnmarshalBuilder();
</pre><pre class="diff" id="removed">-                        return builder.conversionMethodFor(elementDecl);
</pre><pre class="diff" id="added">+                        return builder.createMethodFor(component);
</pre><pre class="diff" id="context">                 }
                 throw new IllegalArgumentException(getClass().getName() + " does not support role "+role);
         }
</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>ArrayTypeDeclarationComponent.java</b></big> <small id="info">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayTypeDeclarationComponent.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayTypeDeclarationComponent.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -11,9 +11,7 @@
</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.BasicMappingFunction;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.MappingComponent;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.asxsd.MarshalBuilder;
</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">@@ -45,7 +43,7 @@
</small></pre><pre class="diff" id="context">                         ASClassType clazz = TypeBuilder.getCurrentType(context);
                         clazz.setDescription("Gah!  This type should not have been generated");
                 } else if (role == CodegenRole.MARSHAL) {
</pre><pre class="diff" id="removed">-                        StatementContainer block = MarshalBuilder.getCurrentMethodCode(context);
</pre><pre class="diff" id="added">+                        StatementContainer block = context.getCurrentMethodCode();
</pre><pre class="diff" id="context">                         block.addStmt("default xml namespace = NAMESPACE");
                         XSDElementDeclaration listElement = XSDUtils.getElementIfContainerForList((XSDTypeDefinition)component);
                         String elementType = context.getTypeDescriptor(listElement).getTypeName();
</pre><pre class="diff"><small id="info">@@ -68,7 +66,7 @@
</small></pre><pre class="diff" id="context">                         }
                         block.addStmt("return _result");
                 } else if (role == CodegenRole.UNMARSHAL) {
</pre><pre class="diff" id="removed">-                        StatementContainer block = UnmarshalBuilder.getCurrentMethodCode(context);
</pre><pre class="diff" id="added">+                        StatementContainer block = context.getCurrentMethodCode();
</pre><pre class="diff" id="context">                         block.addStmt("default xml namespace = NAMESPACE");
                         TypeDescriptor typeDesc = context.getTypeDescriptor(component);
                         block.addStmt("var _result:"+typeDesc.getTypeName()+" = new "+typeDesc.getTypeName()+"()");
</pre><pre class="diff"><small id="info">@@ -84,12 +82,13 @@
</small></pre><pre class="diff" id="context">                 }
         }
 
</pre><pre class="diff" id="removed">-        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component) {
</pre><pre class="diff" id="added">+        public MappingFunction createFunction(CodegenContext context,
+                                              XSDConcreteComponent component)
+        {
</pre><pre class="diff" id="context">                 CodegenRole role = context.getCurrentRole();
                 if (role == CodegenRole.UNMARSHAL) {
</pre><pre class="diff" id="removed">-                        XSDTypeDefinition typeDef = (XSDTypeDefinition)component;
</pre><pre class="diff" id="context">                         UnmarshalBuilder builder = context.getUnmarshalBuilder();
</pre><pre class="diff" id="removed">-                        return builder.conversionMethodFor(typeDef);
</pre><pre class="diff" id="added">+                        return builder.createMethodFor(component);
</pre><pre class="diff" id="context">                 }
                 throw new IllegalArgumentException(getClass().getName() + " does not support role "+role);
         }
</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>AttributeDeclarationComponent.java</b></big> <small id="info">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AttributeDeclarationComponent.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AttributeDeclarationComponent.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -5,9 +5,7 @@
</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.MarshalBuilder;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.StringUtils;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.asxsd.UnmarshalBuilder;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.StatementContainer;
 
 
</pre><pre class="diff"><small id="info">@@ -23,13 +21,13 @@
</small></pre><pre class="diff" id="context">                 XSDAttributeDeclaration attrDecl = (XSDAttributeDeclaration)component;
                 CodegenRole role = context.getCurrentRole();
                 if (role == CodegenRole.UNMARSHAL) {
</pre><pre class="diff" id="removed">-                        StatementContainer code = UnmarshalBuilder.getCurrentMethodCode(context);
</pre><pre class="diff" id="added">+                        StatementContainer code = context.getCurrentMethodCode();
</pre><pre class="diff" id="context">                         String attrAccessExpr = "thisElement."+StringUtils.attrAccess(attrDecl);
                         MappingFunction function = context.functionFor(attrDecl);
                         String converted = function.appliedTo(attrAccessExpr);
                         code.addStmt("_result."+context.variableNameFor(attrDecl)+" = "+converted);
                 } else if (role == CodegenRole.MARSHAL) {
</pre><pre class="diff" id="removed">-                        StatementContainer code = MarshalBuilder.getCurrentMethodCode(context);
</pre><pre class="diff" id="added">+                        StatementContainer code = context.getCurrentMethodCode();
</pre><pre class="diff" id="context">                         String propertyNameExpr = "thisObject."+context.variableNameFor(attrDecl);
                         MappingFunction function = context.functionFor(attrDecl);
                         String converted = function.appliedTo(propertyNameExpr);
</pre><pre class="diff"><small id="info">@@ -38,16 +36,4 @@
</small></pre><pre class="diff" id="context">                         super.generateCode(context, component);
                 }
         }
</pre><pre class="diff" id="removed">-
-        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component) {
-                XSDAttributeDeclaration attrDecl = (XSDAttributeDeclaration)component;
-                CodegenRole role = context.getCurrentRole();
-                if (role == CodegenRole.UNMARSHAL) {
-                        return context.functionFor(attrDecl.getTypeDefinition());
-                }
-                if (role == CodegenRole.MARSHAL) {
-                        return context.functionFor(attrDecl.getTypeDefinition());
-                }
-                return super.functionFor(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="file14" /><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">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AttributeUseComponent.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AttributeUseComponent.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -6,11 +6,9 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.CodegenContext;
 import uk.co.badgersinfoil.asxsd.CodegenRole;
 import uk.co.badgersinfoil.asxsd.DocUtils;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.asxsd.MarshalBuilder;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.StringUtils;
 import uk.co.badgersinfoil.asxsd.TypeBuilder;
 import uk.co.badgersinfoil.asxsd.TypeDescriptor;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.asxsd.UnmarshalBuilder;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASClassType;
 import uk.co.badgersinfoil.metaas.dom.ASField;
 import uk.co.badgersinfoil.metaas.dom.ASIfStatement;
</pre><pre class="diff"><small id="info">@@ -31,10 +29,10 @@
</small></pre><pre class="diff" id="context">                 if (role == CodegenRole.UNMARSHAL) {
                         context.pushAttrScope();
                         if (!attrUse.isRequired()) {
</pre><pre class="diff" id="removed">-                                StatementContainer code = UnmarshalBuilder.getCurrentMethodCode(context);
</pre><pre class="diff" id="added">+                                StatementContainer code = context.getCurrentMethodCode();
</pre><pre class="diff" id="context">                                 String attrAccessExpr = "thisElement."+StringUtils.attrAccess(attrUse.getAttributeDeclaration());
                                 ASIfStatement ifStmt = code.newIf(attrAccessExpr+".length() &gt; 0");
</pre><pre class="diff" id="removed">-                                UnmarshalBuilder.setCurrentMethodCode(context, ifStmt);
</pre><pre class="diff" id="added">+                                context.setCurrentMethodCode(ifStmt);
</pre><pre class="diff" id="context">                         }
                         XSDAttributeDeclaration attrDecl = attrUse.getAttributeDeclaration();
                         context.generateCode(attrDecl);
</pre><pre class="diff"><small id="info">@@ -42,10 +40,10 @@
</small></pre><pre class="diff" id="context">                 } else if (role == CodegenRole.MARSHAL) {
                         context.pushAttrScope();
                         if (!attrUse.isRequired()) {
</pre><pre class="diff" id="removed">-                                StatementContainer code = MarshalBuilder.getCurrentMethodCode(context);
</pre><pre class="diff" id="added">+                                StatementContainer code = context.getCurrentMethodCode();
</pre><pre class="diff" id="context">                                 String propertyNameExpr = "thisObject."+context.variableNameFor(attrUse.getAttributeDeclaration());
                                 ASIfStatement ifStmt = code.newIf(propertyNameExpr+" != null");
</pre><pre class="diff" id="removed">-                                MarshalBuilder.setCurrentMethodCode(context, ifStmt);
</pre><pre class="diff" id="added">+                                context.setCurrentMethodCode(ifStmt);
</pre><pre class="diff" id="context">                         }
                         XSDAttributeDeclaration attrDecl = attrUse.getAttributeDeclaration();
                         context.generateCode(attrDecl);
</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>BooleanSimpleTypeComponent.java</b></big> <small id="info">143 -&gt; 144</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/BooleanSimpleTypeComponent.java        2007-09-05 23:31:58 UTC (rev 143)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/BooleanSimpleTypeComponent.java        2007-09-09 00:10:16 UTC (rev 144)
@@ -9,11 +9,7 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDVariety;
 import uk.co.badgersinfoil.asxsd.CodegenContext;
 import uk.co.badgersinfoil.asxsd.CodegenRole;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.asxsd.MappingFunction;
-import uk.co.badgersinfoil.asxsd.BasicMappingFunction;
-import uk.co.badgersinfoil.asxsd.MarshalBuilder;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.TypeDescriptor;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.asxsd.UnmarshalBuilder;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.StatementContainer;
 
 
</pre><pre class="diff"><small id="info">@@ -32,12 +28,12 @@
</small></pre><pre class="diff" id="context">        &n