Thread: [Waba-commits] CVS: waba/src/share/classes/waba/sys Convert.java,NONE,1.1 Runnable.java,NONE,1.1 Thr
Status: Abandoned
Brought to you by:
bornet
From: Manfred R. <mr...@us...> - 2004-07-10 14:18:14
|
Update of /cvsroot/waba/waba/src/share/classes/waba/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/src/share/classes/waba/sys Added Files: Convert.java Runnable.java Thread.java Time.java Vm.java VmShell.java Log Message: Moved to new location --- NEW FILE: Convert.java --- /* $Id: Convert.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.sys; /** * Convert is used to convert between objects and basic types. */ public class Convert { private Convert() { } /** * Converts the given String to an int. If the string passed is not a valid * integer, 0 is returned. */ public native static int toInt(String s); /** Converts the given boolean to a String. */ public native static String toString(boolean b); /** Converts the given char to a String. */ public native static String toString(char c); /** Converts the given float to its bit representation in IEEE 754 format. */ public native static int toIntBitwise(float f); /** Converts the given IEEE 754 bit representation of a float to a float. */ public native static float toFloatBitwise(int i); /** Converts the given float to a String. */ public native static String toString(float f); /** Converts the given double to a String. */ public native static String toString(double d); /** Converts the given int to a String. */ /** converts the string to upper case letters */ public static String toUpperCase(String s) { char[] c = s.toCharArray(); for (int i=0; i < c.length; i++) c[i] = toUpperCase(c[i]); return new String(c); } /** converts the string to lower case letters */ public static String toLowerCase(String s) { char[] c = s.toCharArray(); for (int i=0; i < c.length; i++) c[i] = toLowerCase(c[i]); return new String(c); } /** converts the char to lower case letter */ public static char toLowerCase(char c) { if ('A' <= c && c <= 'Z') c += 32; return c; } /** converts the char to upper case letter */ public static char toUpperCase(char c) { if ('a' <= c && c <= 'z') c -= 32; return c; } public native static String toString(int i); /** Converts the given long to a String. */ public native static String toString(long l); } --- NEW FILE: Runnable.java --- /* $Id: Runnable.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 2000 Monaka (mon...@mo...) All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Monaka and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. AUTHOR ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. AUTHOR SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. AUTHOR SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY AUTHOR. */ package waba.sys; public interface Runnable { public abstract void run(); } --- NEW FILE: Thread.java --- /* $Id: Thread.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 2000 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ /* 2001.08.06 * This file is modified by Monaka (mon...@mo...) * enabled to use Runnable interface. * appended dummy code for yield. */ /* Waba Thread: <p> It works pretty much like Java's Thread class, except with few cabiats... <p> On all platforms: Everytime you use it, you have to write out as "waba.sys.Thread", instead of just "Thread". This way, Java compiler doesn't get confused with java.lang.Thread. <p> On PalmOS: Threads are implemented as "GREEN" threads which let you run threads on platforms which doesn't support native multi-threading. <p> You have to ".stop()" it, when it's done. <p> It blocks everything if ".run()" method calls other time-consuming methods. i.e. serial and socket communication. Since it blocks everything else, you don't have to do any shared-resource protection. <p> The main thread scheduler (sounds very fancy, but it's very simple) is always running, even there's no thread is running. So, it eats the battery power some more. <p> Also, the run() method is always called by the VM, so the while(true){...} is not necessary within the run() method. <p> On WinCE & Win32: Now native threading is implemented on WinCE & Win32 paltforms(11/15/2001). <p> Thus, the resolution of context switch becomes system dependent, possibly slower than green thread implementation. <p> Also any shared-resources, i.e. Graphics, GUIs, Serial Port, Socket, etc. need some kind of thread synchronization. <br> Sync methods / blocks and signal(for notify() in Java) / signalAll (notifyAll() in Java) are provided for this purpose, but they are not tested at the time of writing (2001-11-20). <p> If you could provide me some detail information of the problem when it's encountered (when and how or what caused the problem, and the trace of the situation leading up to that point), I will try to fix as much as my free time alllows (as many other open-source project). ;-( */ package waba.sys; import waba.sys.Runnable; public class Thread { private Runnable target; /** Allocate a new thread object */ public Thread(Runnable target) { this.target = target; } /** Allocate a new thread object */ public Thread() { target = null; } //private native void _nativeCreate(); /** * Causes this thread to starts execution. * After this function called, WabaVM calls run() method. * @also run() */ public final native void start(); /** * If this thread was constructed with the object Runnable inheritance, * it calls the Runnable object's run(). Otherwize it just returns and * does nothing. * * On PalmOS: * Once Threads are ".start()"ed, * the run() method is always called by the VM, * so the while(true){...} is not necessary within the run() method. */ public void run() { if (target != null) target.run(); } /** * On PalmOS: * Causes this thread to stop execution. * This method is still necessary for green threads. */ public final native void stop(); /** * Causes this thread to sleep. * <p> * On PalmOS: * @param millisecond The value is NOT based on mill-seconds, * but rather specifies how many times * a thread yields its turn to other threads. *<p> * i.e. when sleep counts are set to two different threads as threadA.sleep(1) and threadB.sleep(5), * Thread B gives up 5 turns to Thread A. * The implementation became like this, since there is no high-resolution timer * for some of the supported platforms (notably PalmOS). */ public final native void sleep(int millisecond); /** * Causes currently executed thread to pause tempolary and to enable the another thread execution. * This is not implemented yet. */ public static final /*native*/ void yield() {}; public final native void waitForSignal(); public final native void signalAll(); public final native void signal(); public static native Thread currentThread(); public static native void setPriority(int priorityNumber); } --- NEW FILE: Time.java --- /* $Id: Time.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.sys; /** * Time identifies a date and time. * <p> * Here is an example of Time being used to display the current date: * * <pre> * Time t = new Time(); * ... * g.drawText("Today is " + t.year + "/" + t.month + "/" + t.day); * </pre> */ public class Time { /** The year as its full set of digits (year 2010 is 2010). */ public int year; /** The month in the range of 1 to 12. */ public int month; /** The day in the range of 1 to the last day in the month. */ public int day; /** The hour in the range of 0 to 23. */ public int hour; /** The minute in the range of 0 to 59. */ public int minute; /** The second in the range of 0 to 59. */ public int second; /** Milliseconds in the range of 0 to 999. */ public int millis; /** * Constructs a time object set to the current date and time. */ public Time() { _nativeCreate(); } private native void _nativeCreate(); } --- NEW FILE: Vm.java --- /* $Id: Vm.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.sys; /** * Vm contains various system level methods. * <p> * This class contains methods to copy arrays, obtain a timestamp, * sleep and get platform and version information. */ // NOTE: // In the future, these methods may include getting unique object id's, // getting object classes, sleep (for single threaded apps), // getting amount of memory used/free, etc. // The reason these methods should appear in this class and not somewhere // like the Object class is because each method added to the Object class // adds one more method to every object in the system. public class Vm { private Vm() { } /** * Copies the elements of one array to another array. This method returns * true if the copy is successful. It will return false if the array types * are not compatible or if either array is null. If the length parameter * would cause the copy to read or write past the end of one of the arrays, * an index out of range error will occur. If false is returned then no * copying has been performed. * @param srcArray the array to copy elements from * @param srcStart the starting position in the source array * @param dstArray the array to copy elements to * @param dstStart the starting position in the destination array * @param length the number of elements to copy */ public static native boolean copyArray(Object srcArray, int srcStart, Object dstArray, int dstStart, int length); /** * Returns true if the system supports a color display and false otherwise. */ public static native boolean isColor(); /** * Returns a time stamp in milliseconds. The time stamp is the time * in milliseconds since some arbitrary starting time fixed when * the VM starts executing. The maximum time stamp value is (1 << 30) and * when it is reached, the timer will reset to 0 and will continue counting * from there. */ public static native int getTimeStamp(); /** Returns the platform the Virtual Machine is running under as a string. */ public static native String getPlatform(); /** * Returns the username of the user running the Virutal Machine. Because of * Java's security model, this method will return null when called in a Java * applet. This method will also return null under most WinCE devices (that * will be fixed in a future release). */ public static native String getUserName(); /** * Returns the version of the Waba Virtual Machine. The major version is * base 100. For example, version 1.0 has value 100. Version 2.0 has a * version value of 200. A beta 0.8 VM will have version 80. */ public static int getVersion() { return 150; } /** * Executes a command. * <p> * As an example, the following call could be used to run the command * "scandir /p mydir" under Java, Win32 or WinCE: * <pre> * int result = Vm.exec("scandir", "/p mydir", 0, true); * </pre> * This example executes the Scribble program under PalmOS: * <pre> * Vm.exec("Scribble", null, 0, false); * </pre> * This example executes the web clipper program under PalmOS, telling * it to display a web page by using launchCode 54 (CmdGoToURL). * <pre> * Vm.exec("Clipper", "http://www.yahoo.com", 54, true); * </pre> * The args parameter passed to this method is the arguments string * to pass to the program being executed. * <p> * The launchCode parameter is only used under PalmOS. Under PalmOS, it is * the launch code value to use when the Vm calls SysUIAppSwitch(). * If 0 is passed, the default launch code (CmdNormalLaunch) is used to * execute the program. * <p> * The wait parameter passed to this method determines whether to execute * the command asynchronously. If false, then the method will return without * waiting for the command to complete execution. If true, the method will * wait for the program to finish executing and the return value of the * method will be the value returned from the application under Java, Win32 * and WinCE. * <p> * Under PalmOS, the wait parameter is ignored since executing another * program terminates the running program. * * @param command the command to execute * @param args command arguments * @param launchCode launch code for PalmOS applications * @param wait whether to wait for the command to complete execution before returning */ public static native int exec(String command, String args, int launchCode, boolean wait); /** * Sets the device's "auto-off" time. This is the time in seconds where, if no * user interaction occurs with the device, it turns off. To keep the device always * on, pass 0. This method only works under PalmOS. The integer returned is * the previous auto-off time in seconds. */ public static native int setDeviceAutoOff(int seconds); /** * Causes the VM to pause execution for the given number of milliseconds. * @param millis time to sleep in milliseconds */ public static native void sleep(int millis); } --- NEW FILE: VmShell.java --- /* $Id: VmShell.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 2000 SmartData This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by SmartData and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. SMARTDATA ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. SMARTDATA SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. SMARTDATA SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY SMARTDATA. */ package waba.sys; /** * Vm contains various system level methods. * <p> * This class contains methods to copy arrays, obtain a timestamp, * sleep and get platform and version information. */ // NOTE: // In the future, these methods may include getting unique object id's, // getting object classes, sleep (for single threaded apps), // getting amount of memory used/free, etc. // The reason these methods should appear in this class and not somewhere // like the Object class is because each method added to the Object class // adds one more method to every object in the system. public class VmShell { private VmShell() {} public static native void print(String str); public static native void println(String str); } |