<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#copied {background-color:#ccccff;}
tr.alt #copied {background-color:#bbbbf7;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="5">Commit in <b><tt>asxsd/trunk/src</tt></b></td></tr>
<tr><td><tt>main/java/uk/co/badgersinfoil/asxsd/components/<a href="#file1">ComplexTypeComponent.java</a></tt> </td><td></td><td align="right" id="added">+9</td><td align="right" id="removed">-12</td><td nowrap="nowrap" align="center">165 -> 166</td></tr>
<tr class="alt"><td><tt> /<a href="#file2">ElementDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+25</td><td align="right" id="removed">-26</td><td nowrap="nowrap" align="center">165 -> 166</td></tr>
<tr><td><tt>test/java/uk/co/badgersinfoil/asxsd/schemas/<a href="#file3"><span id="added">AnonCTypeInNonGlobalElement.java</span></a></tt> </td><td></td><td align="right" id="added">+10</td><td></td><td nowrap="nowrap" align="right">added 166</td></tr>
<tr class="alt"><td><tt>test/resources/xsd/<a href="#file4"><span id="added">AnonCTypeInNonGlobalElement.xsd</span></a></tt> </td><td></td><td align="right" id="added">+15</td><td></td><td nowrap="nowrap" align="right">added 166</td></tr>
<tr><td></td><td></td><td align="right" id="added">+59</td><td align="right" id="removed">-38</td><td></td></tr>
</table>
<small id="info">2 added + 2 modified, total 4 files</small><br />
<div class="tasklist"><ul>
<li><a href="#task1">TODO: move this bit to ElementDeclarationComponent?</a></li>
</ul></div>
<pre class="comment">
Fix broken marshaling code in one instance.
Move code generating the high-level structure of a function next to the code that actually creates the function
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>ComplexTypeComponent.java</b></big> <small id="info">165 -> 166</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ComplexTypeComponent.java        2007-10-12 21:14:48 UTC (rev 165)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ComplexTypeComponent.java        2007-10-14 00:14:37 UTC (rev 166)
@@ -70,20 +70,9 @@
</small></pre><pre class="diff" id="context">                         processAllComplexTypeElementsUnmarshal(context, complexType);
                        block.addStmt("return _result");
                } else if (role == CodegenRole.MARSHAL) {
</pre><pre class="diff" id="removed">-                        StatementContainer block = context.getCurrentMethodCode();
-                        block.addStmt("default xml namespace = NAMESPACE");
-                        if (XSDUtils.isAnonymous(complexType)) {
-                                // TODO: move this bit to ElementDeclarationComponent?
-                                XSDElementDeclaration elementDecl = (XSDElementDeclaration)complexType.getContainer();
-                                block.addStmt("var _result:XML = <"+elementDecl.getName()+"/>");
-                        }
-                        context.pushAttrScope();
-                        MarshalBuilder.setCurrentTargetParentElementExpr(context, "_result");
</pre><pre class="diff" id="context">                         processComplexTypeBaseTypeMarshal(context, complexType);
                        processAllComplexTypeAttributesMarshal(context, complexType);
                        processAllComplexTypeElementsMarshal(context, complexType);
</pre><pre class="diff" id="removed">-                        context.getCurrentMethodCode().addStmt("return _result");
-                        context.popAttrScope();
</pre><pre class="diff" id="context">                 } else if (role == CodegenRole.TYPE) {
                        //ASClassType clazz = TypeBuilder.getCurrentType(context);
                        processComplexTypeBaseType(context, complexType);
</pre><pre class="diff"><small id="info">@@ -145,7 +134,6 @@
</small></pre><pre class="diff" id="context">         }
        private void processAllComplexTypeAttributesMarshal(CodegenContext context, XSDComplexTypeDefinition ctype) {
</pre><pre class="diff" id="removed">-                MarshalBuilder.setCurrentSourceExpr(context, "thisObject");
</pre><pre class="diff" id="context">                 List attrs = ctype.getAttributeContents();
                for (Iterator i=attrs.iterator(); i.hasNext(); ) {
                        XSDAttributeGroupContent attrContent = (XSDAttributeGroupContent)i.next();
</pre><pre class="diff"><small id="info">@@ -279,10 +267,19 @@
</small></pre><pre class="diff" id="context">                         ASMethod meth = clazz.newMethod(methodName, Visibility.PUBLIC, typeName);
                        builder.buildMethodParams(meth, complexType);
                        meth.setStatic(true);
</pre><pre class="diff" id="added">+                        meth.addStmt("default xml namespace = NAMESPACE");
+                        if (XSDUtils.isAnonymous(complexType)) {
<a name="task1" />+                                // <span class="task">TODO</span>: move this bit to ElementDeclarationComponent?
+                                XSDElementDeclaration elementDecl = (XSDElementDeclaration)complexType.getContainer();
+                                meth.addStmt("var _result:XML = <"+elementDecl.getName()+"/>");
+                        }
</pre><pre class="diff" id="context">                         context.pushAttrScope();
</pre><pre class="diff" id="added">+                        MarshalBuilder.setCurrentTargetParentElementExpr(context, "_result");
+                        MarshalBuilder.setCurrentSourceExpr(context, "thisObject");
</pre><pre class="diff" id="context">                         context.setCurrentMethodCode(meth);
                        context.generateCode(complexType);
                        context.popAttrScope();
</pre><pre class="diff" id="added">+                        meth.addStmt("return _result");
</pre><pre class="diff" id="context">                         return meth;
                }
                return super.createFunction(context, component);
</pre></div>
<hr /><a name="file2" /><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">165 -> 166</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ElementDeclarationComponent.java        2007-10-12 21:14:48 UTC (rev 165)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ElementDeclarationComponent.java        2007-10-14 00:14:37 UTC (rev 166)
@@ -30,6 +30,8 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.Visibility;
public class ElementDeclarationComponent extends AbstractMappingComponent {
</pre><pre class="diff" id="added">+        
+        private static final String KEY_CURRENT_FUNCTION_ELEMENT = "uk.co.badgersinfoil.asxsd.components.ElementDeclarationComponent.currentFunctionElement";
</pre><pre class="diff" id="context">
        public TypeDescriptor getTypeDescriptor(CodegenContext context,
         XSDConcreteComponent component)
</pre><pre class="diff"><small id="info">@@ -91,25 +93,21 @@
</small></pre><pre class="diff" id="context">                         }
                } else if (role == CodegenRole.MARSHAL) {
                        XSDTypeDefinition typeDef = elementDecl.getType();
</pre><pre class="diff" id="removed">-                        if (elementDecl.isGlobal()) {
</pre><pre class="diff" id="added">+                        if (isCurrentFuctionElement(context, elementDecl)) {
</pre><pre class="diff" id="context">                                 if (typeDef instanceof XSDSimpleTypeDefinition) {
                                        StatementContainer block = context.getCurrentMethodCode();
</pre><pre class="diff" id="removed">-                                        block.addStmt("var _result:XML = <"+elementDecl.getName()+"/>");
</pre><pre class="diff" id="context">                                         MappingFunction conv = context.functionFor(typeDef);
                                        String accessExpr = "thisValue"; // TODO: get expression from context instead
                                        String converted = conv.appliedTo(accessExpr);
                                        block.addStmt("_result.appendChild("+converted+")");
</pre><pre class="diff" id="removed">-                                        block.addStmt("return _result");
</pre><pre class="diff" id="context">                                 } else {
                                        if (XSDUtils.isAnonymous(typeDef)) {
                                                context.generateCode(typeDef);
                                        } else {
                                                StatementContainer block = context.getCurrentMethodCode();
</pre><pre class="diff" id="removed">-                                                block.addStmt("var _result:XML = <"+elementDecl.getName()+"/>");
</pre><pre class="diff" id="context">                                                 MappingFunction conv = context.functionFor(typeDef);
                                                String accessExpr = MarshalBuilder.getCurrentSourceExpr(context);
                                                block.addStmt(conv.appliedTo("_result, "+accessExpr));
</pre><pre class="diff" id="removed">-                                                block.addStmt("return _result");
</pre><pre class="diff" id="context">                                         }
                                }
                        } else {
</pre><pre class="diff"><small id="info">@@ -117,27 +115,12 @@
</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 (typeDef instanceof XSDSimpleTypeDefinition) {
-                                        block.addStmt("var "+propertyName+":XML = <"+elementDecl.getName()+"/>");
-                                        MappingFunction conv = context.functionFor(elementDecl);
-                                        String converted = conv.appliedTo(accessExpr);
-                                        block.addStmt(propertyName+".appendChild("+converted+")");
-                                        block.addStmt(targetParentExpr+".appendChild("+propertyName+")");
-/*                                } else { // then ComplexType
-                                        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("var "+propertyName+":XML = <"+elementDecl.getName()+"/>");
+                                MappingFunction conv = context.functionFor(elementDecl);
+                                String converted = conv.appliedTo(accessExpr);
+                                block.addStmt(propertyName+".appendChild("+converted+")");
+                                block.addStmt(targetParentExpr+".appendChild("+propertyName+")");
+                        }
</pre><pre class="diff" id="context">                 } else if (role == CodegenRole.TYPE) {
                        ASClassType clazz = TypeBuilder.getCurrentType(context);
                        TypeDescriptor typeDesc = context.getTypeDescriptor(elementDecl);
</pre><pre class="diff"><small id="info">@@ -215,15 +198,31 @@
</small></pre><pre class="diff" id="context">                         ASMethod meth = clazz.newMethod(methodName, Visibility.PUBLIC, typeName);
                        builder.buildMethodParams(meth, elementDecl);
                        meth.setStatic(true);
</pre><pre class="diff" id="added">+                        meth.addStmt("var _result:XML = <"+elementDecl.getName()+"/>");
</pre><pre class="diff" id="context">                         context.pushAttrScope();
</pre><pre class="diff" id="added">+                        setCurrentFuctionElement(context, elementDecl);
</pre><pre class="diff" id="context">                         context.setCurrentMethodCode(meth);
</pre><pre class="diff" id="added">+                        MarshalBuilder.setCurrentSourceExpr(context, ((ASArg)meth.getArgs().get(0)).getName());
</pre><pre class="diff" id="context">                         context.generateCode(elementDecl);
                        context.popAttrScope();
</pre><pre class="diff" id="added">+                        meth.addStmt("return _result");
</pre><pre class="diff" id="context">                         return meth;
                }
                throw new IllegalArgumentException(getClass().getName() + " does not support role "+role);
        }
</pre><pre class="diff" id="added">+        private static void setCurrentFuctionElement(CodegenContext context,
+         XSDElementDeclaration elementDecl)
+        {
+                context.setAttribute(KEY_CURRENT_FUNCTION_ELEMENT, elementDecl);
+        }
+        
+        private static boolean isCurrentFuctionElement(CodegenContext context,
+         XSDElementDeclaration elementDecl)
+        {
+                return context.getAttribute(KEY_CURRENT_FUNCTION_ELEMENT) == elementDecl;
+        }
+
</pre><pre class="diff" id="context">         public MappingFunction functionFor(CodegenContext context,
         XSDConcreteComponent component)
        {
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas</span><br />
<div class="fileheader" id="added"><big><b>AnonCTypeInNonGlobalElement.java</b></big> <small id="info">added at 166</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/AnonCTypeInNonGlobalElement.java         (rev 0)
+++ trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/AnonCTypeInNonGlobalElement.java        2007-10-14 00:14:37 UTC (rev 166)
@@ -0,0 +1,10 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.asxsd.schemas;
+
+import uk.co.badgersinfoil.metaas.dom.ASField;
+
+public class AnonCTypeInNonGlobalElement extends SchemaTestCase {
+        public void testIt() {
+                ASField a = getTestASClass().getField("a");
+                assertNotNull(a);
+        }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/test/resources/xsd</span><br />
<div class="fileheader" id="added"><big><b>AnonCTypeInNonGlobalElement.xsd</b></big> <small id="info">added at 166</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/resources/xsd/AnonCTypeInNonGlobalElement.xsd         (rev 0)
+++ trunk/src/test/resources/xsd/AnonCTypeInNonGlobalElement.xsd        2007-10-14 00:14:37 UTC (rev 166)
@@ -0,0 +1,15 @@
</small></pre><pre class="diff" id="added">+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ targetNamespace="http://example.org/test">
+ <complexType name="Test">
+ <sequence>
+ <element name="a">
+ <complexType>
+ <sequence>
+ <element name="b" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+</schema>
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.12</small></center>
</body></html>