Package jnr.ffi

Examples of jnr.ffi.Pointer


       
        int creationFlags = WindowsLibC.NORMAL_PRIORITY_CLASS | WindowsLibC.CREATE_UNICODE_ENVIRONMENT;
        WindowsProcessInformation processInformation = new WindowsProcessInformation(getRuntime());

        // FIXME: Convert envp into useful wideEnv
        Pointer wideEnv = null;
        byte[] programW = WindowsHelpers.toWString(program);
        byte[] cwd = WindowsHelpers.toWString(WindowsHelpers.escapePath(handler.getCurrentWorkingDirectory().toString()) +"\\");
        ByteBuffer commandW = ByteBuffer.wrap(WindowsHelpers.toWString(command));
        boolean returnValue = wlibc().CreateProcessW(programW, commandW,
                securityAttributes, securityAttributes,
View Full Code Here


            throw new IllegalArgumentException("global variable type not supported: " + javaType);
        }

        set.start();
        set.aload(0);
        Pointer pointer = DirectMemoryIO.wrap(runtime, address);
        set.getfield(builder.getClassNamePath(), builder.getObjectFieldName(pointer, Pointer.class), ci(Pointer.class));
        set.lconst_0();

        set.aload(1);
        set.checkcast(javaType);
View Full Code Here

        Class boxedType = toNativeConverter != null ? toNativeConverter.nativeType() : javaType;
        NativeType nativeType = Types.getType(runtime, boxedType, annotations).getNativeType();
        ToNativeType toNativeType = new ToNativeType(javaType, nativeType, annotations, toNativeConverter, null);
        FromNativeType fromNativeType = new FromNativeType(javaType, nativeType, annotations, fromNativeConverter, null);
        Variable variable;
        Pointer memory = MemoryUtil.newPointer(runtime, symbolAddress);
        variable = getNativeVariableAccessor(memory, toNativeType, fromNativeType);
        return toNativeType.getToNativeConverter() != null
                ? getConvertingVariable(variable, toNativeType.getToNativeConverter(), fromNativeType.getFromNativeConverter())
                : variable;
    }
View Full Code Here

        return new BoundedMemoryIO(this, offset, size);
    }


    public void transferTo(long offset, Pointer other, long otherOffset, long count) {
        Pointer dst = other instanceof DelegatingMemoryIO ? ((DelegatingMemoryIO) other).getDelegatedMemoryIO() : other;

        dst.checkBounds(otherOffset, count);

        if (dst instanceof AbstractArrayMemoryIO) {
            AbstractArrayMemoryIO aio = (AbstractArrayMemoryIO) dst;
            get(offset, aio.array(), aio.offset() + (int) otherOffset, (int) count);
View Full Code Here

            }
        }
    }

    public void transferFrom(long offset, Pointer other, long otherOffset, long count) {
        Pointer src = other instanceof DelegatingMemoryIO ? ((DelegatingMemoryIO) other).getDelegatedMemoryIO() : other;

        src.checkBounds(otherOffset, count);

        if (src instanceof AbstractArrayMemoryIO) {
            AbstractArrayMemoryIO aio = (AbstractArrayMemoryIO) src;
            put(offset, aio.array(), aio.offset() + (int) otherOffset, (int) count);
View Full Code Here

       
        int creationFlags = WindowsLibC.NORMAL_PRIORITY_CLASS | WindowsLibC.CREATE_UNICODE_ENVIRONMENT;
        WindowsProcessInformation processInformation = new WindowsProcessInformation(getRuntime());

        // FIXME: Convert envp into useful wideEnv
        Pointer wideEnv = null;
        byte[] programW = WindowsHelpers.toWString(program);
        byte[] cwd = WindowsHelpers.toWString(WindowsHelpers.escapePath(handler.getCurrentWorkingDirectory().toString()) +"\\");
        ByteBuffer commandW = ByteBuffer.wrap(WindowsHelpers.toWString(command));
        boolean returnValue = libc.CreateProcessW(programW, commandW,
                securityAttributes, securityAttributes,
View Full Code Here

    }

    public int posix_spawnp(String path, List<? extends SpawnFileAction> fileActions,
            CharSequence[] argv, CharSequence[] envp) {
        IntByReference pid = new IntByReference(-1);
        Pointer nativeFileActions = nativeFileActions(fileActions);

        try {
            if (libc().posix_spawnp(pid, path, nativeFileActions, null, argv, envp) < 0) {
                Errno e = Errno.valueOf(errno());
                handler.error(e, e.description());
View Full Code Here

        return pid.getValue();
    }

    private final Pointer nativeFileActions(List<? extends SpawnFileAction> fileActions) {
        Pointer nativeFileActions = Memory.allocateDirect(getRuntime(), 128);
        libc().posix_spawn_file_actions_init(nativeFileActions);
        for (SpawnFileAction action : fileActions) {
            action.act(this, nativeFileActions);
        }
View Full Code Here

    public static final void marshal(HeapInvocationBuffer buffer, jnr.ffi.Struct parameter, int parameterFlags, int nativeArrayFlags) {
        if (parameter == null) {
            buffer.putAddress(0L);
        } else {
            jnr.ffi.Struct s = parameter;
            Pointer memory = Struct.getMemory(s, parameterFlags);
           
            if (memory instanceof AbstractArrayMemoryIO) {
                AbstractArrayMemoryIO aio = (AbstractArrayMemoryIO) memory;
                buffer.putArray(aio.array(), aio.offset(), aio.length(), nativeArrayFlags);
           
            } else if (memory.isDirect()) {
                buffer.putAddress(memory.address());
            }
        }
    }
View Full Code Here

    public static final void marshal(HeapInvocationBuffer buffer, jnr.ffi.Struct[] parameter, int parameterFlags, int nativeArrayFlags) {
        if (parameter == null) {
            buffer.putAddress(0L);
        } else {
            jnr.ffi.Struct[] array = parameter;
            Pointer memory = Struct.getMemory(array[0], parameterFlags);
            if (!(memory instanceof DelegatingMemoryIO)) {
                throw new RuntimeException("Struct array must be backed by contiguous array");
            }
            memory = ((DelegatingMemoryIO) memory).getDelegatedMemoryIO();
            if (memory instanceof AbstractArrayMemoryIO) {
                AbstractArrayMemoryIO aio = (AbstractArrayMemoryIO) memory;
                buffer.putArray(aio.array(), aio.offset(), aio.length(), nativeArrayFlags);
           
            } else if (memory.isDirect()) {
                buffer.putAddress(memory.address());
            }
        }
    }
View Full Code Here

TOP

Related Classes of jnr.ffi.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.