⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cptr.java

📁 学习JAVA编程的示例
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @param buf    <code>float</code> array into which data is copied
     * @param index  array index to which data is copied
     * @param length number of elements from C pointer that must be copied
     */
    public native void copyOut(int bOff, float[] buf, int index, int length);

    /**
     * Indirect the C pointer, copying <em>from</em> memory pointed to by C
     * pointer, into the specified array.
     *
     * @param bOff   byte offset from pointer from which data is copied
     * @param buf    <code>double</code> array into which data is copied
     * @param index  array index to which data is copied
     * @param length number of elements from C pointer that must be copied
     */
    public native void copyOut(int bOff, double[] buf, int index, int length);

    /**
     * Indirect the C pointer as a pointer to <code>byte</code>.  This is
     * equivalent to the expression 
     * <code>*((jbyte *)((char *)cptr + * offset))</code>.
     *
     * @param offset offset from pointer to perform the indirection
     * @return the <code>byte</code> value being pointed to
     */
    public native byte getByte(int offset);

    /**
     * Indirect the C pointer as a pointer to <code>short</code>.  This is
     * equivalent to the expression
     * <code>*((jshort *)((char *)cptr + offset))</code>.
     *
     * @param offset byte offset from pointer to perform the indirection
     * @return the <code>short</code> value being pointed to
     */
    public native short getShort(int offset);

    /**
     * Indirect the C pointer as a pointer to <code>int</code>.  This is
     * equivalent to the expression
     * <code>*((jint *)((char *)cptr + offset))</code>.
     *
     * @param offset byte offset from pointer to perform the indirection
     * @return the <code>int</code> value being pointed to
     */
    public native int getInt(int offset);

    /**
     * Indirect the C pointer as a pointer to <code>long</code>.  This is
     * equivalent to the expression
     * <code>*((jlong *)((char *)cptr + offset))</code>.
     *
     * @param offset byte offset from pointer to perform the indirection
     * @return the <code>long</code> value being pointed to
     */
    public native long getLong(int offset);

    /**
     * Indirect the C pointer as a pointer to <code>float</code>.  This is
     * equivalent to the expression
     * <code>*((jfloat *)((char *)cptr + offset))</code>.
     *
     * @param offset byte offset from pointer to perform the indirection
     * @return the <code>float</code> value being pointed to
     */
    public native float getFloat(int offset);

    /**
     * Indirect the C pointer as a pointer to <code>double</code>.  This is
     * equivalent to the expression
     * <code>*((jdouble *)((char *)cptr + offset))</code>.
     *
     * @param offset byte offset from pointer to perform the indirection
     * @return the <code>double</code> value being pointed to
     */
    public native double getDouble(int offset);

    /**
     * Indirect the C pointer as a pointer to pointer.  This is equivalent to
     * the expression <code>*((void **)((char *)cptr + offset))</code>.
     *
     * @param offset byte offset from pointer to perform the indirection
     * @return the <code>pointer</code> value being pointed to
     */
    public native CPtr getCPtr(int offset);

    /**
     * Indirect the C pointer as a pointer to <code>char *</code>, a
     * <code>NULL</code>-terminated C string. Convert the C string to a
     * <code>java.lang.String</code>.
     *
     * @param offset byte offset from pointer to obtain the C string
     * @return the <code>String</code> value being pointed to 
     */
    public native String getString(int offset);

    /**
     * Set <code>value</code> at location being pointed to. This is equivalent
     * to the expression
     * <code>*((jbyte *)((char *)cptr + offset)) = value</code>.
     *
     * @param offset byte offset from pointer at which <code>value</code>
     *		     must be set
     * @param value <code>byte</code> value to set
     */
    public native void setByte(int offset, byte value);

    /**
     * Set <code>value</code> at location being pointed to. This is equivalent
     * to the expression
     * <code>*((jshort *)((char *)cptr + offset)) = value</code>.
     *
     * @param offset byte offset from pointer at which <code>value</code>
     *		     must be set
     * @param value <code>short</code> value to set
     */
    public native void setShort(int offset, short value);

    /**
     * Set <code>value</code> at location being pointed to. This is equivalent
     * to the expression
     * <code>*((jint *)((char *)cptr + offset)) = value</code>.
     *
     * @param offset byte offset from pointer at which <code>value</code>
     *		     must be set
     * @param value <code>int</code> value to set
     */
    public native void setInt(int offset, int value);

    /**
     * Set <code>value</code> at location being pointed to. This is equivalent
     * to the expression
     * <code>*((jlong *)((char *)cptr + offset)) = value</code>.
     *
     * @param offset byte offset from pointer at which <code>value</code>
     *               must be set
     * @param value <code>long</code> value to set
     */
    public native void setLong(int offset, long value);

    /**
     * Set <code>value</code> at location being pointed to. This is equivalent
     * to the expression
     * <code>*((jfloat *)((char *)cptr + offset)) = value</code>.
     *
     * @param offset byte offset from pointer at which <code>value</code>
     *               must be set
     * @param value <code>float</code> value to set
     */
    public native void setFloat(int offset, float value);

    /**
     * Set <code>value</code> at location being pointed to. This is equivalent
     * to the expression
     * <code>*((jdouble *)((char *)cptr + offset)) = value</code>.
     *
     * @param offset byte offset from pointer at which <code>value</code>
     *               must be set
     * @param value <code>double</code> value to set
     */
    public native void setDouble(int offset, double value);

    /**
     * Set <code>value</code> at location being pointed to. This is equivalent
     * to the expression *((void **)((char *)cptr + offset)) = value</code>.
     *
     * @param offset byte offset from pointer at which <code>value</code> 
     *               must be set
     * @param value <code>CPtr</code> value to set
     */
    public native void setCPtr(int offset, CPtr value);

    /**
     * Copy string <code>value</code> to the location being pointed to.  Copy
     * each element in <code>value</code>, converted to native encoding, at an
     * <code>offset</code>from the location pointed to by this pointer.
     *
     * @param offset byte offset from pointer at which characters in
     * 		     <code>value</code> must be set
     * @param value  <code>java.lang.String</code> value to set 
     */
    public native void setString(int offset, String value);

    /* Initialize field and method IDs for native methods of this class. */
    private static native int initIDs(CPtr p);
    
    static {
        System.loadLibrary("disp");
	NULL = new CPtr();
        SIZE = initIDs(NULL);
    }

    /* peer and the no-args constructor are deliberately package private, so
       all classes that are abstractions of a C pointer will can only be in
       one isolated package.  */
    
    /* Pointer value of the real C pointer. Use long to be 64-bit safe. */
    long peer;

    /* No-args constructor, see comment above. */
    CPtr() {}
 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -