Merge pull request #2772 from JakubValtar/preproc-constructorCast-fix

Fixes #1936 - Preproc constructor cast fix
This commit is contained in:
Ben Fry
2014-08-12 09:25:32 -04:00
5 changed files with 40 additions and 4 deletions
+4 -3
View File
@@ -194,13 +194,14 @@ constructorCast!
// if this is a string literal, make sure the type we're trying to cast
// to is one of the supported ones
//
{ #e.getType() != STRING_LITERAL ||
( #t.getType() == LITERAL_byte ||
{ (#e == null) ||
( (#e.getType() != STRING_LITERAL) ||
( #t.getType() == LITERAL_boolean ||
#t.getType() == LITERAL_double ||
#t.getType() == LITERAL_float ||
#t.getType() == LITERAL_int ||
#t.getType() == LITERAL_long ||
#t.getType() == LITERAL_short ) }?
#t.getType() == LITERAL_short )) }?
// create the node
//
{#constructorCast = #(#[CONSTRUCTOR_CAST,"CONSTRUCTOR_CAST"], t, e);}
+29
View File
@@ -0,0 +1,29 @@
import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.opengl.*;
import java.util.HashMap;
import java.util.ArrayList;
import java.io.File;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
public class bug1936 extends PApplet {
public void setup() {
char a = PApplet.parseChar(PApplet.parseByte(PApplet.parseInt("15")));
noLoop();
}
static public void main(String[] passedArgs) {
String[] appletArgs = new String[] { "bug1936" };
if (passedArgs != null) {
PApplet.main(concat(appletArgs, passedArgs));
} else {
PApplet.main(appletArgs);
}
}
}
+1
View File
@@ -0,0 +1 @@
char a = char(byte(int("15")));
@@ -276,6 +276,11 @@ public class ParserTests {
public void bug1534() {
expectGood("bug1534");
}
@Test
public void bug1936() {
expectGood("bug1936");
}
@Test
public void bug315g() {
+1 -1
View File
@@ -9635,7 +9635,7 @@ public class PApplet extends Applet
}
*/
static final public float[] parseByte(byte what[]) {
static final public float[] parseFloat(byte what[]) {
float floaties[] = new float[what.length];
for (int i = 0; i < what.length; i++) {
floaties[i] = what[i];