List of usage examples for com.google.gwt.dev.shell.designtime MethodAdaptor toString
@Override
public final String toString()
From source file:com.google.gdt.eclipse.designer.moz.jsni.GeckoDispatchAdapter32.java
License:Open Source License
/** * Retrieve a field and store in the passed JsValue. This function is called * exclusively from native code./*from www. ja v a2s . c om*/ * * @param name name of the field to retrieve * @param jsValue a reference to the JsValue object to receive the value of * the field */ public void getField(String member, int /*long*/ jsRootedValue) { JsValueMoz32/*64*/ jsValue = new JsValueMoz32/*64*/(jsRootedValue); ClassLoader classLoader = classLoaderRef.get(); if (classLoader == null) { jsValue.setUndefined(); return; } DispatchIdOracle dispIdOracle = dispIdOracleRef.get(); if (dispIdOracle == null) { jsValue.setUndefined(); return; } int dispId = getDispId(member); if (dispId < 0) { // no field by that name, return undefined jsValue.setUndefined(); return; } if (javaDispatch.isField(dispId)) { Field field = javaDispatch.getField(dispId); JsValueGlue.set(jsValue, classLoader, dispIdOracle, field.getType(), javaDispatch.getFieldValue(dispId)); return; } else { MethodAdaptor method = javaDispatch.getMethod(dispId); AccessibleObject obj = method.getUnderlyingObject(); DispatchMethod32/*64*/ dispMethod = (DispatchMethod32/*64*/) WrappersCache .getWrapperForObject(classLoader, obj); if (dispMethod == null) { dispMethod = new MethodDispatch32/*64*/(classLoader, dispIdOracle, method); WrappersCache.putWrapperForObject(classLoader, obj, dispMethod); } jsValue.setWrappedFunction(method.toString(), dispMethod); } }
From source file:com.google.gdt.eclipse.designer.moz.jsni.GeckoDispatchAdapter64.java
License:Open Source License
/** * Retrieve a field and store in the passed JsValue. This function is called * exclusively from native code.//from ww w . j av a 2s .c o m * * @param name name of the field to retrieve * @param jsValue a reference to the JsValue object to receive the value of * the field */ public void getField(String member, long jsRootedValue) { JsValueMoz64 jsValue = new JsValueMoz64(jsRootedValue); ClassLoader classLoader = classLoaderRef.get(); if (classLoader == null) { jsValue.setUndefined(); return; } DispatchIdOracle dispIdOracle = dispIdOracleRef.get(); if (dispIdOracle == null) { jsValue.setUndefined(); return; } int dispId = getDispId(member); if (dispId < 0) { // no field by that name, return undefined jsValue.setUndefined(); return; } if (javaDispatch.isField(dispId)) { Field field = javaDispatch.getField(dispId); JsValueGlue.set(jsValue, classLoader, dispIdOracle, field.getType(), javaDispatch.getFieldValue(dispId)); return; } else { MethodAdaptor method = javaDispatch.getMethod(dispId); AccessibleObject obj = method.getUnderlyingObject(); DispatchMethod64 dispMethod = (DispatchMethod64) WrappersCache.getWrapperForObject(classLoader, obj); if (dispMethod == null) { dispMethod = new MethodDispatch64(classLoader, dispIdOracle, method); WrappersCache.putWrapperForObject(classLoader, obj, dispMethod); } jsValue.setWrappedFunction(method.toString(), dispMethod); } }
From source file:com.google.gdt.eclipse.designer.webkit.jsni.WebKitDispatchAdapter.java
License:Open Source License
public H getField(H jsContext, String name) { LowLevelWebKit.pushJsContext(jsContext); ClassLoader classLoader = classLoaderRef.get(); if (classLoader == null) { return LowLevelWebKit.getJsUndefined(jsContext); }/*from w ww .j av a 2 s . c om*/ DispatchIdOracle dispIdOracle = dispIdOracleRef.get(); if (dispIdOracle == null) { return LowLevelWebKit.getJsUndefined(jsContext); } try { int dispId = getDispId(name); if (dispId < 0) { return LowLevelWebKit.getJsUndefined(jsContext); } if (javaDispatch.isField(dispId)) { Field field = javaDispatch.getField(dispId); JsValueWebKit<H> jsValue = new JsValueWebKit<H>(); JsValueGlue.set(jsValue, classLoader, dispIdOracle, field.getType(), javaDispatch.getFieldValue(dispId)); H jsval = jsValue.getJsValue(); // Native code will eat an extra ref. LowLevelWebKit.gcProtect(jsContext, jsval); return jsval; } else { MethodAdaptor method = javaDispatch.getMethod(dispId); AccessibleObject obj = method.getUnderlyingObject(); DispatchMethod<?> dispMethod = (DispatchMethod<?>) WrappersCache.getWrapperForObject(classLoader, obj); if (dispMethod == null) { dispMethod = new MethodDispatch<H>(classLoader, dispIdOracle, method); WrappersCache.putWrapperForObject(classLoader, obj, dispMethod); } // Native code eats the same ref it gave us. return LowLevelWebKit.wrapDispatchMethod(jsContext, method.toString(), dispMethod); } } finally { LowLevelWebKit.popJsContext(jsContext); } }