|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
GuiTestCaseJames,
I get java14 compile errors for the new class ca.odell.glazedlists.GuiTestCase, you too? It looks to me that declawer can't deal with a for each array loop... Holger ______________________________________________________________________ XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! Jetzt testen! http://produkte.web.de/club/?mc=021130 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: GuiTestCaseHi Holger,
I hacked declawer to support for-each loops over arrays a week ago. I sent a mail to the list, but I guess it didn't get through. Here it is again... I needed Declawer to handle foreach loops over arrays, so I added a little code that does this. I also fixed a bug - when declawer generates the code for the foreach loop, it always used the same name for the iterator, which led to name clashes with nested foreach loops. I fixed that by simply incrementing a counter, so a new name is used for each temporary variable. There may be better solutions. I changed the part that generates the foreach loop for collections to use the idiom suggested in Josh Bloch's "Effective Java": for (Iterator i = c.iterator(); i.hasNext(); ) {...} It doesn't change the variable scopes, it's just a little more compact than using an extra block. Here's the new code in com.sun.tools.javac.tree.Pretty. It replaces the old version of visitForeachLoop(). private static final AtomicInteger tempVarCount = new AtomicInteger(); private String declawerVar( String name ) { return "declawer$"+tempVarCount.getAndIncrement()+"$"+name; } public void visitForeachLoop(ForeachLoop tree) { // replace for each loops with Iteration counterparts if (tree.expr.type.tag == TypeTags.ARRAY) { String arrayVar = declawerVar("array"); String lengthVar = declawerVar("length"); String countVar = declawerVar("count"); print("{"); print(tree.expr.type+" "+arrayVar+" = "); printExpr(tree.expr); print(";"); print("int "+lengthVar+" = "+arrayVar+".length;"); print("for (int "+countVar+" = 0; "+countVar+" < "+lengthVar+"; "+countVar+"++) {"); printExpr(tree.var); print("; "); print(tree.var.name+" = "+arrayVar+"["+countVar+"];"); printStat(tree.body); print("}}"); } else { String iterVar = declawerVar("iter"); print("for (java.util.Iterator "+iterVar+" = "); printExpr(tree.expr); print(".iterator(); "+iterVar+".hasNext(); )"); print("{"); printExpr(tree.var); print("; "); print(tree.var.name+" = ("+tree.var.type+") "+iterVar+".next();"); printStat(tree.body); print("}"); } } I attached the new version of Pretty.java, and a new version of the test class Testy.java. Declawer is really neat! We need to run some of our Java 1.5 code inside a Oracle 10g server, which only has a 1.4 JVM. With Declawer, we can do that without removing all the generics from our code. Is Declawer in any public SVN or CVS repository? Bye, Christopher. On Nov 11, 2007 10:36 PM, Holger Brands <hbrands@...> wrote: > James, > > I get java14 compile errors for the new class > ca.odell.glazedlists.GuiTestCase, you too? > > It looks to me that declawer can't deal with > a for each array loop... > > Holger > ______________________________________________________________________ > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! > Jetzt testen! http://produkte.web.de/club/?mc=021130 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@... > For additional commands, e-mail: dev-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: GuiTestCaseHere are the complete classes, Pretty.java and Testy.java.
On Nov 11, 2007 10:36 PM, Holger Brands <hbrands@...> wrote: > James, > > I get java14 compile errors for the new class > ca.odell.glazedlists.GuiTestCase, you too? > > It looks to me that declawer can't deal with > a for each array loop... > > Holger > ______________________________________________________________________ > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! > Jetzt testen! http://produkte.web.de/club/?mc=021130 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@... > For additional commands, e-mail: dev-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: GuiTestCaseHi Christopher,
actually your mail did get through and I remembered it after I posted about GuiTestCase. I think James or Jesse will consider your contribution when they find some time. They are the creators of Declawer ;-) Thanks for sharing your enhancement. Holger > > Hi Holger, > > I hacked declawer to support for-each loops over arrays a week ago. > I sent a mail to the list, but I guess it didn't get through. Here it > is again... > > I needed Declawer to handle foreach loops over arrays, > so I added a little code that does this. > > I also fixed a bug - when declawer generates the code for the > foreach loop, it always used the same name for the iterator, > which led to name clashes with nested foreach loops. I fixed > that by simply incrementing a counter, so a new name is used > for each temporary variable. There may be better solutions. > > I changed the part that generates the foreach loop for > collections to use the idiom suggested in Josh Bloch's > "Effective Java": for (Iterator i = c.iterator(); i.hasNext(); ) {...} > It doesn't change the variable scopes, it's just a little > more compact than using an extra block. > > Here's the new code in com.sun.tools.javac.tree.Pretty. > It replaces the old version of visitForeachLoop(). > > > private static final AtomicInteger tempVarCount = new AtomicInteger(); > > private String declawerVar( String name ) > { > return "declawer$"+tempVarCount.getAndIncrement()+"$"+name; > } > > public void visitForeachLoop(ForeachLoop tree) > { > // replace for each loops with Iteration counterparts > if (tree.expr.type.tag == TypeTags.ARRAY) > { > String arrayVar = declawerVar("array"); > String lengthVar = declawerVar("length"); > String countVar = declawerVar("count"); > print("{"); > print(tree.expr.type+" "+arrayVar+" = "); > printExpr(tree.expr); > print(";"); > print("int "+lengthVar+" = "+arrayVar+".length;"); > print("for (int "+countVar+" = 0; "+countVar+" < "+lengthVar+"; > "+countVar+"++) {"); > printExpr(tree.var); > print("; "); > print(tree.var.name+" = "+arrayVar+"["+countVar+"];"); > printStat(tree.body); > print("}}"); > } > else > { > String iterVar = declawerVar("iter"); > print("for (java.util.Iterator "+iterVar+" = "); > printExpr(tree.expr); > print(".iterator(); "+iterVar+".hasNext(); )"); > print("{"); > printExpr(tree.var); > print("; "); > print(tree.var.name+" = ("+tree.var.type+") "+iterVar+".next();"); > printStat(tree.body); > print("}"); > } > } > > I attached the new version of Pretty.java, and a new version > of the test class Testy.java. > > Declawer is really neat! We need to run some of our Java 1.5 > code inside a Oracle 10g server, which only has a 1.4 JVM. > With Declawer, we can do that without removing all the generics > from our code. > > Is Declawer in any public SVN or CVS repository? > > Bye, > Christopher. > > > On Nov 11, 2007 10:36 PM, Holger Brands <hbrands@...> wrote: > > James, > > > > I get java14 compile errors for the new class > > ca.odell.glazedlists.GuiTestCase, you too? > > > > It looks to me that declawer can't deal with > > a for each array loop... > > > > Holger > > ______________________________________________________________________ > > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! > > Jetzt testen! http://produkte.web.de/club/?mc=021130 > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscribe@... > > For additional commands, e-mail: dev-help@... > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@... > For additional commands, e-mail: dev-help@... > > _____________________________________________________________________ Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! http://smartsurfer.web.de/?mc=100071&distributionid=000000000066 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: GuiTestCaseFYI, I looked over the changes about a week ago and kicked the tires. It seemed to work ok. I think we'll include it when I get back from my vacation. Aloha from Hawaii Glaziers!
James
On Nov 13, 2007 10:11 PM, Holger Brands <hbrands@...> wrote: Hi Christopher, |
|
|
Re: GuiTestCaseI have uploaded a new declawer.jar to java.net. For those who build GL from sources, simply delete \tools\declawer.jar and the new one will be downloaded and used.
Thanks to Christopher for contributing back! We'll make use of "nicer" array iteration in GL source code now... James On Nov 13, 2007 11:16 PM, James Lemieux <jplemieux@...> wrote: FYI, I looked over the changes about a week ago and kicked the tires. It seemed to work ok. I think we'll include it when I get back from my vacation. Aloha from Hawaii Glaziers! |
|
|
Re: GuiTestCaseGlad I could help!
On Nov 14, 2007 10:06 PM, James Lemieux <jplemieux@...> wrote: > I have uploaded a new declawer.jar to java.net. For those who build GL from > sources, simply delete \tools\declawer.jar and the new one will be > downloaded and used. > > Thanks to Christopher for contributing back! We'll make use of "nicer" array > iteration in GL source code now... > > James > > > > On Nov 13, 2007 11:16 PM, James Lemieux <jplemieux@...> wrote: > > FYI, I looked over the changes about a week ago and kicked the tires. It > seemed to work ok. I think we'll include it when I get back from my > vacation. Aloha from Hawaii Glaziers! > > > > James > > > > > > > > > > > > On Nov 13, 2007 10:11 PM, Holger Brands <hbrands@...> wrote: > > > > > Hi Christopher, > > > > > > actually your mail did get through and I remembered it after I posted > > > about GuiTestCase. > > > I think James or Jesse will consider your contribution when they find > > > some time. They are the creators of Declawer ;-) > > > > > > Thanks for sharing your enhancement. > > > > > > Holger > > > > > > > > > > > > > > > > > > > > Hi Holger, > > > > > > > > I hacked declawer to support for-each loops over arrays a week ago. > > > > I sent a mail to the list, but I guess it didn't get through. Here it > > > > is again... > > > > > > > > I needed Declawer to handle foreach loops over arrays, > > > > so I added a little code that does this. > > > > > > > > I also fixed a bug - when declawer generates the code for the > > > > foreach loop, it always used the same name for the iterator, > > > > which led to name clashes with nested foreach loops. I fixed > > > > that by simply incrementing a counter, so a new name is used > > > > for each temporary variable. There may be better solutions. > > > > > > > > I changed the part that generates the foreach loop for > > > > collections to use the idiom suggested in Josh Bloch's > > > > "Effective Java": for (Iterator i = c.iterator(); i.hasNext(); ) {...} > > > > It doesn't change the variable scopes, it's just a little > > > > more compact than using an extra block. > > > > > > > > Here's the new code in com.sun.tools.javac.tree.Pretty. > > > > It replaces the old version of visitForeachLoop(). > > > > > > > > > > > > private static final AtomicInteger tempVarCount = new AtomicInteger(); > > > > > > > > private String declawerVar( String name ) > > > > { > > > > return "declawer$"+tempVarCount.getAndIncrement()+"$"+name; > > > > } > > > > > > > > public void visitForeachLoop(ForeachLoop tree) > > > > { > > > > // replace for each loops with Iteration counterparts > > > > if (tree.expr.type.tag == TypeTags.ARRAY) > > > > { > > > > String arrayVar = declawerVar("array"); > > > > String lengthVar = declawerVar("length"); > > > > String countVar = declawerVar("count"); > > > > print("{"); > > > > print(tree.expr.type+" "+arrayVar+" = "); > > > > printExpr(tree.expr); > > > > print(";"); > > > > print("int "+lengthVar+" = "+arrayVar+".length;"); > > > > print("for (int "+countVar+" = 0; "+countVar+" < "+lengthVar+"; > > > > "+countVar+"++) {"); > > > > printExpr(tree.var); > > > > print("; "); > > > > print(tree.var.name+" = "+arrayVar+"["+countVar+"];"); > > > > printStat( tree.body); > > > > print("}}"); > > > > } > > > > else > > > > { > > > > String iterVar = declawerVar("iter"); > > > > print("for (java.util.Iterator "+iterVar+" = "); > > > > printExpr(tree.expr); > > > > print(".iterator(); "+iterVar+".hasNext(); )"); > > > > print("{"); > > > > printExpr(tree.var); > > > > print("; "); > > > > print( tree.var.name+" = ("+tree.var.type+") "+iterVar+".next();"); > > > > printStat(tree.body); > > > > print("}"); > > > > } > > > > } > > > > > > > > I attached the new version of Pretty.java, and a new version > > > > of the test class Testy.java. > > > > > > > > Declawer is really neat! We need to run some of our Java 1.5 > > > > code inside a Oracle 10g server, which only has a 1.4 JVM. > > > > With Declawer, we can do that without removing all the generics > > > > from our code. > > > > > > > > Is Declawer in any public SVN or CVS repository? > > > > > > > > Bye, > > > > Christopher. > > > > > > > > > > > > > > > > > > > > > On Nov 11, 2007 10:36 PM, Holger Brands < hbrands@...> wrote: > > > > > James, > > > > > > > > > > I get java14 compile errors for the new class > > > > > ca.odell.glazedlists.GuiTestCase, you too? > > > > > > > > > > It looks to me that declawer can't deal with > > > > > a for each array loop... > > > > > > > > > > Holger > > > > > > ______________________________________________________________________ > > > > > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! > > > > > Jetzt testen! http://produkte.web.de/club/?mc=021130 > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: dev-unsubscribe@... > > > > > For additional commands, e-mail: dev-help@... > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: dev-unsubscribe@... > > > > For additional commands, e-mail: dev-help@... > > > > > > > > > > > > > > > > > _____________________________________________________________________ > > > Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > > > http://smartsurfer.web.de/?mc=100071&distributionid=000000000066 > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: dev-unsubscribe@... > > > For additional commands, e-mail: dev-help@... > > > > > > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
| Free embeddable forum powered by Nabble | Forum Help |