We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentCore,  Processing Development Environment (PDE) › LITERAL_class handling in PdeEmitter
Page Index Toggle Pages: 1
LITERAL_class handling in PdeEmitter (Read 1538 times)
LITERAL_class handling in PdeEmitter
Feb 17th, 2010, 6:33am
 
Hello,

Some time ago, I wanted to use Java Reflection in Processing, but trying to run the dummy sketch below yielded an "Invalid type:70" error.

Code:
Class a = PApplet.class;

void draw() {
 background(255);
 line(random(width), random(height), random(width), random(height));
}


Today, I tracked the error down and realized that the "class" token after "PApplet." was ignored when writing the sketch out as Java code.  

If you add
Code:
case LITERAL_class: 


to the long list of cases around line 670 in src/processing/preproc/PdeEmitter.pde, everything works as expected.

At the end of that file is an out-commented list of cases, with comment "The following are tokens, but I don't think JavaRecognizer ever produces an AST with one of these types:"

Maybe it's a good idea to insert them all around line 670 so that they will be passed through into the Java code?

Cheers,
 Christian
Re: LITERAL_class handling in PdeEmitter
Reply #1 - Feb 18th, 2010, 8:09am
 
You should consider submitting this to the bug tracker. You can find the bug tracker under the 'contribute' section of the main page, and you can use your discourse credentials.
Re: LITERAL_class handling in PdeEmitter
Reply #2 - Feb 18th, 2010, 2:06pm
 
Yes, of course – should have thought about that myself. Roll Eyes
Thanks for reminding me.
Page Index Toggle Pages: 1