/** * Obtain a <code>Function</code> representing a native * function pointer. In general, this function should be used by dynamic * languages; Java code should allow JNA to bind to a specific Callback * interface instead by defining a return type or Structure field type. * * <p>The allocated instance represents a pointer to the native * function pointer. * * @param p Native function pointer */ public static Function getFunction(Pointer p) { return getFunction(p, 0, null); }
/** * Obtain a <code>Function</code> representing a native * function pointer. In general, this function should be used by dynamic * languages; Java code should allow JNA to bind to a specific Callback * interface instead by defining a return type or Structure field type. * * <p>The allocated instance represents a pointer to the native * function pointer. * * @param p * Native function pointer * @param callFlags * Function <a href="#callflags">call flags</a> */ public static Function getFunction(Pointer p, int callFlags) { return getFunction(p, callFlags, null); }
@Override public int AddRef() { Function f = Function.getFunction(vTable[1], Function.ALT_CONVENTION); return f.invokeInt(new Object[]{interfacePointer}); }
@Override public WinNT.HRESULT QueryInterface(REFIID byValue, PointerByReference pointerByReference) { Function f = Function.getFunction(vTable[0], Function.ALT_CONVENTION); return new WinNT.HRESULT(f.invokeInt(new Object[]{interfacePointer, byValue, pointerByReference})); }
@Override public WinNT.HRESULT QueryInterface(REFIID byValue, PointerByReference pointerByReference) { Function f = Function.getFunction(vTable[0], Function.ALT_CONVENTION); return new WinNT.HRESULT(f.invokeInt(new Object[]{interfacePointer, byValue, pointerByReference})); }
@Override public HRESULT GetUIObjectOf(WinDef.HWND hwndOwner, int cidl, Pointer apidl, REFIID riid, IntByReference rgfReserved, PointerByReference ppv) { Function f = Function.getFunction(vTable[10], Function.ALT_CONVENTION); return new WinNT.HRESULT( f.invokeInt(new Object[]{interfacePointer, hwndOwner, cidl, apidl, riid, rgfReserved, ppv})); }
@Override public HRESULT Clone(PointerByReference ppenum) { Function f = Function.getFunction(vTable[6], Function.ALT_CONVENTION); return new HRESULT(f.invokeInt(new Object[]{interfacePointer, ppenum})); } };
@Override public WinNT.HRESULT ParseDisplayName(WinDef.HWND hwnd, Pointer pbc, String pszDisplayName, IntByReference pchEaten, PointerByReference ppidl, IntByReference pdwAttributes) { Function f = Function.getFunction(vTable[3], Function.ALT_CONVENTION); return new WinNT.HRESULT(f.invokeInt(new Object[]{interfacePointer, hwnd, pbc, pszDisplayName, pchEaten, ppidl, pdwAttributes})); }
@Override public HRESULT BindToStorage(Pointer pidl, Pointer pbc, REFIID riid, PointerByReference ppv) { Function f = Function.getFunction(vTable[6], Function.ALT_CONVENTION); return new WinNT.HRESULT( f.invokeInt(new Object[]{interfacePointer, pidl, pbc, riid, ppv})); }
@Override public HRESULT CompareIDs(WinDef.LPARAM lParam, Pointer pidl1, Pointer pidl2) { Function f = Function.getFunction(vTable[7], Function.ALT_CONVENTION); return new WinNT.HRESULT( f.invokeInt(new Object[]{interfacePointer, lParam, pidl1, pidl2})); }
@Override public HRESULT CreateViewObject(WinDef.HWND hwndOwner, REFIID riid, PointerByReference ppv) { Function f = Function.getFunction(vTable[8], Function.ALT_CONVENTION); return new WinNT.HRESULT( f.invokeInt(new Object[]{interfacePointer, hwndOwner, riid, ppv})); }
@Override public HRESULT GetAttributesOf(int cidl, Pointer apidl, IntByReference rgfInOut) { Function f = Function.getFunction(vTable[9], Function.ALT_CONVENTION); return new WinNT.HRESULT( f.invokeInt(new Object[]{interfacePointer, cidl, apidl, rgfInOut})); }
@Override public HRESULT SetNameOf(WinDef.HWND hwnd, Pointer pidl, String pszName, int uFlags, PointerByReference ppidlOut) { Function f = Function.getFunction(vTable[12], Function.ALT_CONVENTION); return new WinNT.HRESULT( f.invokeInt(new Object[]{interfacePointer, hwnd, pidl, pszName, uFlags, ppidlOut})); } };
protected int _invokeNativeInt(int vtableId, Object[] args) { Pointer vptr = this.getPointer().getPointer(0); // we take the vtable id and multiply with the pointer size (4 bytes on // 32bit OS) Function func = Function.getFunction(vptr.getPointer(vtableId * Native.POINTER_SIZE)); return func.invokeInt(args); }
protected void _invokeNativeVoid(int vtableId, Object[] args) { Pointer vptr = this.getPointer().getPointer(0); // we take the vtable id and multiply with the pointer size (4 bytes on // 32bit OS) Function func = Function.getFunction(vptr.getPointer(vtableId * Native.POINTER_SIZE)); func.invokeVoid(args); }
public/* [local] */void ReleaseVarDesc( /* [in] */VARDESC pVarDesc) { Pointer vptr = this.getPointer().getPointer(0); Function func = Function.getFunction(vptr.getPointer(84)); func.invokeInt(new Object[] { this.getPointer(), pVarDesc }); } }
public HRESULT IsName( /* [annotation][out][in] */ WString szNameBuf, /* [in] */ULONG lHashVal, /* [out] */BOOLbyReference pfName) { Pointer vptr = this.getPointer().getPointer(0); Function func = Function.getFunction(vptr.getPointer(40)); int hr = func.invokeInt(new Object[] { this.getPointer(), szNameBuf, lHashVal, pfName }); return new HRESULT(hr); }
public/* [local] */HRESULT GetFuncDesc( /* [in] */UINT index, /* [out] */FUNCDESC.ByReference pFuncDesc) { Pointer vptr = this.getPointer().getPointer(0); Function func = Function.getFunction(vptr.getPointer(20)); int hr = func.invokeInt(new Object[] { this.getPointer(), index, pFuncDesc }); return new HRESULT(hr); }
public/* [local] */HRESULT GetNames( /* [in] */MEMBERID memid, /* [length_is][size_is][out] */BSTR[] rgBstrNames, /* [in] */UINT cMaxNames, /* [out] */UINTbyReference pcNames) { Pointer vptr = this.getPointer().getPointer(0); Function func = Function.getFunction(vptr.getPointer(28)); int hr = func.invokeInt(new Object[] { this.getPointer(), memid, rgBstrNames, cMaxNames, pcNames }); return new HRESULT(hr); }
public HRESULT GetTypeAttr( /* [out] */TYPEATTR.ByReference pTypeAttr) { Pointer vptr = this.getPointer().getPointer(0); Function func = Function.getFunction(vptr.getPointer(12)); int hr = func.invokeInt(new Object[] { this.getPointer(), pTypeAttr }); pTypeAttr.read(); return new HRESULT(hr); }