mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Avoid creating multiple wrappers.
This commit is contained in:
parent
37770f863b
commit
f294ddcb34
@ -74,11 +74,18 @@ public class JavaAdapter extends ScriptableObject {
|
|||||||
return res;
|
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,
|
public static Object js_JavaAdapter(Context cx, Object[] args,
|
||||||
Function ctorObj, boolean inNewExpr)
|
Function ctorObj, boolean inNewExpr)
|
||||||
throws InstantiationException, NoSuchMethodException,
|
throws InstantiationException, NoSuchMethodException,
|
||||||
IllegalAccessException, InvocationTargetException,
|
IllegalAccessException, InvocationTargetException,
|
||||||
ClassNotFoundException
|
ClassNotFoundException, NoSuchFieldException
|
||||||
{
|
{
|
||||||
Class superClass = Object.class;
|
Class superClass = Object.class;
|
||||||
Class[] intfs = new Class[args.length-1];
|
Class[] intfs = new Class[args.length-1];
|
||||||
@ -112,8 +119,8 @@ public class JavaAdapter extends ScriptableObject {
|
|||||||
|
|
||||||
Class[] ctorParms = { Scriptable.class };
|
Class[] ctorParms = { Scriptable.class };
|
||||||
Object[] ctorArgs = { obj };
|
Object[] ctorArgs = { obj };
|
||||||
Object v = adapterClass.getConstructor(ctorParms).newInstance(ctorArgs);
|
Object adapter = adapterClass.getConstructor(ctorParms).newInstance(ctorArgs);
|
||||||
return setAdapterProto(obj,v);
|
return getAdapterSelf(adapterClass, adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class createAdapterClass(Context cx, Scriptable jsObj,
|
public static Class createAdapterClass(Context cx, Scriptable jsObj,
|
||||||
|
@ -74,11 +74,18 @@ public class JavaAdapter extends ScriptableObject {
|
|||||||
return res;
|
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,
|
public static Object js_JavaAdapter(Context cx, Object[] args,
|
||||||
Function ctorObj, boolean inNewExpr)
|
Function ctorObj, boolean inNewExpr)
|
||||||
throws InstantiationException, NoSuchMethodException,
|
throws InstantiationException, NoSuchMethodException,
|
||||||
IllegalAccessException, InvocationTargetException,
|
IllegalAccessException, InvocationTargetException,
|
||||||
ClassNotFoundException
|
ClassNotFoundException, NoSuchFieldException
|
||||||
{
|
{
|
||||||
Class superClass = Object.class;
|
Class superClass = Object.class;
|
||||||
Class[] intfs = new Class[args.length-1];
|
Class[] intfs = new Class[args.length-1];
|
||||||
@ -112,8 +119,8 @@ public class JavaAdapter extends ScriptableObject {
|
|||||||
|
|
||||||
Class[] ctorParms = { Scriptable.class };
|
Class[] ctorParms = { Scriptable.class };
|
||||||
Object[] ctorArgs = { obj };
|
Object[] ctorArgs = { obj };
|
||||||
Object v = adapterClass.getConstructor(ctorParms).newInstance(ctorArgs);
|
Object adapter = adapterClass.getConstructor(ctorParms).newInstance(ctorArgs);
|
||||||
return setAdapterProto(obj,v);
|
return getAdapterSelf(adapterClass, adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class createAdapterClass(Context cx, Scriptable jsObj,
|
public static Class createAdapterClass(Context cx, Scriptable jsObj,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user