org.bridj.Pointer Java Examples

The following examples show how to use org.bridj.Pointer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClearVolumeC.java    From clearvolume with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static int send8bitUINTVolumeDataToSink(	final int pSinkId,
												final int pChannelId,
												final long pBufferAddress,
												final long pBufferLength,
												final int pWidthInVoxels,
												final int pHeightInVoxels,
												final int pDepthInVoxels)
{
	final Pointer<Byte> lBridJPointer = getBridJPointer(pBufferAddress,
														pBufferLength,
														Byte.class);

	final ByteBuffer lByteBuffer = lBridJPointer.getByteBuffer();

	return send8bitUINTVolumeDataToSink(pSinkId,
										pChannelId,
										lByteBuffer,
										pWidthInVoxels,
										pHeightInVoxels,
										pDepthInVoxels);
}
 
Example #2
Source File: Module.java    From llvm-j with MIT License 5 votes vote down vote up
/**
 * Verifies that a module is valid, throwing an exception if not.
 */
public void verify()
        throws LLVMException {
    Pointer<Pointer<Byte>> ppByte = Pointer.pointerToCStrings("");
    int retval = LLVMVerifyModule(module,
            LLVMVerifierFailureAction.LLVMReturnStatusAction, ppByte);
    if (retval != 0) {
        Pointer<Byte> pByte = ppByte.getPointer(Byte.class);
        final String message = pByte.getCString();
        LLVMDisposeMessage(pByte);
        throw new LLVMException(message);
    }
}
 
Example #3
Source File: ExecutionEngine.java    From llvm-j with MIT License 5 votes vote down vote up
public Value findFunction(String name) { // Pointer<Pointer<LLVMOpaqueValue>> outFn) {
    Pointer<Byte> cstr = Pointer.pointerToCString(name);
    Pointer<LLVMValueRef> outFn = Pointer
            .allocateTypedPointer(LLVMValueRef.class);
    boolean err = LLVMFindFunction(engine, cstr, outFn) != 0;
    if (err) {
        throw new RuntimeException("LLVMFindFunction can't find " + name);
    }
    return new Value(outFn.get());
}
 
Example #4
Source File: ExecutionEngine.java    From llvm-j with MIT License 5 votes vote down vote up
static Pointer<LLVMGenericValueRef> internalize(GenericValue[] values) {
    int n = values.length;
    LLVMGenericValueRef[] inner = new LLVMGenericValueRef[n];
    for (int i = 0; i < n; i++) {
        inner[i] = values[i].ref();
    }

    Pointer<LLVMGenericValueRef> array = Pointer.allocateTypedPointers(
            LLVMGenericValueRef.class, n);
    array.setArray(inner);

    return array;
}
 
Example #5
Source File: Value.java    From llvm-j with MIT License 5 votes vote down vote up
public static Value constInlineAsm(TypeRef ty, String asmString,
        String constraints, boolean hasSideEffects, boolean isAlignStack) {
    return new Value(LLVMConstInlineAsm(ty.type(),
            Pointer.pointerToCString(asmString),
            Pointer.pointerToCString(constraints), hasSideEffects ? 1 : 0,
            isAlignStack ? 1 : 0));
}
 
Example #6
Source File: TypeRef.java    From llvm-j with MIT License 5 votes vote down vote up
static Pointer<LLVMTypeRef> internalize(TypeRef[] types) {
    int n = types.length;
    LLVMTypeRef[] inner = new LLVMTypeRef[n];
    for (int i = 0; i < n; i++) {
        inner[i] = types[i].type;
    }

    Pointer<LLVMTypeRef> array = Pointer.allocateTypedPointers(
            LLVMTypeRef.class, types.length);
    array.setArray(inner);

    return array;
}
 
Example #7
Source File: SXJNA.java    From SikuliNG with MIT License 5 votes vote down vote up
/**
 * getAll the current value of a variable from real Windows environment
 *
 * @param name of the environment variable
 * @return current content
 */
public static String getEnvironmentVariable(String name) {
  final int BUFFER_SIZE =  32767;
  Pointer<Character> buffer = Pointer.allocateArray(Character.class, BUFFER_SIZE);
  int result = GetEnvironmentVariableW(Pointer.pointerToWideCString(name), buffer, BUFFER_SIZE);
  if (result == 0) {
    log.error("WinKernel32: getEnvironmentVariable: does not work for: %s", name);
    return null;
  }
  return buffer.getWideCString();
}
 
Example #8
Source File: SXJNA.java    From SikuliNG with MIT License 5 votes vote down vote up
/**
 * set the value of a variable in real Windows environment
 *
 * @param name of the environment variable
 * @param value of the environment variable
 * @return success
 */
public static boolean setEnvironmentVariable(String name, String value) {
  if (!SetEnvironmentVariableW(Pointer.pointerToWideCString(name), Pointer.pointerToWideCString(value))) {
    log.error("WinKernel32: setEnvironmentVariable: does not work for: %s = %s", name, value);
    return false;
  }
  return true;
}
 
Example #9
Source File: Value.java    From llvm-j with MIT License 5 votes vote down vote up
static Pointer<LLVMValueRef> internalize(Value[] values) {
    int n = values.length;
    LLVMValueRef[] inner = new LLVMValueRef[n];
    for (int i = 0; i < n; i++) {
        inner[i] = values[i].value;
    }

    Pointer<LLVMValueRef> array = Pointer.allocateTypedPointers(
            LLVMValueRef.class, values.length);
    array.setArray(inner);

    return array;
}
 
