Commit 38941ae0 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Bring in more shelf changes.

parent a322346e
...@@ -11,6 +11,7 @@ package cc.squirreljme.jvm.mle; ...@@ -11,6 +11,7 @@ package cc.squirreljme.jvm.mle;
import cc.squirreljme.jvm.mle.brackets.TypeBracket; import cc.squirreljme.jvm.mle.brackets.TypeBracket;
import cc.squirreljme.jvm.mle.constants.MonitorResultType; import cc.squirreljme.jvm.mle.constants.MonitorResultType;
import cc.squirreljme.jvm.mle.exceptions.MLECallError;
/** /**
* This shelf supports object anything that has to do with objects. * This shelf supports object anything that has to do with objects.
...@@ -28,6 +29,19 @@ public final class ObjectShelf ...@@ -28,6 +29,19 @@ public final class ObjectShelf
{ {
} }
/**
* Checks if the given object can be stored in the specified array.
*
* @param __array The array to check.
* @param __val The value to check
* @return If the value can be stored in the given array.
* @throws MLECallError If given type is not an array or {@code __array}
* is {@code null}.
* @since 2021/02/07
*/
public static native boolean arrayCheckStore(Object __array, Object __val)
throws MLECallError;
/** /**
* Copies the given arrays. If the source and destination are the same * Copies the given arrays. If the source and destination are the same
* array, the copy operation will not collide with itself. * array, the copy operation will not collide with itself.
...@@ -180,6 +194,27 @@ public final class ObjectShelf ...@@ -180,6 +194,27 @@ public final class ObjectShelf
*/ */
public static native int identityHashCode(Object __o); public static native int identityHashCode(Object __o);
/**
* Checks if this object is an array.
*
* @param __object The object to check.
* @return If this object is an array.
* @since 2021/04/07
*/
public static native boolean isArray(Object __object);
/**
* Checks if this object is an instance of the given type.
*
* @param __o The object to check.
* @param __type The type it may be.
* @return If this object is an instance of the given type.
* @throws MLECallError If {@code __type} is null.
* @since 2021/02/07
*/
public static native boolean isInstance(Object __o, TypeBracket __type)
throws MLECallError;
/** /**
* Creates a new instance of the given type. * Creates a new instance of the given type.
* *
...@@ -203,6 +238,10 @@ public final class ObjectShelf ...@@ -203,6 +238,10 @@ public final class ObjectShelf
/** /**
* Waits on the given monitor. * Waits on the given monitor.
* *
* If the monitor will block and SquirrelJME is running in cooperative
* single threaded mode, this will relinquish control of the current
* thread.
*
* @param __object The object to wait on. * @param __object The object to wait on.
* @param __ms The milliseconds to wait. * @param __ms The milliseconds to wait.
* @param __ns The nanoseconds to wait. * @param __ns The nanoseconds to wait.
......
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
package cc.squirreljme.jvm.mle; package cc.squirreljme.jvm.mle;
import cc.squirreljme.jvm.mle.brackets.TaskBracket;
import cc.squirreljme.jvm.mle.brackets.TracePointBracket; import cc.squirreljme.jvm.mle.brackets.TracePointBracket;
import cc.squirreljme.jvm.mle.brackets.VMThreadBracket; import cc.squirreljme.jvm.mle.brackets.VMThreadBracket;
import cc.squirreljme.jvm.mle.constants.ThreadModelType;
import cc.squirreljme.jvm.mle.exceptions.MLECallError; import cc.squirreljme.jvm.mle.exceptions.MLECallError;
/** /**
...@@ -43,6 +45,14 @@ public final class ThreadShelf ...@@ -43,6 +45,14 @@ public final class ThreadShelf
public static native VMThreadBracket createVMThread(Thread __javaThread) public static native VMThreadBracket createVMThread(Thread __javaThread)
throws MLECallError; throws MLECallError;
/**
* Returns the exit code for the current process.
*
* @return The exit code for the current process.
* @since 2020/06/17
*/
public static native int currentExitCode();
/** /**
* Returns the current Java thread. * Returns the current Java thread.
* *
...@@ -52,12 +62,25 @@ public final class ThreadShelf ...@@ -52,12 +62,25 @@ public final class ThreadShelf
public static native Thread currentJavaThread(); public static native Thread currentJavaThread();
/** /**
* Returns the exit code for the current process. * Returns the current virtual machine thread.
* *
* @return The exit code for the current process. * @return The current virtual machine thread.
* @since 2020/06/17 * @since 2021/05/08
*/ */
public static native int currentExitCode(); public static native VMThreadBracket currentVMThread();
/**
* Checks if these two threads are the same.
*
* @param __a The first thread.
* @param __b The second thread.
* @return If these are the same thread.
* @throws MLECallError If either arguments are null.
* @since 2021/05/08
*/
public static native boolean equals(VMThreadBracket __a,
VMThreadBracket __b)
throws MLECallError;
/** /**
* Returns whether the interrupt flag was raised and clears it. * Returns whether the interrupt flag was raised and clears it.
...@@ -126,6 +149,14 @@ public final class ThreadShelf ...@@ -126,6 +149,14 @@ public final class ThreadShelf
public static native void javaThreadSetDaemon(Thread __javaThread) public static native void javaThreadSetDaemon(Thread __javaThread)
throws MLECallError; throws MLECallError;
/**
* Returns the {@link ThreadModelType} of the virtual machine.
*
* @return The {@link ThreadModelType} of the virtual machine.
* @since 2021/05/07
*/
public static native int model();
/** /**
* Runs the main entry point for the current process and gives it all of * Runs the main entry point for the current process and gives it all of
* the arguments that were specified on program initialization. * the arguments that were specified on program initialization.
...@@ -161,6 +192,10 @@ public final class ThreadShelf ...@@ -161,6 +192,10 @@ public final class ThreadShelf
* *
* If both times are zero, this means to yield the thread (give up its * If both times are zero, this means to yield the thread (give up its
* current execution context). * current execution context).
*
* If SquirrelJME is running in cooperative
* single threaded mode, this will relinquish control of the current
* thread.
* *
* @param __ms The number of milliseconds. * @param __ms The number of milliseconds.
* @param __ns The number of nanoseconds. * @param __ns The number of nanoseconds.
...@@ -267,11 +302,26 @@ public final class ThreadShelf ...@@ -267,11 +302,26 @@ public final class ThreadShelf
public static native boolean vmThreadStart(VMThreadBracket __vmThread) public static native boolean vmThreadStart(VMThreadBracket __vmThread)
throws MLECallError; throws MLECallError;
/**
* Returns the task that owns the given thread.
*
* @param __vmThread The thread to get the task of.
* @return The task for the given thread.
* @throws MLECallError If the thread is not valid.
* @since 2021/05/08
*/
public static native TaskBracket vmThreadTask(VMThreadBracket __vmThread)
throws MLECallError;
/** /**
* Waits for the state of threads to be updated, or just times out. * Waits for the state of threads to be updated, or just times out.
* *
* A thread update is when another thread becomes alive, becomes dead, * A thread update is when another thread becomes alive, becomes dead,
* or is started. * or is started.
*
* If waiting and SquirrelJME is running in cooperative
* single threaded mode, this will relinquish control of the current
* thread.
* *
* @param __ms The amount of time to wait for. * @param __ms The amount of time to wait for.
* @return If the thread was interrupted while waiting. * @return If the thread was interrupted while waiting.
......
...@@ -9,9 +9,11 @@ ...@@ -9,9 +9,11 @@
package cc.squirreljme.jvm.mle; package cc.squirreljme.jvm.mle;
import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.mle.brackets.JarPackageBracket; import cc.squirreljme.jvm.mle.brackets.JarPackageBracket;
import cc.squirreljme.jvm.mle.brackets.TypeBracket; import cc.squirreljme.jvm.mle.brackets.TypeBracket;
import cc.squirreljme.jvm.mle.exceptions.MLECallError; import cc.squirreljme.jvm.mle.exceptions.MLECallError;
import cc.squirreljme.runtime.cldc.debug.Debugging;
/** /**
* Provides the shelf for types that exist within the JVM. * Provides the shelf for types that exist within the JVM.
...@@ -20,14 +22,25 @@ import cc.squirreljme.jvm.mle.exceptions.MLECallError; ...@@ -20,14 +22,25 @@ import cc.squirreljme.jvm.mle.exceptions.MLECallError;
*/ */
public final class TypeShelf public final class TypeShelf
{ {
/**
* Not used.
*
* @since 2021/01/20
*/
private TypeShelf()
{
}
/** /**
* Returns the binary name of the given class. * Returns the binary name of the given class.
* *
* @param __type The type to get the binary name of. * @param __type The type to get the binary name of.
* @return The binary name of this class. * @return The binary name of this class.
* @throws MLECallError If the type is not valid.
* @since 2020/06/07 * @since 2020/06/07
*/ */
public static native String binaryName(TypeBracket __type); public static native String binaryName(TypeBracket __type)
throws MLECallError;
/** /**
* Returns the name of the package the class is within. * Returns the name of the package the class is within.
...@@ -119,6 +132,16 @@ public final class TypeShelf ...@@ -119,6 +132,16 @@ public final class TypeShelf
*/ */
public static native TypeBracket findType(String __name); public static native TypeBracket findType(String __name);
/**
* Initializes the given class.
*
* @param __info The class info to initialize.
* @throws MLECallError If the class is {@code null}.
* @since 2020/11/28
*/
public static native void initClass(TypeBracket __info)
throws MLECallError;
/** /**
* Returns the JAR that the type is within. * Returns the JAR that the type is within.
* *
...@@ -151,6 +174,34 @@ public final class TypeShelf ...@@ -151,6 +174,34 @@ public final class TypeShelf
public static native boolean isArray(TypeBracket __type) public static native boolean isArray(TypeBracket __type)
throws MLECallError; throws MLECallError;
/**
* Performs the same logic as {@link Class#isAssignableFrom(Class)},
* checks if the given class can be assigned to this one. The check is
* in the same order as {@code instanceof Object} that is
* {@code b.getClass().isAssignableFrom(a.getClass()) == (a instanceof b)}
* and {@code (Class<B>)a} does not throw {@link ClassCastException}.
*
* @param __this The basis class
* @param __other The target class which is checked for assignment.
* @return If the given
* @throws MLECallError On null arguments.
* @since 2021/02/07
*/
public static native boolean isAssignableFrom(TypeBracket __this,
TypeBracket __other)
throws MLECallError;
/**
* Checks if the given class is initialized.
*
* @param __type The class info to initialize.
* @return If the class is initialized.
* @throws MLECallError If the type is not valid.
* @since 2021/01/20
*/
public static native boolean isClassInit(TypeBracket __type)
throws MLECallError;
/** /**
* Checks if this is an enumeration. * Checks if this is an enumeration.
* *
......
...@@ -16,9 +16,9 @@ import cc.squirreljme.jvm.mle.brackets.UIWidgetBracket; ...@@ -16,9 +16,9 @@ import cc.squirreljme.jvm.mle.brackets.UIWidgetBracket;
import cc.squirreljme.jvm.mle.callbacks.UIDisplayCallback; import cc.squirreljme.jvm.mle.callbacks.UIDisplayCallback;
import cc.squirreljme.jvm.mle.callbacks.UIFormCallback; import cc.squirreljme.jvm.mle.callbacks.UIFormCallback;
import cc.squirreljme.jvm.mle.constants.UIItemPosition; import cc.squirreljme.jvm.mle.constants.UIItemPosition;
import cc.squirreljme.jvm.mle.constants.UIWidgetProperty;
import cc.squirreljme.jvm.mle.constants.UIItemType; import cc.squirreljme.jvm.mle.constants.UIItemType;
import cc.squirreljme.jvm.mle.constants.UIMetricType; import cc.squirreljme.jvm.mle.constants.UIMetricType;
import cc.squirreljme.jvm.mle.constants.UIWidgetProperty;
import cc.squirreljme.jvm.mle.exceptions.MLECallError; import cc.squirreljme.jvm.mle.exceptions.MLECallError;
/** /**
......
...@@ -11,12 +11,12 @@ package cc.squirreljme.jvm.mle.callbacks; ...@@ -11,12 +11,12 @@ package cc.squirreljme.jvm.mle.callbacks;
import cc.squirreljme.jvm.mle.brackets.UIFormBracket; import cc.squirreljme.jvm.mle.brackets.UIFormBracket;
import cc.squirreljme.jvm.mle.brackets.UIItemBracket; import cc.squirreljme.jvm.mle.brackets.UIItemBracket;
import cc.squirreljme.jvm.mle.constants.UIWidgetProperty;
import cc.squirreljme.jvm.mle.constants.UIKeyEventType; import cc.squirreljme.jvm.mle.constants.UIKeyEventType;
import cc.squirreljme.jvm.mle.constants.UIKeyModifier; import cc.squirreljme.jvm.mle.constants.UIKeyModifier;
import cc.squirreljme.jvm.mle.constants.UIMouseButton; import cc.squirreljme.jvm.mle.constants.UIMouseButton;
import cc.squirreljme.jvm.mle.constants.UIMouseEventType; import cc.squirreljme.jvm.mle.constants.UIMouseEventType;
import cc.squirreljme.jvm.mle.constants.UIPixelFormat; import cc.squirreljme.jvm.mle.constants.UIPixelFormat;
import cc.squirreljme.jvm.mle.constants.UIWidgetProperty;
/** /**
* Interface that is used a callback on a user-interface form is to be done. * Interface that is used a callback on a user-interface form is to be done.
......
...@@ -17,10 +17,34 @@ package cc.squirreljme.jvm.mle.constants; ...@@ -17,10 +17,34 @@ package cc.squirreljme.jvm.mle.constants;
*/ */
public interface NonStandardKey public interface NonStandardKey
{ {
/** Star key. */
int KEY_STAR =
42;
/** Pound key. */
int KEY_POUND =
35;
/** Unknown, zero is the invalid index so always make it known. */ /** Unknown, zero is the invalid index so always make it known. */
byte UNKNOWN = byte UNKNOWN =
0; 0;
/** The up arrow key. */
int KEY_UP =
-1;
/** Down arrow key. */
int KEY_DOWN =
-2;
/** Left arrow key. */
int KEY_LEFT =
-3;
/** Right arrow key. */
int KEY_RIGHT =
-4;
/** Game Up. */ /** Game Up. */
byte VGAME_UP = byte VGAME_UP =
-9; -9;
...@@ -121,11 +145,36 @@ public interface NonStandardKey ...@@ -121,11 +145,36 @@ public interface NonStandardKey
byte INSERT = byte INSERT =
-33; -33;
/** Game Virtual Left Command. */
byte VGAME_COMMAND_LEFT =
-34;
/** Game Virtual Right Command. */
byte VGAME_COMMAND_RIGHT =
-35;
/** Game virtual Center Command. */
byte VGAME_COMMAND_CENTER =
-36;
/** F24. */ /** F24. */
byte F24 = byte F24 =
-35; -37;
/** F1. */ /** F1. */
byte F1 = NonStandardKey.F24 - 24; byte F1 =
NonStandardKey.F24 - 24;
/** F2. */
byte F2 =
NonStandardKey.F1 + 1;
/** F3. */
byte F3 =
NonStandardKey.F1 + 2;
/** F13. */
byte F13 =
NonStandardKey.F1 + 12;
} }
...@@ -18,25 +18,46 @@ public interface UIKeyModifier ...@@ -18,25 +18,46 @@ public interface UIKeyModifier
{ {
/** Alt key modifier. */ /** Alt key modifier. */
int MODIFIER_ALT = int MODIFIER_ALT =
65536; 0x10000;
/** Shift key modifier. */
int MODIFIER_SHIFT =
0x20000;
/** Control (Ctrl) key modifier. */
int MODIFIER_CTRL =
0x40000;
/** Left Command Button. (SquirrelJME). */
int MODIFIER_LEFT_COMMAND =
0x80000;
/** Ctrl key modifier. */ /** Right Command button. (SquirrelJME). */
int MODIFIER_CHR = int MODIFIER_RIGHT_COMMAND =
8388608; 0x100000;
/** Command key modifier. */ /** Command key modifier. */
int MODIFIER_COMMAND = int MODIFIER_COMMAND =
4194304; 0x400000;
/** The Function key. */
int MODIFIER_FUNCTION =
0x800000;
/** Ctrl key modifier. */ /** Left and right commands, used for middle command. */
int MODIFIER_CTRL = int MODIFIER_LEFT_RIGHT_COMMANDS =
262144; UIKeyModifier.MODIFIER_LEFT_COMMAND |
UIKeyModifier.MODIFIER_RIGHT_COMMAND;
/** Mask specifically for the limits of J2ME. */
int J2ME_MASK =
UIKeyModifier.MODIFIER_ALT |
UIKeyModifier.MODIFIER_FUNCTION | UIKeyModifier.MODIFIER_COMMAND |
UIKeyModifier.MODIFIER_CTRL | UIKeyModifier.MODIFIER_SHIFT;
/** Mask for all the modifier keys. */ /** Mask for all the modifier keys. */
int MODIFIER_MASK = int MASK =
13041664; UIKeyModifier.J2ME_MASK |
UIKeyModifier.MODIFIER_LEFT_RIGHT_COMMANDS;
/** Shift key modifier. */
int MODIFIER_SHIFT =
131072;
} }
...@@ -107,7 +107,11 @@ public interface UIWidgetProperty ...@@ -107,7 +107,11 @@ public interface UIWidgetProperty
byte INT_UPDATE_LIST_SELECTION_LOCK = byte INT_UPDATE_LIST_SELECTION_LOCK =
18; 18;
/** The form title. */
byte STRING_FORM_TITLE =
19;
/** The number of properties. */ /** The number of properties. */
byte NUM_PROPERTIES = byte NUM_PROPERTIES =
19; 20;
} }
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
package cc.squirreljme.jvm.mle.exceptions; package cc.squirreljme.jvm.mle.exceptions;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
/** /**
* This is thrown when there was an error made during a MLE call. * This is thrown when there was an error made during a MLE call.
* *
...@@ -61,4 +64,17 @@ public class MLECallError ...@@ -61,4 +64,17 @@ public class MLECallError
{ {
this.initCause(__t); this.initCause(__t);
} }
/**
* Initializes system call exception.
*
* @param __callId The {@link SystemCallIndex}.
* @param __code The {@link SystemCallError}.
* @since 2020/11/29
*/
public MLECallError(int __callId, int __code)
{
// {@squirreljme.error ZZ4k Failed system call. (The ID; The Error)}
super("ZZ4k " + __callId + " " + __code);
}
} }