[Laszlo-checkins] r13205 - in openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo: compiler sc
Max Carlson
max at openlaszlo.org
Fri Mar 6 23:34:41 PST 2009
This is great! It's a huge change though, with a certain amount of
risk. It probably would have been better if this had gone through
review. For example, I see a bunch of changes that are just whitespace
- which will make the merge trickier later.
But, it's still great to get such a nice improvement from a customer -
we need to thank them for their contribution!
hqm at openlaszlo.org wrote:
> Author: hqm
> Date: 2009-03-06 22:24:05 -0800 (Fri, 06 Mar 2009)
> New Revision: 13205
>
> Modified:
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilerMediaCache.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/FileResolver.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ImportCompiler.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/LibraryCompiler.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SourceLocator.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SplashCompiler.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/StyleSheetCompiler.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewCompiler.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
> openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java
> Log:
> Change 20090307-hqm-q by hqm at badtzmaru.home on 2009-03-07 01:20:26 EST
> in /Users/hqm/openlaszlo/4.2
> for http://svn.openlaszlo.org/openlaszlo/branches/4.2
>
> Summary: Compilation time is double in Laszlo 4.2.0
>
> New Features:
>
> Bugs Fixed: LPP-7817
>
> Technical Reviewer: hminsky
> QA Reviewer: (pending)
> Doc Reviewer: (pending)
>
> Documentation:
>
> Release Notes:
>
> Details:
>
> skip-pre-commit-checks
>
> + integrate changes from customer to increase compile speed
>
> Tests:
>
> compile calendar,lzpix swf8 solo and proxied
>
> run lzc --scache off , verify that compile time is reduced, extra swf file is not written if --nodeploy flag is set
>
> + ant lztest
>
> + smokecheck swf8
>
>
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -35,7 +35,7 @@
> public class Compiler {
> /** Set this to log the modified schema. */
> public static Logger SchemaLogger = Logger.getLogger("schema");
> -
> +
> public static List KNOWN_RUNTIMES =
> Arrays.asList(new String[] {"swf7", "swf8", "swf9", "swf10", "dhtml", "j2me", "svg", "null"});
> public static List SCRIPT_RUNTIMES =
> @@ -51,7 +51,7 @@
> "$debug", "$profile", "$backtrace", "$runtime",
> "$swf7", "$swf8", "$as2", "$swf9", "$swf10", "$as3", "$dhtml", "$j2me", "$svg", "$js1"
> });
> -
> +
> /** Called to resolve file references (<code>src</code>
> * attributes).
> */
> @@ -97,15 +97,15 @@
> public String getProperty(String key) {
> return mProperties.getProperty(key);
> }
> -
> +
> public void setProperty(String key, String value) {
> mProperties.setProperty(key, value);
> }
> -
> +
> public FileResolver getFileResolver() {
> return mFileResolver;
> - }
> -
> + }
> +
> /** Sets the file resolver for this compiler. The file resolver
> * is used to resolve the names used in include directives to
> * files.
> @@ -121,14 +121,14 @@
> public void setMediaCache(CompilerMediaCache cache) {
> this.mMediaCache = cache;
> }
> -
> - /** Create a CompilationEnvironment with the properties and
> +
> + /** Create a CompilationEnvironment with the properties and
> * FileResolver of this compiler.
> */
> public CompilationEnvironment makeCompilationEnvironment() {
> return new CompilationEnvironment(mProperties, mFileResolver, mMediaCache);
> }
> -
> +
> /** Compiles <var>sourceFile</var> to <var>objectFile</var>. If
> * compilation fails, <var>objectFile</var> is deleted.
> *
> @@ -176,7 +176,7 @@
> {
> FileUtils.makeFileAndParentDirs(objectFile);
>
> - // Compile to a byte-array, and write out to objectFile, and
> + // Compile to a byte-array, and write out to objectFile, and
> // write a copy into sourceFile.[swf|js] if this is a serverless deployment.
> CompilationEnvironment env = makeCompilationEnvironment();
> ByteArrayOutputStream bstream = new ByteArrayOutputStream();
> @@ -190,7 +190,7 @@
> ostream.close();
>
> // If the app is serverless, write out a .lzx.swf file when compiling
> - if (canvas != null && !canvas.isProxied()) {
> + if (canvas != null && !canvas.isProxied() && env.getProperty("nodeploy") == null) {
>
> // Create a foo.lzx.[js|swf] serverless deployment file for sourcefile foo.lzx
> String runtime = props.getProperty(CompilationEnvironment.RUNTIME_PROPERTY);
> @@ -235,7 +235,7 @@
> }
> }
> }
> -
> +
> public Properties getProperties() {
> return (Properties)mProperties.clone();
> }
> @@ -250,7 +250,7 @@
> if ("null".equals(runtime)) {
> return new NullWriter(props, ostr, mMediaCache, true, env);
> } else if (env.isAS3()) {
> - return new SWF9Writer(props, ostr, mMediaCache, true, env);
> + return new SWF9Writer(props, ostr, mMediaCache, true, env);
> } else if (SCRIPT_RUNTIMES.contains(runtime)) {
> return new DHTMLWriter(props, ostr, mMediaCache, true, env);
> } else {
> @@ -277,11 +277,13 @@
> public Canvas compile(File file, OutputStream ostr, Properties props, CompilationEnvironment env)
> throws CompilationError, IOException
> {
> - mLogger.info("compiling " + file + "...");
> + if (mLogger.isInfoEnabled()) {
> + mLogger.info("compiling " + file + "...");
> + }
>
> CompilationErrorHandler errors = env.getErrorHandler();
> env.setApplicationFile(file);
> -
> +
> // Copy target properties (debug, logdebug, profile, krank,
> // runtime) from props arg to CompilationEnvironment
> String runtime = props.getProperty(env.RUNTIME_PROPERTY);
> @@ -289,7 +291,9 @@
> boolean noCodeGeneration = "true".equals(env.getProperty(CompilationEnvironment.NO_CODE_GENERATION));
>
> if (runtime != null) {
> - mLogger.info("canvas compiler compiling runtime = " + runtime);
> + if (mLogger.isInfoEnabled()) {
> + mLogger.info("canvas compiler compiling runtime = " + runtime);
> + }
> env.setProperty(env.RUNTIME_PROPERTY, runtime);
> if (! KNOWN_RUNTIMES.contains(runtime)) {
> List runtimes = new Vector();
> @@ -297,7 +301,7 @@
> iter.hasNext(); ) {
> runtimes.add("\"" + iter.next() + "\"");
> }
> -
> +
> throw new CompilationError(
> MessageFormat.format(
> "Request for unknown runtime: The \"lzr\" query parameter has the value \"{0}\". It must be {1}{2}.",
> @@ -312,6 +316,7 @@
> }
>
> String proxied = props.getProperty(CompilationEnvironment.PROXIED_PROPERTY);
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -320,7 +325,9 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> Compiler.class.getName(),"051018-257", new Object[] {props.toString()})
> );
> + }
> if (proxied != null) {
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -329,6 +336,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> Compiler.class.getName(),"051018-266", new Object[] {proxied})
> );
> + }
> env.setProperty(CompilationEnvironment.PROXIED_PROPERTY, proxied);
> }
>
> @@ -341,9 +349,9 @@
> if (lzconsoledebug != null) {
> env.setProperty(CompilationEnvironment.CONSOLEDEBUG_PROPERTY, lzconsoledebug);
> }
> -
>
>
> +
> String backtrace = props.getProperty(CompilationEnvironment.BACKTRACE_PROPERTY);
> if (backtrace != null) {
> if ("true".equals(backtrace)) {
> @@ -382,8 +390,9 @@
> if (nameFunctions != null) {
> env.setProperty(CompilationEnvironment.NAME_FUNCTIONS, nameFunctions);
> }
> -
> +
> try {
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -392,17 +401,18 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> Compiler.class.getName(),"051018-303", new Object[] {file.getAbsolutePath()})
> );
> + }
> // Initialize the schema from the base LFC interface file
> - try {
> +
> + try {
> env.getSchema().loadSchema(env);
> } catch (org.jdom.JDOMException e) {
> throw new ChainedException(e);
> }
>
> -
> Document doc = env.getParser().parse(file, env);
> Element root = doc.getRootElement();
> -
> +
> // Override passed in runtime target properties with the
> // canvas values.
> if ("true".equals(root.getAttributeValue("debug"))) {
> @@ -416,20 +426,24 @@
> // cssfile cannot be set in the canvas tag
> String cssfile = props.getProperty(CompilationEnvironment.CSSFILE_PROPERTY);
> if (cssfile != null) {
> - mLogger.info("Got cssfile named: " + cssfile);
> + if (mLogger.isInfoEnabled()) {
> + mLogger.info("Got cssfile named: " + cssfile);
> + }
> cssfile = root.getAttributeValue("cssfile");
> throw new CompilationError(
> "cssfile attribute of canvas is no longer supported. Use <stylesheet> instead.");
> -
> - }
>
> - mLogger.debug("Making a writer...");
> + }
> +
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("Making a writer...");
> + }
> ViewSchema schema = env.getSchema();
> Set externalLibraries = null;
> // If we are not linking, then we consider all external
> // files to have already been imported.
> if (! linking) { externalLibraries = env.getImportedLibraryFiles(); }
> - if (root.getName().intern() !=
> + if (root.getName().intern() !=
> (linking ? "canvas" : "library")) {
> throw new CompilationError(
> /* (non-Javadoc)
> @@ -441,11 +455,11 @@
> );
> }
> Compiler.updateRootSchema(root, env, schema, externalLibraries);
> -
> +
> if (noCodeGeneration) {
> return null;
> }
> -
> +
> Properties nprops = (Properties) env.getProperties().clone();
> Map compileTimeConstants = new HashMap();
> compileTimeConstants.put("$debug", new Boolean(
> @@ -468,9 +482,9 @@
> compileTimeConstants.put("$as3", Boolean.valueOf(env.isAS3()));
> compileTimeConstants.put("$dhtml", Boolean.valueOf("dhtml".equals(runtime)));
> compileTimeConstants.put("$j2me", Boolean.valueOf("j2me".equals(runtime)));
> - compileTimeConstants.put("$svg", Boolean.valueOf("svg".equals(runtime)));
> + compileTimeConstants.put("$svg", Boolean.valueOf("svg".equals(runtime)));
> compileTimeConstants.put("$js1", Boolean.valueOf(Arrays.asList(new String[] {"dhtml", "j2me", "svg"}).contains(runtime)));
> -
> +
> // [todo: 2006-04-17 hqm] These compileTimeConstants will be used by the script compiler
> // at compile time, but they won't be emitted into the object code for user apps. Only
> // the compiled LFC emits code which defines these constants. We need to have some
> @@ -481,20 +495,23 @@
>
> env.setObjectWriter(writer);
>
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("new env..." + env.getProperties().toString());
> + }
>
> - mLogger.debug("new env..." + env.getProperties().toString());
> -
> processCompilerInstructions(root, env);
>
> compileElement(root, env);
> if (linking) {
> ViewCompiler.checkUnresolvedResourceReferences (env);
> }
> - mLogger.debug("done...");
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("done...");
> + }
> // This isn't in a finally clause, because it won't generally
> // succeed if an error occurs.
> writer.close();
> -
> +
> Canvas canvas = env.getCanvas();
> if (!errors.isEmpty()) {
> if (canvas != null) {
> @@ -511,7 +528,10 @@
> // set file path (relative to webapp) in canvas
> canvas.setFilePath(FileUtils.relativePath(file, LPS.HOME()));
> }
> - mLogger.info("done");
> +
> + if (mLogger.isInfoEnabled()) {
> + mLogger.info("done");
> + }
> return canvas;
> } catch (CompilationError e) {
> // TBD: e.initPathname(file.getPath());
> @@ -558,7 +578,7 @@
> "}());\n";
> } else {
> // it's a remote debug request, send a response to client
> - prog =
> + prog =
> "(function () {\n" +
> " #pragma 'scriptElement'\n" +
> "_level0.Debug.displayResult(\n"+
> @@ -575,7 +595,7 @@
> " #pragma 'scriptElement'\n" +
> CompilerUtils.sourceLocationDirective(null, new Integer(0), new Integer(0)) +
> script+"\n"+
> - " if (Debug.remoteDebug) { _level0.__LzDebug.sockWriteAsXML(true,"+seqnum+");};\n" +
> + " if (Debug.remoteDebug) { _level0.__LzDebug.sockWriteAsXML(true,"+seqnum+");};\n" +
> " }());\n" +
> "this._parent.loader.returnData( this._parent )";
> action = ScriptCompiler.compileToByteArray(wrapper, props);
> @@ -630,7 +650,7 @@
> props.setProperty(CompilationEnvironment.DEBUG_PROPERTY, "true");
> props.put(org.openlaszlo.sc.Compiler.SWF9_APP_CLASSNAME, SWF9Writer.DEBUG_EVAL_CLASSNAME);
> props.put(org.openlaszlo.sc.Compiler.SWF9_WRAPPER_CLASSNAME, SWF9Writer.DEBUG_EVAL_CLASSNAME);
> - props.put(org.openlaszlo.sc.Compiler.SWF9_APPLICATION_PREAMBLE,
> + props.put(org.openlaszlo.sc.Compiler.SWF9_APPLICATION_PREAMBLE,
> "public class " + SWF9Writer.DEBUG_EVAL_CLASSNAME +
> " extends " + SWF9Writer.DEBUG_EVAL_SUPERCLASS + " {\n " + SWF9Writer.imports + "}\n");
>
> @@ -784,7 +804,9 @@
> }
> try {
> ElementCompiler compiler = getElementCompiler(element, env);
> - mLogger.debug("compiling element "+element.getName() + " with compiler "+compiler.getClass().toString());
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("compiling element "+element.getName() + " with compiler "+compiler.getClass().toString());
> + }
> compiler.compile(element);
> } catch (CompilationError e) {
> // todo: wrap instead
> @@ -836,7 +858,7 @@
> compileElement(root, env);
> }
> }
> -
> +
> static void updateSchemaFromLibrary(File file, CompilationEnvironment env,
> ViewSchema schema, Set visited, Set externalLibraries)
> {
> @@ -874,7 +896,7 @@
> processCompilerInstruction(env, pi);
> }
> }
> -
> +
> protected void processCompilerInstruction(CompilationEnvironment env,
> ProcessingInstruction pi) {
> if (pi.getPseudoAttributeValue("class") != null)
> @@ -885,7 +907,7 @@
> }
> }
> }
> -
> +
> protected void processClassInstruction(CompilationEnvironment env,
> String className,
> ProcessingInstruction pi) {
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilerMediaCache.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilerMediaCache.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilerMediaCache.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -38,14 +38,14 @@
>
> /** Properties */
> private static Properties mProperties = null;
> -
> +
> /** See the constructor. */
> protected File mCacheDirectory;
>
> /**
> * Creates a new <code>CompilerMediaCache</code> instance.
> */
> - public CompilerMediaCache(File cacheDirectory, Properties props)
> + public CompilerMediaCache(File cacheDirectory, Properties props)
> throws IOException {
> super("cmcache", cacheDirectory, props);
> this.mCacheDirectory = cacheDirectory;
> @@ -75,13 +75,14 @@
> * @param toType type of file to transcode into
> */
> public synchronized File transcode(
> - File inputFile,
> - String fromType,
> - String toType)
> - throws TranscoderException,
> - FileNotFoundException,
> + File inputFile,
> + String fromType,
> + String toType)
> + throws TranscoderException,
> + FileNotFoundException,
> IOException {
>
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -90,6 +91,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> CompilerMediaCache.class.getName(),"051018-90", new Object[] {fromType, toType})
> );
> + }
> if (fromType.equalsIgnoreCase(toType)) {
> return inputFile;
> }
> @@ -103,13 +105,14 @@
> String key = FileUtils.relativePath(inputFile, LPS.HOME()) + ":" + toType;
>
> /* we don't use the cache's encoding support; we do it ourselves */
> - String enc = null;
> + String enc = null;
> boolean lockit = false;
> Item item = findItem(key, null, lockit);
>
> String inputFilePath = inputFile.getAbsolutePath();
> File cacheFile = item.getFile();
> String cacheFilePath = cacheFile.getAbsolutePath();
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -118,6 +121,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> CompilerMediaCache.class.getName(),"051018-118", new Object[] {inputFilePath, cacheFilePath})
> );
> + }
>
> InputStream input = null;
> FileOutputStream output = null;
> @@ -125,9 +129,10 @@
> if (!cacheFile.exists() || !inputFile.canRead() ||
> inputFile.lastModified() > cacheFile.lastModified() ||
> mProperties.getProperty("forcetranscode", "false") == "true") {
> -
> +
> item.markDirty();
>
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -136,10 +141,12 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> CompilerMediaCache.class.getName(),"051018-135")
> );
> + }
>
> CachedInfo info = item.getInfo();
> try {
> input = Transcoder.transcode(inputFile, fromType, toType);
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -148,6 +155,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> CompilerMediaCache.class.getName(),"051018-147")
> );
> + }
> item.update(input, null);
> info.setLastModified(cacheFile.lastModified());
> item.updateInfo();
> @@ -155,7 +163,8 @@
> } finally {
> FileUtils.close(input);
> }
> - } else {
> + } else {
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -164,6 +173,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> CompilerMediaCache.class.getName(),"051018-163")
> );
> + }
> }
>
> updateCache(item);
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/FileResolver.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/FileResolver.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/FileResolver.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -54,7 +54,8 @@
> * supplies the context for partial pathnames.)
> */
> class DefaultFileResolver implements FileResolver {
> -
> + private static Logger mLogger = Logger.getLogger(FileResolver.class);
> +
> public Set binaryIncludes = new HashSet();
>
> public Set getBinaryIncludes() { return binaryIncludes; }
> @@ -100,8 +101,6 @@
> }
>
> protected File resolveInternal(CompilationEnvironment env, String pathname, String base) {
> - Logger mLogger = Logger.getLogger(FileResolver.class);
> -
> final String FILE_PROTOCOL = "file";
> String protocol = FILE_PROTOCOL;
>
> @@ -145,7 +144,9 @@
> v.add(base);
> if (SWFtoPNG) {
> String toAdd = FileUtils.insertSubdir(base + "/", "autoPng");
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("Default File Resolver Adding " + toAdd + '\n');
> + }
> v.add(toAdd);
> }
> if (!pathname.startsWith("./") && !pathname.startsWith("../")) {
> @@ -161,16 +162,22 @@
> File f = (new File(dir, pathname)).getCanonicalFile();
> if (f.exists() ||
> ((binaryIncludes != null) && binaryIncludes.contains(f))) {
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("Resolved " + pathname + " to " +
> f.getAbsolutePath());
> + }
> return f;
> } else if (SWFtoPNG) {
> String autoPngPath = FileUtils.insertSubdir(f.getPath(), "autoPng");
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("Default File Resolver Looking for " + autoPngPath + '\n');
> + }
> File autoPngFile = new File(autoPngPath);
> if (autoPngFile.exists()) {
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("Default File Resolver " + pathname + " to " +
> autoPngFile.getAbsolutePath() + '\n');
> + }
> return autoPngFile;
> } else {
> File [] pathArray = FileUtils.matchPlusSuffix(autoPngFile);
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ImportCompiler.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ImportCompiler.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ImportCompiler.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -24,7 +24,7 @@
> class ImportCompiler extends ToplevelCompiler {
> final static String HREF_ANAME = "href";
> final static String NAME_ANAME = "name";
> -
> +
> private static Logger mLogger = Logger.getLogger(ImportCompiler.class);
>
> ImportCompiler(CompilationEnvironment env) {
> @@ -50,7 +50,9 @@
> String libname = XMLUtils.requireAttributeValue(element, NAME_ANAME);
> String stage = XMLUtils.requireAttributeValue(element, "stage");
>
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("ImportCompiler.compile libname="+libname+", href="+href+", stage="+stage);
> + }
>
> Element module = LibraryCompiler.resolveLibraryElement(
> element, mEnv, mEnv.getImportedLibraryFiles());
> @@ -73,7 +75,7 @@
> ImportCompiler.class.getName(),"051018-71", new Object[] {libproxied, importproxied})
> , element);
> }
> -
> +
> // We're not compiling this into the current app, we're
> // building a separate binary library object file for it.
> File appdir = mEnv.getApplicationFile().getParentFile();
> @@ -93,15 +95,16 @@
> String libfile = libsrcfile.getName();
> String libprefix = mEnv.getLibPrefix();
> String runtime = mEnv.getProperty(mEnv.RUNTIME_PROPERTY);
> - String extension = ".lib";
> - if (mEnv.isAS3() || mEnv.isSWF()) {
> - extension = "." + runtime + ".swf";
> + String extension = ".swf";
> + if (mEnv.isAS3()) {
> + extension = ".swf";
> } else if (Compiler.SCRIPT_RUNTIMES.contains(runtime)) {
> extension = ".js";
> - }
> + }
> String objfilename = libprefix + "/" + libfile + extension;
> String objpath = mEnv.getLibPrefixRelative() + "/" + libfile + extension;
>
> + if (mLogger.isInfoEnabled()) {
> mLogger.info(
> /* (non-Javadoc)
> * @i18n.test
> @@ -110,6 +113,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> ImportCompiler.class.getName(),"051018-103", new Object[] {libsrcfile, objfilename})
> );
> + }
>
> try {
> FileUtils.makeFileAndParentDirs(new File(objfilename));
> @@ -120,7 +124,9 @@
> if (mEnv.isAS3()) {
> // In Flash 9/10 we compile the main app first, then compile the libraries
> // against that generated source tree.
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("... queueing import lib compilation" +libsrcfile+", " +objfilename +", "+ objpath+", "+module);
> + }
> queueLibraryCompilation(libsrcfile, objfilename, objpath, module);
> } else {
> compileLibrary(libsrcfile, objfilename, objpath, module);
> @@ -194,7 +200,7 @@
> } else {
> throw new CompilationError("runtime "+runtime+" not supported for generating an import library", element);
> }
> -
> +
> env.setObjectWriter(writer);
> // Set the main SWFWriter so we can output resources
> // to the main app
> @@ -209,7 +215,7 @@
> // copy the fontmanager from old env to new one.
> writer.setFontManager(mEnv.getGenerator().getFontManager());
> writer.setCanvasDefaults(mEnv.getCanvas(), mEnv.getMediaCache());
> -
> +
> writer.openSnippet(liburl);
>
> env.compileScript("// BEGIN compiling <IMPORT> Library "+liburl+"\n");
> @@ -231,7 +237,7 @@
> // prefix. But this covers global var lookups inside
> // of a library.
> if (Compiler.SWF_RUNTIMES.contains(runtime)) {
> - ((SWFWriter) env.getGenerator()).setLevel0(true);
> + ((SWFWriter) env.getGenerator()).setLevel0(true);
> }
>
>
> @@ -251,7 +257,7 @@
> }
>
> ViewCompiler.checkUnresolvedResourceReferences (env);
> -
> +
> writer.closeSnippet();
> env.compileScript("// FINISH compiling <IMPORT> Library "+liburl+"\n");
> } finally {
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/LibraryCompiler.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/LibraryCompiler.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/LibraryCompiler.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -20,7 +20,7 @@
> class LibraryCompiler extends ToplevelCompiler {
> final static String HREF_ANAME = "href";
> final static String INCLUDES_ANAME = "includes";
> -
> +
> /** Logger
> */
> private static Logger mLogger = Logger.getLogger(LibraryCompiler.class);
> @@ -44,7 +44,9 @@
> try {
> File key = file.getCanonicalFile();
> if (!visited.contains(key)) {
> - mLogger.debug("Resolving: " + key);
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("Resolving: " + key);
> + }
> visited.add(key);
>
> // If we're compiling a loadable library, add this to
> @@ -75,25 +77,65 @@
> if (env.parsedLibraryCache.get(file) != null) {
> root = (Element) env.parsedLibraryCache.get(file);
> } else {
> - Document doc = env.getParser().parse(file, env);
> - root = doc.getRootElement();
> + String keepParsedLibraries = env.getProperty("keepParsedLibraries");
> + File serializedFile = new File(key.getParent(), "." + key.getName() + ".ser");
> + if (keepParsedLibraries != null && serializedFile.exists() && serializedFile.lastModified() > file.lastModified()) {
> + try {
> + FileInputStream fis = new FileInputStream(serializedFile);
> + ObjectInputStream in = new ObjectInputStream(fis);
> + root = (Element)in.readObject();
> + in.close();
> + keepParsedLibraries = null;
> + }
> + catch(IOException ex) {
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("Error loading " + serializedFile + " " + ex);
> + }
> + }
> + catch(ClassNotFoundException ex) {
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("Error loading " + serializedFile + " " + ex);
> + }
> + }
> + }
> + if (root == null) {
> + Document doc = env.getParser().parse(file, env);
> + root = doc.getRootElement();
> + }
> env.parsedLibraryCache.put(file, root);
> - mLogger.debug("" + file + ": " + root + " attributes: " + root.getAttributes());
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("" + file + ": " + root + " attributes: " + root.getAttributes());
> + }
> // Look for and add any includes from a binary library
> String includesAttr = root.getAttributeValue(INCLUDES_ANAME);
> - File base = new File(Parser.getSourcePathname(root)).getParentFile();
> if (includesAttr != null) {
> - // This modularity sucks
> - Set binaryIncludes = env.getFileResolver().getBinaryIncludes();
> - for (StringTokenizer st = new StringTokenizer(includesAttr);
> - st.hasMoreTokens();) {
> - String name = FileUtils.fromURLPath((String)st.nextToken());
> - File canon = new File(base, name).getCanonicalFile();
> - mLogger.debug("binary include: " + canon);
> - visited.add(canon);
> - binaryIncludes.add(canon);
> + File base = new File(Parser.getSourcePathname(root)).getParentFile();
> + // This modularity sucks
> + Set binaryIncludes = env.getFileResolver().getBinaryIncludes();
> + for (StringTokenizer st = new StringTokenizer(includesAttr);
> + st.hasMoreTokens();) {
> + String name = FileUtils.fromURLPath((String)st.nextToken());
> + File canon = new File(base, name).getCanonicalFile();
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("binary include: " + canon);
> + }
> + visited.add(canon);
> + binaryIncludes.add(canon);
> }
> }
> + if (keepParsedLibraries != null) {
> + try {
> + FileOutputStream fos = new FileOutputStream(serializedFile);
> + ObjectOutputStream out = new ObjectOutputStream(fos);
> + out.writeObject(root);
> + out.close();
> + }
> + catch(IOException ex) {
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("Error saving " + serializedFile + " " + ex);
> + }
> + }
> + }
> }
> return root;
> } else {
> @@ -103,7 +145,7 @@
> throw new CompilationError(e);
> }
> }
> -
> +
> /** Return the resolved library element and add the library to visited.
> * If the library has already been visited, return null instead.
> */
> @@ -118,7 +160,7 @@
> File file = env.resolveReference(element, HREF_ANAME, true);
> return resolveLibraryElement(file, env, visited);
> }
> -
> +
> public void compile(Element element) throws CompilationError
> {
> element = resolveLibraryElement(
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -29,12 +29,14 @@
> " Write progress information to standard output.",
> "--mcache on|off",
> " Turns on/off media cache. Default is off.",
> + "--scache on|off",
> + " Turns on/off script cache. Default is on.",
> "--onerror [throw|warn]",
> " Action to take on compilation errors. Defaults to warn.",
> "--help",
> " Prints this message.",
> - "--flush-script-cache[=true|false]",
> - " Flush script cache before compiling, boolean value optional. System default can be set in lps.properties ",
> + "--flush-script-cache",
> + " Doesn't flush script cache before compiling.",
> "--script-cache-dir directory",
> " Location of script cache directory (default <lps>/work/scache)",
> "--media-cache-dir directory",
> @@ -95,7 +97,7 @@
> /** This method implements the behavior described in main
> * but also returns an integer error code.
> */
> - public static int lzc(String args[], String logFile,
> + public static int lzc(String args[], String logFile,
> String outFileName, String outDir)
> throws IOException
> {
> @@ -110,7 +112,7 @@
> } else {
> logger.addAppender(new FileAppender(layout, logFile, false));
> }
> -
> +
> Compiler compiler = new Compiler();
>
> String tmpdirstr = System.getProperty("java.io.tmpdir");
> @@ -123,7 +125,8 @@
> compiler.setProperty(CompilationEnvironment.RUNTIME_PROPERTY,
> LPS.getProperty("compiler.runtime.default",
> LPS.getRuntimeDefault()));
> - boolean flushScriptCache = "false".equals(LPS.getProperty("compiler.scache.persist", "true"));
> + boolean flushScriptCache = true;
> + boolean enableScriptCache = true;
> Boolean forceTransCode = null;
> String outFileArg = null;
> boolean saveScriptOption = false;
> @@ -147,11 +150,11 @@
> LPS.setHome(lhome);
> } else if (arg == "--schema") {
> compiler.SchemaLogger.setLevel(Level.ALL);
> + } else if (arg == "--keepscriptcache") {
> + flushScriptCache = false;
> + System.err.println("--keepscriptcache is deprecated. This is now the default behavior.");
> } else if (arg == "--flush-script-cache") {
> flushScriptCache = true;
> - } else if (arg.startsWith("--flush-script-cache=")) {
> - String value = arg.substring("--flush-script-cache=".length());
> - flushScriptCache = "true".equals(value);
> } else if (arg == "-o" || arg == "--output") {
> outFileArg = safeArg("-o or --output", args, ++i);
> if (outFileArg == null) {
> @@ -206,6 +209,19 @@
> System.err.println(MORE_HELP);
> return 1;
> }
> + } else if (arg == "-scache" || arg == "--scache") {
> + String value = safeArg("-scache", args, ++i);
> + if (value == null) {
> + return 1;
> + } else if (value.equals("on")) {
> + enableScriptCache = true;
> + } else if (value.equals("off")) {
> + enableScriptCache = false;
> + } else {
> + System.out.println("Invalid value for --scache");
> + System.err.println(MORE_HELP);
> + return 1;
> + }
> } else if (arg == "-log" || arg == "--log") {
> String log = safeArg("-log or --log", args, ++i);
> if (log == null) {
> @@ -270,10 +286,12 @@
> }
> compiler.setMediaCache(cache);
>
> - ScriptCompiler.initScriptCompilerCache(new File(scriptCacheDir), new Properties());
> + if (enableScriptCache) {
> + ScriptCompiler.initScriptCompilerCache(new File(scriptCacheDir), new Properties());
>
> - if (flushScriptCache) {
> - ScriptCompiler.clearCacheStatic();
> + if (flushScriptCache) {
> + ScriptCompiler.clearCacheStatic();
> + }
> }
>
> LPS.initialize();
> @@ -302,7 +320,7 @@
> intermediateName = sourceNameNoExt + ".lzs";
> }
> if (saveStateOption) {
> - // remove old
> + // remove old
> File dir = new File(sourceName).getCanonicalFile().getParentFile();
> final String pat = new File(sourceNameNoExt).getName() +
> "-ast(?:in|out)-[0-9]*.txt";
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -79,7 +79,7 @@
> /** media cache for transcoding */
> protected CompilerMediaCache mCache = null;
>
> - /** <String,Resource> maps resource files to the Resources
> + /** <String,Resource> maps resource files to the Resources
> * definition in the swf file. */
> protected Map mResourceMap = new HashMap();
> protected Map mClickResourceMap = new HashMap();
> @@ -108,7 +108,7 @@
> /**
> * Initializes a ObjectWriter with an OutputStream to which a new object file
> * will be written when <code>ObjectWriter.close()</code> is called.
> - *
> + *
> * @param stream A <code>java.io.OutputStream</code> that the
> * movie will be written to.
> * @param props list of properties
> @@ -124,12 +124,12 @@
> this.mStream = stream;
> this.mEnv = env;
> }
> -
> +
> /**
> * Sets the canvas for the app
> *
> * @param canvas
> - *
> + *
> */
> abstract void setCanvas(Canvas canvas, String canvasConstructor);
>
> @@ -205,7 +205,7 @@
> {
> try {
> String inputMimeType = MimeType.fromExtension(fileName);
> - if (!Transcoder.canTranscode(inputMimeType, MimeType.SWF)
> + if (!Transcoder.canTranscode(inputMimeType, MimeType.SWF)
> && !inputMimeType.equals(MimeType.SWF)) {
> inputMimeType = Transcoder.guessSupportedMimeTypeFromContent(fileName);
> if (inputMimeType == null || inputMimeType.equals("")) {
> @@ -222,28 +222,29 @@
> // No need to get these from the cache since they don't need to be
> // transcoded and we usually keep the cmcache on disk.
> if (inputMimeType.equals(MimeType.SWF)) {
> -
> +
> long fileSize = FileUtils.getSize(new File(fileName));
> -
> +
> Element elt = new Element("resource");
> elt.setAttribute("name", name);
> elt.setAttribute("mime-type", inputMimeType);
> elt.setAttribute("source", fileName);
> elt.setAttribute("filesize", "" + fileSize);
> mInfo.addContent(elt);
> -
> +
> return importSWF(fileName, name, false);
> }
>
> - // TODO: [2002-12-3 bloch] use cache for mp3s; for now we're skipping it
> + // TODO: [2002-12-3 bloch] use cache for mp3s; for now we're skipping it
> // arguably, this is a fixme
> - if (inputMimeType.equals(MimeType.MP3) ||
> + if (inputMimeType.equals(MimeType.MP3) ||
> inputMimeType.equals(MimeType.XMP3)) {
> return importMP3(fileName, name);
> }
> -
> +
> File inputFile = new File(fileName);
> File outputFile = mCache.transcode(inputFile, inputMimeType, MimeType.SWF);
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -252,6 +253,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> ObjectWriter.class.getName(),"051018-584", new Object[] {fileName, name, new Long(outputFile.length())})
> );
> + }
>
> long fileSize = FileUtils.getSize(outputFile);
>
> @@ -288,10 +290,10 @@
> * @param name name of the MovieClip/Sprite
> * @throws CompilationError
> */
> - abstract public void importPreloadResource(String fileName, String name)
> + abstract public void importPreloadResource(String fileName, String name)
> throws ImportResourceError;
>
> - abstract public void importPreloadResource(File fileName, String name)
> + abstract public void importPreloadResource(File fileName, String name)
> throws ImportResourceError;
>
> /** Import a multiframe resource into the current movie. Using a
> @@ -307,7 +309,9 @@
> * File should refer to a graphical asset. */
> public String importResource(File file)
> {
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("ObjectResource:importResource(File) "+file.getPath());
> + }
> Resource res;
>
> try {
> @@ -346,8 +350,8 @@
> String createName() {
> return mNameSupply.next();
> }
> -
>
> +
> /**
> * collect fonts for later use
> */
> @@ -361,7 +365,7 @@
> for( int k=0; k<frame.size(); k++ ) {
> FlashObject fo = frame.getFlashObjectAt(k);
> fo.collectFonts( mFontsCollector );
> - //mLogger.debug("FONTS size "
> + //mLogger.debug("FONTS size "
> //+ mFontsCollector.getFonts().size());
> }
> }
> @@ -372,7 +376,7 @@
> * @param name
> * @param addStop if true, add stop action to last frame
> */
> - protected Resource importSWF(String fileName, String name, boolean addStop)
> + protected Resource importSWF(String fileName, String name, boolean addStop)
> throws IVException, FileNotFoundException {
>
> FlashFile f = FlashFile.parse(fileName);
> @@ -401,7 +405,7 @@
> mMultiFrameResourceSet.add(res);
> }
> }
> -
> +
> return res;
> }
>
> @@ -411,7 +415,7 @@
> * @param fileName
> * @param name
> */
> - protected Resource importMP3(String fileName, String name)
> + protected Resource importMP3(String fileName, String name)
> throws IVException, IOException {
>
> long fileSize = FileUtils.getSize(new File(fileName));
> @@ -469,7 +473,7 @@
> mFlashDef = def;
> }
>
> - /** Create a resource
> + /** Create a resource
> */
> public Resource(String name, FlashDef def, int width, int height) {
> mName = name;
> @@ -505,7 +509,7 @@
> * @param fileName file name of the resource
> * @param name name of the resource
> */
> - protected Resource getMultiFrameResource(String fileName, String name, int fNum)
> + protected Resource getMultiFrameResource(String fileName, String name, int fNum)
> throws ImportResourceError
> {
> Resource res = (Resource)mMultiFrameResourceMap.get(fileName);
> @@ -535,7 +539,7 @@
> throws FileNotFoundException, CompilationError;
>
>
> - public void setScriptLimits(int recursion, int timeout) {
> + public void setScriptLimits(int recursion, int timeout) {
> this.mRecursionLimit = recursion;
> this.mExecutionTimeout = timeout;
> }
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -62,10 +62,10 @@
>
> /** If true, wrap 'with (_level0) { ...} ' around code blocks */
> private boolean level0 = false;
> -
> +
> /** Total number of frames in the movie **/
> private int mLastFrame = 0;
> -
> +
> /** Input text fontinfo map */
> private final TreeMap mInputTextSet = new TreeMap();
>
> @@ -89,10 +89,10 @@
> private int mFlashVersion = 6;
>
> /** frame rate of movie */
> - private int mFrameRate = 30;
> + private int mFrameRate = 30;
>
> /** Leading for text and input text */
> - private int mTextLeading = 2;
> + private int mTextLeading = 2;
>
> private Map mDeviceFontTable = new HashMap();
>
> @@ -107,7 +107,7 @@
> /**
> * Initializes a SWFWriter with an OutputStream to which a new SWF
> * will be written when <code>SWFWriter.close()</code> is called.
> - *
> + *
> * @param stream A <code>java.io.OutputStream</code> that the
> * movie will be written to.
> * @param props list of properties
> @@ -154,10 +154,10 @@
> mFlashFile = new SWFFile(f.getAbsolutePath(), mProperties);
> mFlashFile.setVersion(mFlashVersion);
> // Set the frame rate (shifted)
> - mFlashFile.setFrameRate(mFrameRate << 8);
> -
> + mFlashFile.setFrameRate(mFrameRate << 8);
> +
> // mFlashFile.printContent(System.out);
> -
> +
> if (LPS.isInternalBuild()) {
> long lfcModTime = f.lastModified();
> List newerFiles = new Vector(); // List<File>
> @@ -189,7 +189,7 @@
> throw new ChainedException(e);
> }
> }
> -
> +
> FontManager getFontManager() {
> return mFontManager;
> }
> @@ -219,7 +219,7 @@
>
> addScript(script, 0);
> }
> -
> +
> void addPreloader(CompilationEnvironment env) {
> if (mPreloaderAdded == true) return;
>
> @@ -241,7 +241,7 @@
> * Sets the canvas for the movie
> *
> * @param canvas
> - *
> + *
> */
> void setCanvas(Canvas canvas, String canvasConstructor) {
> Rectangle2D r = new Rectangle2D.Double(
> @@ -254,11 +254,11 @@
> int bgc = canvas.getBGColor();
> int red = (bgc >> 16) & 0xff;
> int green = (bgc >> 8) & 0xff;
> - int blue = (bgc) & 0xff;
> + int blue = (bgc) & 0xff;
> Color c = new Color(red, green, blue);
> SetBackgroundColor setbgc = new SetBackgroundColor(c);
> mFlashFile.getMainScript().setBackgroundColor(setbgc);
> -
> +
> // Write scriptlimits tag if requested
> if ((this.mRecursionLimit != 0) || (this.mExecutionTimeout != 0)) {
> // ScriptLimits tag, to set max recursion depth and timeout
> @@ -274,14 +274,16 @@
> //scriptWriter.println(canvasConstructor);
> byte[] action = ScriptCompiler.compileToByteArray(canvasConstructor, props);
> Program program = new Program(action, 0, action.length);
> - mLogger.debug(" Adding a program of " + action.length + " bytes.");
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug(" Adding a program of " + action.length + " bytes.");
> + }
> addProgram(program);
>
> // Set width and height properties for preloader...
> mWidth = canvas.getWidth();
> mHeight = canvas.getHeight();
>
> - // Get default font info
> + // Get default font info
> FontInfo fontInfo = canvas.getFontInfo();
>
> mDefaultFontName = canvas.defaultFont;
> @@ -299,7 +301,7 @@
> mResourceTableIndex = frame.size();
> frame.addFlashObject(new SetBackgroundColor(new Color(0, 0, 0)));
>
> - mEnv.getCanvas().addInfo(mInfo);
> + mEnv.getCanvas().addInfo(mInfo);
>
> // always write out the preloader...
> ObjectWriter sw = mEnv.getGenerator();
> @@ -318,7 +320,7 @@
> this.mCache = mc;
> mWidth = canvas.getWidth();
> mHeight = canvas.getHeight();
> - // Get default font info
> + // Get default font info
> FontInfo fontInfo = canvas.getFontInfo();
> mDefaultFontName = canvas.defaultFont;
> mDefaultFontFileName = canvas.defaultFontFilename;
> @@ -348,6 +350,7 @@
> byte[] action = ScriptCompiler.compileToByteArray(script, mProperties);
> //scriptWriter.println(script);
> Program program = new Program(action, 0, action.length);
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -356,6 +359,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> SWFWriter.class.getName(),"051018-410", new Object[] {new Integer(action.length)})
> );
> + }
> addProgram(program);
> return action.length;
> }
> @@ -373,6 +377,7 @@
> byte[] action = ScriptCompiler.compileToByteArray(script, mProperties);
> //scriptWriter.println(script);
> Program program = new Program(action, 0, action.length);
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -381,6 +386,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> SWFWriter.class.getName(),"051018-410", new Object[] {new Integer(action.length)})
> );
> + }
> addProgram(program, offset);
> }
>
> @@ -398,7 +404,7 @@
> * Adds the program to the specified frame
> *
> * @param program to be added
> - * @param offset of frame to add to
> + * @param offset of frame to add to
> */
> private void addProgram(Program program, int offset) {
> Frame frame = mFlashFile.getMainScript().getFrameAt(offset);
> @@ -436,7 +442,7 @@
> * @param name name of the MovieClip/Sprite
> * @throws CompilationError
> */
> - public void importPreloadResource(String fileName, String name)
> + public void importPreloadResource(String fileName, String name)
> throws ImportResourceError
> {
> if (name.equals(""))
> @@ -444,7 +450,7 @@
> importResource(fileName, name, 0, mPreloaderFontsCollector);
> }
>
> - public void importPreloadResource(File fFileName, String name)
> + public void importPreloadResource(File fFileName, String name)
> throws ImportResourceError
> {
> if (name.equals(""))
> @@ -458,7 +464,7 @@
> public void importPreloadResource(List sources, String name, File parent)
> throws ImportResourceError
> {
> - if (name.equals(""))
> + if (name.equals(""))
> name = createName();
> importResource(sources, name, parent, 0, mPreloaderFontsCollector);
> }
> @@ -470,7 +476,7 @@
> *
> * @param sources file names of the resources
> * @param name name of the MovieClip/Sprite
> - * @param parent parent's File object
> + * @param parent parent's File object
> */
> public void importResource(List sources, String name, File parent)
> {
> @@ -482,7 +488,7 @@
> *
> * @param sources file names of the resources
> * @param name name of the MovieClip/Sprite
> - * @param parent parent's File object
> + * @param parent parent's File object
> * @param frameNum frame offset to add to
> */
> public void importResource(List sources, String name, File parent, int frameNum)
> @@ -536,7 +542,7 @@
> * @param fontsCollector fonts collector for resource (used by preloader)
> * @throws CompilationError
> */
> - public void importResource(String fileName, String name, int frameNum,
> + public void importResource(String fileName, String name, int frameNum,
> FontsCollector fontsCollector)
> throws CompilationError
> {
> @@ -545,14 +551,14 @@
> if (inputFile.isDirectory()) {
> String[] sources = inputFile.list();
> ArrayList outsources = new ArrayList();
> -
> +
> for (int i = 0; i < sources.length; i++) {
> String fname = fileName + File.separator + sources[i];
> File f = new File(fname);
> - //mLogger.debug("SWFWriter file: " + f.isFile());
> + //mLogger.debug("SWFWriter file: " + f.isFile());
>
> if (f.isFile()) {
> - //mLogger.debug("SWFWriter adding: " + fname);
> + //mLogger.debug("SWFWriter adding: " + fname);
> outsources.add(fname);
> }
> }
> @@ -560,7 +566,9 @@
> return;
> }
>
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(" Importing resource " + name);
> + }
> try {
> fileName = new File(fileName).getCanonicalPath();
> } catch (java.io.IOException e) {
> @@ -579,7 +587,7 @@
> if (fontsCollector != null) def.collectFonts(fontsCollector);
> mFlashFile.addDefToLibrary(name, def);
> def.setName(name);
> -
> +
> } else {
> def = res.getFlashDef();
> if (fontsCollector != null) def.collectFonts(fontsCollector);
> @@ -587,12 +595,12 @@
> // Add an element with 0 size, since it's already there.
> Element elt = new Element("resource");
> elt.setAttribute("name", name);
> - // elt.setAttribute("mime-type", MimeType.MP3);
> + // elt.setAttribute("mime-type", MimeType.MP3);
> elt.setAttribute("source", fileName);
> elt.setAttribute("filesize", "0");
> mInfo.addContent(elt);
> - }
> -
> + }
> +
> ExportAssets ea = new ExportAssets();
> ea.addAsset(name, def);
> Timeline timeline = mFlashFile.getMainScript().getTimeline();
> @@ -602,17 +610,17 @@
> Frame frame = timeline.getFrameAt(frameNum);
> frame.addFlashObject(ea);
> }
> -
> +
> /** Import a multiframe resource into the current movie. Using a
> * name that already exists clobbers the old resource (for now).
> *
> * @param sources file names of the resources
> * @param name name of the MovieClip/Sprite
> - * @param parent parent's File object
> + * @param parent parent's File object
> * @param frameNum frame offset to add to
> * @param fontsCollector fonts collector for resource (used by preloader)
> */
> - public void importResource(List sources, String name, File parent, int frameNum,
> + public void importResource(List sources, String name, File parent, int frameNum,
> FontsCollector fontsCollector)
>
> {
> @@ -624,34 +632,40 @@
> *
> * @param sources file names of the resources
> * @param name name of the MovieClip/Sprite
> - * @param parent parent's File object
> + * @param parent parent's File object
> * @param frameNum frame offset to add to
> * @param fontsCollector fonts collector for resource (used by preloader)
> - * @param addStop if true, add a stop frame after each imported resource
> + * @param addStop if true, add a stop frame after each imported resource
> */
> - public void importResource(List sources, String name, File parent, int frameNum,
> + public void importResource(List sources, String name, File parent, int frameNum,
> FontsCollector fontsCollector, boolean addStop)
> {
> Script out = new Script(1);
> String fileName = null;
> - mLogger.debug("Including multiple resources as " + name);
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("Including multiple resources as " + name);
> + }
> int width = 0;
> int height = 0;
> int fNum = 0;
> for (Iterator e = sources.iterator() ; e.hasNext() ;) {
> fileName = (String)e.next();
> - mLogger.debug(" Importing " + fileName);
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug(" Importing " + fileName);
> + }
>
> // Definition to add to the library (without stop)
> Resource res = getMultiFrameResource(fileName, name, fNum);
> - Script scr = (Script)res.getFlashDef();
> + Script scr = (Script)res.getFlashDef();
> if (fontsCollector != null) scr.collectFonts(fontsCollector);
> int bc = out.getFrameCount();
> out.appendScript(scr);
> int fc = out.getFrameCount();
> Frame f = out.getFrameAt(fc - 1);
> if (addStop) f.addStopAction();
> - mLogger.debug(" Added " + (fc - bc) + " of " + fc + "frame(s)");
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug(" Added " + (fc - bc) + " of " + fc + "frame(s)");
> + }
>
> int rw = res.getWidth();
> int rh = res.getHeight();
> @@ -661,8 +675,8 @@
> if (rh > height) {
> height = rh;
> }
> - // NOTE: add the ratio attribute to each frame here; this
> - // appears to be required to make a multi-frame resource that has individual
> + // NOTE: add the ratio attribute to each frame here; this
> + // appears to be required to make a multi-frame resource that has individual
> // frames that are swfs with nested movieclips work correctly.
> // This was "guessed" by dumping the contents
> // of a multi-frame SWF created by the Flash tool itself.
> @@ -701,7 +715,7 @@
>
> /** Imports this resource, if it has not previously been imported, as
> * resource that can be used as a click region, and returns in any
> - * case the name of the clip that refers to it.
> + * case the name of the clip that refers to it.
> */
> public String importClickResource(File file) throws ImportResourceError
> {
> @@ -721,7 +735,7 @@
> FlashDef def;
> Rectangle2D bounds;
>
> - // FIXME: [2004-06-29 bloch]
> + // FIXME: [2004-06-29 bloch]
> // For each instance in the first frame, add a button record.
> // Get bounds for entire clip; should only get bounds for first frame!
> // Should only allow swf resources as click resources.
> @@ -741,7 +755,7 @@
> if (matrix == null) {
> matrix = new java.awt.geom.AffineTransform();
> }
> -
> +
> but.addButtonRecord(new ButtonRecord(ButtonRecord.HitTest,
> inst.def, 1, matrix, cxform));
> }
> @@ -755,22 +769,22 @@
> but.addActionCondition(ActionCondition.onPress(program(
> "_root.LzMouseKernel.handleMouseEvent( myView, 'onmousedown')")));
> but.addActionCondition(ActionCondition.onRelease(program(
> - "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseup');" +
> + "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseup');" +
> "_root.LzMouseKernel.handleMouseEvent( myView, 'onclick')")));
> but.addActionCondition(ActionCondition.onReleaseOutside(program(
> - "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseup');" +
> + "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseup');" +
> "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseupoutside')")));
> but.addActionCondition(ActionCondition.onRollOver(program(
> "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseover')")));
> but.addActionCondition(ActionCondition.onRollOut(program(
> "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseout')")));
> but.addActionCondition(ActionCondition.onDragOut(program(
> - "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseout');" +
> + "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseout');" +
> "_root.LzMouseKernel.handleMouseEvent( myView, 'onmousedragout')")));
> but.addActionCondition(ActionCondition.onDragOver(program(
> - "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseover');" +
> + "_root.LzMouseKernel.handleMouseEvent( myView, 'onmouseover');" +
> "_root.LzMouseKernel.handleMouseEvent( myView, 'onmousedragin')")));
> -
> +
> name = createName();
>
> // Scale the movieclip to 100x100 for use by LFC.
> @@ -794,12 +808,12 @@
>
> return name;
> }
> -
> +
> /**
> - * Recursively strips out the ActionScript from a
> + * Recursively strips out the ActionScript from a
> * given movie Script (MovieClip)
> *
> - * Actually, it leaves the actionscript blocks in,
> + * Actually, it leaves the actionscript blocks in,
> * but turns them into programs that do nothing.
> */
> private void stripActions(Script s) {
> @@ -897,11 +911,11 @@
>
> // Always compress
> mFlashFile.setCompressed(true);
> -
> - try {
>
> + try {
> +
> InputStream input;
> - input = mFlashFile.generate(mEnv.getEmbedFonts() ? mFontsCollector : new FontsCollector(),
> + input = mFlashFile.generate(mEnv.getEmbedFonts() ? mFontsCollector : new FontsCollector(),
> mEnv.getEmbedFonts() ? mPreloaderFontsCollector : new FontsCollector(),
> mPreloaderAdded).getInputStream();
>
> @@ -916,7 +930,7 @@
> }
>
> public void openSnippet(String liburl) throws IOException {
> - // How do we make sure an initial frame exists? Does this do it?
> + // How do we make sure an initial frame exists? Does this do it?
> Frame frame = mFlashFile.getMainScript().getFrameAt(mLastFrame);
> // if we don't have any frame, then code which adds resources gets
> // an error. This happens if you have a resource declared before any code.
> @@ -941,8 +955,8 @@
> // unfortunately; we haven't figured out a way to make the
> // imported image assets be visible/attachable to the loading
> // movieclip.
> -
>
> +
> if (mLibFontsDefined) {
> ImportAssets2 ia = new ImportAssets2();
> //System.err.println("setting ImportAssets url="+this.liburl);
> @@ -964,7 +978,7 @@
> FlashDef def = (FlashDef) enu.nextElement();
> ia.addAsset(def.getName(), def);
> }
> -
> +
> Timeline timeline = mFlashFile.getMainScript().getTimeline();
> Frame frame = timeline.getFrameAt(timeline.getFrameCount() - 1);
> frame.addFlashObject(ia);
> @@ -980,9 +994,9 @@
> addProgram(program);
>
>
> - try {
> + try {
> InputStream input;
> - input = mFlashFile.generate(mEnv.getEmbedFonts() ? mFontsCollector : new FontsCollector(),
> + input = mFlashFile.generate(mEnv.getEmbedFonts() ? mFontsCollector : new FontsCollector(),
> mEnv.getEmbedFonts() ? mPreloaderFontsCollector : new FontsCollector(),
> mPreloaderAdded).getInputStream();
> FileUtils.send(input, mStream);
> @@ -1016,6 +1030,7 @@
>
> int styleBits = FontInfo.styleBitsFromString(style);
>
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -1024,8 +1039,9 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> SWFWriter.class.getName(),"051018-1225", new Object[] {face, style})
> );
> + }
>
> - FontInfo fontInfo = mEnv.getCanvas().getFontInfo();
> + FontInfo fontInfo = mEnv.getCanvas().getFontInfo();
> boolean isDefault = false;
>
> Font font = importFont(fileName, face, styleBits, false);
> @@ -1035,16 +1051,16 @@
> if (styleBits == FontInfo.PLAIN) {
> isDefault = true;
> mDefaultFont = font;
> - }
> + }
> }
>
> FontFamily family = mFontManager.getFontFamily(face, true);
>
> switch (styleBits) {
> - case FontInfo.PLAIN:
> + case FontInfo.PLAIN:
> if (family.plain != null) {
> if (!isDefault || mDefaultFontUsedForMeasurement) {
> - warn(env,
> + warn(env,
> /* (non-Javadoc)
> * @i18n.test
> * @org-mes="Redefined plain style of font: " + p[0]
> @@ -1057,7 +1073,7 @@
> family.plain = font; break;
> case FontInfo.BOLD:
> if (family.bold != null) {
> - warn(env,
> + warn(env,
> /* (non-Javadoc)
> * @i18n.test
> * @org-mes="Redefined bold style of font: " + p[0]
> @@ -1069,7 +1085,7 @@
> family.bold = font; break;
> case FontInfo.ITALIC:
> if (family.italic != null) {
> - warn(env,
> + warn(env,
> /* (non-Javadoc)
> * @i18n.test
> * @org-mes="Redefined italic style of font: " + p[0]
> @@ -1081,7 +1097,7 @@
> family.italic = font; break;
> case FontInfo.BOLDITALIC:
> if (family.bitalic != null) {
> - warn(env,
> + warn(env,
> /* (non-Javadoc)
> * @i18n.test
> * @org-mes="Redefined bold italic style of font: " + p[0]
> @@ -1107,7 +1123,7 @@
> /**
> * Import a font into the SWF we are writing
> *
> - * @param fileName name of font file
> + * @param fileName name of font file
> * @param face font name of font in LZX
> */
> private Font importFont(String fileName, String face, int styleBits,
> @@ -1118,6 +1134,7 @@
> return Font.createDummyFont(face);
> }
>
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -1126,11 +1143,12 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> SWFWriter.class.getName(),"051018-1327", new Object[] {face, fileName})
> );
> + }
>
> String fromType = FontType.fromName(fileName);
> String location = null;
> try {
> - File fontFile = mCache.transcode(new File(fileName), fromType,
> + File fontFile = mCache.transcode(new File(fileName), fromType,
> FontType.FFT);
> location = fontFile.getAbsolutePath();
> } catch (TranscoderException e) {
> @@ -1158,7 +1176,8 @@
>
> try {
>
> - // Parse the font
> + // Parse the font
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -1167,6 +1186,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> SWFWriter.class.getName(),"051018-1368", new Object[] {location})
> );
> + }
> FlashFile fontFile = FlashFile.parse( location );
> Enumeration defs = fontFile.definitions();
> FontDef fontDef = (FontDef)defs.nextElement();
> @@ -1185,7 +1205,7 @@
> SWFWriter.class.getName(),"051018-1385", new Object[] {fileName})
> );
> }
> - // Make sure font has LAYOUT info
> + // Make sure font has LAYOUT info
> if ((font.flags & Font.HAS_LAYOUT) == 0) {
> throw new CompilationError(
> /* (non-Javadoc)
> @@ -1233,7 +1253,7 @@
> /**
> * Import all action script blocks
> */
> - void importActions(String fileName)
> + void importActions(String fileName)
> throws FileNotFoundException, IVException {
>
> Timeline t = FlashFile.parse(fileName).getMainScript().getTimeline();
> @@ -1253,7 +1273,7 @@
> /**
> * @return first action block
> */
> - DoAction getFirstDoAction(String fileName)
> + DoAction getFirstDoAction(String fileName)
> throws FileNotFoundException, IVException {
>
> Timeline t = FlashFile.parse(fileName).getMainScript().getTimeline();
> @@ -1293,6 +1313,7 @@
> // before this action script is added!
> String name = (String)fonts.nextElement();
> FontFamily family = mFontManager.getFontFamily(name);
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -1301,9 +1322,10 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> SWFWriter.class.getName(),"051018-1502", new Object[] {name})
> );
> + }
>
> actions.append("_root.LzFontManager.addFont('" + name + "', " );
> -
> +
> appendFont(actions, family.plain, family.getBounds(FontInfo.PLAIN));
> actions.append(",");
> appendFont(actions, family.bold, family.getBounds(FontInfo.BOLD));
> @@ -1314,7 +1336,7 @@
> actions.append("\n)\n");
> }
>
> - if (mProperties.getProperty("trace.fonts", "false").equals("true")) {
> + if (mLogger.isDebugEnabled() && mProperties.getProperty("trace.fonts", "false").equals("true")) {
> mLogger.debug(actions.toString());
> }
>
> @@ -1338,8 +1360,8 @@
> Iterator resources = sset.iterator();
> while(resources.hasNext()) {
> Resource res = (Resource)resources.next();
> - String str = "canvas.resourcetable[\"" + res.getName() +
> - "\"]={ width : " + res.getWidth() + ", height :" +
> + String str = "canvas.resourcetable[\"" + res.getName() +
> + "\"]={ width : " + res.getWidth() + ", height :" +
> res.getHeight() + "};\n";
> buf.append(str);
> }
> @@ -1441,7 +1463,7 @@
> actions.append("advancetable:");
>
> int idx, adv;
> -
> +
> actions.append(newline);
> actions.append("[");
> // FIXME: [2003-03-19 bloch] We only support ANSI 8bit (up to
> @@ -1490,11 +1512,11 @@
> but is strictly wrong */
> /*max = max - adv;
> if (max < 0) max = 0;
> -
> +
> if (max > adj) {
> adj = max;
> }*/
> -
> +
> // Convert to pixels rounded to nearest 100th
> double lsb = emUnitsToPixels(adj);
> actions.append(lsb);
> @@ -1524,7 +1546,7 @@
> adv = font.getAdvanceValue(idx);
> adj = m - adv;
> if (adj < 0) adj = 0;
> -
> +
> // Convert to pixels rounded to nearest 100th
> double rsb = emUnitsToPixels(adj);
> actions.append(rsb);
> @@ -1554,7 +1576,7 @@
> if (family == null) {
> return null;
> /*
> - throw new CompilationError("Font '" + fontName +
> + throw new CompilationError("Font '" + fontName +
> "' used but not defined");
> */
> }
> @@ -1575,7 +1597,7 @@
> /**
> * @return true if the font exists
> *
> - * If this is the default bold font and it hasn't been
> + * If this is the default bold font and it hasn't been
> * declared, import it.
> */
> boolean checkFontExists(FontInfo fontInfo) {
> @@ -1584,13 +1606,13 @@
> if (fontInfo.getName() == null) {
> return false;
> }
> -
> +
> boolean a = mFontManager.checkFontExists(fontInfo);
> if (a) {
> return a;
> }
>
> - if (fontInfo.getName().equals(mDefaultFontName) &&
> + if (fontInfo.getName().equals(mDefaultFontName) &&
> fontInfo.styleBits == FontInfo.PLAIN) {
> try {
> File f = mEnv.resolve(mDefaultFontFileName, null);
> @@ -1624,7 +1646,7 @@
> );
> }
> return true;
> - }
> + }
>
> if (fontInfo.getName().equals(mDefaultFontName) &&
> fontInfo.styleBits == FontInfo.ITALIC) {
> @@ -1642,7 +1664,7 @@
> );
> }
> return true;
> - }
> + }
>
> if (fontInfo.getName().equals(mDefaultFontName) &&
> fontInfo.styleBits == FontInfo.BOLDITALIC) {
> @@ -1660,7 +1682,7 @@
> );
> }
> return true;
> - }
> + }
>
> return false;
> }
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SourceLocator.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SourceLocator.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SourceLocator.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -8,13 +8,14 @@
> * J_LZ_COPYRIGHT_END *********************************************************/
>
> package org.openlaszlo.compiler;
> +import java.io.Serializable;
> import org.jdom.Namespace;
>
> /** Holds XML Element source meta-information; start and end line-number, source file
> *
> * @author Henry Minsky
> */
> -public class SourceLocator {
> +public class SourceLocator implements Serializable {
> String pathname;
> /** Name to use in user messages. */
> String messagePathname;
> @@ -22,10 +23,10 @@
> int startColumnNumber;
> int endLineNumber;
> int endColumnNumber;
> -
> +
> /** A string that shouldn't occur in a filename. */
> private static String serializationSeparator = "[]";
> -
> +
> static SourceLocator fromString(String string) {
> SourceLocator locator = new SourceLocator();
> java.util.StringTokenizer st = new java.util.StringTokenizer(string, serializationSeparator);
> @@ -37,7 +38,7 @@
> locator.endColumnNumber = Integer.parseInt(st.nextToken());
> return locator;
> }
> -
> +
> public String toString() {
> StringBuffer buffer = new StringBuffer();
> buffer.append(pathname);
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SplashCompiler.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SplashCompiler.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/SplashCompiler.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -40,7 +40,7 @@
>
> public void compile(Element element) throws CompilationError {
> if (mEnv.isDHTML()) return;
> -
> +
> ViewCompiler viewCompiler = new ViewCompiler(mEnv);
> ResourceCompiler res = new ResourceCompiler(mEnv);
> StringBuffer script = new StringBuffer();
> @@ -63,12 +63,12 @@
> child.setAttribute("resourcename", "lzprelresource");
> element.addContent(child);
> }
> -
> +
> ObjectWriter sw = mEnv.getGenerator();
> sw.addPreloader(mEnv);
> -
> +
> for (Iterator iter = element.getChildren("view", element.getNamespace()).iterator();
> - iter.hasNext(); ) {
> + iter.hasNext(); ) {
> Element child = (Element) iter.next();
> // Change the child into the format that the runtime expects
> // TODO: [2003-01-13 ows] change the runtime to expect the
> @@ -98,7 +98,7 @@
> rname = child.getAttributeValue("name");
> if (rname == null) {
> rname = sw.createName();
> - }
> + }
> child.setAttribute("name", rname);
> }
> try {
> @@ -118,7 +118,7 @@
> script.append(VIEW_INSTANTIATION_FNAME + "(" +
> model.asJavascript() +
> ");" );
> -
> +
> String scriptstr = script.toString();
> if (scriptstr != "") {
> try {
> @@ -126,10 +126,12 @@
> } catch (org.openlaszlo.sc.CompilerException e) {
> throw new CompilationError(element, e);
> }
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("Adding preloader script: " + script);
> + }
> }
> }
> -
> +
> private String[] getBlogList() {
> return new String[] {
> "http://wetmachine.com/",
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/StyleSheetCompiler.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/StyleSheetCompiler.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/StyleSheetCompiler.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -44,69 +44,77 @@
>
> public void compile(Element element) {
> try {
> + if (mLogger.isInfoEnabled()) {
> mLogger.info("StyleSheetCompiler.compile called!");
> -
> + }
> +
> if (!element.getChildren().isEmpty()) {
> throw new CompilationError("<stylesheet> elements can't have children",
> element);
> }
> -
> +
> String pathname = null;
> - String stylesheetText = element.getText();
> - String src = element.getAttributeValue(SRC_ATTR_NAME);
> -
> + String stylesheetText = element.getText();
> + String src = element.getAttributeValue(SRC_ATTR_NAME);
> +
> if (src != null) {
> + if (mLogger.isInfoEnabled()) {
> mLogger.info("reading in stylesheet from src=" + src);
> - // Find the css file
> + }
> + // Find the css file
> // Using the FileResolver accomplishes two nice things:
> // 1, it searches the standard directory include paths
> // including the application directory for the css file.
> // 2, it adds the css file to the dependencies for the
> // current application. This makes the application be
> // recompiled if the css file changes.
> - // This fixes LPP-2733 [bshine 10.20.06]
> -
> + // This fixes LPP-2733 [bshine 10.20.06]
> +
> String base = mEnv.getApplicationFile().getParent();
>
> - // [bshine 12.29.06] For LPP-2974, we also have to
> - // check for the css file relative to the file which is including it.
> + // [bshine 12.29.06] For LPP-2974, we also have to
> + // check for the css file relative to the file which is including it.
> // First try to find the css file as a sibling of this source file
> String sourceDir = new File(Parser.getSourcePathname(element)).getParent();
> File resolvedFile = mEnv.resolve(src, sourceDir);
> -
> - // If our first try at finding the css file doesn't find it as a sibling,
> - // try to resolve relative to the application source file.
> +
> + // If our first try at finding the css file doesn't find it as a sibling,
> + // try to resolve relative to the application source file.
> if (! resolvedFile.exists() ) {
> resolvedFile = mEnv.resolve(src, base);
> if (resolvedFile.exists()) {
> + if (mLogger.isInfoEnabled()) {
> mLogger.info("Resolved css file to a file that exists!");
> + }
> } else {
> mLogger.error("Could not resolve css file to a file that exists.");
> throw new CompilationError("Could not find css file " + src);
> }
> }
> -
> +
> // Actually parse and compile the stylesheet! W00t!
> CSSHandler fileHandler = CSSHandler.parse( resolvedFile );
> this.compile(fileHandler, element);
>
>
> } else if (stylesheetText != null && (!"".equals(stylesheetText))) {
> + if (mLogger.isInfoEnabled()) {
> mLogger.info("inline stylesheet");
> - CSSHandler inlineHandler = CSSHandler.parse(stylesheetText);
> - this.compile(inlineHandler, element);
> - //
> + }
> + CSSHandler inlineHandler = CSSHandler.parse(stylesheetText);
> + this.compile(inlineHandler, element);
> + //
> } else {
> // TODO: i18n errors
> throw new CompilationError("<stylesheet> element must have either src attribute or inline text. This has neither.",
> - element);
> + element);
> }
> -
> +
> } catch (CompilationError e) {
> // If there was an error compiling a stylesheet, we report
> // it as a compilation error, and fail the compile.
> // Fixes LPP-2734 [bshine 10.20.06]
> - mLogger.error("Error compiling StyleSheet element: " + element);
> + mLogger.error("Error compiling StyleSheet element: " + element);
> throw e;
> } catch (IOException e) {
> // This exception indicates there was a problem reading the
> @@ -125,14 +133,14 @@
> throw new CompilationError(message);
> } catch (CSSException e) {
> // CSSExceptions don't provide a line number, just a message
> - // Fixes LPP-2734 [bshine 10.20.06]
> + // Fixes LPP-2734 [bshine 10.20.06]
> mLogger.error("Error compiling css: " + element);
> throw new CompilationError("Error compiling css, no line number available: "
> - + e.getMessage());
> + + e.getMessage());
> } catch (Exception e) {
> // This catch clause will catch disastrous errors; normal expected
> // css-related errors are handled with the more specific catch clauses
> - // above.
> + // above.
>
> /**
> * NOTE: [2008-10-14 ptw] If you are trying to debug CSS
> @@ -142,15 +150,17 @@
> */
>
> mLogger.error("Exception compiling css: " + element + ", " + e.getMessage());
> - throw new CompilationError("Error compiling css. " + e.getMessage());
> + throw new CompilationError("Error compiling css. " + e.getMessage());
> }
>
> }
> -
> +
> void compile(CSSHandler handler, Element element) throws CompilationError {
> - mLogger.debug("compiling CSSHandler using new unique names");
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("compiling CSSHandler using new unique names");
> + }
> String script = "";
> - for (int i=0; i < handler.mRuleList.size(); i++) {
> + for (int i=0; i < handler.mRuleList.size(); i++) {
> Rule rule = (Rule)handler.mRuleList.get(i);
> script += "$lzc$style._addRule(new $lzc$rule(" +
> buildSelector(rule.getSelector()) + ", " +
> @@ -163,17 +173,19 @@
> script +=
> "));\n";
> }
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("whole stylesheet as css " + script +"\n\n");
> + }
> mEnv.compileScript(CompilerUtils.sourceLocationDirective(element, true) +
> - // NOTE [2007-06-02 bshine] This semicolon is needed
> - // to work around bug LPP-4083, javascript compiler
> + // NOTE [2007-06-02 bshine] This semicolon is needed
> + // to work around bug LPP-4083, javascript compiler
> // doesn't emit a semicolon somewhere
> ";" +
> // NOTE: [2007-02-11 ptw] It is crucial
> // that this be terminated with a `;` so
> // that it is a statement, not an
> // expression.
> - " (function() { var $lzc$style = LzCSSStyle, $lzc$rule = LzCSSStyleRule;\n" + script + "})();", element );
> + " (function() { var $lzc$style = LzCSSStyle, $lzc$rule = LzCSSStyleRule;\n" + script + "})();", element );
> }
>
>
> @@ -181,7 +193,7 @@
> String selectorString = "\"selector_not_handled\"";
>
> switch (sel.getSelectorType()) {
> - case Selector.SAC_ELEMENT_NODE_SELECTOR:
> + case Selector.SAC_ELEMENT_NODE_SELECTOR:
> // This selector matches only tag type
> ElementSelector es = (ElementSelector)sel;
> selectorString = buildElementSelectorJS(es.getLocalName());
> @@ -192,8 +204,8 @@
> // [someattr="someval"]
> // simple[role="private"]
> ConditionalSelector cs = (ConditionalSelector)sel;
> - // Take care of the simple selector part of this
> - selectorString = buildConditionalSelectorJS(cs.getCondition(),cs.getSimpleSelector());
> + // Take care of the simple selector part of this
> + selectorString = buildConditionalSelectorJS(cs.getCondition(),cs.getSimpleSelector());
> break;
> case Selector.SAC_DESCENDANT_SELECTOR:
> DescendantSelector ds = (DescendantSelector)sel;
> @@ -201,18 +213,20 @@
> break;
> default:
> selectorString = "unknown_selector" + Integer.toString(sel.getSelectorType());
> - }
> + }
>
> return selectorString;
> }
>
> String buildElementSelectorJS(String localName) {
> - return "\"" + localName + "\"";
> + return "\"" + localName + "\"";
> }
>
> String buildConditionalSelectorJS(Condition cond, SimpleSelector simpleSelector) {
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("Conditional selector: " + cond.toString());
> - String condString = "no_match";
> + }
> + String condString = "no_match";
> switch (cond.getConditionType()) {
> case Condition.SAC_ID_CONDITION: /* #id */
> AttributeCondition idCond = (AttributeCondition) cond;
> @@ -220,65 +234,71 @@
> break;
>
> case Condition.SAC_ATTRIBUTE_CONDITION: // [attr] or [attr="val"] or elem[attr="val"]
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("Attribute condition");
> + }
> AttributeCondition attrCond = (AttributeCondition) cond;
> String name = attrCond.getLocalName();
> String value = attrCond.getValue();
> condString = "{ attrname: \"" + name + "\", attrvalue: \"" + value + "\"";
> - // The simple selector is the element part of the selector, ie,
> + // The simple selector is the element part of the selector, ie,
> // foo in foo[bar="baz"]. If there is no element part of the selector, ie
> - // [bar="lum"] then batik gives us a non-null SimpleSelector with a
> - // localName of the null string. We don't write out the simple selector if
> - // it's not specified.
> + // [bar="lum"] then batik gives us a non-null SimpleSelector with a
> + // localName of the null string. We don't write out the simple selector if
> + // it's not specified.
> if (simpleSelector != null) {
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("simple selector:" + simpleSelector.toString());
> + }
> if (simpleSelector.getSelectorType() == Selector.SAC_ELEMENT_NODE_SELECTOR) {
>
> - ElementSelector es = (ElementSelector)simpleSelector;
> + ElementSelector es = (ElementSelector)simpleSelector;
> String simpleSelectorString = es.getLocalName();
> // Discard the simple selector if it isn't specified
> - if (simpleSelectorString != null)
> - condString += ", simpleselector: \"" + simpleSelectorString + "\"";
> + if (simpleSelectorString != null)
> + condString += ", simpleselector: \"" + simpleSelectorString + "\"";
> } else {
> mLogger.error("Can't handle CSS selector " + simpleSelector.toString());
> }
> - }
> -
> + }
> +
> condString += "}";
> - mLogger.debug("Cond string: " + condString );
> + if (mLogger.isDebugEnabled()) {
> + mLogger.debug("Cond string: " + condString );
> + }
> break;
> default:
> }
> return condString;
> }
>
> - /**
> + /**
> * Build a string holding the javascript to create the selector at runtime, where
> - the selector is a descendant selector, ie
> + the selector is a descendant selector, ie
> E F
> would be
> descendantrule.selector = [
> - "E",
> + "E",
> "F" ];
> - The selector is specified as an array of selectors, ancestor first.
> + The selector is specified as an array of selectors, ancestor first.
> */
> String buildDescendantSelector(DescendantSelector ds) {
> // We need the simple selector and the ancestor selector
> SimpleSelector ss = ds.getSimpleSelector();
> Selector ancestorsel = ds.getAncestorSelector();
> String str = "[";
> -
> +
> // If this is complicated, it will be [ "something", "complicated" ]
> // Strip excessive square brackets. This lets us pretend to unroll
> - // recursive selectors into a list of selectors.
> + // recursive selectors into a list of selectors.
> // This is a cheap way to get deep selectors.
> String ancestorselstr = buildSelector(ancestorsel);
> ancestorselstr = ancestorselstr.replace('[', ' ');
> - ancestorselstr = ancestorselstr.replace(']', ' ');
> - str += ancestorselstr;
> + ancestorselstr = ancestorselstr.replace(']', ' ');
> + str += ancestorselstr;
> str += ", ";
> str += buildSelector(ss);
> -
> +
> str += "]";
> // mLogger.error("Here's the whole descendant selector:" + str);
> return str;
> @@ -287,18 +307,18 @@
>
> Pattern resourcePattern = Pattern.compile("^\\s*resource\\s*\\(\\s*['\"]\\s*(.*)\\s*['\"]\\s*\\)\\s*$");
> /**
> - * Build a string holding the javascript to create the rule's properties attribute.
> + * Build a string holding the javascript to create the rule's properties attribute.
> * This should just be a standard javascript object composed of attributes and values,
> * wrapped in curly quotes. Escape the quotes for attributes' values.
> * for example "{ width: 500, occupation: \"pet groomer and holistic veterinarian\",
> - miscdata: \"spends most days indoors\"}""
> - */
> + miscdata: \"spends most days indoors\"}""
> + */
> String buildPropertiesJavascript(Rule rule, Element element, CompilationEnvironment env) {
> /*
> - String props = "{ width: 500, occupation: \"pet groomer and holistic veterinarian\"," +
> + String props = "{ width: 500, occupation: \"pet groomer and holistic veterinarian\"," +
> " miscdata: \"spends most days indoors\"} ";
> - */
> -
> + */
> +
> StringWriter result = new StringWriter();
> try {
> Map properties = rule.getStyleMap();
> @@ -331,7 +351,7 @@
> throw new CompilationError(element, e);
> }
> return result.toString();
> - }
> + }
> }
>
>
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -64,7 +64,7 @@
> }
>
> /**
> - * Compute text width for a given font
> + * Compute text width for a given font
> *
> * @param text text stringtext string
> * @param fontInfo font info for this text
> @@ -79,6 +79,8 @@
> int size = fontInfo.getSize();
> int style = fontInfo.styleBits;
>
> +
> + if (mTextLogger.isDebugEnabled()) {
> mTextLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -87,6 +89,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> TextCompiler.class.getName(),"051018-87", new Object[] {fontName, fontInfo.getStyle(), new Integer(fontInfo.getSize()), text})
> );
> + }
>
> if (text.length() == 0) {
> return 0;
> @@ -150,28 +153,30 @@
> if (i == length - 1) {
> double m = 0;
> try {
> - m = bounds[idx].getMaxX();
> + m = bounds[idx].getMaxX();
> } catch (Exception e) {
> }
> if (m > adv) {
> adv = m;
> }
> - }
> + }
>
> if (i == 0) {
> try {
> double m = bounds[idx].getMinX();
> if (m > 0) {
> adv += m;
> - }
> + }
> } catch (Exception e) {
> }
> - }
> + }
>
> last_charwidth = adv;
> width += adv;
>
> + if (mLogger.isDebugEnabled()) {
> mLogger.debug("adv " + adv);
> + }
> }
>
> if (i != length - 1) {
> @@ -191,8 +196,9 @@
> // to trim the trailing space from the HTML formatted text
> if (c == ' ') {
> lm.last_spacewidth = (double)(last_charwidth * fontInfo.getSize()) / 1024.0;
> - }
> + }
>
> + if (mTextLogger.isDebugEnabled()) {
> mTextLogger.debug(
> /* (non-Javadoc)
> * @i18n.test
> @@ -201,6 +207,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> TextCompiler.class.getName(),"051018-201", new Object[] {text, fontInfo.getName(), new Integer(fontInfo.getSize()), fontInfo.getStyle(), new Double(w)})
> );
> + }
>
> // FIXME: [2003-09-26 bloch] handle empty string case? should it be w/out slop?
> // Match this in LzNewText.as
> @@ -318,7 +325,7 @@
> }
>
>
> - /**
> + /**
> Processes the text content of the element. The element
> content may contain XHTML markup elements, which we will
> interpret as we map over the content. Normally, whitespace
> @@ -326,7 +333,7 @@
> will cause the enclosed text to be treated as verbatim,
> meaning means that whitespace and linebreaks will be
> preserved.
> -
> +
> Supported XHTML markup is currently:
> <ul>
> <li> P, BR cause linebreaks
> @@ -418,7 +425,7 @@
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> TextCompiler.class.getName(),"051018-418")
> );
> - }
> + }
> }
> }
> }
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewCompiler.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewCompiler.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewCompiler.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -48,12 +48,12 @@
> private static final String WHEN_ONCE = "once";
> private static final String WHEN_ALWAYS = "always";
> private static final String WHEN_PATH = "path";
> -
> +
> private ViewSchema mSchema;
> -
> +
> private static Logger mLogger = Logger.getLogger(ViewCompiler.class);
> private static Logger mTraceLogger = Logger.getLogger("trace.xml");
> -
> +
> public ViewCompiler(CompilationEnvironment env) {
> super(env);
> mSchema = env.getSchema();
> @@ -119,7 +119,7 @@
> static boolean isElement(Element element) {
> return true;
> }
> -
> +
> /** Collect the names of classes that are referenced. */
> static void collectElementNames(Element element, Set names) {
> names.add(element.getName());
> @@ -129,7 +129,7 @@
> collectElementNames((Element) iter.next(), names);
> }
> }
> -
> +
> static void collectLayoutElement(Element element, Set names) {
> if (element.getAttributeValue("layout") != null) {
> try {
> @@ -171,19 +171,19 @@
> new org.jdom.output.XMLOutputter();
> mTraceLogger.info(outputter.outputString(element));
> }
> -
> +
> NodeModel model = NodeModel.elementAsModel(element, mSchema, mEnv);
> model = model.expandClassDefinitions();
>
> String script = VIEW_INSTANTIATION_FNAME + "(" +
> model.asJavascript() + ", " + model.totalSubnodes() +
> ");";
> -
> +
> // Don't keep non-class models around
> if (!element.getName().equals("class")) {
> ((ElementWithLocationInfo) element).model = null;
> }
> -
> +
> if (tracexml) {
> mLogger.debug(
> /* (non-Javadoc)
> @@ -202,7 +202,7 @@
> throw e;
> }
> }
> -
> +
> /**
> * Modify the DOM in place, to what the runtime expects. This
> * function encapsulates the behavior that is common to root
> @@ -256,7 +256,7 @@
> sUnsupportedServerlessFiletypesSWF7.put("gif", "true");
>
> }
> -
> +
> static void checkUnsupportedMediaTypes(CompilationEnvironment env, Element elt, String url) {
> String suffix = FileUtils.getExtension(url);
> if (env.isSWF()) {
> @@ -322,7 +322,7 @@
> // remove this <attribute name="resource" .../>
> // child because we just copied the value to the
> // parent elt.
> - iter.remove();
> + iter.remove();
> }
> }
> }
> @@ -402,7 +402,7 @@
> }
> }
> }
> -
> +
> // Recurse
> Iterator iter;
> for (iter = elt.getChildren().iterator();
> @@ -415,7 +415,7 @@
> CompilationEnvironment env) {
> final String ATTR_NAME = "clickregion";
> String value = elt.getAttributeValue(ATTR_NAME);
> -
> +
> if (value != null) {
> if (value.matches(sConstraintPatStr) ||
> ScriptCompiler.isIdentifier(value) ||
> @@ -439,7 +439,7 @@
> elt.setAttribute(ATTR_NAME, value);
> }
> }
> -
> +
> // Recurse
> Iterator iter;
> for (iter = elt.getChildren().iterator();
> @@ -447,7 +447,7 @@
> compileClickResources((Element) iter.next(), env);
> }
> }
> -
> +
> static void checkUnresolvedResourceReferences (CompilationEnvironment env) {
> Map refs = env.resourceReferences();
> Set resourceNames = env.getResourceNames();
> @@ -487,10 +487,10 @@
> return;
> }
>
> - // Build a list of superclasses
> + // Build a list of superclasses
> Vector parents = new Vector();
> ClassModel lzxclass = classinfo;
> - // walk
> + // walk
> while (lzxclass != null) {
> parents.insertElementAt(lzxclass, 0);
> lzxclass = lzxclass.superclass;
> @@ -529,9 +529,9 @@
> * for measuring text, since we have no way to pass those text
> * widths to the runtime, but we do need this to check if we need
> * to import the default bold or italic fonts.
> - *
> - *
> *
> + *
> + *
> * @param env
> * @param elt
> * @param fontInfo the current font name/style/size
> @@ -541,7 +541,6 @@
> FontInfo fontInfo,
> Set classList) {
>
> - classList = new HashSet(classList);
>
> // Clone a copy of the font info
> fontInfo = new FontInfo(fontInfo);
> @@ -550,24 +549,26 @@
> mergeClassFontInfo (elt, fontInfo, env);
> // Now override with any directly declared attributes
> mergeFontInfo(elt, fontInfo);
> -
> +
> String fontName = fontInfo.getName();
>
> // If it inherits from text or inputttext, annotate it with font info
> - if ("text".equals(elt.getName()) ||
> - "text".equals(mSchema.getBaseClassname(elt.getName())) ||
> - "inputtext".equals(elt.getName()) ||
> - "inputtext".equals(mSchema.getBaseClassname(elt.getName()))) {
> + String eltName = elt.getName();
> + if ("text".equals(eltName) ||
> + "text".equals(mSchema.getBaseClassname(eltName)) ||
> + "inputtext".equals(eltName) ||
> + "inputtext".equals(mSchema.getBaseClassname(eltName))) {
> compileTextMetrics(elt, env, fontInfo);
> }
> - ClassModel classinfo = env.getSchema().getClassModel(elt.getName());
> + ClassModel classinfo = env.getSchema().getClassModel(eltName);
>
> // If this invokes a 'user-defined' class, let's walk that
> // class's source tree now
> if (classinfo != null && classinfo.definition != null) {
> + classList = new HashSet(classList);
> // check if we are in an instance of a class that we are
> // already descended into (loop detection)
> - if (classList.contains(elt.getName().intern())) {
> + if (classList.contains(eltName.intern())) {
> return;
> }
> for (Iterator iter = classinfo.definition.getChildren().iterator(); iter.hasNext();
> @@ -626,7 +627,7 @@
> }
> }
> }
> -
> +
> /** Merge in font attribute info from an element into a FontInfo.
> *
> * @param elt the element to look for font attributes on
> @@ -666,7 +667,7 @@
> }
>
> /** return true if element has an attribute named ATTRIBUTE in
> - * it's attribute list, or has a child lzx element
> + * it's attribute list, or has a child lzx element
> * <attribute name="ATTRIBUTE"/>
> */
> protected static boolean hasAttribute(Element elt, String attrName) {
> @@ -687,7 +688,7 @@
>
>
> /** return value if element has an attribute named ATTRNAME in
> - * it's attribute list, or has a child lzx element
> + * it's attribute list, or has a child lzx element
> * <attribute name="ATTRNAME" value="VAL"/>
> */
> protected static String getAttributeValue(Element elt, String attrName) {
> @@ -731,7 +732,7 @@
> if (fontInfo.getStyle() != null) {
> elt.setAttribute("fontstyle", fontInfo.getStyle());
> }
> -
> +
> }
>
>
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -3,7 +3,7 @@
> * ****************************************************************************/
>
> /* J_LZ_COPYRIGHT_BEGIN *******************************************************
> -* Copyright 2001-2009 Laszlo Systems, Inc. All Rights Reserved. *
> +* Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved. *
> * Use is subject to license terms. *
> * J_LZ_COPYRIGHT_END *********************************************************/
>
> @@ -30,15 +30,15 @@
>
> /** The location of the Laszlo LFC bootstrap interface declarations file */
> private final String SCHEMA_PATH = LPS.HOME() + File.separator +
> - "WEB-INF" + File.separator +
> - "lps" + File.separator +
> + "WEB-INF" + File.separator +
> + "lps" + File.separator +
> "schema" + File.separator + "lfc.lzx";
>
> private Document schemaDOM = null;
>
> private static Document sCachedSchemaDOM;
> private static long sCachedSchemaLastModified;
> -
> +
> /** Default table of attribute name -> typecode */
> private static final Map sAttributeTypes = new HashMap();
>
> @@ -47,7 +47,7 @@
>
> /** {String} */
> private static final Set sMouseEventAttributes;
> -
> +
> /** Maps a class (name) to its ClassModel. Holds info about
> * attribute/types for each class, as well as pointer to the
> * superclass if any.
> @@ -84,7 +84,7 @@
> public static final Type XML_LITERAL = newType("xmlLiteral");
> public static final Type METHOD_TYPE = newType("method");
> public static final Type NODE_TYPE = newType("node");
> -
> +
> static {
>
> sHTMLContentElements.add("text");
> @@ -98,7 +98,7 @@
> "onkeypress", "onstart" , "onstop",
> "onfocus", "onblur",
> "onkeydown", "onkeyup", "onsubmit", "onreset", "onselect",
> - "onchange" , "oninit", "onerror", "ondata", "ontimeout",
> + "onchange" , "oninit", "onerror", "ondata", "ontimeout",
> "oncommand" , "onapply" , "onremove"};
> setAttributeTypes(mouseEventAttributes, EVENT_HANDLER_TYPE);
> setAttributeTypes(eventAttributes, EVENT_HANDLER_TYPE);
> @@ -109,7 +109,7 @@
> LPS.getMiscDirectory() + File.separator +
> "lzx-autoincludes.properties";
> public static final Properties sAutoincludes = new Properties();
> -
> +
> static {
> try {
> InputStream is = new FileInputStream(AUTOINCLUDES_PROPERTY_FILE);
> @@ -122,7 +122,7 @@
> throw new ChainedException(e);
> }
> }
> -
> +
> public ViewSchema() {
>
> }
> @@ -331,10 +331,11 @@
> * @param attributeDefs list of attribute name/type defs
> */
> public void addElement (Element elt, String tagName,
> - String superTagName, List attributeDefs,
> + String superTagName, List attributeDefs,
> CompilationEnvironment env)
> {
> ClassModel superclass = getClassModel(superTagName);
> +
> if (superclass == null) {
> throw new CompilationError(
> /* (non-Javadoc)
> @@ -381,7 +382,7 @@
> while (iterator.hasNext()) {
> Element child = (Element) iterator.next();
> if (child.getName().equals("containsElements")) {
> - // look for <element>tagname</element>
> + // look for <element>tagname</element>
> Iterator iter1 = child.getChildren().iterator();
> while (iter1.hasNext()) {
> Element etag = (Element) iter1.next();
> @@ -392,9 +393,9 @@
> throw new CompilationError(
> "containsElement block must only contain <element> tags", etag);
> }
> - }
> + }
> } else if (child.getName().equals("forbiddenElements")) {
> - // look for <element>tagname</element>
> + // look for <element>tagname</element>
> Iterator iter1 = child.getChildren().iterator();
> while (iter1.hasNext()) {
> Element etag = (Element) iter1.next();
> @@ -405,7 +406,7 @@
> throw new CompilationError(
> "containsElement block must only contain <element> tags", etag);
> }
> - }
> + }
> }
> }
>
> @@ -414,13 +415,12 @@
>
> // Add in the attribute declarations.
> addAttributeDefs(elt, tagName, attributeDefs, env);
> -
> }
>
> /**
> * Add this list of attribute name/type info to the in-core model of the class definitions.
> *
> - * @param sourceElement the user's LZX source file element that holds class LZX definition
> + * @param sourceElement the user's LZX source file element that holds class LZX definition
> * @param classname the class we are defining
> * @param attributeDefs list of AttributeSpec attribute info to add to the Schema
> *
> @@ -457,7 +457,7 @@
> * @org-mes="In class '" + p[0] + "' attribute '" + p[1] + "' with type '" + p[2] + "' is overriding superclass attribute with same name but different type: " + p[3]
> */
> org.openlaszlo.i18n.LaszloMessages.getMessage(
> - ViewSchema.class.getName(),"051018-364", new Object[] {classname, attr.name, attr.type.toString(), parentType.toString()}),
> + ViewSchema.class.getName(),"051018-364", new Object[] {classname, attr.name, attr.type.toString(), parentType.toString()}),
> sourceElement);
> }
> }
> @@ -538,7 +538,7 @@
>
> // Look up attribute in type map for this element
> ClassModel classModel = getClassModel(elementName);
> -
> +
> if (classModel != null) {
> try {
> type = classModel.getAttributeTypeOrException(attrName, allocation);
> @@ -587,7 +587,7 @@
>
> // Look up attribute in type map for this element
> ClassModel classModel = getClassModel(elementName);
> -
> +
> if (classModel != null) {
> return classModel.getAttribute(attrName, allocation);
> } else {
> @@ -674,9 +674,9 @@
> ((ClassModel)i.next()).setIsBuiltin(true);
> }
> }
> -
>
>
> +
> /** Check if a child element can legally be contained in a parent element.
> This works with the class hierarchy as follows:
>
> @@ -689,13 +689,13 @@
>
>
> + If not, ascend up the parent classmodel, and call canContainElement recursively
> -
> +
> */
> public boolean canContainElement (String parentTag, String childTag) {
> // Get list of legally nestable tags
> ClassModel parent = getClassModel(parentTag);
>
> - // TODO [hqm 2007-09]: CHECK FOR NULL HERE
> + // TODO [hqm 2007-09]: CHECK FOR NULL HERE
>
> Set tagset = parent.getContainsSet();
> Set forbidden = parent.getForbiddenSet();
> @@ -710,7 +710,7 @@
> // check all superclasses of the childTag
> ClassModel childclass = getClassModel(childTag);
>
> - // TODO [hqm 2007-09]: CHECK FOR NULL HERE
> + // TODO [hqm 2007-09]: CHECK FOR NULL HERE
>
> while (childclass != null) {
> String superclassname = childclass.getSuperTagName();
> @@ -728,7 +728,7 @@
> return false;
> }
>
> -
> +
> /** @return true if this element is an input text field */
> boolean isInputTextElement(Element e) {
> String classname = e.getName();
> @@ -791,7 +791,7 @@
> String name = e.getName();
> return name.equals("doc");
> }
> -
> +
> /* Constants for parsing CSS colors. */
> static final PatternMatcher sMatcher = new Perl5Matcher();
> static final Pattern sRGBPattern;
> @@ -976,7 +976,7 @@
> super(message);
> }
> }
> -
> +
> /** Parse according to http://www.w3.org/TR/2001/WD-css3-color-20010305,
> * but also allow 0xXXXXXX */
> public static int parseColor(String str) {
> @@ -1037,7 +1037,7 @@
> handlerAttributes.add("name");
> handlerAttributes.add("args");
> handlerAttributes.add("reference");
> -
> +
> setterAttributes.add("name");
> setterAttributes.add("args");
> setterAttributes.add("allocation");
>
> Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java
> ===================================================================
> --- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java 2009-03-07 01:34:23 UTC (rev 13204)
> +++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java 2009-03-07 06:24:05 UTC (rev 13205)
> @@ -38,7 +38,7 @@
> // TODO: [2002-11-28 ows] use org.apache.commons.util.BufferCache?
> // TODO: [2002-11-28 ows] wrap in Collections.synchronizedMap?
> private static ScriptCompiler mScriptCache = null;
> -
> +
> public ScriptCompiler(String name, File cacheDirectory, Properties props)
> throws IOException {
> super(name, cacheDirectory, props);
> @@ -185,12 +185,6 @@
> // so make a copy of properties that neutralizes that.
> properties = (Properties) properties.clone();
> properties.setProperty("filename", "");
> - // The key is a string representation of the arguments:
> - // properties, and the script.
> - StringWriter writer = new StringWriter();
> - writer.write(sortedPropertiesList(properties));
> - writer.getBuffer().append(script);
> - String key = writer.toString();
> // Check the cache. clearCache may clear the cache at any
> // time, so use a copy of it so that it doesn't change state
> // between a test that it's null and a method call on it.
> @@ -201,6 +195,12 @@
> if (mScriptCache == null) {
> return _compileToByteArray(script, properties);
> } else {
> + // The key is a string representation of the arguments:
> + // properties, and the script.
> + StringWriter writer = new StringWriter();
> + writer.write(sortedPropertiesList(properties));
> + writer.getBuffer().append(script);
> + String key = writer.toString();
> synchronized (mScriptCache) {
> item = mScriptCache.findItem(key, null, false);
> }
> @@ -218,7 +218,7 @@
> item.markClean();
> }
> }
> -
> +
> mScriptCache.updateCache(item);
>
> return (byte[]) code;
> @@ -226,12 +226,12 @@
> throw new CompilationError(e, "IOException in compilation/script-cache");
> }
> }
> -
> +
> /**
> * @param action actionscript byte codes
> * @param ostream outputstream to write SWF
> */
> - public static void writeScriptToStream(byte[] action,
> + public static void writeScriptToStream(byte[] action,
> OutputStream ostream, int swfversion) throws IOException {
> FlashFile file = FlashFile.newFlashFile();
> Script s = new Script(1);
> @@ -324,7 +324,7 @@
> }
> writer.write("}");
> }
> -
> +
> /** Writes a LaszloScript array literal that evaluates to a
> * LaszloScript array whose elements are LaszloScript
> * representations of the arguments elements.
> @@ -351,7 +351,7 @@
> }
> writer.write("]");
> }
> -
> +
> /** Returns true iff the string is a valid JavaScript identifier. */
> public static boolean isIdentifier(String s) {
> if (s.length() == 0)
> @@ -368,7 +368,7 @@
> }
> return true;
> }
> -
> +
> /** Enclose the specified string in double-quotes, and character-quote
> * any characters that need it.
> * @param s a string
> @@ -400,7 +400,7 @@
> switch (c) {
> case '\n':
> writer.write("\\n");
> - break;
> + break;
> case '\r':
> writer.write("\\r");
> break;
> @@ -484,7 +484,7 @@
> switch (c) {
> case '\n':
> writer.write("\\n");
> - break;
> + break;
> case '\r':
> writer.write("\\r");
> break;
>
>
> _______________________________________________
> Laszlo-checkins mailing list
> Laszlo-checkins at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins
--
Regards,
Max Carlson
OpenLaszlo.org
More information about the Laszlo-checkins
mailing list