Package com.sun.jna

Examples of com.sun.jna.NativeLibrary


        testlib = null;
    }

    public void testFunctionMapper() throws Exception {
        FunctionMapper mapper = StdCallLibrary.FUNCTION_MAPPER;
        NativeLibrary lib = NativeLibrary.getInstance("testlib");

        Method[] methods = {
            TestLibrary.class.getMethod("returnInt32ArgumentStdCall",
                                        new Class[] { int.class }),
            TestLibrary.class.getMethod("returnStructureByValueArgumentStdCall",
                                        new Class[] {
                                            TestLibrary.TestStructure.ByValue.class
                                        }),
            TestLibrary.class.getMethod("callInt32StdCallCallback",
                                        new Class[] {
                                            TestLibrary.Int32Callback.class,
                                            int.class, int.class,
                                        }),
        };

        for (int i=0;i < methods.length;i++) {
            String name = mapper.getFunctionName(lib, methods[i]);
            assertTrue("Function name not decorated for method "
                       + methods[i].getName()
                       + ": " + name, name.indexOf("@") != -1);
            assertEquals("Wrong name in mapped function",
                         name, lib.getFunction(name, StdCallLibrary.STDCALL_CONVENTION).getName());
        }
    }
View Full Code Here


        testlib = null;
    }

    public void testFunctionMapper() throws Exception {
        FunctionMapper mapper = StdCallLibrary.FUNCTION_MAPPER;
        NativeLibrary lib = NativeLibrary.getInstance("testlib");

        Method[] methods = {
            TestLibrary.class.getMethod("returnInt32ArgumentStdCall",
                                        new Class[] { int.class }),
            TestLibrary.class.getMethod("returnStructureByValueArgumentStdCall",
                                        new Class[] {
                                            TestLibrary.TestStructure.ByValue.class
                                        }),
            TestLibrary.class.getMethod("callInt32StdCallCallback",
                                        new Class[] {
                                            TestLibrary.Int32Callback.class,
                                            int.class, int.class,
                                        }),
        };

        for (int i=0;i < methods.length;i++) {
            String name = mapper.getFunctionName(lib, methods[i]);
            assertTrue("Function name not decorated for method "
                       + methods[i].getName()
                       + ": " + name, name.indexOf("@") != -1);
            assertEquals("Wrong name in mapped function",
                         name, lib.getFunction(name, StdCallLibrary.STDCALL_CONVENTION).getName());
        }
    }
View Full Code Here

        NativeCallBody call = getNativeCallBody(tc, target);

        try {
            /* Load the library and locate the symbol. */
            /* TODO: Error handling! */
            NativeLibrary library = libname == null || libname.equals("")
                ? NativeLibrary.getProcess()
                : NativeLibrary.getInstance(libname);
            call.entry_point = library.getFunction(symbol);
   
            /* TODO: Set the calling convention. */
   
            /* Set up the argument types. */
            int n = (int) arguments.elems(tc);
View Full Code Here

    public static SixModelObject nativecallglobal(String libname, String symbol, SixModelObject target_spec, SixModelObject target_type, ThreadContext tc) {
        try {
            /* Load the library and locate the symbol. */
            /* TODO: Error handling! */
            NativeLibrary library = libname == null || libname.equals("")
                ? NativeLibrary.getProcess()
                : NativeLibrary.getInstance(libname);
            Pointer entry_point = library.getGlobalVariableAddress(symbol);

            StorageSpec ss = target_spec.st.REPR.get_storage_spec(tc, target_spec.st);
            if (ss.boxed_primitive == StorageSpec.BP_STR)
                entry_point = entry_point.getPointer(0);

View Full Code Here

    protected void tearDown() {
        testlib = null;
    }

    public void testFunctionMapper() throws Exception {
        NativeLibrary lib = NativeLibrary.getInstance("testlib");
        Method m = TestLibrary.class.getMethod("returnInt32ArgumentStdCall", new Class[] { int.class });
        assertEquals("Function mapper should provide decorated name",
                     "returnInt32ArgumentStdCall@" + Native.getNativeSize(int.class),
                     StdCallLibrary.FUNCTION_MAPPER.getFunctionName(lib, m));
       
View Full Code Here

TOP

Related Classes of com.sun.jna.NativeLibrary

Copyright © 2015 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.