當前位置: 首頁>>代碼示例>>Java>>正文


Java Pointer類代碼示例

本文整理匯總了Java中com.sun.jna.Pointer的典型用法代碼示例。如果您正苦於以下問題:Java Pointer類的具體用法?Java Pointer怎麽用?Java Pointer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Pointer類屬於com.sun.jna包,在下文中一共展示了Pointer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import com.sun.jna.Pointer; //導入依賴的package包/類
@Override
public void init() {
	super.init();
	WindowManager.createWindow(handle, window, true);

	long hwndGLFW = glfwGetWin32Window(window.getID());
	HWND hwnd = new HWND(Pointer.createConstant(hwndGLFW));

	WindowProc proc = new WindowProc() {

		@Override
		public long invoke(long hw, int uMsg, long wParam, long lParam) {
			if (hw == hwndGLFW)
				switch (uMsg) {
				case WM_WINDOWPOSCHANGING:
					WINDOWPOS pos = new WINDOWPOS(new Pointer(lParam));
					pos.flags |= SWP_NOZORDER | SWP_NOACTIVATE;
					pos.write();
					break;
				}
			return org.lwjgl.system.windows.User32.DefWindowProc(hw, uMsg, wParam, lParam);
		}
	};
	User32.INSTANCE.SetWindowLongPtr(hwnd, GWL_WNDPROC, Pointer.createConstant(proc.address()));
	User32Ext.INSTANCE.SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
	User32Ext.INSTANCE.SetWindowLongPtr(hwnd, GWL_STYLE, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

	User32.INSTANCE.SetWindowPos(hwnd, new HWND(Pointer.createConstant(HWND_BOTTOM)), 0, 0, 0, 0,
			SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
	wallpaper = window.getResourceLoader().loadNVGTexture(getCurrentDesktopWallpaper(), true);
	TaskManager.addTask(() -> window.setVisible(true));
}
 
開發者ID:Guerra24,項目名稱:NanoUI,代碼行數:33,代碼來源:Background.java

示例2: loadFromInputStream

import com.sun.jna.Pointer; //導入依賴的package包/類
public Pointer loadFromInputStream(final InputStream in, String schemaName) {
	final byte[] buffer = new byte[1024];
	IfcEngineInterface.StreamCallback fn = new IfcEngineInterface.StreamCallback() {
		public int invoke(Pointer pointer) {
			try {
				int read = in.read(buffer, 0, 1024);
				if (read == -1) {
					return -1;
				}
				ByteBuffer byteBuffer = pointer.getByteBuffer(0, read);
				byteBuffer.put(buffer, 0, read);
				return read;
			} catch (IOException e) {
			}
			return -1;
		}
	};
	callBacks.add(fn);
	return engine.xxxxOpenModelByStream(0, fn, schemaName);
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:21,代碼來源:IfcEngine.java

示例3: InstanceDerivedTransformationMatrix

import com.sun.jna.Pointer; //導入依賴的package包/類
public InstanceDerivedTransformationMatrix(Pointer model, Pointer instance, double _11, double _12, double _13, double _14, double _21, double _22, double _23, double _24,
		double _31, double _32, double _33, double _34, double _41, double _42, double _43, double _44) {
	this.model = model;
	this.instance = instance;
	this._11 = _11;
	this._12 = _12;
	this._13 = _13;
	this._14 = _14;
	this._21 = _21;
	this._22 = _22;
	this._23 = _23;
	this._24 = _24;
	this._31 = _31;
	this._32 = _32;
	this._33 = _33;
	this._34 = _34;
	this._41 = _41;
	this._42 = _42;
	this._43 = _43;
	this._44 = _44;
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:22,代碼來源:IfcEngine.java

示例4: read

import com.sun.jna.Pointer; //導入依賴的package包/類
public char[] read(String key) {
    try {
        byte[] serviceName = key.getBytes("UTF-8");
        byte[] accountName = "NetBeans".getBytes("UTF-8");
        int[] dataLength = new int[1];
        Pointer[] data = new Pointer[1];
        error("find", SecurityLibrary.LIBRARY.SecKeychainFindGenericPassword(null, serviceName.length, serviceName,
                accountName.length, accountName, dataLength, data, null));
        if (data[0] == null) {
            return null;
        }
        byte[] value = data[0].getByteArray(0, dataLength[0]); // XXX ought to call SecKeychainItemFreeContent
        return new String(value, "UTF-8").toCharArray();
    } catch (UnsupportedEncodingException x) {
        LOG.log(Level.WARNING, null, x);
        return null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:MacProvider.java

示例5: owlGetMappedItem

import com.sun.jna.Pointer; //導入依賴的package包/類
public float[] owlGetMappedItem(Pointer model, Pointer instance, long owlInstance) {
	Memory memory = new Memory(16 * 4 * getPlatformMultiplier());
	LongByReference owlInstanceReference = new LongByReference();
	owlInstanceReference.setValue(owlInstance);
	engine.owlGetMappedItem(model, instance, owlInstanceReference, memory);
	if (getPlatformMultiplier() == 2) {
		double[] doubleArray = memory.getDoubleArray(0, 16);
		float[] floatArray = new float[16];
		for (int i=0; i<16; i++) {
			floatArray[i] = (float)doubleArray[i];
		}
		return floatArray;
	} else {
		return memory.getFloatArray(0, 16);
	}
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:17,代碼來源:IfcEngine.java

示例6: main

import com.sun.jna.Pointer; //導入依賴的package包/類
public static void main(String[] args) {
    final User32 user32 = User32.INSTANCE;

    user32.EnumWindows(new User32.WNDENUMPROC() {

        int count;

        public boolean callback(Pointer hWnd, Pointer userData) {
            byte[] windowText = new byte[512];
            user32.GetWindowTextA(hWnd, windowText, 512);
            String wText = Native.toString(windowText);
            wText = (wText.isEmpty()) ? "" : "; text: " + wText;
            System.out.println("Found window " + hWnd + ", total " + ++count + wText);
            return true;
        }
    }, null);
}
 
開發者ID:symphonicon,項目名稱:Fav-Track,代碼行數:18,代碼來源:JNAMain.java

示例7: findDefaultMode

import com.sun.jna.Pointer; //導入依賴的package包/類
private Pointer findDefaultMode(final Pointer runLoop) {
    final Pointer modes = cf.CFRunLoopCopyAllModes(runLoop);
    if (modes != Pointer.NULL) {
        final int modesCount = cf.CFArrayGetCount(modes).intValue();
        for (int i=0; i< modesCount; i++) {
            final Pointer mode = cf.CFArrayGetValueAtIndex(modes, new NativeLong(i));
            if (mode != Pointer.NULL && DEFAULT_RUN_LOOP_MODE.equals(cf.CFStringGetCStringPtr(mode, ENC_MAC_ROMAN))) {
                return mode;
            }
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:OSXNotifier.java

示例8: init

import com.sun.jna.Pointer; //導入依賴的package包/類
/**
 * It's a heavy init method.
 */
public void init() {
    for (int i = 0; i < poolSize; i++) {
        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(fileSize);

        final long address = ((DirectBuffer) byteBuffer).address();
        Pointer pointer = new Pointer(address);
        LibC.INSTANCE.mlock(pointer, new NativeLong(fileSize));

        availableBuffers.offer(byteBuffer);
    }
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:15,代碼來源:TransientStorePool.java

示例9: main

import com.sun.jna.Pointer; //導入依賴的package包/類
public static void main(String args[]) throws InterruptedException {
    Pointer pointer;
    System.out.println("running in " + System.getProperty("sun.arch.data.model"));

    System.out.println("Loading dll");
    autoHotKeyDll lib = (autoHotKeyDll) Native.loadLibrary("AutoHotkey.dll", autoHotKeyDll.class);

    System.out.println("initialisation");
    lib.ahktextdll(new WString(""), new WString(""), new WString(""));
    // Thread.sleep(100);
    // lib.addFile(new WString(System.getProperty("user.dir") + "\\lib.ahk"), 1);
    // Thread.sleep(1000);

    // System.out.println("function call");
    // System.out.println("return:" + lib.ahkFunction(new WString("function"),new WString(""),new WString(""),new
    // WString(""),new WString(""),new WString(""),new WString(""),new WString(""),new WString(""),new
    // WString(""),new WString("")).getString(0));
    Thread.sleep(1000);

    System.out.println("displaying cbBox");
    lib.ahkExec(new WString("Send {Right}"));
    Thread.sleep(1000);
}
 
開發者ID:SlideKB,項目名稱:SlideBar,代碼行數:24,代碼來源:AHKTest.java

示例10: AVBitStreamFilter

import com.sun.jna.Pointer; //導入依賴的package包/類
/**
 * @param name C type : const char*<br>
 * @param codec_ids C type : AVCodecID*<br>
 * @param priv_class C type : const AVClass*<br>
 * @param init C type : init_callback*<br>
 * @param filter C type : filter_callback*<br>
 * @param close C type : close_callback*
 */
public AVBitStreamFilter(Pointer name, IntByReference codec_ids, Pointer priv_class, int priv_data_size, org.ffmpeg.avfilter6.AVFilter.init_callback init, filter_callback filter, close_callback close) {
	super();
	this.name = name;
	this.codec_ids = codec_ids;
	this.priv_class = priv_class;
	this.priv_data_size = priv_data_size;
	this.init = init;
	this.filter = filter;
	this.close = close;
}
 
開發者ID:cqjjjzr,項目名稱:Laplacian,代碼行數:19,代碼來源:AVBitStreamFilter.java

示例11: invoke

import com.sun.jna.Pointer; //導入依賴的package包/類
@Override
public void invoke(Pointer streamRef, Pointer clientCallBackInfo, NativeLong numEvents, Pointer eventPaths, Pointer eventFlags, Pointer eventIds) {
    final long st = System.currentTimeMillis();
    final int length = numEvents.intValue();
    final Pointer[] pointers = eventPaths.getPointerArray(0, length);
    int flags[];
    if (eventFlags == null) {
        flags = new int[length];
        LOG.log(DEBUG_LOG_LEVEL, "FSEventStreamCallback eventFlags == null, expected int[] of size {0}", length); //NOI18N
    } else {
        flags = eventFlags.getIntArray(0, length);
    }
    for (int i=0; i<length; i++) {
        final Pointer p = pointers[i];
        int flag = flags[i];
        final String path = p.getString(0);

        if ((flag & kFSEventStreamEventFlagMustScanSubDirs) ==  kFSEventStreamEventFlagMustScanSubDirs ||
            (flag & kFSEventStreamEventFlagMount) == kFSEventStreamEventFlagMount ||
            (flag & kFSEventStreamEventFlagUnmount) == kFSEventStreamEventFlagUnmount) {
            events.add(ALL_CHANGE);
        } else {
            events.add(path);
        }
        LOG.log(DEBUG_LOG_LEVEL, "Event on {0}", new Object[]{path});
    }
    LOG.log(PERF_LOG_LEVEL, "Callback time: {0}", (System.currentTimeMillis() - st));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:OSXNotifier.java

示例12: setPointer

import com.sun.jna.Pointer; //導入依賴的package包/類
@Override
public void setPointer(Pointer p) {
    if (immutable) {
        throw new UnsupportedOperationException("immutable reference");
    }

    super.setPointer(p);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:WindowsNotifier.java

示例13: getValue

import com.sun.jna.Pointer; //導入依賴的package包/類
public HANDLE getValue() {
    Pointer p = getPointer().getPointer(0);
    if (p == null)
        return null;
    if (INVALID_HANDLE_VALUE.getPointer().equals(p))
        return INVALID_HANDLE_VALUE;
    HANDLE h = new HANDLE();
    h.setPointer(p);
    return h;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:WindowsNotifier.java

示例14: apply

import com.sun.jna.Pointer; //導入依賴的package包/類
@Override
public int apply(Pointer opaque, Pointer buf, int buf_size) {
    try {
        byte[] tempbuf = new byte[buf_size];
        int readLen = stream.read(tempbuf, 0, buf_size);
        if (readLen == -1) return AVERROR_EOF;
        buf.write(0, tempbuf, 0, readLen);
        return readLen;
    } catch (Exception ex) {
        return -1;
    }
}
 
開發者ID:cqjjjzr,項目名稱:Laplacian,代碼行數:13,代碼來源:FFmpegDecodeBridge.java

示例15: getStringFromCFStringRef

import com.sun.jna.Pointer; //導入依賴的package包/類
/**
 * Converts CFString object to String.
 * 
 * @param cfStringPointer Pointer to CFString object
 * @return String from CFString
 */
private String getStringFromCFStringRef(Pointer cfStringPointer) {
    if (cfStringPointer != null) {
        long lenght = cfLibrary.CFStringGetLength(cfStringPointer);
        long maxSize = cfLibrary.CFStringGetMaximumSizeForEncoding(lenght, 0x08000100); // 0x08000100 = UTF-8

        Pointer buffer = new Memory(maxSize);

        if (cfLibrary.CFStringGetCString(cfStringPointer, buffer, maxSize, 0x08000100)) { // 0x08000100 = UTF-8
            return buffer.getString(0L);
        }
    }
    
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:MacNetworkProxy.java


注:本文中的com.sun.jna.Pointer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。