summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli/runtime/Accessor.cs5
-rw-r--r--src/cli/runtime/Keyword.cs5
-rw-r--r--src/org/clojure/runtime/Accessor.java4
-rw-r--r--src/org/clojure/runtime/Keyword.java2
4 files changed, 13 insertions, 3 deletions
diff --git a/src/cli/runtime/Accessor.cs b/src/cli/runtime/Accessor.cs
index 1c436334..c15f91a0 100644
--- a/src/cli/runtime/Accessor.cs
+++ b/src/cli/runtime/Accessor.cs
@@ -14,5 +14,8 @@ namespace org.clojure.runtime
{
public class Accessor :Indexer
{
- public String name; public Namespace ns; internal Accessor(String name, Namespace ns) { this.ns = ns; this.name = name; } public String toString() { if(ns == null) return "#:." + name; return ns.name + ":." + name; } /** * Indexer implements IFn for attr access * This single arg version is the getter * @param tld * @param obj - must be AMap * @return the value of the attr or nil if not found * @throws Exception */ override public Object invoke(ThreadLocalData tld, Object obj) //throws Exception { if(obj is AMap) return ((AMap)obj).get(this); return Reflector.invokeInstanceMember(name,obj); } /** * Indexer implements IFn for attr access * This two arg version is the setter * @param tld * @param obj - must be AMap * @param val * @return val * @throws Exception */ override public Object invoke(ThreadLocalData tld, Object obj, Object val) //throws Exception { if(obj is AMap) return ((AMap)obj).put(this,val); return Reflector.invokeInstanceMember(name,obj,val); } override public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3) //throws Exception { return Reflector.invokeInstanceMember(name,arg1,arg2,arg3); } override public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3, Object arg4) //throws Exception { return Reflector.invokeInstanceMember(name,arg1,arg2,arg3,arg4); } override public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) //throws Exception { return Reflector.invokeInstanceMember(name,arg1,arg2,arg3,arg4,arg5); } override public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Cons args) //throws Exception { return Reflector.invokeInstanceMember(name,arg1,arg2,arg3,arg4,arg5,args); } }
+ public String name; public Namespace ns; internal Accessor(String name, Namespace ns) { this.ns = ns; this.name = name; } public String toString() { if(ns == null) return "#:." + name; return ns.name + ":." + name; } /** * Indexer implements IFn for attr access * This single arg version is the getter * @param tld * @param obj - must be AMap * @return the value of the attr or nil if not found * @throws Exception */ override public Object invoke(ThreadLocalData tld, Object obj) //throws Exception { if(obj is AMap) return ((AMap)obj).get(this);
+ else if (obj == null)
+ return null;
+ return Reflector.invokeInstanceMember(name, obj); } /** * Indexer implements IFn for attr access * This two arg version is the setter * @param tld * @param obj - must be AMap * @param val * @return val * @throws Exception */ override public Object invoke(ThreadLocalData tld, Object obj, Object val) //throws Exception { if(obj is AMap) return ((AMap)obj).put(this,val); return Reflector.invokeInstanceMember(name,obj,val); } override public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3) //throws Exception { return Reflector.invokeInstanceMember(name,arg1,arg2,arg3); } override public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3, Object arg4) //throws Exception { return Reflector.invokeInstanceMember(name,arg1,arg2,arg3,arg4); } override public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) //throws Exception { return Reflector.invokeInstanceMember(name,arg1,arg2,arg3,arg4,arg5); } override public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Cons args) //throws Exception { return Reflector.invokeInstanceMember(name,arg1,arg2,arg3,arg4,arg5,args); } }
}
diff --git a/src/cli/runtime/Keyword.cs b/src/cli/runtime/Keyword.cs
index 6e1bf33b..98f3773c 100644
--- a/src/cli/runtime/Keyword.cs
+++ b/src/cli/runtime/Keyword.cs
@@ -25,7 +25,10 @@ public String name; override public String ToString()
{
return ":" + name;
}
- public static Keyword intern(String name) { lock(table) { Keyword sym = (Keyword) table[name]; if(sym == null) table.Add(name, sym = new Keyword(name)); return sym; } } /** * Used by Namespace.intern() * * @param name */ Keyword(String name) { this.name = name; } /** * Indexer implements IFn for attr access * This single arg version is the getter * @param tld * @param obj - must be AMap * @return the value of the attr or nil if not found */ override public Object invoke(ThreadLocalData tld, Object obj) /*throws Exception*/ { return ((AMap)obj).get(this); } /** * Indexer implements IFn for attr access * This two arg version is the setter * @param tld * @param obj - must be AMap * @param val * @return val */ override public Object invoke(ThreadLocalData tld, Object obj, Object val) /*throws Exception*/ { return ((AMap)obj).put(this,val); }
+ public static Keyword intern(String name) { lock(table) { Keyword sym = (Keyword) table[name]; if(sym == null) table.Add(name, sym = new Keyword(name)); return sym; } } /** * Used by Namespace.intern() * * @param name */ Keyword(String name) { this.name = name; } /** * Indexer implements IFn for attr access * This single arg version is the getter * @param tld * @param obj - must be AMap * @return the value of the attr or nil if not found */ override public Object invoke(ThreadLocalData tld, Object obj) /*throws Exception*/ {
+ if (obj == null)
+ return null;
+ return ((AMap)obj).get(this); } /** * Indexer implements IFn for attr access * This two arg version is the setter * @param tld * @param obj - must be AMap * @param val * @return val */ override public Object invoke(ThreadLocalData tld, Object obj, Object val) /*throws Exception*/ { return ((AMap)obj).put(this,val); }
}
} \ No newline at end of file
diff --git a/src/org/clojure/runtime/Accessor.java b/src/org/clojure/runtime/Accessor.java
index 9b74bdf4..ca4a44d1 100644
--- a/src/org/clojure/runtime/Accessor.java
+++ b/src/org/clojure/runtime/Accessor.java
@@ -42,7 +42,9 @@ public Object invoke(ThreadLocalData tld, Object obj) throws Exception
{
if(obj instanceof AMap)
return ((AMap)obj).get(this);
- return Reflector.invokeInstanceMember(name,obj);
+ else if (obj == null)
+ return null;
+ return Reflector.invokeInstanceMember(name,obj);
}
/**
diff --git a/src/org/clojure/runtime/Keyword.java b/src/org/clojure/runtime/Keyword.java
index 822737eb..7fa09415 100644
--- a/src/org/clojure/runtime/Keyword.java
+++ b/src/org/clojure/runtime/Keyword.java
@@ -57,6 +57,8 @@ public String toString()
*/
public Object invoke(ThreadLocalData tld, Object obj) throws Exception
{
+ if (obj == null)
+ return null;
return ((AMap)obj).get(this);
}