From 34a0b58ed178e02794aa0a3ba4ecba06bb278016 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 7 Jun 2015 23:11:35 -0400 Subject: [PATCH] prevent size() and fullScreen() from being used together --- .../processing/mode/java/preproc/PdePreprocessor.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/src/processing/mode/java/preproc/PdePreprocessor.java b/java/src/processing/mode/java/preproc/PdePreprocessor.java index a4e21ea11..9912a1756 100644 --- a/java/src/processing/mode/java/preproc/PdePreprocessor.java +++ b/java/src/processing/mode/java/preproc/PdePreprocessor.java @@ -324,9 +324,16 @@ public class PdePreprocessor { } } + String[] sizeContents = matchMethod("size", searchArea); + String[] fullContents = matchMethod("fullScreen", searchArea); + // First check and make sure they aren't both being used, otherwise it'll + // throw a confusing state exception error that one "can't be used here". + if (sizeContents != null && fullContents != null) { + throw new SketchException("size() and fullScreen() cannot be used in the same sketch", false); + } + // Get everything inside the parens for the size() method //String[] contents = PApplet.match(searchArea, SIZE_CONTENTS_REGEX); - String[] sizeContents = matchMethod("size", searchArea); if (sizeContents != null) { StringList args = breakCommas(sizeContents[1]); SurfaceInfo info = new SurfaceInfo(); @@ -366,7 +373,6 @@ public class PdePreprocessor { } // if no size() found, check for fullScreen() //contents = PApplet.match(searchArea, FULL_SCREEN_CONTENTS_REGEX); - String[] fullContents = matchMethod("fullScreen", searchArea); if (fullContents != null) { SurfaceInfo info = new SurfaceInfo(); info.statement = fullContents[0];