This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: define-namespace in compiled files
- From: Per Bothner <per at bothner dot com>
- To: Chris Dean <Chris dot Dean at sokitomi dot com>
- Cc: Kawa List <kawa at sources dot redhat dot com>
- Date: Tue, 29 Apr 2003 23:11:10 -0700
- Subject: Re: define-namespace in compiled files
- References: <24576.1051657534@mercedsystems.com>
Chris Dean wrote:
I'm unable to use define-namespace from a compiled file. However, when
running interactively it works fine.
The attached patch should fix the problem.
However, this causes the Long:new to be looked up at run time.
We really want it to be looked up at compile time. I'll take
a look at what's involved in that.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
Index: Interpreter.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/Interpreter.java,v
retrieving revision 1.44
diff -u -r1.44 Interpreter.java
--- Interpreter.java 29 Mar 2003 18:54:22 -0000 1.44
+++ Interpreter.java 30 Apr 2003 06:07:58 -0000
@@ -456,7 +456,7 @@
/** Used when defining a namespace alias (prefix), in the XML sense.
* Define in a namespace prefix NS is equivalent to defining a constant
- * named NAMESPACE_PREFIX+"NS" whose value is teh namespace URI. */
+ * named NAMESPACE_PREFIX+"NS" whose value is the namespace URI. */
public static final String NAMESPACE_PREFIX = "$Namespace$";
public static final int VALUE_NAMESPACE = 1<<0;
@@ -618,6 +618,21 @@
{
if (uri != null && uri.startsWith("class:"))
return ClassMethods.apply(uri.substring(6), name);
+ }
+ int colon = name.indexOf(':');
+ Environment env = sym.getEnvironment();
+ if (colon > 1 & env != null)
+ {
+ String prefix = (NAMESPACE_PREFIX+name.substring(0, colon)).intern();
+ Object uri_val = env.get(prefix, null);
+ if (uri_val != null)
+ {
+ if (! (uri_val instanceof Environment))
+ uri_val = uri_val.toString();
+ sym = Symbol.make(uri_val, name.substring(colon+1));
+ return function ? getSymbolProcedure(sym)
+ : getSymbolValue(sym);
+ }
}
throw new UnboundSymbol(name);
}