Example #10
Source File: ExecutionEngine.java    From llvm-j with MIT License 5 votes vote down vote up
public void createJITCompilerForModule(Module m, int optLevel) throws LLVMException {
    Pointer<Pointer<Byte>> ppByte = Pointer.pointerToCStrings("");
    Pointer<LLVMExecutionEngineRef> pExec = Pointer.allocate(LLVMExecutionEngineRef.class);
    pExec.set(engine);
    int retval = LLVMCreateJITCompilerForModule(pExec, m.module(), optLevel, ppByte);
    if (retval != 0) {
        Pointer<Byte> pByte = ppByte.getPointer(Byte.class);
        final String message = pByte.getCString();
        LLVMDisposeMessage(pByte);
        throw new LLVMException(message);
    }
}
 
Example #11
Source File: ProgressHelperWindowsJava8.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
WindowProgress(Window window) {
    ITaskbarList3 taskbarList;
    Pointer<Integer> hwnd;
    try {
        taskbarList = COMRuntime.newInstance(ITaskbarList3.class);
        long hwndVal = JAWTUtils.getNativePeerHandle(window);
        hwnd = (Pointer<Integer>) Pointer.pointerToAddress(hwndVal);
    } catch (ClassNotFoundException | RuntimeException e) {
        // Probably too old a Windows version
        taskbarList = null;
        hwnd = null;
    }
    this.taskbarList = taskbarList;
    this.hwnd = hwnd;
}
 
Example #12
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildPhi(LLVMTypeRef ty, String name) {
    return new Value(LLVMBuildPhi(builder, ty,
            Pointer.pointerToCString(name)));
}
 
Example #13
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildCall(Value fn, String name, Value... args) {
    return new Value(LLVMBuildCall(builder, fn.value(), Value.internalize(args),
            args.length, Pointer.pointerToCString(name)));
}
 
Example #14
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildLoad(Value pointerVal, String name) {
    return new Value(LLVMBuildLoad(builder, pointerVal.value(),
            Pointer.pointerToCString(name)));
}
 
Example #15
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildFPExt(Value val, LLVMTypeRef destTy, String name) {
    return new Value(LLVMBuildFPExt(builder, val.value(), destTy,
            Pointer.pointerToCString(name)));
}
 
Example #16
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildFPToSI(Value val, LLVMTypeRef destTy, String name) {
    return new Value(LLVMBuildFPToSI(builder, val.value(), destTy,
            Pointer.pointerToCString(name)));
}
 
Example #17
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildUIToFP(Value val, LLVMTypeRef destTy, String name) {
    return new Value(LLVMBuildUIToFP(builder, val.value(), destTy,
            Pointer.pointerToCString(name)));
}
 
Example #18
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildSIToFP(Value val, LLVMTypeRef destTy, String name) {
    return new Value(LLVMBuildSIToFP(builder, val.value(), destTy,
            Pointer.pointerToCString(name)));
}
 
Example #19
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildFPTrunc(Value val, LLVMTypeRef destTy, String name) {
    return new Value(LLVMBuildFPTrunc(builder, val.value(), destTy,
            Pointer.pointerToCString(name)));
}
 
Example #20
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildInBoundsGEP(Value ptr, Pointer<LLVMValueRef> indices,
        int numIndices, String name) {
    return new Value(LLVMBuildInBoundsGEP(builder, ptr.value(), indices,
            numIndices, Pointer.pointerToCString(name)));
}
 
Example #21
Source File: Module.java    From llvm-j with MIT License 4 votes vote down vote up
public Value addGlobal(TypeRef ty, String name) {
    return new Value(LLVMAddGlobal(module(), ty.type(),
            Pointer.pointerToCString(name)));
}
 
Example #22
Source File: ExecutionEngine.java    From llvm-j with MIT License 4 votes vote down vote up
public Pointer<?> recompileAndRelinkFunction(Value fn) {
    return LLVMRecompileAndRelinkFunction(engine, fn.value());
}
 
Example #23
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildPhi(TypeRef ty, String name) {
    return new Value(LLVMBuildPhi(builder, ty.type(),
            Pointer.pointerToCString(name)));
}
 
Example #24
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildZExtOrBitCast(Value val, LLVMTypeRef destTy, String name) {
    return new Value(LLVMBuildZExtOrBitCast(builder, val.value(), destTy,
            Pointer.pointerToCString(name)));
}
 
Example #25
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildNSWNeg(Value v, String name) {
    return new Value(LLVMBuildNSWNeg(builder, v.value(),
            Pointer.pointerToCString(name)));
}
 
Example #26
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildNeg(Value v, String name) {
    return new Value(LLVMBuildNeg(builder, v.value(),
            Pointer.pointerToCString(name)));
}
 
Example #27
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildOr(Value lhs, Value rhs, String name) {
    return new Value(LLVMBuildOr(builder, lhs.value(), rhs.value(),
            Pointer.pointerToCString(name)));
}
 
Example #28
Source File: Value.java    From llvm-j with MIT License 4 votes vote down vote up
public static Value constInBoundsGEP(Value constantVal,
        Pointer<LLVMValueRef> constantIndices, int numIndices) {
    return new Value(LLVMConstInBoundsGEP(constantVal.value(),
            constantIndices, numIndices));
}
 
Example #29
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildAShr(Value lhs, Value rhs, String name) {
    return new Value(LLVMBuildAShr(builder, lhs.value(), rhs.value(),
            Pointer.pointerToCString(name)));
}
 
Example #30
Source File: Builder.java    From llvm-j with MIT License 4 votes vote down vote up
public Value buildShl(Value lhs, Value rhs, String name) {
    return new Value(LLVMBuildShl(builder, lhs.value(), rhs.value(),
            Pointer.pointerToCString(name)));
}