/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class contains the collection of utility functions to help work with
* native data types on different platforms similarly.
*/
class Native {
static int longSize;
static int dataModel;
static {
new PrivilegedAction() {
}
});
try {
} catch (Exception e) {
dataModel = 32;
}
if (dataModel == 32) {
longSize = 4;
} else {
longSize = 8;
}
}
/**
* Set of helper function to read data of different PLATFORM types
* from memory pointer by <code>ptr</code>
* Note, names of types in function are NATIVE PLATFORM types
* and they have the same size as they would have in C compiler
* on the same platform.
*/
/**
* Access to C byte data(one byte)
*/
}
/**
* Stores to C byte data(one byte)
*/
}
/**
* Converts length bytes of data pointed by <code>data</code> into byte array
* Returns null if data is zero
* @param data native pointer to native memory
* @param length size in bytes of native memory
*/
if (data == 0) {
return null;
}
}
return res;
}
/**
* Stores byte array into native memory and returns pointer to this memory
* Returns 0 if bytes is null
*/
return 0;
}
}
return res;
}
/**
* Access to C unsigned byte data(one byte)
*/
}
/**
* Stores to C unsigned byte data(one byte)
*/
}
/**
* Converts length usnigned bytes of data pointed by <code>data</code> into
* short array
* Returns null if data is zero
* @param data native pointer to native memory
* @param length size in bytes of native memory
*/
if (data == 0) {
return null;
}
}
return res;
}
/**
* Stores short array as unsigned bytes into native memory and returns pointer
* to this memory
* Returns 0 if bytes is null
*/
return 0;
}
}
return res;
}
/**
* Access to C short data(two bytes)
*/
/**
* Stores to C short data(two bytes)
*/
}
return 0;
}
}
return res;
}
/**
* Access to C unsigned short data(two bytes)
*/
/**
* Stores to C unsigned short data(two bytes)
*/
}
/**
* Stores int array as unsigned shorts into native memory and returns pointer
* to this memory
* Returns 0 if bytes is null
*/
return 0;
}
}
return res;
}
/**
* Access to C int data(four bytes)
*/
/**
* Stores to C int data(four bytes)
*/
}
return 0;
}
}
return res;
}
/**
* Access to C unsigned int data(four bytes)
*/
/**
* Stores to C unsigned int data(four bytes)
*/
}
/**
* Stores long array as unsigned intss into native memory and returns pointer
* to this memory
* Returns 0 if bytes is null
*/
return 0;
}
}
return res;
}
/**
* Access to C long data(size depends on platform)
*/
static int getLongSize() {
return longSize;
}
} else {
}
}
/**
* Stores to C long data(four bytes)
* Note: <code>data</code> has <code>long</code> type
* to be able to keep 64-bit C <code>long</code> data
*/
} else {
}
}
}
/**
* Returns index's element of the array of native long pointed by ptr
*/
}
/**
* Stores Java long[] array into memory. Memory location is treated as array
* of native <code>long</code>s
*/
}
}
/**
* Stores Java Vector of Longs into memory. Memory location is treated as array
* of native <code>long</code>s
*/
}
}
/**
* Stores Java Vector of Longs into memory. Memory location is treated as array
* of native <code>long</code>s. Array is stored in reverse order
*/
}
}
/**
* Converts length bytes of data pointed by <code>data</code> into byte array
* Returns null if data is zero
* @param data native pointer to native memory
* @param length size in longs(platform dependent) of native memory
*/
if (data == 0) {
return null;
}
}
return res;
}
return 0;
}
}
return res;
}
/**
* Access to C "unsigned long" date type, which is XID in X
*/
// Compensate sign-expansion
} else {
// Can't do anything!!!
}
}
}
/**
* Allocates memory for array of native <code>long</code>s of the size <code>length</code>
*/
}
}
}
}
}
/**
* Set of function to return sizes of C data of the appropriate
* type.
*/
static int getWindowSize() {
return getLongSize();
}
/**
* Set of function to access CARD32 type. All data which types are derived
* from CARD32 should be accessed using this accessors.
* These types are: XID(Window, Drawable, Font, Pixmap, Cursor, Colormap, GContext, KeySym),
* Atom, Mask, VisualID, Time
*/
}
}
}
}
static int getCard32Size() {
return getLongSize();
}
}
}
}