Package com.sun.jna

Examples of com.sun.jna.Pointer


     * Invokes the native function with a native string return value.
     * Returns a {@link RubyString} to ruby.
     */
    private static final class StringInvoker implements FunctionInvoker {
        public final IRubyObject invoke(Ruby runtime, Function function, Object[] args) {
            Pointer address = function.invokePointer(args);
            if (address == null) {
                return runtime.getNil();
            }
            int len = (int) address.indexOf(0, (byte) 0);
            if (len == 0) {
                return RubyString.newEmptyString(runtime);
            }
            ByteList bl = new ByteList(len);
            bl.length(len);
            address.read(0, bl.unsafeBytes(), bl.begin(), len);
           
            return RubyString.newString(runtime, bl);
        }
View Full Code Here


        return new JNABuffer(context.getRuntime(), this,
                RubyNumeric.fix2long(value));
    }
    @JRubyMethod(name = "put_pointer", required = 2)
    public IRubyObject put_pointer(ThreadContext context, IRubyObject offset, IRubyObject value) {
        Pointer ptr;
        if (value instanceof JNAMemoryPointer) {
            ptr = ((JNAMemoryPointer) value).getAddress();
        } else if (value.isNil()) {
            ptr = Pointer.NULL;
        } else {
View Full Code Here

        }
    }

    public @Override char[] read(String key) {
        Pointer[] found = new Pointer[1];
        Pointer attributes = LIBRARY.g_array_new(0, 0, GnomeKeyringAttribute_SIZE);
        try {
            LIBRARY.gnome_keyring_attribute_list_append_string(attributes, KEY, key);
            error(GnomeKeyringLibrary.LIBRARY.gnome_keyring_find_items_sync(GNOME_KEYRING_ITEM_GENERIC_SECRET, attributes, found));
        } finally {
            LIBRARY.gnome_keyring_attribute_list_free(attributes);
View Full Code Here

        }
        return null;
    }

    public @Override void save(String key, char[] password, String description) {
        Pointer attributes = LIBRARY.g_array_new(0, 0, GnomeKeyringAttribute_SIZE);
        try {
            LIBRARY.gnome_keyring_attribute_list_append_string(attributes, KEY, key);
            int[] item_id = new int[1];
            error(GnomeKeyringLibrary.LIBRARY.gnome_keyring_item_create_sync(
                    null, GNOME_KEYRING_ITEM_GENERIC_SECRET, description != null ? description : key, attributes, new String(password), true, item_id));
View Full Code Here

        }
    }

    public @Override void delete(String key) {
        Pointer[] found = new Pointer[1];
        Pointer attributes = LIBRARY.g_array_new(0, 0, GnomeKeyringAttribute_SIZE);
        try {
            LIBRARY.gnome_keyring_attribute_list_append_string(attributes, KEY, key);
            error(GnomeKeyringLibrary.LIBRARY.gnome_keyring_find_items_sync(GNOME_KEYRING_ITEM_GENERIC_SECRET, attributes, found));
        } finally {
            LIBRARY.gnome_keyring_attribute_list_free(attributes);
View Full Code Here

    private Structure readStructureByReference(NSInvocation invocation, int index,
            Class<? extends Structure> type)
    {
        Memory buffer = new Memory(Native.POINTER_SIZE);
        invocation.getArgument_atIndex(buffer, index);
        Pointer pointerToResult = buffer.getPointer(0);
        Structure result = newInstance(type);       
        return copyBufferToStructure(pointerToResult, result);
    }
View Full Code Here

        return buf;
    }

    public ByteBuffer toByteBuffer()
    {
        ByteBuffer buffer = new Pointer(peer).getByteBuffer(0, size);

        if (buffer != null)
            return buffer;

        buffer = ByteBuffer.allocate((int) size);
View Full Code Here

            inBufferDescription.cBuffers = new NativeLong(1);
            inBufferDescription.pBuffers = inSecBuffer.getPointer();
            inBufferDescription.write();
        }
       
        Pointer contextAttributes = new Memory(NativeLong.SIZE);
        TimeStamp ltime = new TimeStamp();
        ltime.HighPart = new NativeLong(0);
        ltime.LowPart = new NativeLong(0);
        ltime.write();
       
View Full Code Here

        try {
            Constructor<T> constructor = type.getConstructor(Pointer.class);
            int count = cfLibrary.CFArrayGetCount(theArray).intValue();
            List<T> list = new ArrayList<T>(count);
            for (int i = 0; i < count; i++) {
                Pointer itemPointer = cfLibrary.CFArrayGetValueAtIndex(theArray, new CFIndex(i));
                T item = constructor.newInstance(itemPointer);
                list.add(item);
            }
            return list;
        } catch (ReflectiveOperationException ex) {
View Full Code Here

     */
    protected SDLEvent baseWaitEvent() {
        int ret;
        SDLEvent ret_event = null;
        SDL_Event sdl_event = new SDL_Event();
        Pointer holder = sdl_event.getPointer();

        ret = SDLLibrary.INSTANCE.SDL_WaitEvent( holder );
        if ( ret == 1 ) {
            ret_event = SDLEvent.create( sdl_event );
        } else if ( ret == 0 ) {
View Full Code Here

TOP

Related Classes of com.sun.jna.Pointer

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.