<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">+6</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr class="alt"><td><tt><a href="#file2">CodegenContext.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td></td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr><td><tt><a href="#file3">MappingCodeGenerator.java</a></tt> </td><td></td><td align="right" id="added">+26</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">144 -> 145</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></td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr><td><tt><a href="#file5">MappingRegistryFactory.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td></td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr class="alt"><td><tt>components/<a href="#file6">AbstractMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+4</td><td></td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr><td><tt> /<a href="#file7">ArrayElementDeclarationComponent.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">144 -> 145</td></tr>
<tr class="alt"><td><tt> /<a href="#file8">ArrayTypeDeclarationComponent.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">144 -> 145</td></tr>
<tr><td><tt> /<a href="#file9">ElementDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+42</td><td align="right" id="removed">-30</td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr class="alt"><td><tt> /<a href="#file10"><span id="added">ElementDeclarationReferenceComponent.java</span></a></tt> </td><td></td><td align="right" id="added">+57</td><td></td><td nowrap="nowrap" align="right">added 145</td></tr>
<tr><td><tt> /<a href="#file11">OptionallyOccuringParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+5</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr class="alt"><td><tt> /<a href="#file12">SinglyOccuringParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+6</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr><td><tt> /<a href="#file13">StringSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+5</td><td></td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr class="alt"><td><tt> /<a href="#file14">UnknownSimpleTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+7</td><td></td><td nowrap="nowrap" align="center">144 -> 145</td></tr>
<tr><td></td><td></td><td align="right" id="added">+165</td><td align="right" id="removed">-37</td><td></td></tr>
</table>
<small id="info">1 added + 13 modified, total 14 files</small><br />
<pre class="comment">
Fix function-generation bugs introduced by the last commit.
Also split element-ref handling out of ElementDeclarationComponent and into
a new ElementDeclarationReferenceComponent class.
</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">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/BaseCodegenContext.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/BaseCodegenContext.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -58,10 +58,16 @@
</small></pre><pre class="diff" id="context">         }
        public MappingFunction functionFor(XSDConcreteComponent component) {
</pre><pre class="diff" id="added">+                MappingComponent mapComp = componentFor(component);
+                return mapComp.functionFor(this, component);
+        }
+
+        public MappingFunction getOrCreateFunction(XSDConcreteComponent component) {
</pre><pre class="diff" id="context">                 XSDNamedComponent namedComponent = (XSDNamedComponent)component;
                CodegenRole role = getCurrentRole();
                MappingFunction convert = functionStore.get(role, namedComponent);
                if (convert == null) {
</pre><pre class="diff" id="added">+                        pushAttrScope();
</pre><pre class="diff" id="context">                         convert = createFunction(namedComponent);
                        if (convert.getImplementation() == null) {
                                throw new RuntimeException("null fn for "+namedComponent);
</pre><pre class="diff"><small id="info">@@ -70,7 +76,6 @@
</small></pre><pre class="diff" id="context">                         // now that we've got a ref to the method in the map,
                        // its safe to generate the method body without the
                        // potential for infinite recursion,
</pre><pre class="diff" id="removed">-                        pushAttrScope();
</pre><pre class="diff" id="context">                         setCurrentMethodCode(convert.getImplementation());
                        generateCode(namedComponent);
                        popAttrScope();
</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">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenContext.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/CodegenContext.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -20,6 +20,8 @@
</small></pre><pre class="diff" id="context">
        public MappingFunction createFunction(XSDConcreteComponent component);
</pre><pre class="diff" id="added">+        public MappingFunction getOrCreateFunction(XSDConcreteComponent component);
+
</pre><pre class="diff" id="context">         public StatementContainer getCurrentMethodCode();
        public void setCurrentMethodCode(StatementContainer code);
</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">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingCodeGenerator.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingCodeGenerator.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -9,6 +9,7 @@
</small></pre><pre class="diff" id="context"> import java.util.Iterator;
import java.util.List;
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.XSDSchema;
import org.eclipse.xsd.XSDTypeDefinition;
import uk.co.badgersinfoil.metaas.ActionScriptProject;
</pre><pre class="diff"><small id="info">@@ -19,13 +20,20 @@
</small></pre><pre class="diff" id="context">         private UnmarshalBuilder unmarshalerBuilder;
        private MarshalBuilder marshalerBuilder;
        private TypeBuilder typeBuilder;
</pre><pre class="diff" id="added">+        private CodegenContext context;
</pre><pre class="diff" id="context">
        public MappingCodeGenerator(ActionScriptProject project) {
                typeBuilder = new TypeBuilder(project, nameGen);
</pre><pre class="diff" id="removed">-                unmarshalerBuilder = new UnmarshalBuilder(project, typeBuilder);
</pre><pre class="diff" id="added">+                BaseCodegenContext ctxt = new BaseCodegenContext(MappingRegistryFactory.createMappingRegistry(), project);
+                ctxt.setTypeBuilder(typeBuilder);
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">-                marshalerBuilder = new MarshalBuilder(project, typeBuilder);
</pre><pre class="diff" id="added">+                unmarshalerBuilder = new UnmarshalBuilder(project, typeBuilder, ctxt);
+                ctxt.setUnmarshalBuilder(unmarshalerBuilder);
+
+                marshalerBuilder = new MarshalBuilder(project, typeBuilder, ctxt);
+                ctxt.setMarshalBuilder(marshalerBuilder);
+                context = ctxt;
</pre><pre class="diff" id="context">         }
        public void processSchema(XSDSchema schema) throws IOException {
</pre><pre class="diff"><small id="info">@@ -51,6 +59,22 @@
</small></pre><pre class="diff" id="context">         public MarshalBuilder getMarshalerBuilder() {
                return marshalerBuilder;
        }
</pre><pre class="diff" id="added">+        
+        public MappingFunction marshalMethodFor(XSDConcreteComponent component) {
+                context.pushAttrScope();
+                context.setCurrentRole(CodegenRole.MARSHAL);
+                MappingFunction fn = context.functionFor(component);
+                context.popAttrScope();
+                return fn;
+        }
+        
+        public MappingFunction unmarshalMethodFor(XSDConcreteComponent component) {
+                context.pushAttrScope();
+                context.setCurrentRole(CodegenRole.UNMARSHAL);
+                MappingFunction fn = context.functionFor(component);
+                context.popAttrScope();
+                return fn;
+        }
</pre><pre class="diff" id="context">
        public TypeBuilder getTypeBuilder() {
                return typeBuilder;
</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">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingComponent.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -11,5 +11,6 @@
</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="added">+        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component);
</pre><pre class="diff" id="context">         public MappingFunction createFunction(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>MappingRegistryFactory.java</b></big> <small id="info">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingRegistryFactory.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/MappingRegistryFactory.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -13,6 +13,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.components.ComplexTypeComponent;
import uk.co.badgersinfoil.asxsd.components.DateTimeSimpleTypeComponent;
import uk.co.badgersinfoil.asxsd.components.ElementDeclarationComponent;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.components.ElementDeclarationReferenceComponent;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.components.FloatSimpleTypeComponent;
import uk.co.badgersinfoil.asxsd.components.IntSimpleTypeComponent;
import uk.co.badgersinfoil.asxsd.components.ModelGroupParticleComponent;
</pre><pre class="diff"><small id="info">@@ -35,6 +36,7 @@
</small></pre><pre class="diff" id="context">                 reg.register(new ArrayElementDeclarationComponent());
                reg.register(new ArrayTypeDeclarationComponent());
                reg.register(new ChoiceMappingComponent());
</pre><pre class="diff" id="added">+                reg.register(new ElementDeclarationReferenceComponent());
</pre><pre class="diff" id="context">                 reg.register(new ElementDeclarationComponent());
                reg.register(new FloatSimpleTypeComponent());
                reg.register(new IntSimpleTypeComponent());
</pre></div>
<hr /><a name="file6" /><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">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractMappingComponent.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/AbstractMappingComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -33,4 +33,8 @@
</small></pre><pre class="diff" id="context">                 CodegenRole role = context.getCurrentRole();
                throw new RuntimeException(getClass().getName()+" does not suppport operation createFunction(role="+role+")");
        }
</pre><pre class="diff" id="added">+
+        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component) {
+                return context.getOrCreateFunction(component);
+        }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file7" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>ArrayElementDeclarationComponent.java</b></big> <small id="info">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayElementDeclarationComponent.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayElementDeclarationComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -22,7 +22,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.StatementContainer;
import uk.co.badgersinfoil.metaas.dom.Visibility;
</pre><pre class="diff" id="removed">-public class ArrayElementDeclarationComponent <span id="removedchars">implements </span>MappingComponent {
</pre><pre class="diff" id="added">+public class ArrayElementDeclarationComponent <span id="addedchars">extends Abstract</span>MappingComponent {
</pre><pre class="diff" id="context">
        public TypeDescriptor getTypeDescriptor(CodegenContext context,
         XSDConcreteComponent 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>ArrayTypeDeclarationComponent.java</b></big> <small id="info">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayTypeDeclarationComponent.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ArrayTypeDeclarationComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -20,7 +20,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASConstants;
import uk.co.badgersinfoil.metaas.dom.StatementContainer;
</pre><pre class="diff" id="removed">-public class ArrayTypeDeclarationComponent <span id="removedchars">implements </span>MappingComponent {
</pre><pre class="diff" id="added">+public class ArrayTypeDeclarationComponent <span id="addedchars">extends Abstract</span>MappingComponent {
</pre><pre class="diff" id="context">
        public TypeDescriptor getTypeDescriptor(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>ElementDeclarationComponent.java</b></big> <small id="info">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ElementDeclarationComponent.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ElementDeclarationComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -69,32 +69,25 @@
</small></pre><pre class="diff" id="context">                                 String propertyName = context.variableNameFor(elementDecl);
                                String accessExpr = MarshalBuilder.getCurrentSourceExpr(context);
                                String targetParentExpr = MarshalBuilder.getCurrentTargetParentElementExpr(context);
</pre><pre class="diff" id="removed">-                                if (elementDecl.isElementDeclarationReference()) {
</pre><pre class="diff" id="added">+                                XSDTypeDefinition typeDef = elementDecl.getType();
+                                if (typeDef instanceof XSDSimpleTypeDefinition) {
+                                        block.addStmt("var "+propertyName+":XML = <"+elementDecl.getName()+"/>");
</pre><pre class="diff" id="context">                                         MappingFunction conv = context.functionFor(elementDecl);
                                        String converted = conv.appliedTo(accessExpr);
</pre><pre class="diff" id="removed">-                                        block.addStmt(targetParentExpr+".appendChild("+converted+")");
-                                } else {
-                                        XSDTypeDefinition typeDef = elementDecl.getType();
-                                        if (typeDef instanceof XSDSimpleTypeDefinition) {
-                                                block.addStmt("var "+propertyName+":XML = <"+elementDecl.getName()+"/>");
</pre><pre class="diff" id="added">+                                        block.addStmt(propertyName+".appendChild("+converted+")");
+                                        block.addStmt(targetParentExpr+".appendChild("+propertyName+")");
+                                } else { // then ComplexType
+                                        if (XSDUtils.isAnonymous(typeDef)) {
</pre><pre class="diff" id="context">                                                 MappingFunction conv = context.functionFor(elementDecl);
                                                String converted = conv.appliedTo(accessExpr);
</pre><pre class="diff" id="removed">-                                                block.addStmt(propertyName+".appendChild("+converted+")");
-                                                block.addStmt(targetParentExpr+".appendChild("+propertyName+")");
-                                        } else { // then ComplexType
-//                                                context.generateCode(role, typeDef);
-                                                if (XSDUtils.isAnonymous(typeDef)) {
-                                                        MappingFunction conv = context.functionFor(elementDecl);
-                                                        String converted = conv.appliedTo(accessExpr);
-                                                        block.addStmt(targetParentExpr+".appendChild("+converted+")");
-                                                } else {
-                                                        String access = "_"+context.variableNameFor(elementDecl);
-                                                        block.addStmt("var "+access + ":XML = <"+elementDecl.getName()+"/>");
-                                                        MappingFunction conv = context.functionFor(elementDecl);
-                                                        String converted = conv.appliedTo(access + ", " + accessExpr);
-                                                        block.addStmt(converted);
-                                                        block.addStmt(targetParentExpr+".appendChild("+access+")");
-                                                }
</pre><pre class="diff" id="added">+                                                block.addStmt(targetParentExpr+".appendChild("+converted+")");
+                                        } else {
+                                                String access = "_"+context.variableNameFor(elementDecl);
+                                                block.addStmt("var "+access + ":XML = <"+elementDecl.getName()+"/>");
+                                                MappingFunction conv = context.functionFor(elementDecl);
+                                                String converted = conv.appliedTo(access + ", " + accessExpr);
+                                                block.addStmt(converted);
+                                                block.addStmt(targetParentExpr+".appendChild("+access+")");
</pre><pre class="diff" id="context">                                         }
                                }
                        }
</pre><pre class="diff"><small id="info">@@ -108,18 +101,13 @@
</small></pre><pre class="diff" id="context">                 }
        }
</pre><pre class="diff" id="removed">-        public MappingFunction createFunction(CodegenContext context,
-         XSDConcreteComponent component)
-        {
</pre><pre class="diff" id="added">+        public MappingFunction createFunction(CodegenContext context, XSDConcreteComponent component) {
</pre><pre class="diff" id="context">                 XSDElementDeclaration elementDecl = (XSDElementDeclaration)component;
</pre><pre class="diff" id="removed">-                if (elementDecl.isElementDeclarationReference()) {
-                        return context.createFunction(elementDecl.getResolvedElementDeclaration());
-                }
</pre><pre class="diff" id="context">                 CodegenRole role = context.getCurrentRole();
                if (role == CodegenRole.UNMARSHAL) {
                        UnmarshalBuilder builder = context.getUnmarshalBuilder();
                        XSDTypeDefinition typeDef = elementDecl.getType();
</pre><pre class="diff" id="removed">-                        if (XSDUtils.isAnonymous(typeDef)) {
</pre><pre class="diff" id="added">+                        if (XSDUtils.isAnonymous(typeDef) || elementDecl.isGlobal()) {
</pre><pre class="diff" id="context">                                 return builder.createMethodFor(elementDecl);
                        }
                        return builder.createMethodFor(typeDef);
</pre><pre class="diff"><small id="info">@@ -127,11 +115,35 @@
</small></pre><pre class="diff" id="context">                 if (role == CodegenRole.MARSHAL) {
                        MarshalBuilder builder = context.getMarshalBuilder();
                        XSDTypeDefinition typeDef = elementDecl.getType();
</pre><pre class="diff" id="removed">-                        if (XSDUtils.isAnonymous(typeDef)) {
</pre><pre class="diff" id="added">+                        if (XSDUtils.isAnonymous(typeDef) || elementDecl.isGlobal()) {
</pre><pre class="diff" id="context">                                 return builder.createMethodFor(elementDecl);
                        }
                        return builder.createMethodFor(typeDef);
                }
                throw new IllegalArgumentException(getClass().getName() + " does not support role "+role);
        }
</pre><pre class="diff" id="added">+
+        public MappingFunction functionFor(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                XSDElementDeclaration elementDecl = (XSDElementDeclaration)component;
+                CodegenRole role = context.getCurrentRole();
+                if (role == CodegenRole.UNMARSHAL) {
+                        UnmarshalBuilder builder = context.getUnmarshalBuilder();
+                        XSDTypeDefinition typeDef = elementDecl.getType();
+                        if (XSDUtils.isAnonymous(typeDef)) {
+                                return context.getOrCreateFunction(elementDecl);
+                        }
+                        return context.getOrCreateFunction(typeDef);
+                }
+                if (role == CodegenRole.MARSHAL) {
+                        MarshalBuilder builder = context.getMarshalBuilder();
+                        XSDTypeDefinition typeDef = elementDecl.getType();
+                        if (XSDUtils.isAnonymous(typeDef) || elementDecl.isGlobal()) {
+                                return context.getOrCreateFunction(elementDecl);
+                        }
+                        return context.getOrCreateFunction(typeDef);
+                }
+                throw new IllegalArgumentException(getClass().getName() + " does not support role "+role);
+        }
</pre><pre class="diff" id="context"> }
</pre></div>
<hr /><a name="file10" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader" id="added"><big><b>ElementDeclarationReferenceComponent.java</b></big> <small id="info">added at 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ElementDeclarationReferenceComponent.java         (rev 0)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ElementDeclarationReferenceComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -0,0 +1,57 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.asxsd.components;
+
+import org.eclipse.xsd.XSDConcreteComponent;
+import org.eclipse.xsd.XSDElementDeclaration;
+import uk.co.badgersinfoil.asxsd.CodegenContext;
+import uk.co.badgersinfoil.asxsd.CodegenRole;
+import uk.co.badgersinfoil.asxsd.MappingFunction;
+import uk.co.badgersinfoil.asxsd.MarshalBuilder;
+import uk.co.badgersinfoil.asxsd.TypeDescriptor;
+import uk.co.badgersinfoil.metaas.dom.StatementContainer;
+
+public class ElementDeclarationReferenceComponent extends AbstractMappingComponent {
+
+        public void generateCode(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                XSDElementDeclaration resolvedElementDecl = resolve(component);
+                CodegenRole role = context.getCurrentRole();
+                if (role == CodegenRole.UNMARSHAL) {
+//                        StatementContainer block = context.getCurrentMethodCode();
+//                        String accessExpr = UnmarshalBuilder.getCurrentSourceExpr(context);
+//                        MappingFunction conv = context.functionFor(resolvedElementDecl);
+//                        block.addStmt("return "+conv.appliedTo(accessExpr));
+                        context.generateCode(resolvedElementDecl);
+                } else if (role == CodegenRole.MARSHAL) {
+                        StatementContainer block = context.getCurrentMethodCode();
+                        String accessExpr = MarshalBuilder.getCurrentSourceExpr(context);
+                        String targetParentExpr = MarshalBuilder.getCurrentTargetParentElementExpr(context);
+                        MappingFunction conv = context.functionFor(resolvedElementDecl);
+                        String converted = conv.appliedTo(accessExpr);
+                        block.addStmt(targetParentExpr+".appendChild("+converted+")");
+                } else if (role == CodegenRole.TYPE) {
+                        context.generateCode(resolve(component));
+                } else {
+                        throw new RuntimeException(getClass().getName()+" does not suppport operation generateCodeFor(role="+role+")");
+                }
+        }
+
+        public TypeDescriptor getTypeDescriptor(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                return context.getTypeDescriptor(resolve(component));
+        }
+
+        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component) {
+                return context.functionFor(resolve(component));
+        }
+
+        private static XSDElementDeclaration resolve(XSDConcreteComponent elementDeclaration) {
+                return ((XSDElementDeclaration)elementDeclaration).getResolvedElementDeclaration();
+        }
+
+        public boolean willAccept(XSDConcreteComponent component) {
+                return component instanceof XSDElementDeclaration
+                 && ((XSDElementDeclaration)component).isElementDeclarationReference();
+        }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></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>OptionallyOccuringParticleComponent.java</b></big> <small id="info">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/OptionallyOccuringParticleComponent.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/OptionallyOccuringParticleComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -7,6 +7,7 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDElementDeclaration;
import org.eclipse.xsd.XSDParticle;
import org.eclipse.xsd.XSDParticleContent;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDSimpleTypeDefinition;
</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">@@ -23,11 +24,14 @@
</small></pre><pre class="diff" id="context">         {
                CodegenRole role = context.getCurrentRole();
                if (role == CodegenRole.UNMARSHAL) {
</pre><pre class="diff" id="added">+                        XSDElementDeclaration elementDecl = (XSDElementDeclaration)particle.getContent();
</pre><pre class="diff" id="context">                         StatementContainer block = context.getCurrentMethodCode();
                        String fieldAccess = "_result." + context.variableNameFor(particle.getContent());
                        String accessExpr = "_children[_seq++]";
</pre><pre class="diff" id="added">+                        if (elementDecl.getResolvedElementDeclaration().getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
+                                accessExpr += ".text()";
+                        }
</pre><pre class="diff" id="context">                         MappingFunction unmarshaler = context.functionFor(particle.getContent());
</pre><pre class="diff" id="removed">-                        XSDElementDeclaration elementDecl = (XSDElementDeclaration)particle.getContent();
</pre><pre class="diff" id="context">                         elementDecl = elementDecl.getResolvedElementDeclaration();
                        String qname = "new QName("+ActionScriptFactory.str(elementDecl.getTargetNamespace())+", "+ActionScriptFactory.str(elementDecl.getName())+")";
                        // TODO: don't strictly need to test that there are remaining elements if we know there should be mandatory elements following this optional one,
</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>SinglyOccuringParticleComponent.java</b></big> <small id="info">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/SinglyOccuringParticleComponent.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/SinglyOccuringParticleComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -7,6 +7,7 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDElementDeclaration;
import org.eclipse.xsd.XSDParticle;
import org.eclipse.xsd.XSDParticleContent;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDSimpleTypeDefinition;
</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">@@ -34,9 +35,13 @@
</small></pre><pre class="diff" id="context">         {
                CodegenRole role = context.getCurrentRole();
                if (role == CodegenRole.UNMARSHAL) {
</pre><pre class="diff" id="added">+                        XSDElementDeclaration elementDecl = (XSDElementDeclaration)particle.getContent();
</pre><pre class="diff" id="context">                         StatementContainer block = context.getCurrentMethodCode();
</pre><pre class="diff" id="removed">-                        String fieldAccess = "_result." + context.variableNameFor(<span id="removedchars">particle.getContent()</span>);
</pre><pre class="diff" id="added">+                        String fieldAccess = "_result." + context.variableNameFor(<span id="addedchars">elementDecl</span>);
</pre><pre class="diff" id="context">                         String accessExpr = "_children[_seq++]";
</pre><pre class="diff" id="added">+                        if (elementDecl.getResolvedElementDeclaration().getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
+                                accessExpr += ".text()";
+                        }
</pre><pre class="diff" id="context">                         MappingFunction unmarshaler = context.functionFor(particle.getContent());
                        block.addStmt(fieldAccess + " = " + unmarshaler.appliedTo(accessExpr));
                } else if (role == CodegenRole.MARSHAL) {
</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>StringSimpleTypeComponent.java</b></big> <small id="info">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/StringSimpleTypeComponent.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/StringSimpleTypeComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -9,6 +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="added">+import uk.co.badgersinfoil.asxsd.MappingFunction;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.TypeDescriptor;
import uk.co.badgersinfoil.metaas.dom.StatementContainer;
</pre><pre class="diff"><small id="info">@@ -29,6 +30,10 @@
</small></pre><pre class="diff" id="context">                 return new TypeDescriptor("String", false, null);
        }
</pre><pre class="diff" id="added">+        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component) {
+                return IdentityMappingFunction.INSTANCE;
+        }
+
</pre><pre class="diff" id="context">         protected boolean willAcceptType(XSDSimpleTypeDefinition simpleType) {
                return simpleType.getVariety() == XSDVariety.ATOMIC_LITERAL
                 && localName.equals(simpleType.getName())
</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>UnknownSimpleTypeComponent.java</b></big> <small id="info">144 -> 145</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/UnknownSimpleTypeComponent.java        2007-09-09 00:10:16 UTC (rev 144)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/UnknownSimpleTypeComponent.java        2007-09-10 00:18:36 UTC (rev 145)
@@ -4,9 +4,11 @@
</small></pre><pre class="diff" id="context">
package uk.co.badgersinfoil.asxsd.components;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDConcreteComponent;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDSimpleTypeDefinition;
import org.eclipse.xsd.XSDVariety;
import uk.co.badgersinfoil.asxsd.CodegenContext;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.MappingFunction;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.asxsd.TypeDescriptor;
/**
</pre><pre class="diff"><small id="info">@@ -27,6 +29,11 @@
</small></pre><pre class="diff" id="context"> //                return new TypeDescriptor(ASConstants.TYPE_STRING, false, null);
        }
</pre><pre class="diff" id="added">+        public MappingFunction functionFor(CodegenContext context, XSDConcreteComponent component) {
+                XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition)component;
+                return context.functionFor(simpleType.getBaseTypeDefinition());
+        }
+
</pre><pre class="diff" id="context">         protected boolean willAcceptType(XSDSimpleTypeDefinition simpleType) {
                return simpleType.getVariety() == XSDVariety.ATOMIC_LITERAL
                 && simpleType.getBaseTypeDefinition() != null
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.12</small></center>
</body></html>