Avoid creating multiple wrappers.

This commit is contained in:
nboyd%atg.com 2000-10-02 20:46:08 +00:00
Родитель 4294555de4
Коммит 2307ef527d
2 изменённых файлов: 20 добавлений и 6 удалений

Просмотреть файл

@ -74,11 +74,18 @@ public class JavaAdapter extends ScriptableObject {
return res;
}
public static Object getAdapterSelf(Class adapterClass, Object adapter)
throws NoSuchFieldException, IllegalAccessException
{
Field self = adapterClass.getDeclaredField("self");
return self.get(adapter);
}
public static Object js_JavaAdapter(Context cx, Object[] args,
Function ctorObj, boolean inNewExpr)
throws InstantiationException, NoSuchMethodException,
IllegalAccessException, InvocationTargetException,
ClassNotFoundException
ClassNotFoundException, NoSuchFieldException
{
Class superClass = Object.class;
Class[] intfs = new Class[args.length-1];
@ -112,8 +119,8 @@ public class JavaAdapter extends ScriptableObject {
Class[] ctorParms = { Scriptable.class };
Object[] ctorArgs = { obj };
Object v = adapterClass.getConstructor(ctorParms).newInstance(ctorArgs);
return setAdapterProto(obj,v);
Object adapter = adapterClass.getConstructor(ctorParms).newInstance(ctorArgs);
return getAdapterSelf(adapterClass, adapter);
}
public static Class createAdapterClass(Context cx, Scriptable jsObj,

Просмотреть файл

@ -74,11 +74,18 @@ public class JavaAdapter extends ScriptableObject {
return res;
}
public static Object getAdapterSelf(Class adapterClass, Object adapter)
throws NoSuchFieldException, IllegalAccessException
{
Field self = adapterClass.getDeclaredField("self");
return self.get(adapter);
}
public static Object js_JavaAdapter(Context cx, Object[] args,
Function ctorObj, boolean inNewExpr)
throws InstantiationException, NoSuchMethodException,
IllegalAccessException, InvocationTargetException,
ClassNotFoundException
ClassNotFoundException, NoSuchFieldException
{
Class superClass = Object.class;
Class[] intfs = new Class[args.length-1];
@ -112,8 +119,8 @@ public class JavaAdapter extends ScriptableObject {
Class[] ctorParms = { Scriptable.class };
Object[] ctorArgs = { obj };
Object v = adapterClass.getConstructor(ctorParms).newInstance(ctorArgs);
return setAdapterProto(obj,v);
Object adapter = adapterClass.getConstructor(ctorParms).newInstance(ctorArgs);
return getAdapterSelf(adapterClass, adapter);
}
public static Class createAdapterClass(Context cx, Scriptable jsObj,