Package com.sun.jna

Examples of com.sun.jna.Function$NativeMappedArray


   
    @Override
    public final Invoker createInvoker(Ruby runtime, String libraryName, String functionName,
            NativeType returnType, NativeParam[] parameterTypes, String convention) {
        int conv = "stdcall".equals(convention) ? Function.ALT_CONVENTION : Function.C_CONVENTION;
        Function function = NativeLibrary.getInstance(libraryName).getFunction(functionName, conv);
        FunctionInvoker functionInvoker = getFunctionInvoker(returnType);
        Marshaller[] marshallers = new Marshaller[parameterTypes.length];
        for (int i = 0; i < marshallers.length; ++i) {
            marshallers[i] = getMarshaller(parameterTypes[i], conv);
        }
View Full Code Here


    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
                * Pointer.SIZE));
        return func.invokeInt(args);
    }
View Full Code Here

    protected Object _invokeNativeObject(int vtableId, Object[] args,
            Class returnType) {
        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
                * Pointer.SIZE));
        return func.invoke(returnType, args);
    }
View Full Code Here

   
    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
                * Pointer.SIZE));
        func.invokeVoid(args);
    }
View Full Code Here

        // create the OpenGL context to get function address
        WinDef.HGLRC hGLRC = OpenGL32.INSTANCE.wglCreateContext(hdc);
        OpenGL32.INSTANCE.wglMakeCurrent(hdc, hGLRC);
        Pointer funcPointer = OpenGL32.INSTANCE.wglGetProcAddress("wglEnumGpusNV");
        Function fncEnumGpusNV = (funcPointer == null) ? null : Function.getFunction(funcPointer);
        OpenGL32.INSTANCE.wglDeleteContext(hGLRC);

        // destroy the window
        User32.INSTANCE.ReleaseDC(hWnd, hdc);
        User32Util.destroyWindow(hWnd);

        // abort if the nVidia extensions are not present
        if (fncEnumGpusNV == null) return 0;

        // enumerate nVidia adapters
        HGLRCByReference hGPU = new HGLRCByReference();
        for (int i = 0; i < 16; i++) {
            Boolean ok = (Boolean) fncEnumGpusNV.invoke(Boolean.class, new Object[] { Integer.valueOf(i), hGPU, });
            if (!ok.booleanValue()) return i;
        }

        return 0;
    }
View Full Code Here

        // create the OpenGL context to get function address
        WinDef.HGLRC hGLRC = OpenGL32.INSTANCE.wglCreateContext(hdc);
        OpenGL32.INSTANCE.wglMakeCurrent(hdc, hGLRC);
        Pointer funcPointer = OpenGL32.INSTANCE.wglGetProcAddress("wglEnumGpusNV");
        Function fncEnumGpusNV = (funcPointer == null) ? null : Function.getFunction(funcPointer);
        OpenGL32.INSTANCE.wglDeleteContext(hGLRC);

        // destroy the window
        User32.INSTANCE.ReleaseDC(hWnd, hdc);
        User32Util.destroyWindow(hWnd);

        // abort if the nVidia extensions are not present
        if (fncEnumGpusNV == null) return 0;

        // enumerate nVidia adapters
        HGLRCByReference hGPU = new HGLRCByReference();
        for (int i = 0; i < 16; i++) {
            Boolean ok = (Boolean) fncEnumGpusNV.invoke(Boolean.class, new Object[] { Integer.valueOf(i), hGPU, });
            if (!ok.booleanValue()) return i;
        }

        return 0;
    }
View Full Code Here

        long numArgs = (Long)pSig.send("numberOfArguments");
        long respondsToSelector = msg(parent, "respondsToSelector:", selector );
        if ( respondsToSelector > 0 ){
            long impl = msg(parent, "methodForSelector:", selector);
            Pointer pImpl = new Pointer(impl);
            Function func = Function.getFunction(pImpl);
            long returnType = (Long)pSig.send("methodReturnType");
            String strReturnType = new Pointer(returnType).getString(0);
            String prefixes = "rnNoORV";
            int offset = 0;
            while ( prefixes.indexOf(strReturnType.charAt(offset)) != -1 ){
                offset++;
                if ( offset > strReturnType.length()-1 ){
                    break;
                }
            }
            if ( offset > 0 ){
                strReturnType = strReturnType.substring(offset);
            }
           
            Object[] args = new Object[new Long(numArgs).intValue()];
            args[0] = peer;
            args[1] = parent;
            for ( int i=2; i<numArgs; i++){
                long argumentSigAddr = (Long)pSig.send("getArgumentTypeAtIndex:", i);
                String argumentSignature = new Pointer(argumentSigAddr).getString(0);
                LongByReference ptrRef = new LongByReference();
                msg(invocation, "getArgument:atIndex:", ptrRef.getPointer(), i);
                args[i] = ptrRef.getValue();
            }
            char retTypeChar = strReturnType.charAt(0);
           
            Class retType = null;
            switch ( retTypeChar){
                case 'v':
                    retType = void.class; break;
                   
                case 'f':
                    retType = float.class; break;
                case 'd':
                    retType = double.class; break;
               
                case '*':
                    retType = String.class; break;
                   
                case 'i':
                case 'I':
                case 's':
                case 'S':
                case 'c':
                case 'C':
                case 'B':
                   
                    retType = int.class;break;
               
                   
                case 'l':
                case 'L':
                case 'q':
                case 'Q':
                    retType = long.class;break;
               
                case '@':
                case '#':
                case ':':
                case '^':
                case '?':
                    retType = Pointer.class; break;
                default:
                    // If we don't know how to handle the return type properly,
                    // then let's just give up and pass it to the parent object
                    // the normal way
                    //System.out.println("We give up... passing "+sel(selector)+" to parent");
                    msg(invocation, "invokeWithTarget:", parent);
                    return;
                   
               
                   
                   
            }
           
            Object retVal = func.invoke(retType, args);
           
            if ( !void.class.equals(retType)){
                // We need to set the return value.
               
                if ( retVal == null ){
View Full Code Here

TOP

Related Classes of com.sun.jna.Function$NativeMappedArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.