mirror of
https://github.com/processing/processing4.git
synced 2026-05-03 09:26:25 +02:00
fix get/setenv issues, fix imports for android
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
PdePreprocessor - wrapper for default ANTLR-generated parser
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
Copyright (c) 2004-09 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
ANTLR-generated parser and several supporting classes written
|
||||
@@ -387,10 +387,11 @@ public class PdePreprocessor {
|
||||
}
|
||||
|
||||
protected int writeImports(PrintStream out) {
|
||||
out.println("import processing.core.*; ");
|
||||
out.println("import processing.xml.*; ");
|
||||
out.println();
|
||||
int count = 3;
|
||||
int count = 1;
|
||||
for (String s : getCoreImports()) {
|
||||
out.println(s);
|
||||
count++;
|
||||
}
|
||||
|
||||
if (programImports.size() != 0) {
|
||||
for (String item : programImports) {
|
||||
@@ -492,6 +493,14 @@ public class PdePreprocessor {
|
||||
public ArrayList<String> getExtraImports() {
|
||||
return programImports;
|
||||
}
|
||||
|
||||
|
||||
public String[] getCoreImports() {
|
||||
return new String[] {
|
||||
"import processing.core.*;",
|
||||
"import processing.xml.*;"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -250,11 +250,20 @@ public class Build {
|
||||
|
||||
|
||||
class Preproc extends PdePreprocessor {
|
||||
|
||||
public int writeImports(PrintStream out) {
|
||||
out.println("package " + getPackageName() + ";");
|
||||
out.println();
|
||||
return super.writeImports(out);
|
||||
}
|
||||
|
||||
public String[] getCoreImports() {
|
||||
return new String[] {
|
||||
"import processing.android.core.*;",
|
||||
"import processing.android.opengl.*;", // temporary
|
||||
"import processing.android.xml.*;"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -209,9 +209,19 @@ public class Device {
|
||||
"1" // start with key down
|
||||
};
|
||||
try {
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
int result;
|
||||
int attempts = 0;
|
||||
do {
|
||||
result = Runtime.getRuntime().exec(cmd).waitFor();
|
||||
attempts++;
|
||||
} while (result != 0 && attempts < 5);
|
||||
|
||||
attempts = 0;
|
||||
cmd[cmd.length - 1] = "0"; // send key up
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
do {
|
||||
result = Runtime.getRuntime().exec(cmd).waitFor();
|
||||
attempts++;
|
||||
} while (result != 0 && attempts < 5);
|
||||
|
||||
} catch (InterruptedException ie) { }
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2008 Ben Fry and Casey Reas
|
||||
Copyright (c) 2008-2009 Ben Fry and Casey Reas
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -30,7 +30,6 @@ import com.sun.jna.Native;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.Platform.CLibrary;
|
||||
import processing.app.windows.Registry.REGISTRY_ROOT_KEY;
|
||||
import processing.core.PApplet;
|
||||
|
||||
@@ -274,14 +273,14 @@ public class Platform extends processing.app.Platform {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
// Code partially thanks to Richard Quirk from:
|
||||
// http://quirkygba.blogspot.com/2009/11/setting-environment-variables-in-java.html
|
||||
|
||||
|
||||
public interface WinLibC extends Library {
|
||||
WinLibC INSTANCE = (WinLibC) Native.loadLibrary("msvcrt", WinLibC.class);
|
||||
|
||||
public int _putenv(String name);
|
||||
// int setenv(String name, String value, int overwrite);
|
||||
// String getenv(String name);
|
||||
// int unsetenv(String name);
|
||||
// int putenv(String string);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user