Skip to content

Commit c67e488

Browse files
committed
don't add main() method to footer
1 parent b05dacf commit c67e488

File tree

1 file changed

+95
-91
lines changed

1 file changed

+95
-91
lines changed

src/processing/mode/android/AndroidPreprocessor.java

Lines changed: 95 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ public SurfaceInfo initSketchSize(String code) throws SketchException {
6868
System.err.println("found here: http://wiki.processing.org/w/Android");
6969
throw new SketchException("Could not parse the size() command.");
7070
}
71-
/*
72-
sizeStatement = surfaceInfo.getStatement();
73-
sketchWidth = surfaceInfo.getWidth();
74-
sketchHeight = surfaceInfo.getHeight();
75-
sketchRenderer = surfaceInfo.getRenderer();*/
7671
return surfaceInfo;
7772
}
7873

@@ -108,7 +103,6 @@ static public String[] parseSketchSmooth(String code, boolean fussy) {
108103
"value (not variables) for the smooth() command.\n" +
109104
"See the smooth() reference for an explanation.";
110105
Messages.showWarning("Could not find smooth level", message, null);
111-
// new Exception().printStackTrace(System.out);
112106
return null;
113107
}
114108

@@ -117,89 +111,6 @@ static public String[] parseSketchSmooth(String code, boolean fussy) {
117111
return new String[] { null, null }; // not an error, just empty
118112
}
119113

120-
121-
/*
122-
protected boolean parseSketchSize() {
123-
// This matches against any uses of the size() function, whether numbers
124-
// or variables or whatever. This way, no warning is shown if size() isn't
125-
// actually used in the applet, which is the case especially for anyone
126-
// who is cutting/pasting from the reference.
127-
128-
String scrubbed = processing.mode.java.JavaBuild.scrubComments(sketch.getCode(0).getProgram());
129-
String[] matches = PApplet.match(scrubbed, processing.mode.java.JavaBuild.SIZE_REGEX);
130-
// PApplet.println("matches: " + Sketch.SIZE_REGEX);
131-
// PApplet.println(matches);
132-
133-
if (matches != null) {
134-
boolean badSize = false;
135-
136-
if (matches[1].equals("screenWidth") ||
137-
matches[1].equals("screenHeight") ||
138-
matches[2].equals("screenWidth") ||
139-
matches[2].equals("screenHeight")) {
140-
final String message =
141-
"The screenWidth and screenHeight variables are named\n" +
142-
"displayWidth and displayHeight in this release of Processing.";
143-
Base.showWarning("Time for a quick update", message, null);
144-
return false;
145-
}
146-
147-
if (!matches[1].equals("displayWidth") &&
148-
!matches[1].equals("displayHeight") &&
149-
PApplet.parseInt(matches[1], -1) == -1) {
150-
badSize = true;
151-
}
152-
if (!matches[2].equals("displayWidth") &&
153-
!matches[2].equals("displayHeight") &&
154-
PApplet.parseInt(matches[2], -1) == -1) {
155-
badSize = true;
156-
}
157-
158-
if (badSize) {
159-
// found a reference to size, but it didn't seem to contain numbers
160-
final String message =
161-
"The size of this applet could not automatically be determined\n" +
162-
"from your code. Use only numeric values (not variables) for the\n" +
163-
"size() command. See the size() reference for more information.";
164-
Base.showWarning("Could not find sketch size", message, null);
165-
System.out.println("More about the size() command on Android can be");
166-
System.out.println("found here: http://wiki.processing.org/w/Android");
167-
return false;
168-
}
169-
170-
// PApplet.println(matches);
171-
sizeStatement = matches[0]; // the full method to be removed from the source
172-
sketchWidth = matches[1];
173-
sketchHeight = matches[2];
174-
sketchRenderer = matches[3].trim();
175-
if (sketchRenderer.length() == 0) {
176-
sketchRenderer = null;
177-
}
178-
} else {
179-
sizeStatement = null;
180-
sketchWidth = null;
181-
sketchHeight = null;
182-
sketchRenderer = null;
183-
}
184-
return true;
185-
}
186-
*/
187-
188-
189-
/*
190-
public PreprocessorResult write(Writer out, String program, String[] codeFolderPackages)
191-
throws SketchException, RecognitionException, TokenStreamException {
192-
if (sizeStatement != null) {
193-
int start = program.indexOf(sizeStatement);
194-
program = program.substring(0, start) +
195-
program.substring(start + sizeStatement.length());
196-
}
197-
// the OpenGL package is back in 2.0a5
198-
//program = program.replaceAll("import\\s+processing\\.opengl\\.\\S+;", "");
199-
return super.write(out, program, codeFolderPackages);
200-
}
201-
*/
202-
203114

