1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.jvm
.mle
;
12 import cc
.squirreljme
.jvm
.mle
.brackets
.TypeBracket
;
13 import cc
.squirreljme
.jvm
.mle
.constants
.MonitorResultType
;
14 import cc
.squirreljme
.jvm
.mle
.exceptions
.MLECallError
;
15 import cc
.squirreljme
.runtime
.cldc
.annotation
.Api
;
18 * This shelf supports object anything that has to do with objects.
23 public final class ObjectShelf
35 * Checks if the given object can be stored in the specified array.
37 * @param __array The array to check.
38 * @param __val The value to check
39 * @return If the value can be stored in the given array.
40 * @throws MLECallError If given type is not an array or {@code __array}
45 public static native boolean arrayCheckStore(Object __array
, Object __val
)
49 * Copies the given arrays. If the source and destination are the same
50 * array, the copy operation will not collide with itself.
52 * @param __src The source array.
53 * @param __srcOff The source offset.
54 * @param __dest The destination array.
55 * @param __destOff The destination offset.
56 * @param __len The elements to copy.
60 public static native void arrayCopy(boolean[] __src
, int __srcOff
,
61 boolean[] __dest
, int __destOff
, int __len
);
64 * Copies the given arrays. If the source and destination are the same
65 * array, the copy operation will not collide with itself.
67 * @param __src The source array.
68 * @param __srcOff The source offset.
69 * @param __dest The destination array.
70 * @param __destOff The destination offset.
71 * @param __len The elements to copy.
75 public static native void arrayCopy(byte[] __src
, int __srcOff
,
76 byte[] __dest
, int __destOff
, int __len
);
79 * Copies the given arrays. If the source and destination are the same
80 * array, the copy operation will not collide with itself.
82 * @param __src The source array.
83 * @param __srcOff The source offset.
84 * @param __dest The destination array.
85 * @param __destOff The destination offset.
86 * @param __len The elements to copy.
90 public static native void arrayCopy(short[] __src
, int __srcOff
,
91 short[] __dest
, int __destOff
, int __len
);
94 * Copies the given arrays. If the source and destination are the same
95 * array, the copy operation will not collide with itself.
97 * @param __src The source array.
98 * @param __srcOff The source offset.
99 * @param __dest The destination array.
100 * @param __destOff The destination offset.
101 * @param __len The elements to copy.
104 @SquirrelJMEVendorApi
105 public static native void arrayCopy(char[] __src
, int __srcOff
,
106 char[] __dest
, int __destOff
, int __len
);
109 * Copies the given arrays. If the source and destination are the same
110 * array, the copy operation will not collide with itself.
112 * @param __src The source array.
113 * @param __srcOff The source offset.
114 * @param __dest The destination array.
115 * @param __destOff The destination offset.
116 * @param __len The elements to copy.
119 @SquirrelJMEVendorApi
120 public static native void arrayCopy(int[] __src
, int __srcOff
,
121 int[] __dest
, int __destOff
, int __len
);
124 * Copies the given arrays. If the source and destination are the same
125 * array, the copy operation will not collide with itself.
127 * @param __src The source array.
128 * @param __srcOff The source offset.
129 * @param __dest The destination array.
130 * @param __destOff The destination offset.
131 * @param __len The elements to copy.
134 @SquirrelJMEVendorApi
135 public static native void arrayCopy(long[] __src
, int __srcOff
,
136 long[] __dest
, int __destOff
, int __len
);
139 * Copies the given arrays. If the source and destination are the same
140 * array, the copy operation will not collide with itself.
142 * @param __src The source array.
143 * @param __srcOff The source offset.
144 * @param __dest The destination array.
145 * @param __destOff The destination offset.
146 * @param __len The elements to copy.
149 @SquirrelJMEVendorApi
150 public static native void arrayCopy(float[] __src
, int __srcOff
,
151 float[] __dest
, int __destOff
, int __len
);
154 * Copies the given arrays. If the source and destination are the same
155 * array, the copy operation will not collide with itself.
157 * @param __src The source array.
158 * @param __srcOff The source offset.
159 * @param __dest The destination array.
160 * @param __destOff The destination offset.
161 * @param __len The elements to copy.
164 @SquirrelJMEVendorApi
165 public static native void arrayCopy(double[] __src
, int __srcOff
,
166 double[] __dest
, int __destOff
, int __len
);
169 * Fills part of the given array with the specified value.
171 * @param __b The buffer to fill.
172 * @param __o The offset into the buffer.
173 * @param __l The length of the bytes to fill.
174 * @param __v The value to store into the buffer.
175 * @throws MLECallError If any argument is {@code null}, or the offset
176 * and/or length exceed the array bounds.
179 @SquirrelJMEVendorApi
180 public static native void arrayFill(boolean[] __b
, int __o
, int __l
,
185 * Fills part of the given array with the specified value.
187 * @param __b The buffer to fill.
188 * @param __o The offset into the buffer.
189 * @param __l The length of the bytes to fill.
190 * @param __v The value to store into the buffer.
191 * @throws MLECallError If any argument is {@code null}, or the offset
192 * and/or length exceed the array bounds.
195 @SquirrelJMEVendorApi
196 public static native void arrayFill(byte[] __b
, int __o
, int __l
,
201 * Fills part of the given array with the specified value.
203 * @param __b The buffer to fill.
204 * @param __o The offset into the buffer.
205 * @param __l The length of the bytes to fill.
206 * @param __v The value to store into the buffer.
207 * @throws MLECallError If any argument is {@code null}, or the offset
208 * and/or length exceed the array bounds.
211 @SquirrelJMEVendorApi
212 public static native void arrayFill(short[] __b
, int __o
, int __l
,
217 * Fills part of the given array with the specified value.
219 * @param __b The buffer to fill.
220 * @param __o The offset into the buffer.
221 * @param __l The length of the bytes to fill.
222 * @param __v The value to store into the buffer.
223 * @throws MLECallError If any argument is {@code null}, or the offset
224 * and/or length exceed the array bounds.
227 @SquirrelJMEVendorApi
228 public static native void arrayFill(char[] __b
, int __o
, int __l
,
233 * Fills part of the given array with the specified value.
235 * @param __b The buffer to fill.
236 * @param __o The offset into the buffer.
237 * @param __l The length of the bytes to fill.
238 * @param __v The value to store into the buffer.
239 * @throws MLECallError If any argument is {@code null}, or the offset
240 * and/or length exceed the array bounds.
243 @SquirrelJMEVendorApi
244 public static native void arrayFill(int[] __b
, int __o
, int __l
,
249 * Fills part of the given array with the specified value.
251 * @param __b The buffer to fill.
252 * @param __o The offset into the buffer.
253 * @param __l The length of the bytes to fill.
254 * @param __v The value to store into the buffer.
255 * @throws MLECallError If any argument is {@code null}, or the offset
256 * and/or length exceed the array bounds.
259 @SquirrelJMEVendorApi
260 public static native void arrayFill(long[] __b
, int __o
, int __l
,
265 * Fills part of the given array with the specified value.
267 * @param __b The buffer to fill.
268 * @param __o The offset into the buffer.
269 * @param __l The length of the bytes to fill.
270 * @param __v The value to store into the buffer.
271 * @throws MLECallError If any argument is {@code null}, or the offset
272 * and/or length exceed the array bounds.
275 @SquirrelJMEVendorApi
276 public static native void arrayFill(float[] __b
, int __o
, int __l
,
281 * Fills part of the given array with the specified value.
283 * @param __b The buffer to fill.
284 * @param __o The offset into the buffer.
285 * @param __l The length of the bytes to fill.
286 * @param __v The value to store into the buffer.
287 * @throws MLECallError If any argument is {@code null}, or the offset
288 * and/or length exceed the array bounds.
291 @SquirrelJMEVendorApi
292 public static native void arrayFill(double[] __b
, int __o
, int __l
,
297 * Returns the length of the array if this object is an array.
299 * @param __object The object to get the length of.
300 * @return The length of the array or a negative value if this is not an
304 @SquirrelJMEVendorApi
305 public static native int arrayLength(Object __object
);
308 * Allocates a new array.
310 * @param <T> The resultant type of the array.
311 * @param __type The type to allocate the array for.
312 * @param __len The length of the array.
313 * @return The newly allocated array as the given object.
316 @SquirrelJMEVendorApi
317 public static native <T
> T
arrayNew(TypeBracket __type
, int __len
);
320 * Checks if the given thread holds the lock on the given method.
322 * @param __javaThread The Java thread to check if it holds the lock.
323 * @param __o The object to check.
324 * @return If the given thread holds the lock.
327 @SquirrelJMEVendorApi
328 public static native boolean holdsLock(Thread __javaThread
, Object __o
);
331 * Returns the identity hashcode of the object.
333 * @param __o The object to get the hashcode of.
334 * @return The identity hashcode of the object.
337 @SquirrelJMEVendorApi
338 public static native int identityHashCode(Object __o
);
341 * Checks if this object is an array.
343 * @param __object The object to check.
344 * @return If this object is an array.
347 @SquirrelJMEVendorApi
348 public static native boolean isArray(Object __object
);
351 * Checks if this object is an instance of the given type.
353 * @param __o The object to check.
354 * @param __type The type it may be.
355 * @return If this object is an instance of the given type.
356 * @throws MLECallError If {@code __type} is null.
359 @SquirrelJMEVendorApi
360 public static native boolean isInstance(Object __o
, TypeBracket __type
)
364 * Creates a new instance of the given type.
366 * @param __type The type to instantiate.
367 * @return The newly created object or {@code null} if there was no
371 @SquirrelJMEVendorApi
372 public static native Object
newInstance(TypeBracket __type
);
375 * Notifies the monitors holding onto this object.
377 * @param __object The object to signal.
378 * @param __all Notify all threads?
379 * @return The {@link MonitorResultType}.
382 @SquirrelJMEVendorApi
383 public static native int notify(Object __object
, boolean __all
);
386 * Waits on the given monitor.
388 * If the monitor will block and SquirrelJME is running in cooperative
389 * single threaded mode, this will relinquish control of the current
392 * @param __object The object to wait on.
393 * @param __ms The milliseconds to wait.
394 * @param __ns The nanoseconds to wait.
395 * @return The {@link MonitorResultType}.
398 @SquirrelJMEVendorApi
399 public static native int wait(Object __object
, long __ms
, int __ns
);