Allow java.lang.Hashtables to be passed into PHP as arrays.

This commit is contained in:
Sam Ruby 2000-07-22 17:32:32 +00:00
parent 7893c72965
commit 3f4c7c8359
4 changed files with 46 additions and 0 deletions

View file

@ -45,6 +45,7 @@ public class reflect {
private static native void setResultFromObject(long result, Object value);
private static native void setResultFromArray(long result);
private static native long nextElement(long array);
private static native long hashUpdate(long array, byte key[]);
private static native void setException(long result, byte value[]);
public static native void setEnv();
@ -81,6 +82,15 @@ public class reflect {
setResult(nextElement(result), Array.get(value, i));
}
} else if (value instanceof java.util.Hashtable) {
Hashtable ht = (Hashtable) value;
setResultFromArray(result);
for (Enumeration e = ht.keys(); e.hasMoreElements(); ) {
Object key = e.nextElement();
setResult(hashUpdate(result, key.toString().getBytes()), ht.get(key));
}
} else {
setResultFromObject(result, value);