video working, more work on libraries & import/export

This commit is contained in:
benfry
2004-09-21 19:18:18 +00:00
parent 6cdade27e3
commit 4f3cc80a43
5 changed files with 89 additions and 45 deletions
+4
View File
@@ -338,6 +338,10 @@ public class PdeCompiler implements PdeMessageConsumer {
* any .jar or .zip files inside that folder.
* This will prepend a colon (or whatever the path separator is)
* so that it can be directly appended to another path string.
*
* This will always add the root folder as well, and doesn't bother
* checking to see if there are any .class files in the folder or
* within a subfolder.
*/
static public String contentsToClassPath(File folder) {
if (folder == null) return "";
+22 -14
View File
@@ -43,6 +43,11 @@ public class PdePreprocessor {
static final int JDK14 = 2;
static String defaultImports[][] = new String[3][];
// these ones have the .* at the end, since a class name
// might be at the end instead of .* whcih would make trouble
// other classes using this can lop of the . and anything after
// it to produce a package name consistently.
String extraImports[];
static final int STATIC = 0; // formerly BEGINNER
@@ -134,9 +139,8 @@ public class PdePreprocessor {
// just in case it's not an advanced mode sketch
PatternMatcher matcher = new Perl5Matcher();
PatternCompiler compiler = new Perl5Compiler();
//String mess = "^\\s*(import\\s*[\\w\\d_\\.]+\\s*\\;)";
//String mess = "^\\s*(import\\s*[\\w\\d\\_\\.]+\\s*\\;)";
String mess = "^\\s*(import\\s+\\S+\\s*;)";
//String mess = "^\\s*(import\\s+\\S+\\s*;)";
String mess = "^\\s*(import\\s+)(\\S+)(\\s*;)";
java.util.Vector imports = new java.util.Vector();
Pattern pattern = null;
@@ -152,10 +156,14 @@ public class PdePreprocessor {
if (!matcher.contains(input, pattern)) break;
MatchResult result = matcher.getMatch();
String piece = result.group(1).toString();
String piece1 = result.group(1).toString();
String piece2 = result.group(2).toString(); // the package name
String piece3 = result.group(3).toString();
String piece = piece1 + piece2 + piece3;
int len = piece.length();
imports.add(piece);
//imports.add(piece);
imports.add(piece2);
int idx = program.indexOf(piece);
// just remove altogether?
program = program.substring(0, idx) + program.substring(idx + len);
@@ -241,7 +249,8 @@ public class PdePreprocessor {
File streamFile = new File(buildPath, name + ".java");
PrintStream stream = new PrintStream(new FileOutputStream(streamFile));
writeHeader(stream, extraImports, name);
//writeHeader(stream, extraImports, name);
writeHeader(stream, name);
emitter.setOut(stream);
emitter.print(rootNode);
@@ -277,25 +286,24 @@ public class PdePreprocessor {
* @param exporting Is this being exported from PDE?
* @param name Name of the class being created.
*/
void writeHeader(PrintStream out, String imports[],
String className) {
void writeHeader(PrintStream out, String className) {
// must include processing.core
out.print("import processing.core.*; ");
// emit emports that are needed for classes from the code folder
/*
if (imports != null) {
for (int i = 0; i < imports.length; i++) {
out.print("import " + imports[i] + ".*; ");
}
if (extraImports != null) {
for (int i = 0; i < extraImports.length; i++) {
out.print("import " + extraImports[i] + "; ");
}
}
*/
/*
if (imports != null) {
for (int i = 0; i < imports.length; i++) {
out.print(imports[i]);
}
}
*/
// emit standard imports (read from pde.properties)
// for each language level that's being used.
+14 -1
View File
@@ -72,7 +72,7 @@ public class PdeSketch {
String classPath;
String libraryPath;
boolean externalRuntime;
Vector importedLibraries; // vec of File objects
/**
* path is location of the main .pde file, because this is also
@@ -1138,6 +1138,19 @@ public class PdeSketch {
throw new PdeException(ex.toString());
}
// grab the imports from the code just preproc'd
importedLibraries = new Vector();
String imports[] = preprocessor.extraImports;
for (int i = 0; i < imports.length; i++) {
// remove things up to the last dot
String entry = imports[i].substring(0, imports[i].lastIndexOf('.'));
System.out.println("found package " + entry);
Object libFolder = PdeSketchbook.importToLibraryTable.get(entry);
System.out.println(" found lib folder " + libFolder);
importedLibraries.add(libFolder);
}
// 3. then loop over the code[] and save each .java file
+14 -2
View File
@@ -65,6 +65,9 @@ public class PdeSketchbook {
static File librariesFolder;
static String librariesPath;
// maps imported packages to their library folder
static Hashtable importToLibraryTable = new Hashtable();
// classpath for all known libraries for p5
// (both those in the p5/libs folder and those with lib subfolders
// found in the sketchbook)
@@ -525,10 +528,19 @@ public class PdeSketchbook {
continue;
}
// get the path for all .jar files in this code folder
String libraryClassPath =
PdeCompiler.contentsToClassPath(exported);
// grab all jars and classes from this folder,
// and append them to the library classpath
librariesClassPath += File.pathSeparatorChar +
PdeCompiler.contentsToClassPath(exported);
librariesClassPath +=
File.pathSeparatorChar + libraryClassPath;
// need to associate each import with a library folder
String packages[] =
PdeCompiler.packageListFromClassPath(libraryClassPath);
for (int k = 0; k < packages.length; k++) {
importToLibraryTable.put(packages[k], exported);
}
JMenuItem item = new JMenuItem(list[i]);
item.addActionListener(listener);
+35 -28
View File
@@ -70,23 +70,11 @@ X "Processing" folder not properly created on new install
X add noLoop() to static mode apps
X remove "loop" from special inserts on preproc
040920 afternoon
o when running externally, build into sketch folder?
_ add all imported libs to hash table of jars
_ after export of library, rebuild "import library" menu
_ when running externally, build into sketch folder?
_ static applets need to be able to resize themselves on 'play'
_ figure out what to do with static apps exported as application
_ needs to just hang there
_ scripts will need to call exit() explicitly
_ "create font" not working well with postscript font names
_ need to remap the postscript name back to the java font name
_ or keep a list of font objects, not just the names
_ since already have the list, can use deriveFont
_ tabs on macosx are stinking.. need to use line metrics class
_ libraries
_ attachLibrary(new libsomething()) and attachLibrary("pitaru.Sonia");
o final stop() for static shutdown of lib
@@ -99,15 +87,11 @@ _ be able to link against, but not export, certain parts of lib
_ jsyn.jar not needed on export, netscape libs not needed on export
_ where do libraries for distribution go?
_ libraries subfolder of p5
_ exception in setup() on external app doesn't kill run button
_ also doesn't kill external vm
_ make preferences a modal dialog
_ System.out isn't being heard from P* classes
_ errors inside those classes also causing weirdness
_ this might be a broader running as external app problem
_ errorMessage in PSerial/PClient/PServer are all using System.out
_ netscape.javascript not properly working in 1.4
_ include 'netscape.javascript' as a library to be added
_ but don't export it.. ugh..
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1088034754;start=0
_ after export of library, rebuild "import library" menu
_ get export working again
_ make multiple jar files thing work as an option
@@ -118,6 +102,32 @@ _ buttons on side of sketch do default (last) behavior
_ include a note that 'applet' folder will get emptied/rewritten
_ or rename the old applet folder to something else? (nah, too messy)
_ System.out isn't being heard from P* classes
_ errors inside those classes also causing weirdness
_ this might be a broader running as external app problem
_ errorMessage in PSerial/PClient/PServer are all using System.out
_ write better handler for compiler error:
_ c:/fry/processing/build/windows/work/lib/build/Temporary_8501_3382.java:1:63:1:70: Semantic Error: You need to modify your classpath, sourcepath, bootclasspath, and/or extdirs setup. Package "poo/shoe" could not be found in:
_ write handler for loop() error, warning user to rename loop to draw
_ c:/fry/processing/build/windows/work/lib/build/Temporary_1452_9170.java:29:6:29:11: Semantic Error: The method "void loop();" with default access cannot replace the accessible method "void loop();" with public access declared in type "processing.core.PApplet".
_ static applets need to be able to resize themselves on 'play'
_ figure out what to do with static apps exported as application
_ needs to just hang there
_ scripts (no graphics) will need to call exit() explicitly
_ "create font" not working well with postscript font names
_ need to remap the postscript name back to the java font name
_ or keep a list of font objects, not just the names
_ since already have the list, can use deriveFont
_ tabs on macosx are stinking.. need to use line metrics class
_ exception in setup() on external app doesn't kill run button
_ also doesn't kill external vm
_ make preferences a modal dialog
_ package processing.app for PdeBase, PdeEditor..
_ support for editor plugins
@@ -218,10 +228,6 @@ _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;acti
o is PdeEditorHeader one pixel too tall?
_ menu option for Renderer > to "Core" or "OpenGL"
_ on export, uses this setting to determine if jogl is added to project
_ netscape.javascript not properly working in 1.4
_ include 'netscape.javascript' as a library to be added
_ but don't export it.. ugh..
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1088034754;start=0
_ add a "make archive" option
_ doesn't rename sketch, just names zip file sketch + time stamp
_ need showError/Message/Warning/Prompt design from casey
@@ -230,6 +236,7 @@ _ with an 'email this' button? (include source code too?)
_ also need a "prompt" dialog for asking filenames, etc
_ implement and remove PdeEditorStatus stuff
_ check into open-source paperwork for p5
_
..................................................................