<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>metaas/trunk/src</tt></b></td></tr>
<tr><td><tt>main/java/uk/co/badgersinfoil/metaas/dom/<a href="#file1">ASField.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td></td><td nowrap="nowrap" align="center">565 -&gt; 566</td></tr>
<tr class="alt"><td><tt>main/java/uk/co/badgersinfoil/metaas/impl/<a href="#file2">ASTASField.java</a></tt> </td><td></td><td align="right" id="added">+31</td><td align="right" id="removed">-15</td><td nowrap="nowrap" align="center">565 -&gt; 566</td></tr>
<tr><td><tt>test/java/uk/co/badgersinfoil/metaas/<a href="#file3">ASFieldTests.java</a></tt> </td><td></td><td align="right" id="added">+6</td><td align="right" id="removed">-3</td><td nowrap="nowrap" align="center">565 -&gt; 566</td></tr>
<tr><td></td><td></td><td align="right" id="added">+39</td><td align="right" id="removed">-18</td><td></td></tr>
</table>
<small id="info">3 modified files</small><br />
<pre class="comment">
Allow setInitializer(ASExpression) in attition to the String varient
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/dom</span><br />
<div class="fileheader"><big><b>ASField.java</b></big> <small id="info">565 -&gt; 566</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASField.java        2007-12-04 21:57:14 UTC (rev 565)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASField.java        2007-12-04 23:23:19 UTC (rev 566)
@@ -18,6 +18,8 @@
</small></pre><pre class="diff" id="context">          */
         void setInitializer(String expr);
 
</pre><pre class="diff" id="added">+        public void setInitializer(ASExpression expr);
+
</pre><pre class="diff" id="context">         /**
          * returns the initialiser expression for this field, or null if it
          * has none.
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader"><big><b>ASTASField.java</b></big> <small id="info">565 -&gt; 566</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASField.java        2007-12-04 21:57:14 UTC (rev 565)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASField.java        2007-12-04 23:23:19 UTC (rev 566)
@@ -38,25 +38,41 @@
</small></pre><pre class="diff" id="context">         }
 
         public void setInitializer(String expr) {
</pre><pre class="diff" id="removed">-                LinkedListTree decl = findDecl();
</pre><pre class="diff" id="context">                 if (expr == null) {
</pre><pre class="diff" id="removed">-                        ASTIterator i = new ASTIterator(decl);
-                        if (i.search(AS3Parser.ASSIGN) != null) {
-                                i.remove();
-                        }
</pre><pre class="diff" id="added">+                        removeInitializer();
</pre><pre class="diff" id="context">                 } else {
</pre><pre class="diff" id="removed">-                        LinkedListTree exp = AS3FragmentParser.parseExpr(expr);
-                        LinkedListTree init = ASTUtils.findChildByType(decl, AS3Parser.ASSIGN);
-                        if (init == null) {
-                                init = ASTUtils.newAST(AS3Parser.ASSIGN, "=");
-                                decl.addChildWithTokens(init);
-                        } else {
-                                init.deleteChild(0);
-                        }
-                        init.addChildWithTokens(exp);
</pre><pre class="diff" id="added">+                        setInitAST(AS3FragmentParser.parseExpr(expr));
</pre><pre class="diff" id="context">                 }
         }
</pre><pre class="diff" id="removed">-        
</pre><pre class="diff" id="added">+
+        public void setInitializer(ASExpression expr) {
+                if (expr == null) {
+                        removeInitializer();
+                } else {
+                        setInitAST(((ASTASExpression)expr).getAST());
+                }
+        }
+
+        private void setInitAST(LinkedListTree exp) {
+                LinkedListTree decl = findDecl();
+                LinkedListTree init = ASTUtils.findChildByType(decl, AS3Parser.ASSIGN);
+                if (init == null) {
+                        init = ASTUtils.newAST(AS3Parser.ASSIGN, "=");
+                        decl.addChildWithTokens(init);
+                } else {
+                        init.deleteChild(0);
+                }
+                init.addChildWithTokens(exp);
+        }
+
+        private void removeInitializer() {
+                LinkedListTree decl = findDecl();
+                ASTIterator i = new ASTIterator(decl);
+                if (i.search(AS3Parser.ASSIGN) != null) {
+                        i.remove();
+                }
+        }
+
</pre><pre class="diff" id="context">         public ASExpression getInitializer() {
                 LinkedListTree decl = findDecl();
                 LinkedListTree init = ASTUtils.findChildByType(decl, AS3Parser.ASSIGN);
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">metaas/trunk/src/test/java/uk/co/badgersinfoil/metaas</span><br />
<div class="fileheader"><big><b>ASFieldTests.java</b></big> <small id="info">565 -&gt; 566</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/metaas/ASFieldTests.java        2007-12-04 21:57:14 UTC (rev 565)
+++ trunk/src/test/java/uk/co/badgersinfoil/metaas/ASFieldTests.java        2007-12-04 23:23:19 UTC (rev 566)
@@ -6,6 +6,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASExpression;
 import uk.co.badgersinfoil.metaas.dom.ASField;
 import uk.co.badgersinfoil.metaas.dom.ASIntegerLiteral;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASStringLiteral;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.Visibility;
 import junit.framework.TestCase;
 
</pre><pre class="diff"><small id="info">@@ -53,12 +54,14 @@
</small></pre><pre class="diff" id="context">         public void testInit() throws IOException {
                 // should no none to start with,
                 assertNull(field.getInitializer());
</pre><pre class="diff" id="added">+                
+                field.setInitializer(fact.newStringLiteral("foo"));
+                assertTrue(field.getInitializer() instanceof ASStringLiteral);
</pre><pre class="diff" id="context"> 
                 field.setInitializer("1");
</pre><pre class="diff" id="removed">-                ASExpression init = field.getInitializer();
-                assertTrue(init instanceof ASIntegerLiteral);
</pre><pre class="diff" id="added">+                assertTrue(field.getInitializer() instanceof ASIntegerLiteral);
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-                field.setInitializer(null);  // remove it again
</pre><pre class="diff" id="added">+                field.setInitializer(<span id="addedchars">(String)</span>null);  // remove it again
</pre><pre class="diff" id="context">                 assertNull(field.getInitializer());
 
                 // complicated initialiser value,
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.12</small></center>
</body></html>