204115
@Override
205116
protected int writeImports(final PrintWriter out,
@@ -214,19 +125,22 @@ protected int writeImports(final PrintWriter out,
214125
}
215126

216127

217-
/*
218128
@Override
219129
protected void writeFooter(PrintWriter out, String className) {
220130
SurfaceInfo info = null;
221131
try {
222132
info = initSketchSize(sketch.getMainProgram());
223133
} catch (SketchException e) {
134+
e.printStackTrace();
224135
}
225136

226137
if (info == null) {
227138
// Cannot get size info, just use parent's implementation.
228139
super.writeFooter(out, className);
229140
} else {
141+
// Same as in the parent, but without writing the main() method, which is
142+
// not needed in Android.
143+
230144
if (mode == Mode.STATIC) {
231145
// close off setup() definition
232146
out.println(indent + indent + "noLoop();");
@@ -235,14 +149,22 @@ protected void writeFooter(PrintWriter out, String className) {
235149
}
236150

237151
if ((mode == Mode.STATIC) || (mode == Mode.ACTIVE)) {
152+
// doesn't remove the original size() method, but calling size()
153+
// again in setup() is harmless.
238154
if (!hasMethod("settings") && info.hasSettings()) {
239155
out.println(indent + "public void settings() { " + info.getSettings() + " }");
240156
}
157+
158+
// close off the class definition
241159
out.println("}");
242160
}
243161
}
244162
}
245-
*/
163+
164+
165+
////////////////////////////////////////////////////////////////////////////////
166+
// Assorted commented out code
167+
//
246168

247169
// As of revision 0215 (2.0b7-ish), the default imports are now identical
248170
// between desktop and Android (to avoid unintended incompatibilities).
@@ -314,4 +236,86 @@ public String[] getAndroidImports() {
314236
};
315237
}
316238
*/
239+
240+
/*
241+
protected boolean parseSketchSize() {
242+
// This matches against any uses of the size() function, whether numbers
243+
// or variables or whatever. This way, no warning is shown if size() isn't
244+
// actually used in the applet, which is the case especially for anyone
245+
// who is cutting/pasting from the reference.
246+
247+
String scrubbed = processing.mode.java.JavaBuild.scrubComments(sketch.getCode(0).getProgram());
248+
String[] matches = PApplet.match(scrubbed, processing.mode.java.JavaBuild.SIZE_REGEX);
249+
// PApplet.println("matches: " + Sketch.SIZE_REGEX);
250+
// PApplet.println(matches);
251+
252+
if (matches != null) {
253+
boolean badSize = false;
254+
255+
if (matches[1].equals("screenWidth") ||
256+
matches[1].equals("screenHeight") ||
257+
matches[2].equals("screenWidth") ||
258+
matches[2].equals("screenHeight")) {
259+
final String message =
260+
"The screenWidth and screenHeight variables are named\n" +
261+
"displayWidth and displayHeight in this release of Processing.";
262+
Base.showWarning("Time for a quick update", message, null);
263+
return false;
264+
}
265+
266+
if (!matches[1].equals("displayWidth") &&
267+
!matches[1].equals("displayHeight") &&
268+
PApplet.parseInt(matches[1], -1) == -1) {
269+
badSize = true;
270+
}
271+
if (!matches[2].equals("displayWidth") &&
272+
!matches[2].equals("displayHeight") &&
273+
PApplet.parseInt(matches[2], -1) == -1) {
274+
badSize = true;
275+
}
276+
277+
if (badSize) {
278+
// found a reference to size, but it didn't seem to contain numbers
279+
final String message =
280+
"The size of this applet could not automatically be determined\n" +
281+
"from your code. Use only numeric values (not variables) for the\n" +
282+
"size() command. See the size() reference for more information.";
283+
Base.showWarning("Could not find sketch size", message, null);
284+
System.out.println("More about the size() command on Android can be");
285+
System.out.println("found here: http://wiki.processing.org/w/Android");
286+
return false;
287+
}
288+
289+
// PApplet.println(matches);
290+
sizeStatement = matches[0]; // the full method to be removed from the source
291+
sketchWidth = matches[1];
292+
sketchHeight = matches[2];
293+
sketchRenderer = matches[3].trim();
294+
if (sketchRenderer.length() == 0) {
295+
sketchRenderer = null;
296+
}
297+
} else {
298+
sizeStatement = null;
299+
sketchWidth = null;
300+
sketchHeight = null;
301+
sketchRenderer = null;
302+
}
303+
return true;
304+
}
305+
*/
306+
307+
308+
/*
309+
public PreprocessorResult write(Writer out, String program, String[] codeFolderPackages)
310+
throws SketchException, RecognitionException, TokenStreamException {
311+
if (sizeStatement != null) {
312+
int start = program.indexOf(sizeStatement);
313+
program = program.substring(0, start) +
314+
program.substring(start + sizeStatement.length());
315+
}
316+
// the OpenGL package is back in 2.0a5
317+
//program = program.replaceAll("import\\s+processing\\.opengl\\.\\S+;", "");
318+
return super.write(out, program, codeFolderPackages);
319+
}
320+
*/
317321
}

0 commit comments

Comments
 (0)